コード例 #1
0
        public static void LoadSettings(string name = null)
        {
            if (string.IsNullOrWhiteSpace(name))
                name = Constants.PriorSessionName;

            ConfigurationManager.RefreshSection("appSettings");
            ConfigurationManager.RefreshSection(CosmosCollectionDBConfigurationSection.SectionName);

            var appSettings = ConfigurationManager.AppSettings;

            CopyStoredProcedures = bool.Parse(appSettings[Constants.CopyStoredProcedures]);
            CopyUDFs = bool.Parse(appSettings[Constants.CopyUDFs]);
            CopyTriggers = bool.Parse(appSettings[Constants.CopyTriggers]);
            CopyDocuments = bool.Parse(appSettings[Constants.CopyDocuments]);
            CopyIndexingPolicy = bool.Parse(appSettings[Constants.CopyIndexingPolicy]);
            CopyPartitionKey = bool.Parse(appSettings[Constants.CopyPartitionKey]);
            ReadBatchSize = int.Parse(appSettings[Constants.ReadBatchSize].ToString());
            WriteBatchSize = int.Parse(appSettings[Constants.WriteBatchCount]);
            EnableTextLogging = bool.Parse(appSettings[Constants.EnableTextLogging]);
            SourceOfferThroughputRUs = int.Parse(appSettings[Constants.SourceOfferThroughputRUs]);
            TargetMigrationOfferThroughputRUs = int.Parse(appSettings[Constants.TargetMigrationOfferThroughputRUs]);
            TargetRestOfferThroughputRUs = int.Parse(appSettings[Constants.TargetRestOfferThroughputRUs]);
            ScrubbingRequired = bool.Parse(appSettings[Constants.ScrubbingRequired]);

            SourceSettings = GetSourceSettings(name);

            TargetSettings = GetTargetSettings(name);
        }
コード例 #2
0
        public static CosmosCollectionValues GetTargetSettings(string name)
        {
            var targetConfig = GetCosmosConfigSection().TargetCosmosDBSettings.OfType<CosmosDBSettingsElement>().SingleOrDefault(e => e.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (targetConfig == null)
                throw new Exception($"Target Config with Name: `{name}` not found");

            return CosmosCollectionValues.CreateFromConfiguration(targetConfig);
        }
コード例 #3
0
        static CloneSettings()
        {
            ConfigurationManager.RefreshSection("appSettings");

            CopyStoredProcedures = bool.Parse(ConfigurationManager.AppSettings["CopyStoredProcedures"]);
            CopyUDFs             = bool.Parse(ConfigurationManager.AppSettings["CopyUDFs"]);
            CopyTriggers         = bool.Parse(ConfigurationManager.AppSettings["CopyTriggers"]);
            CopyDocuments        = bool.Parse(ConfigurationManager.AppSettings["CopyDocuments"]);
            CopyIndexingPolicy   = bool.Parse(ConfigurationManager.AppSettings["CopyIndexingPolicy"]);
            CopyPartitionKey     = bool.Parse(ConfigurationManager.AppSettings["CopyPartitionKey"]);
            var value = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            ReadBatchSize                     = int.Parse(ConfigurationManager.AppSettings["ReadBatchSize"].ToString());
            WriteBatchSize                    = int.Parse(ConfigurationManager.AppSettings["WriteBatchCount"]);
            EnableTextLogging                 = bool.Parse(ConfigurationManager.AppSettings["EnableTextLogging"]);
            SourceOfferThroughputRUs          = int.Parse(ConfigurationManager.AppSettings["SourceOfferThroughputRUs"]);
            TargetMigrationOfferThroughputRUs = int.Parse(ConfigurationManager.AppSettings["TargetMigrationOfferThroughputRUs"]);
            TargetRestOfferThroughputRUs      = int.Parse(ConfigurationManager.AppSettings["TargetRestOfferThroughputRUs"]);
            ScrubbingRequired                 = bool.Parse(ConfigurationManager.AppSettings["ScrubbingRequired"]);
            var sourceConfigs = GetConfigurationSection("SourceCosmosDBSettings");

            SourceSettings = new CosmosCollectionValues()
            {
                EndpointUrl    = sourceConfigs["EndpointUrl"],
                AccessKey      = sourceConfigs["AccessKey"],
                DatabaseName   = sourceConfigs["DatabaseName"],
                CollectionName = sourceConfigs["CollectionName"]
                                 //OfferThroughputRUs = int.Parse(sourceConfigs["OfferThroughputRUs"])
            };

            var targetConfigs = GetConfigurationSection("TargetCosmosDBSettings");

            TargetSettings = new CosmosCollectionValues()
            {
                EndpointUrl        = targetConfigs["EndpointUrl"],
                AccessKey          = targetConfigs["AccessKey"],
                DatabaseName       = targetConfigs["DatabaseName"],
                CollectionName     = targetConfigs["CollectionName"],
                OfferThroughputRUs = int.Parse(targetConfigs["OfferThroughputRUs"])
            };
        }
コード例 #4
0
 private static void UpdateCosmosDBSettings(CosmosDBSettingsElement configSetting, CosmosCollectionValues runSetting)
 {
     configSetting.EndpointUrl = runSetting.EndpointUrl;
     configSetting.AccessKey = runSetting.AccessKey;
     configSetting.DatabaseName = runSetting.DatabaseName;
     configSetting.CollectionName = runSetting.CollectionName;
     configSetting.OfferThroughputRUs = runSetting.OfferThroughputRUs;
 }