Esempio n. 1
0
        private TableDescriptor GetMergeTable(ImportSingleTableDialog dialog, IOrderedEnumerable <TableDescriptor> tables)
        {
            foreach (var table in tables)
            {
                if (dialog.GetSelectedTable().Quote() ==
                    string.Format("{0}.{1}", table.Name.GetSchema().Quote(), table.Name.GetName().Quote()))
                {
                    return(table);
                }
            }

            return(null);
        }
Esempio n. 2
0
        private TableDescriptor GetMergeTable(ImportSingleTableDialog dialog, IOrderedEnumerable<TableDescriptor> tables)
        {
            foreach (var table in tables)
            {
                 if (dialog.GetSelectedTable().Quote() ==
                    string.Format("{0}.{1}", table.Name.GetSchema().Quote(), table.Name.GetName().Quote()))
                {
                    return table;
                }
            }

            return null;
        }
Esempio n. 3
0
        private void ImportTable_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var item = ProjectItems.SelectedItem as TreeViewItem;
                if (null == item)
                    return;

                var tag = item.Tag as ScriptNodeTag;

                if (tag == null)
                {
                    return;
                }

                var tableRepository = tag.Tables;

                if (tableRepository == null)
                {
                    MessageBox.Show("Unable to read table repository - try refreshing");
                    return;
                }

                var tables = tableRepository.Get().OrderBy(p => p.Name.GetSchema() + p.Name.GetName());
                var tableList = new List<string>();

                foreach (var table in tables)
                {
                    tableList.Add(string.Format("{0}.{1}", table.Name.GetSchema().Quote(), table.Name.GetName().Quote()));
                }

                var dialog = new ImportSingleTableDialog(tableList);
                var result = dialog.ShowDialog();
                if (String.IsNullOrEmpty(dialog.GetSelectedTable()))
                    return;

                var mergeTable = GetMergeTable(dialog, tables);

                    //tables.FirstOrDefault(
                //    p => dialog.GetSelectedTable().Quote() == dialog.GetSelectedTable().Quote());

                if (dialog.ImportedData == null)
                {
                    return;
                }

                var merge = new MergeStatementFactory().Build(mergeTable, tag.ScriptPath, dialog.ImportedData);
                merge.Data.ExtendedProperties["Changed"] = true;

                var mergeNode = new TreeViewItem();
                mergeNode.Header = merge.Name.Value;
                mergeNode.Tag = merge;
                mergeNode.ContextMenu = ProjectItems.Resources["TableContext"] as ContextMenu;
                item.Items.Add(mergeNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to import table: " + ex.Message);
            }
        }
Esempio n. 4
0
        private void ImportTable_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var item = ProjectItems.SelectedItem as TreeViewItem;
                if (null == item)
                {
                    return;
                }

                var tag = item.Tag as ScriptNodeTag;

                if (tag == null)
                {
                    return;
                }

                var tableRepository = tag.Tables;

                if (tableRepository == null)
                {
                    MessageBox.Show("Unable to read table repository - try refreshing");
                    return;
                }

                var tables    = tableRepository.Get().OrderBy(p => p.Name.GetSchema() + p.Name.GetName());
                var tableList = new List <string>();

                foreach (var table in tables)
                {
                    tableList.Add(string.Format("{0}.{1}", table.Name.GetSchema().Quote(), table.Name.GetName().Quote()));
                }

                var dialog = new ImportSingleTableDialog(tableList);
                var result = dialog.ShowDialog();
                if (String.IsNullOrEmpty(dialog.GetSelectedTable()))
                {
                    return;
                }

                var mergeTable = GetMergeTable(dialog, tables);

                //tables.FirstOrDefault(
                //    p => dialog.GetSelectedTable().Quote() == dialog.GetSelectedTable().Quote());

                if (dialog.ImportedData == null)
                {
                    return;
                }

                var merge = new MergeStatementFactory().Build(mergeTable, tag.ScriptPath, dialog.ImportedData);
                merge.Data.ExtendedProperties["Changed"] = true;

                var mergeNode = new TreeViewItem();
                mergeNode.Header      = merge.Name.Value;
                mergeNode.Tag         = merge;
                mergeNode.ContextMenu = ProjectItems.Resources["TableContext"] as ContextMenu;
                item.Items.Add(mergeNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to import table: " + ex.Message);
            }
        }