Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            AssemblyName name = new AssemblyName("GR.Services");

            services.RegisterAssemblyTypes(null, ServiceLifetime.Singleton, Assembly.Load(name));

            //初始化数据库
            ConfigDb.Init(ConfigHelper.GetString("Connstring"));
            //用静态类存储上下文,得到身份
            services.AddHttpContextAccessorEx();

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o =>
            {
                o.LoginPath        = new PathString("/Login/Index");
                o.AccessDeniedPath = new PathString("/Home/Denied");
            });
            //HttpContextCore.ServiceProvider = services.BuildServiceProvider();
            services.AddControllersWithViews(config =>
            {
                config.Filters.Add(typeof(AjaxLogAttribute));
                config.Filters.Add(typeof(SampleAsyncActionFilter));
            }).AddJsonOptions(option =>
            {
                option.JsonSerializerOptions.PropertyNamingPolicy = null;
            });
            EngineContext.initialize(new GeneralEngine(services.BuildServiceProvider()));
        }
Esempio n. 2
0
        /// <summary>
        /// Create Default DataBase configuration
        /// MSLocalDB
        /// </summary>
        /// <returns></returns>
        private ConfigDb CreateDefaultConfiguration()
        {
            ConfigDb configDb = new ConfigDb();

            configDb.SupportedDataBaseCategories = Enumerations.Configuration.SupportedDataBaseCategories.LocalDataBase;
            configDb.SupportedLocalDataBases     = Enumerations.Configuration.SupportedLocalDataBases.Microsoft_LocalDB;
            return(configDb);
        }
        private void GetStatus(object sender)
        {
            try
            {
                var count = ConfigDb.GetActiveRestrictionCount();

                if (count == null)
                {
                    throw new Exception("Unable to read restriction count");
                }

                Zabbix.Sender.SendData(new ZabbixItem {
                    Host = Config.ZabbixHostKey, Key = Config.ZabbixRestrictionKey, Value = count.ToString()
                });
                Logger.Log.Debug("Send to zabbix - restriction count: {0}", count);
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Error when getting status: {0}", ex.Message);
            }
        }
 private SQLConfigSingleton(IOptions <ConfigDb> settings)
 {
     _configuration    = settings.Value;
     _connectionString = _configuration.ConnectionString;
     _connectDbTimeOut = _configuration.ConnectDbTimeOut;
 }
Esempio n. 5
0
 public FirstConfigService(ConfigDb config)
 {
     _config = config;
 }