Ejemplo n.º 1
0
        /// <summary>
        /// Подключение к СУБД
        /// </summary>
        /// <param name="pCredentials"></param>
        public static void ConnectDb(DbCredentials pCredentials)
        {
            switch (Db.CurrDbType)
            {
                case DbType.Vertica:
                    Connection = DbVertica.ConnectDb(pCredentials);
                    break;
                default: throw new NotImplementedException("Нет реализации для данного типа СУБД");

            }
        }
Ejemplo n.º 2
0
        public static VerticaConnection ConnectDb(DbCredentials pCredentials)
        {
            var vcsb = new VerticaConnectionStringBuilder
            {
                Database = pCredentials.DataBase,
                User = pCredentials.User,
                Password = pCredentials.Password,
                Host = pCredentials.ServerIp
            };

            var vConnection = new VerticaConnection(vcsb.ConnectionString);

            vConnection.Open();
            return vConnection;
        }
Ejemplo n.º 3
0
        public static async Task <DbCredentials> GetDbCredentials()
        {
            if (!File.Exists(CredentialFileName))
            {
                var creds = new DbCredentials("localhost", 3306, "root", "");
                var json  = JsonConvert.SerializeObject(creds, Formatting.Indented);
                await File.WriteAllTextAsync(CredentialFileName, json);

                return(creds);
            }
            else
            {
                var json = await File.ReadAllTextAsync(CredentialFileName);

                return(JsonConvert.DeserializeObject <DbCredentials>(json));
            }
        }