Ejemplo n.º 1
0
        public void SaveConfig(string path)
        {
            var json = SettingStore.getSettingJSON(SettingStore.SingletonStore);
            var bary = Encoding.UTF8.GetBytes(json);

            System.IO.File.WriteAllBytes(path, bary);
        }
Ejemplo n.º 2
0
        public void InitDatabase()
        {
            CommandModel config = new CommandModel();

            config.PluginType = "InitDatabase";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "ProviderName",
                    Value = "System.Data.SqlClient"
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionString",
                    Value = ConnectionString
                },
                new CommandSettingModel()
                {
                    Name  = "TablePrefix",
                    Value = "TEST_" + DateTime.Now.ToString("yyyyMMddHHmmss")
                }
            };
            ISettingStore  settings = new SettingStore(config, null);
            IPluginCommand cmd      = new InitDatabaseCommand(settings, null);
            bool           res      = cmd.Execute();

            Assert.IsTrue(res);
        }
Ejemplo n.º 3
0
        public static void Init(string providerName, string connectionString, string fillHistory = "YES")
        {
            CommandModel config = new CommandModel();

            config.PluginType = "InitTestDatabase";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "ProviderName",
                    Value = providerName
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionString",
                    Value = connectionString
                },
                new CommandSettingModel()
                {
                    Name  = "TablePrefix",
                    Value = "TEST_BUILD"
                },
                new CommandSettingModel()
                {
                    Name  = "FillHistory",
                    Value = fillHistory
                }
            };
            ISettingStore  settings = new SettingStore(config, null);
            IDataStore     data     = new DataStore();
            IPluginCommand cmd      = new InitTestDatabaseCommand(settings, data);
            bool           res      = cmd.Execute();
        }
Ejemplo n.º 4
0
 protected override void Load(bool allowUserSettings, Dictionary <string, string> optionsDictionary)
 {
     foreach (var name in SettingStore.GetUserNames())
     {
         Load(allowUserSettings, optionsDictionary, name, typeof(string));
     }
 }
Ejemplo n.º 5
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            Log.Information("Registering IoC dependencies with container");

            var settingStore      = new SettingStore();
            var credentialService = new CredentialsService(settingStore.ForKey(SettingKeys.Credentials));

            var credentials = credentialService.Get();

            var connectionSettingsService = new ConnectionSettingsService(settingStore.ForKey(SettingKeys.ConnectionSettings));

            container.RegisterInstance(connectionSettingsService);

            var connectionSettings = connectionSettingsService.Get();

            var tfsBuildDefinitionRepository = new TfsBuildDefinitionRepository(credentials, settingStore.ForKey(SettingKeys.BuildDefinitions), settingStore.ForKey(SettingKeys.Builds), connectionSettings);
            var tfsMonitoringService         = new TfsMonitoringService(tfsBuildDefinitionRepository, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30));

            tfsMonitoringService.Start();
            var observableCollections = new Dictionary <string, IObservableRepository>
            {
                { "buildDefinitions", tfsMonitoringService.BuildDefinitions },
                { "builds", tfsMonitoringService.Builds },
                { "settings", tfsMonitoringService.Settings }
            };

            var observableRepositoryHubSubscriptionFactory = new ObservableRepositoryHubSubscriptionFactory(observableCollections);

            container.RegisterInstance(observableRepositoryHubSubscriptionFactory);
            container.RegisterInstance(credentialService);
        }
Ejemplo n.º 6
0
 public void Init(SettingStore settings)
 {
     Settings    = settings;
     DataContext = Settings;
     IsEnabled   = true;
     UpdateVSConfig(this, null);
 }
        public void ParseConfig()
        {
            CommandModel config = new CommandModel();

            config.PluginType = "ParseConfig";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "ConfigPath",
                    Value = @"./infrastructure.config"
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionStringName",
                    Value = "DatabaseConnection"
                }
            };
            IDataStore     data     = new DataStore();
            ISettingStore  settings = new SettingStore(config, null);
            IPluginCommand cmd      = new ParseConfigCommand(settings, data);
            bool           res      = cmd.Execute();

            Assert.IsTrue(res);
            Assert.AreEqual("Data Source=127.0.0.1;Initial Catalog=TestDB;Persist Security Info=True;User ID=user;Password=pass", data.GetValue("ConnectionString", ""));
            Assert.AreEqual("System.Data.SqlClient", data.GetValue("ProviderName", ""));
        }
        public override void SetUp()
        {
            base.SetUp();

            ServiceContainer.Register <IPlatformInfo> (platformInfo  = new PlatformInfo());
            ServiceContainer.Register <ISettingsStore> (settingStore = new SettingStore());
            upgradeManager = new UpgradeManger();
        }
