public void AddDescription(object sender, ExecutedRoutedEventArgs e) { try { var menuInfo = ValidateMenuInfo(sender); if (menuInfo != null) { using (IRepository repository = RepoHelper.CreateRepository(menuInfo.Connectionstring)) { var desc = ExplorerControl.DescriptionCache.Where(d => d.Object == menuInfo.Name && d.Parent == menuInfo.Description).Select(d => d.Description).SingleOrDefault(); DescriptionDialog ro = new DescriptionDialog(desc); ro.Owner = Application.Current.MainWindow; ro.ShowDialog(); if (ro.DialogResult.HasValue && ro.DialogResult.Value == true && !string.IsNullOrWhiteSpace(ro.Description) && ro.Description != desc) { new Helpers.DescriptionHelper().SaveDescription(menuInfo.Connectionstring, ExplorerControl.DescriptionCache, ro.Description, menuInfo.Description, menuInfo.Name); } } } } catch (Exception ex) { MessageBox.Show(Helpers.DataConnectionHelper.ShowErrors(ex)); } }
public void AddDescription(object sender, ExecutedRoutedEventArgs e) { var databaseInfo = ValidateMenuInfo(sender); if (databaseInfo == null) { return; } try { string desc; ExplorerControl.DescriptionCache = new Helpers.DescriptionHelper().GetDescriptions(databaseInfo.DatabaseInfo); desc = ExplorerControl.DescriptionCache.Where(d => d.Object == null && d.Parent == null).Select(d => d.Description).SingleOrDefault(); var ro = new DescriptionDialog(desc) { IsDatabase = true }; ro.ShowModal(); if (ro.DialogResult.HasValue && ro.DialogResult.Value && !string.IsNullOrWhiteSpace(ro.TableDescription) && ro.TableDescription != desc) { new Helpers.DescriptionHelper().SaveDescription(databaseInfo.DatabaseInfo, ExplorerControl.DescriptionCache, ro.TableDescription, null, null); } DataConnectionHelper.LogUsage("DatabaseAddDescription"); } catch (Exception ex) { DataConnectionHelper.SendError(ex, databaseInfo.DatabaseInfo.DatabaseType, false); } }
internal void UpdateDescriptions(MenuCommandParameters menuInfo, string name) { try { using (var repository = DataConnectionHelper.CreateRepository(menuInfo.DatabaseInfo)) { var tableDesc = ExplorerControl.DescriptionCache.Where(d => d.Object == name && d.Parent == null).Select(d => d.Description).SingleOrDefault(); var ro = new DescriptionDialog(tableDesc) { ColumnsInfo = GetSiblingColumnInfo(repository, name) }; ro.ShowModal(); if (!ro.DialogResult.HasValue || ro.DialogResult.Value != true) { return; } //save table description new Helpers.DescriptionHelper().SaveDescription(menuInfo.DatabaseInfo, ExplorerControl.DescriptionCache, ro.TableDescription, null, menuInfo.Name); //save all columns foreach (var item in ro.ColumnsInfo) { new Helpers.DescriptionHelper().SaveDescription(menuInfo.DatabaseInfo, ExplorerControl.DescriptionCache, item.Description, name, item.Name); } ExplorerControl.DescriptionCache = new Helpers.DescriptionHelper().GetDescriptions(menuInfo.DatabaseInfo); ((ExplorerControl)ParentWindow.Content).RefreshTables(menuInfo.DatabaseInfo); DataConnectionHelper.LogUsage("TableUpdateDescriptions"); } } catch (Exception ex) { DataConnectionHelper.SendError(ex, menuInfo.DatabaseInfo.DatabaseType, false); } }