示例#1
0
        public static void DoUpgradeCheck(NewVersionAvailablekDelegate callback)
        {
#if !DEBUG
            Task.Factory.StartNew(() =>
            {
                try {
                    LogFile.Log("Checking for upgrade...");
                    UInt32 id = GetID();
                    int dc, mpb;
                    GetStats(out dc, out mpb);
                    string url = @"http://www.vilett.com/disParity/ping.php?id=" + id.ToString() + (firstRun ? "&firstRun=1" : "") +
                                 "&dc=" + dc + "&mpb=" + mpb + "&beta=" + (Beta ? "1" : "0") + "&ver=" + Version.VersionString;
                    using (WebClient webClient = new WebClient()) {
                        byte[] buf            = webClient.DownloadData(new System.Uri(url));
                        double currentVersion = VersionNum;
                        double latestVersion  = double.Parse(Encoding.ASCII.GetString(buf), CultureInfo.InvariantCulture);
                        LogFile.Log("Current version: {0} Latest version: {1}", currentVersion, latestVersion);
                        if (latestVersion > 0 && latestVersion > currentVersion)
                        {
                            callback(Encoding.ASCII.GetString(buf));
                        }
                    }
                }
                catch (Exception e) {
                    LogFile.Log("Error checking for upgrade: " + e.Message);
                }
            });
#endif
        }
示例#2
0
 public static void DoUpgradeCheck(NewVersionAvailablekDelegate callback)
 {
     #if !DEBUG
       Task.Factory.StartNew(() =>
       {
     try {
       LogFile.Log("Checking for upgrade...");
       UInt32 id = GetID();
       int dc, mpb;
       GetStats(out dc, out mpb);
       string url = @"http://www.vilett.com/disParity/ping.php?id=" + id.ToString() + (firstRun ? "&firstRun=1" : "") +
     "&dc=" + dc + "&mpb=" + mpb + "&beta=" + (Beta ? "1" : "0") + "&ver=" + Version.VersionString;
       using (WebClient webClient = new WebClient()) {
     byte[] buf = webClient.DownloadData(new System.Uri(url));
     double currentVersion = VersionNum;
     double latestVersion = double.Parse(Encoding.ASCII.GetString(buf), CultureInfo.InvariantCulture);
     LogFile.Log("Current version: {0} Latest version: {1}", currentVersion, latestVersion);
     if (latestVersion > 0 && latestVersion > currentVersion)
       callback(Encoding.ASCII.GetString(buf));
       }
     }
     catch (Exception e) {
       LogFile.Log("Error checking for upgrade: " + e.Message);
     }
       });
     #endif
 }