Ejemplo n.º 9
0
        public override void SetUp ()
        {
            base.SetUp ();

            ServiceContainer.Register<IPlatformInfo> (platformInfo = new PlatformInfo ());
            ServiceContainer.Register<ISettingsStore> (settingStore = new SettingStore ());
            upgradeManager = new UpgradeManger ();
        }
Ejemplo n.º 10
0
 protected override void Load(bool allowUserSettings, NameValueCollection optionalValues)
 {
     foreach (var name in SettingStore.GetSettingNames())
     {
         LoadSetting(allowUserSettings, optionalValues, name);
     }
     properties = null;
 }
Ejemplo n.º 11
0
        public void LoadConfig(string path)
        {
            var bary    = System.IO.File.ReadAllBytes(path);
            var rawjson = Encoding.UTF8.GetString(bary);
            var config  = SettingStore.loadSettingJSON(rawjson);

            SettingStore.SingletonStore = config;
        }
Ejemplo n.º 12
0
        public IHttpActionResult SaveSetting(string applicationName, int version, string directory, int objectId, string key, [FromBody] string value)
        {
            var store = new SettingStore(applicationName, version, directory);

            return(SaveSetting(store, new SettingModel {
                Key = key, Value = value, ObjectId = objectId
            }));
        }
Ejemplo n.º 13
0
        public override void SetUp ()
        {
            base.SetUp ();

            ServiceContainer.Register<IPlatformUtils> (platformUtils = new PlatformUtils ());
            ServiceContainer.Register<ISettingsStore> (settingStore = new SettingStore ());
            ServiceContainer.Register<ExperimentManager> (new ExperimentManager ());
            upgradeManager = new UpgradeManger ();
        }
Ejemplo n.º 14
0
 public void Init(SettingStore settings)
 {
     if (Initialized)
     {
         return;
     }
     (this.Content as SolutionOptionWindowControl).Init(settings);
     Initialized = true;
 }
Ejemplo n.º 15
0
        public override async Task <string> GetOrNullAsync(SettingDefinition setting)
        {
            if (CurrentUser.Id == null)
            {
                return(null);
            }

            return(await SettingStore.GetOrNullAsync(setting.Name, Name, CurrentUser.Id.ToString()));
        }
Ejemplo n.º 16
0
        public override void SetUp()
        {
            base.SetUp();

            ServiceContainer.Register <IPlatformUtils> (platformUtils = new PlatformUtils());
            ServiceContainer.Register <ISettingsStore> (settingStore  = new SettingStore());
            ServiceContainer.Register <ExperimentManager> (new ExperimentManager());
            upgradeManager = new UpgradeManger();
        }
        public override async Task <List <SettingValue> > GetAllAsync(SettingDefinition[] settings)
        {
            if (CurrentUser.Id == null)
            {
                return(settings.Select(x => new SettingValue(x.Name, null)).ToList());
            }

            return(await SettingStore.GetAllAsync(settings.Select(x => x.Name).ToArray(), Name, CurrentUser.Id.ToString()));
        }
        public TfsBuildDefinitionRepository(VssCredentials credentials, SettingStore <Dictionary <int, BuildDefinition> > buildDefinitionStore, SettingStore <BuildCollection> buildStore, ConnectionSettings connectionSettings)
        {
            _buildDefinitionStore = buildDefinitionStore;
            _buildStore           = buildStore;
            _connectionSettings   = connectionSettings;
            var tfsCollectionUri = new Uri(_connectionSettings.TfsCollectionUrl);

            _buildClient          = new BuildHttpClient(tfsCollectionUri, credentials);
            _testManagementClient = new TestManagementHttpClient(tfsCollectionUri, credentials);
        }
        public static VSFloatingWindowWrapper Create(Window w, SettingStore settings)
        {
            var r = new VSFloatingWindowWrapper(w, settings);

            if (!r.IsLoaded)
            {
                return(null);
            }
            return(r);
        }
