コード例 #1
0
        private static VersionCheckResult InternalCheck(bool displayErrors)
        {
            try
            {
                var url = VERSION_MANIFEST_URL + "?q=" + Guid.NewGuid().ToString();
                var wr  = WebRequest.CreateHttp(url);
                wr.Proxy   = ProxyCache.GetProxy(url);
                wr.Timeout = 5000;

                using (var response = wr.GetResponse())
                {
                    using (var reader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8))
                    {
                        var availableBuildString = reader.ReadToEnd();
                        AvailableBuild = Version.Parse(availableBuildString);

                        return(CurrentBuild.DetermineUpdate(AvailableBuild));
                    }
                }
            }
            catch (Exception ex)
            {
                if (displayErrors)
                {
                    MessageBox.Show(ex.Message, "Unable to check for updated versions", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(VersionCheckResult.Unknown);
            }
        }
コード例 #2
0
ファイル: UpdateService.cs プロジェクト: yduit/TabularEditor
 private static bool?InternalCheck(bool displayErrors)
 {
     try
     {
         var cli = new WebClient();
         cli.Proxy = ProxyCache.GetProxy(VERSION_MANIFEST_URL);
         var availableBuildString = cli.DownloadString(VERSION_MANIFEST_URL + "?q=" + Guid.NewGuid().ToString());
         AvailableBuild = Version.Parse(availableBuildString);
         if (AvailableBuild > CurrentBuild)
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         if (displayErrors)
         {
             MessageBox.Show(ex.Message, "Unable to check for updated versions", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         return(null);
     }
     return(false);
 }