Ejemplo n.º 1
0
        static bool RefreshSettings()
        {
            List <string> Sections = GetSections(Path.Combine(Environment.CurrentDirectory, "config.ini"));

            Support.iniManager iniEngine = new Support.iniManager(Path.Combine(Environment.CurrentDirectory, "config.ini"));
            foreach (string item in Sections)
            {
                int NewVersion;
                if (!Int32.TryParse(iniEngine.IniReadValue(item, "Version"), out NewVersion))
                {
                    return(false);
                }
                string EncryptionKey = iniEngine.IniReadValue(item, "EncryptionKey");
                string EncryptionIV  = iniEngine.IniReadValue(item, "EncryptionIV");

                int PingTimer;
                if (!int.TryParse(iniEngine.IniReadValue(item, "PingTimer"), out PingTimer))
                {
                    return(false);
                }

                int LogLevel;
                if (!int.TryParse(iniEngine.IniReadValue(item, "LogLevel"), out LogLevel))
                {
                    return(false);
                }

                if (AppsRunning.Count > 0)
                {
                    int FormerVersion = Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion;
                    if (NewVersion != FormerVersion)
                    {
                        Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion = NewVersion;
                        Console.WriteLine("CONFIG update: Using now version " + NewVersion.ToString());
                    }

                    int FormerLogLevel = Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel;
                    if (LogLevel != FormerLogLevel)
                    {
                        Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel = LogLevel;
                        Console.WriteLine("CONFIG update: Using now LogLevel " + LogLevel.ToString());
                    }

                    string FormerEncryptionKey = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey;
                    if (FormerEncryptionKey != EncryptionKey)
                    {
                        Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey = EncryptionKey;
                        Console.WriteLine("CONFIG update: Using now encryption key " + EncryptionKey);
                    }

                    string FormerEncryptionIV = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV;
                    if (FormerEncryptionIV != EncryptionIV)
                    {
                        Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV = EncryptionIV;
                        Console.WriteLine("CONFIG update: Using now encryption IV " + EncryptionIV);
                    }

                    int FormerPingTimer = Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer;
                    if (FormerEncryptionIV != EncryptionIV)
                    {
                        Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer = PingTimer;
                        Console.WriteLine("CONFIG update: Using now PingTimer " + PingTimer.ToString() + "ms");
                    }
                }
            }
            return(true);
        }