小编Pre*_*sto的帖子

JobStorage.Current 属性值尚未初始化。您必须在使用 Hangfire Client 或 Server API 之前设置它

我在 mvc 应用程序中使用 hangfire。我正在向用户发送预约提醒。我已经在我的应用程序中安装了 hangfire。我已经在 startup.cs 类中配置了 hangfire。但是当我运行该应用程序时,它会产生以下错误 JobStorage。当前属性值尚未初始化。您必须在使用 Hangfire Client 或 Server API 之前设置它。

using Hangfire;
using Hangfire.SqlServer;
using Microsoft.Owin;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UKC.Data.Infrastructure;
using UKC.UI.Helper;

[assembly: OwinStartup(typeof(UKC.UI.App_Start.Startup))]
namespace UKC.UI.App_Start
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            GlobalConfiguration.Configuration
               .UseSqlServerStorage("DbEntities");

            app.UseHangfireDashboard();
            app.UseHangfireServer();

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc hangfire

9
推荐指数
4
解决办法
1万
查看次数

使用 Daper.Net 和 NPGSQL 将数据插入 PostgreSQL jsonb 列

我正在尝试使用 Dapper.Net 将 JSON 数据插入到 JSONB PostgreSQL 列中。

用于JSONB文件Npgsql的给人使用的具体指示NpgsqlDbType.Jsonb的数据类型。

使用 Dapper,我试图将其添加为自定义参数,但没有成功。

using (var conn = myconnection)
{
    var sql = "INSERT INTO mytable (jsonbody) VALUES (@jb);";
    dp =  new DynamicParameters();
    dp.Add("jb", stringOfJsonData, (DbType)NpgsqlDbType.Jsonb);
    await conn.ExecuteAsync(sql,dp);                    
}                
Run Code Online (Sandbox Code Playgroud)

我收到的错误是 System.NotSupportedException : The parameter type DbType.36 isn't supported by PostgreSQL or Npgsql

关于如何将这两个库一起用于 JSONB 的任何建议?

谢谢。

c# postgresql npgsql dapper

8
推荐指数
2
解决办法
4668
查看次数

类型文档。如何导入一个 node_modules/@types 并像 IncludeDeclarations 一样固定对它的引用

