Exemple #1
0
        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);
        }
        private void lvwTables_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lvwTables.SelectedItem == null)
            {
                return;
            }

            FlowDocument fdoc = new FlowDocument();
            Paragraph    p1   = new Paragraph();

            DataRowView drw       = lvwTables.SelectedItem as DataRowView;
            string      tableName = drw.Row.Field <string>(1);
            string      ownerName = drw.Row.Field <string>(0);

            txtTableName.Text = tableName;

            TriggerGenerator tg = new TriggerGenerator();

            p1.Inlines.Add(new Run(tg.BuildTrigger(ownerName, tableName)));
            fdoc.Blocks.Add(p1);
            rtblog.Document = fdoc;
        }