Beispiel #1
0
        public Config(string configSuffix = "")
        {
            configSuffix = configSuffix.Trim().Replace(" ", "");
            if (configSuffix != "")
            {
                _configFile = "config_" + configSuffix + ".config";
            }

            var appData = (string) ConfigItems.Debug_Logpath.Default;
            if (!Directory.Exists(appData))
                Directory.CreateDirectory(appData);

            string config = Path.Combine(appData, _configFile);

            _c = new MapConfig(config);

            Fields.Elpis_HotKeys = new Dictionary<int,HotkeyConfig>();

            //If not config file, init with defaults then save
            if (!File.Exists(config))
            {
                LoadConfig();
                SaveConfig();
            }
        }
Beispiel #2
0
        private bool CheckForUpdateInternal(bool beta = false)
        {
            try
            {
                Log.O("Checking for "+(beta?"beta ":"")+"updates...");
                string updateUrl = "";

            #if APP_RELEASE
                updateUrl = ReleaseData.UpdateBaseUrl + ReleaseData.UpdateConfigFile +
                            "?r=" + DateTime.UtcNow.ToEpochTime().ToString();
                    //Because WebClient won't let you disable caching :(
            #endif
                Log.O("Downloading update file: " + updateUrl);

                string data = DownloadString(updateUrl);

                var mc = new MapConfig();
                mc.LoadConfig(data);

                string verStr = mc.GetValue(beta?"BetaVersion":"CurrentVersion", string.Empty);
                DownloadUrl = mc.GetValue(beta ? "BetaDownloadUrl" : "DownloadUrl", string.Empty);
                ReleaseNotesPath = mc.GetValue(beta ? "BetaReleaseNotes" : "ReleaseNotes", string.Empty);

                ReleaseNotes = string.Empty;
                if(ReleaseNotesPath != string.Empty)
                {
                    ReleaseNotes = DownloadString(ReleaseNotesPath);
                }

                Version ver = null;

                if (!Version.TryParse(verStr, out ver))
                {
                    SendUpdateEvent(false);
                    return false;
                }

                NewVersion = ver;

                bool result = false;
                if (NewVersion > CurrentVersion)
                    result = true;

                UpdateNeeded = result;
                SendUpdateEvent(result);
                return result;
            }
            catch (Exception e)
            {
                Log.O("Error checking for updates: " + e);
                UpdateNeeded = false;
                SendUpdateEvent(false);
                return false;
            }
        }