Exemplo n.º 1
0
        /// <summary>
        /// Database initialization checks
        /// </summary>

        #region Database initialization checks

        public static void DBInitializationChecks()
        {
            if (!File.Exists(Settings.sqlFile()))
            {
                SQLStorage db = new SQLStorage();
                db.createDB();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get parameters from DB
        /// </summary>

        #region Get parameters from DB

        public static string retrievePar(string parameter)
        {
            if (!File.Exists(Settings.sqlFile()))
            {
                SQLStorage db = new SQLStorage();
                db.createDB();
            }

            generic_connection.Open();
            string        command = "select value from config where parameter='" + parameter + "';";
            SqliteCommand cmd     = new SqliteCommand(command, generic_connection);
            string        result  = cmd.ExecuteScalar().ToString();

            generic_connection.Close();
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Database initialization checks
        /// </summary>

        #region Database initialization checks

        public static void DBInitializationChecks()
        {
            try
            {
                string sqliteFile        = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Software\\endpoint.db3";
                string MSIConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Software\\configApp.xml";

                if (!File.Exists(sqliteFile) && File.Exists(MSIConfigFilePath))
                {
                    // Read MSI config file

                    XPathDocument  configMSI    = new XPathDocument(MSIConfigFilePath);
                    XPathNavigator navConfigMSI = configMSI.CreateNavigator();

                    globalConfigParams.serverAddress  = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/address").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.serverIP       = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/ip").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.textAnalytics  = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/pcenabled").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.aesKey         = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/cryptkey").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.aesIV          = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/cryptkey").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.serverPassword = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/srvpwd").ToString()).Replace("\0", String.Empty);
                    globalConfigParams.excludedApps   = InstallerClass.DecRijndaelMSI(navConfigMSI.SelectSingleNode("/ConfigParameters/apps").ToString()).Replace("\0", String.Empty);

                    SQLStorage db = new SQLStorage();
                    db.CreateDB();

                    Filesystem.WriteLog("INFO : Internal database created from MSI config file");
                }
                else if (!File.Exists(sqliteFile) && !File.Exists(MSIConfigFilePath))
                {
                    Filesystem.WriteLog("ERROR : Internal database and MSI config file doesn't exist, please run MSI Installer");
                    Environment.Exit(0);
                }
                else
                {
                    Filesystem.WriteLog("INFO : User DB3 database found, continue");
                }
            }
            catch (Exception ex)
            {
                Filesystem.WriteLog("ERROR : Exception trown in Database check procedure : " + ex);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set parameters in DB
        /// </summary>

        #region Set parameters in DB

        public static void modifyPar(string command, string variable_with_value, string uniqueID)
        {
            if (!File.Exists(Settings.sqlFile()))
            {
                SQLStorage db = new SQLStorage();
                db.createDB();
            }

            string[] variable_and_parameter = variable_with_value.Split(' ');
            string   variable = variable_and_parameter[0];
            string   value    = variable_and_parameter[variable_and_parameter.Length - 1];

            generic_connection.Open();
            string        SQLcommand = "update config set value='" + value + "' where parameter='" + variable + "';";
            SqliteCommand cmd        = new SqliteCommand(SQLcommand, generic_connection);

            cmd.ExecuteNonQuery();
            generic_connection.Close();

            // Inform that the command was received

            Network.SendData(variable + " changed!", command, uniqueID, 1);
        }