Ejemplo n.º 20
0
        public void BuildActualScripts()
        {
            CommandModel config = new CommandModel();

            config.PluginType = "BuildScript";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "TempScriptDirectory",
                    Value = "src1/sql"
                },
                new CommandSettingModel()
                {
                    Name  = "ProviderName",
                    Value = ProviderName
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionString",
                    Value = ConnectionString
                },
                new CommandSettingModel()
                {
                    Name  = "TablePrefix",
                    Value = "TEST_BUILD"
                },
                new CommandSettingModel()
                {
                    Name  = "ActualScriptFileName",
                    Value = "log/NotAppliedScripts.txt"
                }
            };
            ISettingStore  settings = new SettingStore(config, null);
            IDataStore     data     = new DataStore();
            IPluginCommand cmd      = new BuildScriptCommand(settings, data);
            bool           res      = cmd.Execute();

            Assert.IsTrue(res);

            List <string> scripts = data.GetValue <List <string> >("ScriptsToApply");

            Assert.AreEqual(2, scripts.Count);

            Assert.IsTrue(scripts[0].EndsWith("script2.sql"));
            Assert.IsTrue(scripts[1].EndsWith("script3.sql"));

            string actScriptPath = "src1/sql/log/NotAppliedScripts.txt";

            Assert.IsTrue(File.Exists(actScriptPath));

            //string expectedScript = GetExpectedScript();
            //string actScript = File.ReadAllText(actScriptPath);
            //Assert.AreEqual(expectedScript, actScript);
        }
Ejemplo n.º 21
0
        public void CollectScripts()
        {
            CommandModel config = new CommandModel();

            config.PluginType = "CollectScripts";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "RootDirectory",
                    Value = "./src"
                },
                new CommandSettingModel()
                {
                    Name  = "LeafDirectory",
                    Value = "init"
                },
                new CommandSettingModel()
                {
                    Name  = "TempScriptDirectory",
                    Value = "ScriptCollect"
                },
                new CommandSettingModel()
                {
                    Name  = "SourceDirectories",
                    Value = "module.*;module.*"
                }
            };
            ISettingStore  settings = new SettingStore(config, null);
            IPluginCommand cmd      = new CollectScriptsCommand(settings, null);
            bool           res      = cmd.Execute();

            Assert.IsTrue(res);

            DirectoryInfo dir = new DirectoryInfo("ScriptCollect");

            Assert.IsTrue(dir.Exists);

            IEnumerable <FileInfo> files = dir.GetFiles();

            Assert.AreEqual(4, files.Count());

            IEnumerable <DirectoryInfo> dirs = dir.GetDirectories();

            Assert.AreEqual(0, dirs.Count());

            Assert.IsTrue(files.Any(f => f.Name == "3_test.sql"));
            Assert.IsTrue(files.Any(f => f.Name == "4_test.sql"));
            //Assert.IsTrue(files.Any(f => f.Name == "5_test.sql"));
            //Assert.IsTrue(files.Any(f => f.Name == "6_test.sql"));
            Assert.IsTrue(files.Any(f => f.Name == "10_test.sql"));
            Assert.IsTrue(files.Any(f => f.Name == "11_test.sql"));
            //Assert.IsTrue(files.Any(f => f.Name == "12_test.sql"));
            //Assert.IsTrue(files.Any(f => f.Name == "13_test.sql"));
        }
Ejemplo n.º 22
0
 public IHttpActionResult GetSetttings(SettingStore store, int objectId)
 {
     try
     {
         return(Ok(controller.GetSettings(store, objectId)));
     }
     catch (Exception ex)
     {
         return(Error(ex));
     }
 }
Ejemplo n.º 23
0
 public IHttpActionResult GetByDirectory(SettingStore store)
 {
     try
     {
         return(Ok <SettingModel[]>(controller.GetSettings(store).ToArray()));
     }
     catch (Exception ex)
     {
         return(Error(ex));
     }
 }
Ejemplo n.º 24
0
 public IHttpActionResult SaveSettings(SettingStore store, IEnumerable <SettingModel> value)
 {
     try
     {
         controller.SaveSettings(store, value);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(Error(ex));
     }
 }
Ejemplo n.º 25
0
        public void ApplyScripts()
        {
            CommandModel config = new CommandModel();

            config.PluginType = "ApplyScript";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "ProviderName",
                    Value = ProviderName
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionString",
                    Value = ConnectionString
                },
                new CommandSettingModel()
                {
                    Name  = "TablePrefix",
                    Value = "TEST_BUILD"
                }
            };
            ISettingStore settings = new SettingStore(config, null);
            IDataStore    data     = new DataStore();
            List <string> scripts  = new List <string>()
            {
                "src1/sql/script2.sql",
                "src1/sql/script3.sql"
            };

            data.SetValue <List <string> >("ScriptsToApply", scripts);
            IPluginCommand cmd = new ApplyScriptCommand(settings, data);
            bool           res = cmd.Execute();



            Assert.IsTrue(res);

            using (DbConnection connection = TestDbHelper.GetConnection(ProviderName, ConnectionString)) {
                using (DbCommand sqlCmd = connection.CreateCommand()) {
                    sqlCmd.CommandText = "select count(*) from TEST_BUILD_DB_DELIVERY_HISTORY";
                    int count = (int)sqlCmd.ExecuteScalar();
                    Assert.AreEqual(2, count);
                }
                using (DbCommand sqlCmd = connection.CreateCommand()) {
                    sqlCmd.CommandText = "select count(*) from TEST_TABLE";
                    int count = (int)sqlCmd.ExecuteScalar();
                    Assert.AreEqual(2, count);
                }
            }
        }
