Пример #1
0
 public async void LoadFirstConnAsync()
 {
     try
     {
         XMLCore.ConnectionDeserialize();
         if (XMLCore.Connections.Count > 0)
         {
             try
             {
                 await XMLCore.Connections.First().LoadDatabasesAsync();
             }
             catch (Exception ex)
             {
                 await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  \r\nStackTrace: {ex.StackTrace}");
             }
         }
         else
         {
             new Views.Windows.ConnectionManagerWin().ShowDialog();
             XMLCore.ConnectionDeserialize();
             XMLCore.Connections.FirstOrDefault()?.LoadDatabasesAsync();
         }
     }
     catch (Exception ex)
     {
         await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  \r\nStackTrace: {ex.StackTrace}");
     }
 }
Пример #2
0
        private async void DeleteConnectionAsync()
        {
            if (SelectedNode != null && SelectedNode is TreeViewModel)
            {
                var res = await dialogCoordinator.ShowMessageAsync(this, $"Are you sure?", $"Are you sure to delete this connection: {(SelectedNode as TreeViewModel).Connection.ConnectionName}?", MessageDialogStyle.AffirmativeAndNegative);

                if (res == MessageDialogResult.Affirmative)
                {
                    XMLCore.Connections.Remove((SelectedNode as TreeViewModel));
                    XMLCore.ConnectionSerialize();
                    XMLCore.ConnectionDeserialize();
                }
            }
        }
Пример #3
0
        private void EditConnectionAsync()
        {
            Views.Windows.ConnectionManagerWin connectionManagerWin = new Views.Windows.ConnectionManagerWin(SelectedNode as TreeViewModel);
            var res = connectionManagerWin.ShowDialog();

            XMLCore.ConnectionDeserialize();
            if (res != null && res == true)
            {
                var cmvm = connectionManagerWin.DataContext as ConnectionManagerVM;
                if (cmvm.EditModel != null)
                {
                    var con = XMLCore.Connections.FirstOrDefault(x => x.Connection.ConnectionName == cmvm.EditModel.ConnectionName);
                    con?.LoadDatabasesAsync();
                }
            }
        }
Пример #4
0
        private async void EditConnectionAsync()
        {
            try
            {
                Views.Windows.ConnectionManagerWin connectionManagerWin = new Views.Windows.ConnectionManagerWin(SelectedNode as TreeViewModel);
                var res = connectionManagerWin.ShowDialog();

                XMLCore.ConnectionDeserialize();
                if (res != null && res == true)
                {
                    var cmvm = connectionManagerWin.DataContext as ConnectionManagerVM;
                    if (cmvm.ConnectionBuilder != null)
                    {
                        var con = XMLCore.Connections.FirstOrDefault(x => x.ConnectionBuilder.Id == cmvm.ConnectionBuilder.Id);
                        con?.LoadDatabasesAsync();
                    }
                }
            }
            catch (Exception ex)
            {
                await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  \r\nStackTrace: {ex.StackTrace}");
            }
        }