小编Luk*_*vin的帖子

如何使用CASE语句在SQL Server中创建透视查询?

Col1仅包含X和Y.

Col1    Col2

X       abc

Y       pqr

X       pqr

X       mnq

Y       cxr
Run Code Online (Sandbox Code Playgroud)

我想这样做:

X    Y    Col2

Yes  Yes  pqr
Yes  No   abc
Yes  No   mnq
No   Yes  cxr
Run Code Online (Sandbox Code Playgroud)

我应该写什么SQL查询?

sql sql-server

6
推荐指数
1
解决办法
2万
查看次数

从表列读取二进制到byte []数组

我在我的应用程序中使用PBKDF2来存储用户密码.在我的Users表中,我有一个Salt和Password列,其确定如下:

// Hash the users password using PBKDF2
var DeriveBytes = new Rfc2898DeriveBytes(_Password, 20);
byte[] _Salt = DeriveBytes.Salt;
byte[] _Key = DeriveBytes.GetBytes(20);  // _Key is put into the Password column
Run Code Online (Sandbox Code Playgroud)

在我的登录页面上,我需要检索此盐和密码.因为它们是byte []数组,所以我将它们存储在我的表中varbinary(MAX).现在我需要检索它们以与用户输入的密码进行比较.我该怎么用SqlDataReader呢?目前我有这个:

