protected override void ExecuteCore(object parameter) { ListView lvw = parameter as ListView; DataRowView drw = lvw.SelectedItem as DataRowView; string ownerName = drw.Row.Field <string>(0); string tableName = drw.Row.Field <string>(1); string message = string.Format(AppStrings.Generate_Trigger, ownerName, tableName); Window wnd = (Window)GetTopParent(lvw); MessageBoxResult result = MessageBox.Show(wnd, message, AppStrings.Question, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (result != MessageBoxResult.Yes) { return; } TriggerGenerator tg = new TriggerGenerator(); tg.GenerateAndExecute(ownerName, tableName); MessageBox.Show(wnd, AppStrings.Trigger_Generation_Completed, AppStrings.Information, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); }
protected override void ExecuteCore(object parameter) { ListView lvw = parameter as ListView; Window wnd = (Window)GetTopParent(lvw); string tableFilterSql = ConfigurationManager.AppSettings[SettingNames.TableFilterSql]; if (string.IsNullOrWhiteSpace(tableFilterSql)) { MessageBox.Show(wnd, AppStrings.Table_Filter_Sql_Is_Not_Defined, AppStrings.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); return; } MessageBoxResult result = MessageBox.Show(wnd, AppStrings.Generate_Trigger_For_Selected_Tables, AppStrings.Question, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (result != MessageBoxResult.Yes) { return; } var dataTable = DataManager.ExecuteCommand(tableFilterSql); var query = from dr in dataTable.Rows.OfType <DataRow>() select new { TableName = dr.Field <string>("TABLE_NAME"), }; var tableList = query.ToDictionary(z => z.TableName, x => x.TableName); TriggerGenerator tg = new TriggerGenerator(); foreach (var lvwItem in lvw.Items) { DataRowView drw = lvwItem as DataRowView; string ownerName = drw.Row.Field <string>(0); string tableName = drw.Row.Field <string>(1); if (tableList.ContainsKey(tableName)) { tg.GenerateAndExecute(ownerName, tableName); } } MessageBox.Show(wnd, AppStrings.Trigger_Generation_Completed, AppStrings.Information, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK); }