Ejemplo n.º 1
0
        private void CheckForUpdates(bool manual = false)
        {
            try
            {
                // Load the webpage
                using (var client = new WebClient())
                {
                    // Load the updateInfo file
                    // https://github.com/Dimencia/MordhauCommunityMapInstaller/raw/master/UpdateInfo.txt
                    string contents = client.DownloadString("https://github.com/Dimencia/MordhauCommunityMapInstaller/raw/master/UpdateInfo.txt");
                    // Normalize line endings
                    contents = contents.Replace("\r\n", "\n");
                    var    lines     = contents.Split('\n');
                    string version   = lines[0];
                    string url       = lines[1];
                    string filename  = lines[2];
                    bool   required  = bool.Parse(lines[3]);
                    string changelog = lines[4];

                    Log($"Detected version {version} vs current {VERSION}");
                    Log(changelog);
                    if ((checkForUpdates || required || manual) && !version.Equals(VERSION))
                    {
                        UpdateAvailable updateForm = new UpdateAvailable(version, url, filename, changelog);
                        updateForm.Show(this);
                        return;
                    }
                    else
                    {
                        Log(Properties.Resources.str_No_updates_found);
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.Message);
                Log(e.StackTrace);
                Log(Properties.Resources.str_Failed_to_check_for_updates);
            }
        }
Ejemplo n.º 2
0
 private void CheckForUpdates()
 {
     try
     {
         // Load the webpage
         using (var client = new WebClient())
         {
             string page = client.DownloadString(s_ProjectGithub);
             Regex  reg  = new Regex(@"(?i)MCMI([^A-Za-z]*)\.exe");
             Match  m    = reg.Match(page);
             if (m.Success)
             {
                 string version = m.Groups[1].Value;
                 Log("Detected version " + version + " vs current " + VERSION);
                 if (!version.Equals(VERSION))
                 {
                     UpdateAvailable updateForm = new UpdateAvailable(version);
                     updateForm.Show(this);
                     return;
                 }
                 else
                 {
                     Log("No updates found");
                 }
             }
             else
             {
                 Log("Error checking for updates");
             }
         }
     }
     catch (Exception e)
     {
         Log(e.Message);
         Log(e.StackTrace);
         Log("Failed to check for updates");
     }
 }