public void SaveConfig(string path) { var json = SettingStore.getSettingJSON(SettingStore.SingletonStore); var bary = Encoding.UTF8.GetBytes(json); System.IO.File.WriteAllBytes(path, bary); }
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); }
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(); }
protected override void Load(bool allowUserSettings, Dictionary <string, string> optionsDictionary) { foreach (var name in SettingStore.GetUserNames()) { Load(allowUserSettings, optionsDictionary, name, typeof(string)); } }
/// <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); }
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(); }
public override void SetUp () { base.SetUp (); ServiceContainer.Register<IPlatformInfo> (platformInfo = new PlatformInfo ()); ServiceContainer.Register<ISettingsStore> (settingStore = new SettingStore ()); upgradeManager = new UpgradeManger (); }
protected override void Load(bool allowUserSettings, NameValueCollection optionalValues) { foreach (var name in SettingStore.GetSettingNames()) { LoadSetting(allowUserSettings, optionalValues, name); } properties = null; }
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; }
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 })); }
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 void Init(SettingStore settings) { if (Initialized) { return; } (this.Content as SolutionOptionWindowControl).Init(settings); Initialized = true; }
public override async Task <string> GetOrNullAsync(SettingDefinition setting) { if (CurrentUser.Id == null) { return(null); } return(await SettingStore.GetOrNullAsync(setting.Name, Name, CurrentUser.Id.ToString())); }
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); }
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); }
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")); }
public IHttpActionResult GetSetttings(SettingStore store, int objectId) { try { return(Ok(controller.GetSettings(store, objectId))); } catch (Exception ex) { return(Error(ex)); } }
public IHttpActionResult GetByDirectory(SettingStore store) { try { return(Ok <SettingModel[]>(controller.GetSettings(store).ToArray())); } catch (Exception ex) { return(Error(ex)); } }
public IHttpActionResult SaveSettings(SettingStore store, IEnumerable <SettingModel> value) { try { controller.SaveSettings(store, value); return(Ok()); } catch (Exception ex) { return(Error(ex)); } }
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); } } }
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); }
public override void Save() { foreach (var name in SettingStore.GetUserNames()) { if (!Folders.ContainsKey(name)) { Reset(name); } } foreach (var name in Folders.Keys) { Save(name); } }
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)); }
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()); }
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)); } }
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; }
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); }