Changeset 8


Ignore:
Timestamp:
Aug 12, 2019, 12:33:47 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated files.
  • Added: ExtTools class for external program and compare tool execution.
Location:
Common
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • Common/Database.cs

    r7 r8  
    2828        public delegate void LogMessageHandler(string text);
    2929        public static event LogMessageHandler LogMessage;
    30         public static string connectionString = "";
    3130        public static string databaseName = "";
    3231        public static string serverName = "";
     
    4039
    4140            // Connect to server
    42             if (type == DatabaseType.MsSql)
    43             {
    44                 connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
    45             } else
    4641            if (type == DatabaseType.SQLite)
    4742            {
    4843                Directory.CreateDirectory(Path.GetDirectoryName(sqliteFileName));
    49                 connectionString = "Data Source=" + sqliteFileName + "; Version=3";
    5044                databaseName = null;
    5145            }
     
    6256                    {
    6357                        // database does not exist, try to create it
    64                         connectionString = "server=" + serverName + "; Trusted_Connection=yes; connection timeout=5";
    6558                        ExecuteNonQuery("CREATE DATABASE " + databaseName);
    6659
    6760                        // Need to wait for the new DB startup in order to continue and be sure it can be accessed
    6861                        if (connection is SqlConnection) SqlConnection.ClearAllPools();
    69 
    70                         connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
    7162                    }
    7263                    else
     
    8778
    8879            return result;
     80        }
     81
     82        public static string GetConnectionString()
     83        {
     84            string connectionString = "";
     85            if (type == DatabaseType.MsSql)
     86            {
     87                connectionString = "server=" + serverName + "; Trusted_Connection=yes; database=" + databaseName + "; connection timeout=5";
     88            }
     89            else
     90            if (type == DatabaseType.SQLite)
     91            {
     92                connectionString = "Data Source=" + sqliteFileName + "; Version=3";
     93            }
     94            return connectionString;
    8995        }
    9096
     
    105111        {
    106112            DbConnection connection = GetFactory().CreateConnection();
    107             connection.ConnectionString = connectionString;
     113            connection.ConnectionString = GetConnectionString();
    108114            return connection;
    109115        }
  • Common/Prompt.cs

    r6 r8  
    2121                StartPosition = FormStartPosition.CenterScreen,
    2222            };
    23             Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
     23            Label textLabel = new Label() { Left = 50, Top = 20, AutoSize = true, Text = text };
    2424            TextBox textBox = new TextBox() { Left = 50, Top = 44, Width = 400, Text = initialValue };
    2525            textBox.SelectAll();
     
    216216                StartPosition = FormStartPosition.CenterScreen,
    217217            };
    218             Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
     218            Label textLabel = new Label() { Left = 50, Top = 20, AutoSize = true, Text = text };
    219219            RichTextBox textBox = new RichTextBox() { Left = 50, Top = 44, Width = 400, Height = dataSize, Text = initialValue };
    220220            textBox.SelectAll();
  • Common/Registry.cs

    r2 r8  
    3535        }
    3636
     37        public static float GetValueFloat(this RegistryKey regKey, string name, float defaultValue)
     38        {
     39            object value = regKey.GetValue(name, defaultValue);
     40            float num;
     41            if (float.TryParse((string)value, out num))
     42                return num;
     43            else return defaultValue;
     44        }
     45
    3746        public static void SetValueBool(this RegistryKey regKey, string name, bool value)
    3847        {
     
    5059            regKey.SetValue(name, value);
    5160        }
     61
     62        public static void SetValueFloat(this RegistryKey regKey, string name, float value)
     63        {
     64            regKey.SetValue(name, value);
     65        }
    5266    }
    5367}
Note: See TracChangeset for help on using the changeset viewer.