Esempio n. 1
0
        /// <summary> Return current version of database. </summary>
        public static bool TryGetCurrentDatabaseVersion(out Version version)
        {
            bool result = false;

            version = new Version();
            try
            {
                result = TryParseVersion(MyDataBase.GetDB().ExecuteQueryWithAnswer($"SELECT {db_field} FROM {db_table}"), out version);
            }
            catch { }

            return(result);
        }
Esempio n. 2
0
        /// <summary> Check connection string for correctness and require the user to enter the correct connection string if needed. </summary>
        private static void CheckConnectionString()
        {
            string connectionString = Configuration.GetVariable("ConnectionString");

            while (string.IsNullOrEmpty(connectionString) || !MyDataBase.GetDB().TestConnectionString(connectionString))
            {
                ConsoleUtility.WriteLine("Connection string not set or entered incorrectly.", TextColor);
                ConsoleUtility.WriteLine(">>>Enter connection string:", TextColor);
                connectionString = ConsoleUtility.ReadLine(TextColor);
                Console.WriteLine();
            }

            Configuration.SetVariable("ConnectionString", connectionString);
        }
Esempio n. 3
0
        /// <summary> Return current version of database. </summary>
        public static bool TryGetCurrentDatabaseVersion(out double version)
        {
            bool isGetted = false;

            version = -1;

            try
            {
                version  = double.Parse(MyDataBase.GetDB().ExecuteQueryWithAnswer("SELECT version FROM db_version"));
                isGetted = true;
            }
            catch { }

            return(isGetted);
        }
Esempio n. 4
0
        private static void Main()
        {
            CheckConfigurationVariables();

            // IT'S FOR TESTS
            if (!MyDataBase.GetDB().IsExistringTable("db_version"))
            {
                MyDataBase.GetDB().ExecuteQueryWithoutAnswer("CREATE TABLE db_versions (verions INT)");
                MyDataBase.GetDB().ExecuteQueryWithoutAnswer("INSERT INTO db_versions VALUES (1.2505)");
            }
            else
            {
                MyDataBase.GetDB().ExecuteQueryWithoutAnswer("UPDATE db_version SET version = 1.2505");
            }

            ShowMainMenu();
        }
Esempio n. 5
0
 /// <summary> Check connection string for correctness and require the user to enter the correct connection string if needed. </summary>
 public static bool CheckConnectionString(string connectionString)
 {
     return(string.IsNullOrEmpty(connectionString) || !MyDataBase.GetDB().TestConnectionString(connectionString));
 }
Esempio n. 6
0
 /// <summary> Set database version. </summary>
 public static void TrySetCurrentDatabaseVersion(Version version)
 {
     MyDataBase.GetDB().ExecuteQueryWithoutAnswer($"UPDATE {db_table} SET {db_field} = '{version.ToString()}'");
 }