private async void ImportScriptsToMaster() { var scriptsToBeImported = ScriptsCollection.Where(s => s.Value.IsSelected).Select(s => s.Value).ToList(); if (scriptsToBeImported.Count > 0) { foreach (var script in scriptsToBeImported) { script.IsSelected = false; script.ScriptStateAction = script.Active ? "Disable" : "Enable"; script.RowColor = script.Active ? "Black" : "DarkGray"; await _scriptDb.AddNewScript(script); RemoveScriptFromGrid(script); } var masterScript = await _masterScriptDb.GetMasterScript(); masterScript.Scripts.AddRange(scriptsToBeImported); await _masterScriptDb.UpdateScript(masterScript); //write masterscript on the disk ProcessScript.ExportScript(Path.Combine(masterScript.Location, masterScript.Name), masterScript.Scripts); Message = "Scripts imported successfully"; MessageVisibility = "Visible"; Helpers.Ui.Select(GetObservableCollectionOfScripts(), false); } else { MessageBox.Show("Please select at least one script from the grid to import", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private async void ImportScriptsToMaster() { var scriptsToBeImported = ScriptsCollection.Where(s => s.Value.IsSelected).Select(s => s.Value).ToList(); if (scriptsToBeImported.Count > 0) { foreach (var script in scriptsToBeImported) { script.IsSelected = false; await _scriptDb.AddNewScript(script); } var masterScript = await _masterScriptDb.GetMasterScript(); masterScript.Scripts.AddRange(scriptsToBeImported); await _masterScriptDb.UpdateScript(masterScript); //write masterscript on the disk ProcessScript.ExportScript(Path.Combine(masterScript.Location, masterScript.Name), masterScript.Scripts); Message = "Scripts imported successfully"; MessageVisibility = "Visible"; } else { MessageBox.Show("Please select at least one script from the grid to import", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private async void InsertScript() { ValidateForm(); MessageVisibility = "Visible"; if (FormIsValid) { var script = new Script { ScriptId = Guid.NewGuid().ToString(), Active = !IsDisabled, Description = ScriptDescription, Name = ScriptName, Text = ScriptContent }; script.ScriptStateAction = script.Active ? "Disable" : "Enable"; script.RowColor = script.Active ? "Black" : "DarkGray"; //add new script in data base await _scriptDb.AddNewScript(script); //add the script in master script too var masterScript = await _masterScriptDb.GetMasterScript(); masterScript.Scripts.Add(script); await _masterScriptDb.UpdateScript(masterScript); //write masterscript on the disk ProcessScript.ExportScript(Path.Combine(masterScript.Location, masterScript.Name), masterScript.Scripts); Message = "Script added successfully."; MessageColor = "#3EA691"; ClearForm(); } else { Message = "Please fill all the fields."; MessageColor = Color.DarkRed.Name; } }