cn.Open();
SqlCommand Command = new SqlCommand("SELECT Salt, Password FROM Users WHERE Email = @Email", cn);
Command.Parameters.Add("@Email", SqlDbType.NVarChar).Value = _Email;
SqlDataReader Reader = Command.ExecuteReader(CommandBehavior.CloseConnection);
Reader.Read();
if (Reader.HasRows)
{
    // This user exists, check their password with the one entered
    byte[] _Salt …
Run Code Online (Sandbox Code Playgroud)

c# sql-server asp.net arrays

6
推荐指数
1
解决办法
3万
查看次数

替代Urlmon.dll中具有更多MIME类型的FindMimeFromData方法

通过Windows DLL可访问的FindMimeFromData方法Urlmon.dll能够确定存储在内存中的给定数据的MIME类型,考虑到存储此类数据的字节数组的前256个字节.

然而,在阅读了它的文档后,我在Windows Internet Explorer中引领了MIME类型检测,在那里我可以找到此方法能够识别的MIME类型.见清单.如您所见,此方法仅限于26种MIME类型.

所以我想知道是否有人能指出我有更多MIME类型的另一种方法,或者另外一种方法/类我可以包含我认为合适的MIME类型.

谢谢.

c# mime-types

6
推荐指数
1
解决办法
2万
查看次数

不断获取部分声明可访问性方法错误

我从我的朋友那里下载了一些代码(我们正在一起工作),当我运行代码几次时,它运行良好,没有错误,然后当我去运行它时,我不断收到以下两个错误:

错误 1 ​​'GuiGame.HareAndTortoiseForm' 的部分声明具有冲突的可访问性修饰符

public partial class HareAndTortoiseForm : Form {
Run Code Online (Sandbox Code Playgroud)

错误 2 声明类型“GuiGame.HareAndTortoiseForm”时缺少部分修饰符;这种类型的另一个部分声明存在

internal class HareAndTortoiseForm {
Run Code Online (Sandbox Code Playgroud)

我认为代码是在我创建 GUI 表单时自动生成的。我尝试更改访问器,使它们都是公共部分,但仍然没有运气。我已经尝试重新下载该文件大约 10 次,但问题仍然存在,我无法找到它的来源或如何修复它。有没有人有任何线索?第一行代码来自 HareAndTortoiseForm.cs 类,另一行来自 HareAndTortoiseForm1.Designer.cs 类。

c#

6
推荐指数
1
解决办法
8308
查看次数

NLog 给出异常可能的解释是缺少零 arg 和单个 arg Common.Logging.Configuration.NameValueCollection 构造函数

我将 NLog 添加到我的应用程序和它的测试项目中。它们都是同一个解决方案的一部分。从应用程序内部 NLog 工作。但是从测试项目得到以下异常:

Unable to create instance of type Common.Logging.NLog.NLogLoggerFactoryAdapter. Possible explanation is lack of zero arg and single arg Common.Logging.Configuration.NameValueCollection constructors
Run Code Online (Sandbox Code Playgroud)

我的 NLog 配置如下:

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>    
    <common>
            <logging>
              <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
                <arg key="configType" value="INLINE" />
              </factoryAdapter>
            </logging>
          </common>
          <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="C:\git\foo\logs\nlog.log" internalLogLevel="Warn">
            <extensions>
              <add assembly="NLog.RollbarSharp" />
            </extensions>
            <targets>
              <target xsi:type="RollbarSharp" name="Rollbar" …
Run Code Online (Sandbox Code Playgroud)

c# logging nlog nuget apache-commons-logging

6
推荐指数
1
解决办法
3051
查看次数

如何创建程序终止后自动删除的临时文件?

我一直在各地搜索,我似乎无法在任何地方找到这样的选项 - 使用GetTempFileName创建的临时文件似乎在应用程序终止后留下.

我该怎么做呢?

c# windows

6
推荐指数
1
解决办法
5950
查看次数

使用Flurl发布多个标头

嗨,我正在使用Flurl,我需要为帖子设置多个标题,并且网站上的文档状态等待url.WithHeaders(new {h1 ="foo",h2 ="bar"}).GetJsonAsync();

我不确定这意味着什么,什么是H1,H2?

我正在尝试设置Headers"API-VERSION:21"和"Authorization:askjdalksdjlaksjdlaksjd";

谢谢

c# flurl

6
推荐指数
1
解决办法
3225
查看次数

Web 应用程序 - 将非常大的数据流保存到本地文件

我想知道现代浏览器中的 Web 应用程序是否有某种正确的方法(互联网协议、浏览器 API 等)从 Web 服务器(在我的例子中是 Nodejs,但问题专注于客户端),并将其保存到客户端文件系统中的一个大文件中。假设数据量太大,无法完全缓冲在应用程序分配的内存中,因此我猜想该进程应该以某种方式将流中的数据块直接附加到文件中。

数据基本上是数万条数据库记录,应写入 csv 等格式。

希望我在这里说得有道理。

html javascript node.js

6
推荐指数
1
解决办法
4380
查看次数

Web API – 使用不记名令牌进行身份验证

我创建了一个 MVC 应用程序,用于允许外部身份验证/注册。它已经创建了所有必要的组件(Owin、EF、注册、登录、注销),我能够在应用程序中执行所有基本活动。

现在,我想将 Web 应用程序与我的移动应用程序也将使用的 Web API 集成。我坚持在 Web API 调用中进行身份验证(使用我从 Web 应用程序收到的不记名令牌)。

我看到了在启用 OWIN 中间件的情况下创建 WEB API 项目的示例。但我不知道如何集中外部身份验证过程并为我的 Web 应用程序和移动应用程序使用令牌而且我不想使用 ANGULAR或单页应用程序。任何人都可以向我建议解决此问题的正确技术途径。谢谢你。

第1步:

我在 Visual Studio 2015 中创建了一个启用个人登录的 MVC 项目。并配置了我在谷歌开发者控制台中配置所有内容的密钥。我的Startup.cs会有以下代码

 public void ConfigureAuth(IAppBuilder app)
    {
        // Configure the db context, user manager and signin manager to use a single instance per request
        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

        // Enable the application to use a cookie to store information for the signed in user
        // and to use …
Run Code Online (Sandbox Code Playgroud)

authentication asp.net-mvc oauth-2.0 owin asp.net-web-api2

6
推荐指数
1
解决办法
3万
查看次数

Visual Studio 2005/2008:如何共享/强制所有开发人员使用相同的格式规则?

我想让团队中的所有开发人员使用相同的规则来格式化几种类型的代码(ASPX,CSS,JavaScript,C#).我可以让视觉工作室看到这些规则的常见位置吗?

我不想依赖导出/导入设置,因为它带来了许多设置.我(例如)不关心开发人员在键入时使用的字体颜色,我只想要类似的格式.你能导入一部分设置吗?

formatting visual-studio

5
推荐指数
1
解决办法
1333
查看次数