我正在尝试生成我的应用程序的文档(使用 TypeDoc)。我有相当困难的场景要做。所以在我的代码中是一些函数,它返回类型为 from 的对象node_modules/@types。我需要将此类型包含在我的文档中,因为我需要显示对此的引用@type并且我也需要显示它@type。所以我正在尝试这些方法:

  1. 在“src”语句中添加了此类型的路径,例如:'**/node_modules/@types/someType/index.d.ts'。我的 TypeDoc 配置:

    typedoc: {
        build: {
            options: {
                module: 'commonjs',
                out: '../MyDocumentation/',
                name: 'MyApp',
                target: 'es5',
                exclude: [
                    '**/folderA/*.d.ts',
                    '**/folderB/*.d.ts'
                ],
                excludePrivate: true,
                externalPattern: "**/*/{fileX,fileY,fileZ}.ts",
                mode: 'file'
            },
            src: [
                'folderA/*.ts',
                'folderB/*.ts',
                '**/node_modules/@types/someType/*.d.ts'
            ]
        }
    }  
    
    Run Code Online (Sandbox Code Playgroud)
  2. 通过将 includeDeclarations 设置为 true。我的 TypeDoc 配置:

    typedoc: {
        build: {
            options: {
                module: 'commonjs',
                out: '../MyDocumentation/',
                name: 'MyApp',
                target: 'es5',
                exclude: [
                    '**/node_modules/**',
                    '**/folderA/*.d.ts',
                    '**/folderB/*.d.ts'
                ],
                includeDeclarations: true,
                excludePrivate: true,
                externalPattern: …
    Run Code Online (Sandbox Code Playgroud)

documentation node-modules gruntjs typescript typedoc

5
推荐指数
0
解决办法
660
查看次数

循环遍历C#列表中的列表

我有一个名为Models的列表,其中包含ID,Title,Variants.Variants是一个包含另一个元素Id,ModelID,Title的列表.我的问题是如何遍历变量列表,这是模型的子列表.

Repository.cs

public class Repository : IRepository
{
    private List<ModelSearch> _list = new List<ModelSearch>();
    public Repository()
    {
        populateList();
    }

    private void populateList()
    {
        _list.Add(new ModelSearch
        {
            ID = 1,
            Title = "Scorpio",
            Variants = new List<Variant> { 
                new Variant { ID = 1, ModelID = 1, Title="scorpio1" },
                new Variant { ID = 2, ModelID = 1, Title="scorpio2" },
                new Variant { ID = 3, ModelID = 1, Title="scorpio3" }
            }
        });

        _list.Add(new ModelSearch
        {
            ID = 2,
            Title = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net list

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

c#:BaseClass虚方法使用在子类中定义的对象

我有一个基类和许多子类.在每个子类中,我使用对象A - 因此我将它放在基类中.因此,使用Object BI的子类的一半不会将B放在基类中.我希望我的基类包含尽可能多的功能,因此我希望基类中的方法能够"做某事"如果定义了对象B. 那有意义吗?

我可能会从错误的角度看待这个问题,我希望你能引导我朝着正确的方向前进.如果我没有充分解释这个问题,请告诉我

我试图将对象B放在基类中,但我不希望每个子类都能够使用对象B.

abstract class BaseClass
{
    public Object A { get; set; }

    protected virtual void SomeMethod()
    {
        if (!(A is null))        
        {
            //Do thing with A
            //This works fine
        }

        if (!(B is null))        
        {
            //Do thing with B
            //This doesnt work - But I want to it work
        }
    }
}

class ChildClass : BaseClass
{
    public Object B { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

c#

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

在 C# 中加密/解密数据的更快方法是什么?

我使用了以下函数,但解密 1100 条联系我们表格的记录需要 50 秒到 1 分钟。所以我过滤一些东西大约需要1分钟的时间。因为我需要加密整个数据,所以我在 C# 中触发过滤器查询。

这是加密方法:

public static string Encrypt(string encryptString)
{
    if (string.IsNullOrEmpty(encryptString))
        return encryptString;

    string EncryptionKey = "---";
    byte[] clearBytes = Encoding.Unicode.GetBytes(encryptString);
    using (Aes encryptor = Aes.Create())
    {
        Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] 
        { 
            0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 
        });

        encryptor.Key = pdb.GetBytes(32);
        encryptor.IV = pdb.GetBytes(16);

        using (MemoryStream ms = new MemoryStream())
        {
            using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
            {
                cs.Write(clearBytes, 0, …
Run Code Online (Sandbox Code Playgroud)

c# encryption

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

接口实现莫名其妙地将List <T>转换为List <Libary.T> C#

我无法实现此功能,因为它是从C#.NET Core 2.0.1中的通用方法派生的,如下所示:

接口

public interface IListable 
{
    List<T> AsList<T>();
}
Run Code Online (Sandbox Code Playgroud)

履行

public class PwActivityTypeCollection : IListable 
{
    public List<PwActivityType> user;
    public List<PwActivityType> system;
    public List<PwActivityType> AsList<PwActivityType>() 
    {
      return user.Concat (system).ToList();
    }
}
Run Code Online (Sandbox Code Playgroud)

请注意,在我尝试实现接口之前,这样可以正常工作.该Concat代码返回List<PwActivityType>预期:

public List<PwActivityType> AsList() 
{
    return user.Concat(system).ToList();
}
Run Code Online (Sandbox Code Playgroud)

错误:

PwActivityType.cs(16,14):错误CS0029:无法将类型'System.Collections.Generic.List <Library.PwActivityType>'隐式转换为'System.Collections.Generic.List <PwActivityType>'[/ Users/shanekenyon/Documents /git/gls_int_prosperworks/library/library.csproj]

c# .net-core

0
推荐指数
1
解决办法
53
查看次数