private void Execute(object sender) { var selectedItem = SelectionManager.SelectedItem; if (selectedItem == null) { MessageBoxFactory.Show("No Item selected", "Export"); return; } var textLines = _applicableTypes[selectedItem.GetType()](selectedItem); if (textLines == null || !textLines.Any()) { MessageBoxFactory.Show("Unable to export inline table because it does not contain any rows", "Export"); return; } var saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Title = "Specify file to export data to"; saveFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; saveFileDialog1.ShowDialog(); if (saveFileDialog1.FileName != "") { System.IO.File.WriteAllLines(saveFileDialog1.FileName, textLines); MessageBoxFactory.Show("Successfuly exported " + textLines.Count() + " rows to file: " + saveFileDialog1.FileName, "Export"); } }
private void UpdateRules(object obj) { var sendToAmazon = false; var viewModel = new AwsSettingsViewModel(RuleApplicationService.RuleApplicationDef); var window = WindowFactory.CreateWindow("Service Settings", new AwsSettingsView(viewModel), false, Strings.OK, Strings.Cancel); window.ButtonClicked += delegate(object sender, WindowButtonClickedEventArgs <AwsSettingsView> args) { if (args.ClickedButtonText == Strings.OK) { _awsServiceInfo.TopEntityName = viewModel.EntityName; _awsServiceInfo.AwsFunctionName = viewModel.AwsFunctionName; _awsServiceInfo.ReturnDefinition = viewModel.ReturnDefinition; sendToAmazon = true; } window.Close(); }; window.Show(); if (sendToAmazon) { var waitWindow = new BackgroundWorkerWaitWindow("Beaming rules...", "Creating temporary rule application file...", true, false, true); waitWindow.DoWork += delegate { InRuleJavaScriptDistributionService.GenerateIndexFile(_awsServiceInfo); var javaScript = InRuleJavaScriptDistributionService.GetJavaScriptRules(RuleApplicationService.RuleApplicationDef); AwsConnection.UpdateLambdaFunction(_awsServiceInfo.AwsFunctionName, javaScript); }; waitWindow.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { var error = e.Error; if (error != null) { var text = $"The following error occurred:\n\n{error.Message}"; MessageBoxFactory.Show(text, "Error getting JavaScript", MessageBoxFactoryImage.Warning); } else if (e.Result != null) { var lines = ((string)e.Result).Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); WindowFactory.ShowLabeledListWindow("Output", "The following information was returned:", lines); } }; waitWindow.ShowDialog(); } }
private void DoIt(object obj) { var commands = CommandService.GetCommands(SelectionManager.SelectedItem); if (commands == null) { MessageBoxFactory.Show("no commands", "no commads"); } else { var window = new CommanderWindow(commands); window.Owner = Application.Current.MainWindow; window.Show(); } }
public void Execute() { try { _ruleAppDef = RuleApplicationService.RuleApplicationDef; _excelFilePath = Utility.BrowseForPath(); _sheetName = Utility.GetSheetName(); if (_excelFilePath.Length == 0) { return; } var spreadsheet = new Spreadsheet(); var rows = spreadsheet.ExtractExcelValues(_excelFilePath, _sheetName); var decisionTableDef = new DecisionTableDef(); decisionTableDef.Name = GetDTName(_excelFilePath); RuleApplicationService.Controller.AddDef(decisionTableDef, SelectedItem); // create a wait window that will run on background thread var window = new BackgroundWorkerWaitWindow("Decision Table Import", "Importing..."); // use delegate to load decision table with data window.DoWork += delegate(object sender, DoWorkEventArgs e) { ExecuteImport(decisionTableDef, rows, spreadsheet); }; // use delegate to report errors and close window window.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MessageBoxFactory.Show("The following error occurred while attempting to import the spreadsheet:\n\n" + e.Error.ToString(), "Import", MessageBoxFactoryImage.Error); } window.Close(); var validations = _ruleAppDef.Validate(); var s = new StringBuilder(); foreach (var validation in validations) { s.AppendLine(validation.ToString()); } if (s.Length > 0) { MessageBoxFactory.Show(s.ToString(), ""); } }; // show the window window.ShowDialog(); } catch (Exception e) { MessageBoxFactory.Show("The following error occurred while attempting to import the spreadsheet:\n\n" + e, "Regimen Import", MessageBoxFactoryImage.Error); } }