Пример #1
0
        private async void SaveAndConnect()
        {
            try
            {
                ConnectionBuilder.BuildConnectionString();

                DTEXMLConnection xMLCore = new DTEXMLConnection();
                if (isEdit)
                {
                    var xmlModel = xMLCore.Connections.FirstOrDefault(x => x.ConnectionBuilder.Id == ConnectionBuilder.Id);
                    var index    = xMLCore.Connections.IndexOf(xmlModel);
                    xMLCore.Connections.RemoveAt(index);
                    xmlModel.ConnectionBuilder = (ConnectionBuilderBase)ConnectionBuilder;
                    xMLCore.Connections.Insert(index, xmlModel);
                }
                else
                {
                    xMLCore.Connections.Insert(0, new TreeViewModel()
                    {
                        ConnectionBuilder = (ConnectionBuilder as ConnectionBuilderBase)
                    });
                }
                xMLCore.ConnectionSerialize();
            }
            catch (Exception ex)
            {
                await dialogCoordinator.ShowMessageAsync(this, $"Error!", $"Error message: {ex.Message}  \r\nStackTrace: {ex.StackTrace}");
            }
        }
Пример #2
0
 public QueryToEntityVM(IDialogCoordinator instance, ConnectionBuilderBase connectionBuilder, string databaseName = null)
 {
     _dialogCoordinator = instance;
     if (connectionBuilder != null)
     {
         ConnectionBuilder = connectionBuilder;
     }
     if (databaseName != null)
     {
         ConnectionBuilder.Database = databaseName;
     }
     ConnectionBuilder.BuildConnectionString();
 }
Пример #3
0
        private bool CheckConnection()
        {
            try
            {
                ConnectionBuilder.BuildConnectionString();
                IDbConnection connection;
                switch (ConnectionBuilder.ConnectionType)
                {
                case CORE.SupportedConnectionsTypes.MySQL:
                    connection = new MySqlConnection(ConnectionBuilder.ConnectionString);
                    connection.Open();
                    connection.Close();
                    break;

                case CORE.SupportedConnectionsTypes.MSSQL:
                    connection = new SqlConnection(ConnectionBuilder.ConnectionString);
                    connection.Open();
                    connection.Close();
                    break;

                case CORE.SupportedConnectionsTypes.PostgreSQL:
                    connection = new NpgsqlConnection(ConnectionBuilder.ConnectionString);
                    connection.Open();
                    connection.Close();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                exception = ex;
                return(false);
            }

            return(true);
        }