Ejemplo n.º 26
0
        protected virtual void DoSet(string key, object value)
        {
            var store = new SettingStore {
                Key = key
            };

            if (!store.SetValue(value))
            {
                var s = this.serializer.Serialize(value);
                store.SetValue(s);
            }
            this.conn.GetConnection().InsertOrReplace(store);
        }
Ejemplo n.º 27
0
 public override void Save()
 {
     foreach (var name in SettingStore.GetUserNames())
     {
         if (!Folders.ContainsKey(name))
         {
             Reset(name);
         }
     }
     foreach (var name in Folders.Keys)
     {
         Save(name);
     }
 }
Ejemplo n.º 28
0
        public override async Task <string> GetOrNullAsync(SettingDefinition setting, string providerKey)
        {
            if (providerKey == null)
            {
                if (CurrentTenant.Id == null)
                {
                    return(null);
                }

                providerKey = CurrentTenant.Id.ToString();
            }

            return(await SettingStore.GetOrNullAsync(setting.Name, Name, providerKey));
        }
Ejemplo n.º 29
0
        public void CollectScripts()
        {
            //if (Directory.Exists("./backup")) {
            //    IEnumerable<string> oldFiles = Directory.GetFiles("./backup", "backup*.bak");
            //    foreach (string item in oldFiles) {
            //        File.Delete(item);
            //    }
            //}

            CommandModel config = new CommandModel();

            config.PluginType = "MakeBackup";
            config.Settings   = new List <CommandSettingModel>()
            {
                new CommandSettingModel()
                {
                    Name  = "BackupDirectory",
                    Value = @"D:\MSSQL\BACKUP\"
                },
                new CommandSettingModel()
                {
                    Name  = "BackupFileName",
                    Value = "backup_#TIMESTAMP#.bak"
                },
                new CommandSettingModel()
                {
                    Name  = "ProviderName",
                    Value = ProviderName
                },
                new CommandSettingModel()
                {
                    Name  = "ConnectionString",
                    Value = ConnectionString
                },
                new CommandSettingModel()
                {
                    Name  = "TablePrefix",
                    Value = "TEST_BUILD"
                }
            };
            ISettingStore  settings = new SettingStore(config, null);
            IPluginCommand cmd      = new MakeBackupCommand(settings, null);
            bool           res      = cmd.Execute();

            Assert.IsTrue(res);

            //IEnumerable<string> files = Directory.GetFiles("./backup", "backup*.bak");
            //Assert.IsTrue(files.Any());
        }
Ejemplo n.º 30
0
 public IHttpActionResult DeleteKey(string applicationName, int version, string directory, int objectId, string key)
 {
     try
     {
         SettingStore store = new SettingStore(applicationName, version, directory);
         controller.DeleteSetting(store, new SettingModel {
             Key = key, ObjectId = objectId
         });
         return(Ok());
     }
     catch (Exception ex)
     {
         return(Error(ex));
     }
 }
Ejemplo n.º 31
0
 public override void Save()
 {
     foreach (var name in SettingStore.GetSettingNames())
     {
         if (!Folders.ContainsKey(name))
         {
             Reset(name);
         }
     }
     foreach (var name in Folders.Keys)
     {
         SaveSetting(name);
     }
     properties = null;
 }
Ejemplo n.º 32
0
        public void SettingStoreBaseSetting()
        {
            CommandModel     cmdConfig;
            ConfigModel      config        = GetTestConfigBaseSettingModel(out cmdConfig);
            ConfigManager    configManager = new ConfigManager();
            EnvironmentModel env           = configManager.GetEnvironmentConfig(config, "DbDelivery", "test");

            ISettingStore store        = new SettingStore(cmdConfig, env);
            string        providerName = store.Get("ProviderName");

            Assert.AreEqual("System.Data.SqlClient", providerName);

            string connectionString = store.Get("ConnectionString");

            Assert.AreEqual("Data Source=192.168.10.33;Initial Catalog=DbDelivery_Test;Persist Security Info=True;User ID=userdb;Password=qwerty1", connectionString);
        }