/// <summary>
 /// Initializes a new instance of the <see cref="KnowledgeBaseSettingsController"/> class.
 /// </summary>
 /// <param name="appConfigRepository">Repository for app config data activity.</param>
 /// <param name="logger">Logs errors and information.</param>
 public KnowledgeBaseSettingsController(
     AppConfigRepository appConfigRepository,
     ILogger <KnowledgeBaseSettingsController> logger)
 {
     this.appConfigRepository = appConfigRepository ?? throw new ArgumentNullException(nameof(appConfigRepository));
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #2
0
        private async Task RunAsync(CancellationToken cancellationToken)
        {
            var startTime = DateTime.Now;

            // Dependencies to inject into the Bulk Device Tester
            var logger           = new TraceLogger();
            var configProvider   = new ConfigurationProvider();
            var telemetryFactory = new CoolerTelemetryFactory(logger);

            var serializer       = new JsonSerialize();
            var transportFactory = new IotHubTransportFactory(serializer, logger, configProvider);

            IVirtualDeviceStorage deviceStorage = null;
            var useConfigforDeviceList          = Convert.ToBoolean(configProvider.GetConfigurationSettingValueOrDefault("UseConfigForDeviceList", "False"));

            if (useConfigforDeviceList)
            {
                deviceStorage = new AppConfigRepository(configProvider, logger);
            }
            else
            {
                deviceStorage = new VirtualDeviceTableStorage(configProvider);
            }

            IDeviceFactory deviceFactory = new CoolerDeviceFactory();

            var tester = new BulkDeviceTester(transportFactory, logger, configProvider, telemetryFactory, deviceFactory, deviceStorage);
            await tester.ProcessDevicesAsync(cancellationToken);

            Trace.TraceInformation("");
            Trace.TraceInformation("*********************************************************************************************************************");
            Trace.TraceInformation("ELAPSED TIME: {0}ms", (DateTime.Now - startTime).TotalMilliseconds);
            Trace.TraceInformation("*********************************************************************************************************************");
            Trace.TraceInformation("");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: klavshp/PnIoTPoc
        private static void StartSimulator()
        {
            // Dependencies to inject into the Bulk Device Tester
            var logger                    = new TraceLogger();
            var configProvider            = new ConfigurationProvider();
            var tableStorageClientFactory = new AzureTableStorageClientFactory();

            var telemetryFactory = new CoolerTelemetryFactory(logger);
            var deviceFactory    = new CoolerDeviceFactory();
            var transportFactory = new IotHubTransportFactory(logger, configProvider);

            IVirtualDeviceStorage deviceStorage;
            var useConfigforDeviceList = Convert.ToBoolean(configProvider.GetConfigurationSettingValueOrDefault("UseConfigForDeviceList", "False"), CultureInfo.InvariantCulture);

            if (useConfigforDeviceList)
            {
                deviceStorage = new AppConfigRepository(configProvider, logger);
            }
            else
            {
                deviceStorage = new VirtualDeviceTableStorage(configProvider, tableStorageClientFactory);
            }

            // Start Simulator
            Trace.TraceInformation("Starting Simulator");
            var tester = new BulkDeviceTester(transportFactory, logger, configProvider, telemetryFactory, deviceFactory, deviceStorage);

            Task.Run(() => tester.ProcessDevicesAsync(CancellationTokenSource.Token), CancellationTokenSource.Token);
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QnAService"/> class.
 /// </summary>
 /// <param name="appConfigRepository">Repository for app config data activity.</param>
 /// <param name="optionsAccessor">A set of key/value application configuration properties.</param>
 /// <param name="qnaMakerRuntimeClient">QnA service runtime client.</param>
 public QnAService(
     AppConfigRepository appConfigRepository,
     IOptionsMonitor <QnAMakerSettings> optionsAccessor,
     IQnAMakerRuntimeClient qnaMakerRuntimeClient)
 {
     this.appConfigRepository   = appConfigRepository ?? throw new ArgumentNullException(nameof(appConfigRepository));
     this.options               = optionsAccessor.CurrentValue ?? throw new ArgumentNullException(nameof(optionsAccessor.CurrentValue));
     this.qnaMakerRuntimeClient = qnaMakerRuntimeClient ?? throw new ArgumentNullException(nameof(qnaMakerRuntimeClient));
 }
コード例 #5
0
        public WelcomeViewModel()
        {
            AppConfigRepository AppConfigData = new AppConfigRepository();

            pile          = AppConfigData.Pile;
            _isMigrateKey = pile.Settings.BucketName;
            _isUseProxy   = pile.Settings.UseProxy;
            _password     = pile.Settings.Password;
            _host         = pile.Settings.Host;
            _port         = pile.Settings.Port;
            _username     = pile.Settings.Username;
        }
コード例 #6
0
 /// <summary>
 /// http://chameleoninformexigent.azurewebsites.net/
 /// </summary>
 /// <returns></returns>
 public static string GetApplicationURL()
 {
     using (AppConfigRepository _AppConfigrepository = new AppConfigRepository())
     {
         return(_AppConfigrepository.GetAllCached().Select(e => new AppConfigViewModel
         {
             Id = e.Id,
             AppKey = e.AppKey,
             AppVaue = e.AppVaue,
         }).FirstOrDefault(e => e.AppKey == "ApplicationURL").AppVaue);
     }
 }
コード例 #7
0
        public AppConfigRepositoryTests()
        {
            this._loggerMock = new Mock <ILogger>();
            this._configurationProviderMock = new Mock <IConfigurationProvider>();
            this.testHostName = "testHostName";
            this.testKey      = "testKey";
            this.testDeviceId = "testDeviceId";

            this._configurationProviderMock.Setup(mock => mock.GetConfigurationSettingValue("iotHub.HostName")).Returns(this.testHostName);

            this.repo = new AppConfigRepository(this._configurationProviderMock.Object, this._loggerMock.Object);
        }
コード例 #8
0
 /// <summary>
 /// Get list of all app config settings
 /// </summary>
 /// <returns></returns>
 public static List <AppConfigViewModel> GetAllAppConfigSettings()
 {
     using (AppConfigRepository _AppConfigrepository = new AppConfigRepository())
     {
         return(_AppConfigrepository.GetAllCached().Select(e => new AppConfigViewModel
         {
             Id = e.Id,
             AppKey = e.AppKey,
             AppVaue = e.AppVaue,
             Caption = e.Caption,
         }).ToList());
     }
 }
コード例 #9
0
        public static void AssemblyInitialize(TestContext testContext)
        {
            // Insert test data.
            var connectionString = new AppConfigRepository().GetConnectionString("configdb");

            using (var sqLiteConnection = new SQLiteConnection(connectionString))
                using (var sqLiteCommand = sqLiteConnection.CreateCommand())
                {
                    sqLiteConnection.Open();

                    // Encode query for sqlite or otherwise the utf8 will be broken.
                    sqLiteCommand.CommandText = File.ReadAllText("config.sql").Recode(Encoding.UTF8, Encoding.Default);
                    sqLiteCommand.ExecuteNonQuery();
                }
        }
コード例 #10
0
        /// <summary>
        /// Update App config settrings
        /// </summary>
        /// <param name="AppConfigViewModelList"></param>
        /// <param name="userId"></param>
        public static void UpdateAppConfigSettings(List <AppConfigViewModel> AppConfigViewModelList, int userId)
        {
            using (AppConfigRepository _AppConfigrepository = new AppConfigRepository())
            {
                AppConfig appConfig = new AppConfig();

                foreach (var item in AppConfigViewModelList)
                {
                    appConfig            = _AppConfigrepository.GetById(Convert.ToInt32(item.Id));
                    appConfig.AppVaue    = item.AppVaue;
                    appConfig.ModifiedBy = userId;
                    _AppConfigrepository.SaveChanges();
                }
            }
        }
コード例 #11
0
        //// get app values for supportDesk
        public static List <AppConfigViewModel> GetAppValuesForSupportDesk()
        {
            List <AppConfigViewModel> lstAppConfigViewModel = new List <AppConfigViewModel>();

            using (AppConfigRepository _AppConfigrepository = new AppConfigRepository())
            {
                lstAppConfigViewModel = _AppConfigrepository.GetAll().Select(e => new AppConfigViewModel
                {
                    Id      = e.Id,
                    AppKey  = e.AppKey,
                    AppVaue = e.AppVaue,
                    Section = e.Section
                }).Where(e => e.Section == "SupportDesk").ToList();
                return(lstAppConfigViewModel);
            }
        }
 public SelectFolderView()
 {
     InitializeComponent();
     if (AppConfigData.Pile.Settings.Restart)
     {
         _AppConfigData = new AppConfigRepository();
         folderLists    = _AppConfigData.Pile.Settings.FolderLists;
         OutputBlock.Inlines.Clear();
         for (var i = 0; i < folderLists.Count(); i++)
         {
             try
             {
                 OutputBlock.Inlines.Add(folderLists[i] + "\n");
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex);
             }
         }
     }
 }
コード例 #13
0
        public SqlServerStore(string nameOrConnectionString, Action <TableMetadataBuilder <SqlDbType> > buildTableConfiguration = null) : base(new[] { typeof(string) })
        {
            ConnectionString = nameOrConnectionString.NonEmptyOrNull() ?? throw new ArgumentNullException(nameof(nameOrConnectionString));;

            var connectionStringName = nameOrConnectionString.GetConnectionStringName();

            if (!string.IsNullOrEmpty(connectionStringName))
            {
                ConnectionString = new AppConfigRepository().GetConnectionString(connectionStringName).NonEmptyOrNull() ?? throw new ArgumentNullException(nameof(nameOrConnectionString));;
            }

            var tableMetadataBuilder = TableMetadataBuilder <SqlDbType> .Create()
                                       .SchemaName("dbo")
                                       .TableName(nameof(Setting))
                                       .Column(nameof(Setting.Name), SqlDbType.NVarChar, 300)
                                       .Column(nameof(Setting.Value), SqlDbType.NVarChar, -1);

            buildTableConfiguration?.Invoke(tableMetadataBuilder);
            TableMetadata          = tableMetadataBuilder.Build();
            _settingCommandFactory = new SettingCommandFactory(TableMetadata);
        }
コード例 #14
0
        private static void ResetData()
        {
            //AppDomain.CurrentDomain.SetData("DataDirectory", Environment.CurrentDirectory);

            var connectionString = new AppConfigRepository().GetConnectionString("SmartConfigTest");

            SqlConnection OpenSqlConnection()
            {
                var sqlConnection = new SqlConnection(connectionString);

                sqlConnection.Open();
                return(sqlConnection);
            }

            using (var sqlConnection = OpenSqlConnection())
                using (var sqlCommand = sqlConnection.CreateCommand())
                    using (var transaction = sqlConnection.BeginTransaction())
                    {
                        sqlCommand.Transaction = transaction;
                        try
                        {
                            sqlCommand.CommandText = ResourceReader.ReadEmbeddedResource <ConfigurationTest_SqlServer>("Resources.CreateSettingTables.sql");
                            sqlCommand.ExecuteNonQuery();

                            sqlCommand.CommandText = ResourceReader.ReadEmbeddedResource <ConfigurationTest_SqlServer>("Resources.TruncateSettingTables.sql");
                            sqlCommand.ExecuteNonQuery();

                            // Insert test data.
                            InsertSetting1(sqlCommand);
                            InsertSetting3(sqlCommand);

                            transaction.Commit();
                        }
                        catch
                        {
                            transaction.Rollback();
                        }
                    }
        }
コード例 #15
0
        private static void ResetData()
        {
            // Insert test data.
            var connectionString = new AppConfigRepository().GetConnectionString("configdb");

            SQLiteConnection OpenSQLiteConnection()
            {
                var sqLiteConnection = new SQLiteConnection(connectionString);

                sqLiteConnection.Open();
                return(sqLiteConnection);
            }

            using (var connection = OpenSQLiteConnection())
                using (var command = connection.CreateCommand())
                    using (var transaction = connection.BeginTransaction())
                    {
                        command.Transaction = transaction;
                        try
                        {
                            command.CommandText = ResourceReader.ReadEmbeddedResource <ConfigurationTest_SQLite>("Resources.CreateSettingTables.sql");
                            command.ExecuteNonQuery();

                            //command.CommandText = ResourceReader.ReadEmbeddedResource<ConfigurationTest>("Resources.TruncateSettingTables.sql");
                            //command.ExecuteNonQuery();

                            // Insert test data.
                            InsertSetting1(command);
                            InsertSetting3(command);

                            transaction.Commit();
                        }
                        catch
                        {
                            transaction.Rollback();
                        }
                    }
        }
コード例 #16
0
        static void StartSimulator()
        {
            // Dependencies to inject into the Bulk Device Tester
            var logger = new TraceLogger();
            var configProvider = new ConfigurationProvider();
            var telemetryFactory = new EngineTelemetryFactory(logger, configProvider);

            var serializer = new JsonSerialize();
            var transportFactory = new IotHubTransportFactory(serializer, logger, configProvider);

            IVirtualDeviceStorage deviceStorage = null;
            var useConfigforDeviceList = Convert.ToBoolean(configProvider.GetConfigurationSettingValueOrDefault("UseConfigForDeviceList", "False"), CultureInfo.InvariantCulture);

            if (useConfigforDeviceList)
            {
                deviceStorage = new AppConfigRepository(configProvider, logger);
            }
            else
            {
                deviceStorage = new VirtualDeviceTableStorage(configProvider);
            }

            IDeviceFactory deviceFactory = new EngineDeviceFactory();

            // Start Simulator
            Trace.TraceInformation("Starting Simulator");
            var tester = new BulkDeviceTester(transportFactory, logger, configProvider, telemetryFactory, deviceFactory, deviceStorage);
            Task.Run(() => tester.ProcessDevicesAsync(cancellationTokenSource.Token), cancellationTokenSource.Token);
        }
コード例 #17
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="uow">工作单元</param>
 /// <param name="factory">仓储创建工厂</param>
 public AppConfigService(IUnitOfWork uow, IRepositoryFactory factory)
     : base(uow, factory)
 {
     appConfigRepository = this.CreateRepository <AppConfigRepository>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AppSettingsService"/> class.
 /// </summary>
 /// <param name="repository">App configuration repository.</param>
 public AppSettingsService(AppConfigRepository repository)
 {
     this.repository = repository ?? throw new ArgumentNullException(nameof(repository));
 }