public SettingEditForm(Setting setting, WorkingDirectoryObject directory) { InitializeComponent(); this.setting = setting; this.directory = directory; comboBox1.DataSource = Enum.GetNames(typeof(ValueDataType)).OrderBy(s => s).ToArray(); comboBox1.SelectedItem = "String"; if (setting != null) { SetEditorWithValue(setting); textKey.Text = setting.Key; textInfo.Text = setting.Info; textObjectId.EditValue = setting.ObjectId; } else { SetEditor(ValueDataType.String); } comboBox1.SelectedIndexChanged += ComboBox1_SelectedIndexChanged; }
private async Task OpenSettings() { gridControlDirectories.Visible = false; gridControlSettings.Visible = true; var directory = gridViewDirectories.GetRow(gridViewDirectories.FocusedRowHandle) as SettingsDirectory; Level = ApplicationControlLevel.Setting; try { OnShowProgress(); if (directory != null) { ShowDirectory(directory); currentDirectory = await settingsManager.OpenDirectoryAsync(Application.Name, CurrentVersion.Version, directory.Name); if (currentDirectory != null) { gridControlDirectories.Visible = false; gridControlSettings.Visible = true; gridControlSettings.DataSource = currentDirectory.Items; } } } finally { OnHideProgress(); } }
public async Task SettingsPerObject() { await CreateApplicationMasterAsync(); List <Setting> settings = new List <Setting>(); settings.Add(new Setting { ObjectId = 0, Key = Util.RandomString(), Value = Util.RandomString() }); settings.Add(new Setting { ObjectId = 1, Key = Util.RandomString(), Value = Util.RandomString() }); await currentDirectory.SaveAsync(settings); currentDirectory = await settingsManager.OpenDirectoryAsync(currentApplicationName, currentDirectory.Name); Assert.IsTrue(currentDirectory.Items.Count() == 2); currentDirectory.ObjectID = 1; Assert.IsTrue(currentDirectory.Items.Count() == 1); await currentDirectory.SaveAsync("test", "tst"); Assert.IsTrue(currentDirectory.Items.Count() == 2); Assert.IsTrue(currentDirectory.Items.All(i => i.ObjectId == 1)); }
public async Task CopyDirectoryMasterAsync() { await CreateDirectoryMasterAsync(); try { string newName = Util.RandomString(); string directoryDescription = currentDirectory.Description; string settingsKey = "Sample"; bool settingValue = true; await currentDirectory.SaveAsync(settingsKey, settingValue); await settingsManager.CopyDirectoryAsync(currentApplicationName, currentDirectory.Name, newName); currentDirectory = await settingsManager.OpenDirectoryAsync(currentApplicationName, newName); Assert.AreEqual(newName, currentDirectory.Name); Assert.AreEqual(directoryDescription, currentDirectory.Description); Assert.IsTrue(await currentDirectory.Exists(settingsKey)); Assert.IsTrue((await currentDirectory.GetBooleanAsync(settingsKey)).Value); } catch (SettingsException ex) { Assert.Fail(ex.Message); } }
public async Task CreateApplicationMasterAsync() { if (currentApplication == null) { settingsManager = new SettingsManager(_url, _masterKey); string applicationName = "Settings" + Util.RandomString(); string description = Util.RandomString(); await settingsManager.CreateApplicationAsync(applicationName, description); currentApplication = await settingsManager.GetApplication(applicationName); Assert.AreEqual(currentApplication.Name, applicationName); Assert.AreEqual(currentApplication.Description, description); currentApplicationName = currentApplication.Name; currentDirectory = await settingsManager.OpenDirectoryAsync(applicationName); } }
public async Task CreateDirectoryMasterAsync() { await CreateApplicationMasterAsync(); try { string directoryName = Util.RandomString(); string directoryDescription = Util.RandomString(); await settingsManager.CreateDirectoryAsync(currentApplicationName, directoryName, directoryDescription); currentDirectory = await settingsManager.OpenDirectoryAsync(currentApplicationName, directoryName); Assert.AreEqual(directoryName, currentDirectory.Name); Assert.AreEqual(directoryDescription, currentDirectory.Description); } catch (SettingsException ex) { Assert.Fail(ex.Message); } }
public async Task<WorkingDirectoryObject> OpenDirectoryAsync(string applicationName, int version, string directoryName, int objectId) { var applicationProvider = new ApplicationProvider(_url, _apiKey, applicationName); var application = await applicationProvider.Get(); if (application == null) { throw new SettingNotFoundException(directoryName); } var directory = application.Directories.SingleOrDefault(d => string.Equals(d.Name, directoryName)); if (directory == null) { throw new SettingNotFoundException(directoryName); } var workingDirectory = new WorkingDirectoryObject(directory, applicationName, version, objectId, _url, _apiKey); workingDirectory.UseCache = true; workingDirectory.ExplicitlySave = false; await workingDirectory.Reload(); return workingDirectory; }