Esempio n. 1
0
        private void CorruptedFilesFound()
        {
            /* START Show Redownloader Progress*/
            StartScanner.Visible    = false;
            StopScanner.Visible     = false;
            VerifyHashText.Location = new Point(99, 300);
            VerifyHashText.Size     = new Size(287, 70);
            VerifyHashText.Text     = "Currently (re)downloading files\nThis part may take awhile\ndepending on your connection.";
            redownloadedCount       = 0;

            if (File.Exists("invalidfiles.dat") && File.ReadAllLines("invalidfiles.dat") != null)
            {
                DownloadProgressText.Text = "\nPreparing to Download Files";
                string[] files = File.ReadAllLines("invalidfiles.dat");

                foreach (string text in files)
                {
                    currentCount = files.Count();
                    try
                    {
                        string text2   = FileSettingsSave.GameInstallation + text;
                        string address = FinalCDNURL + "/unpacked" + text.Replace("\\", "/");
                        if (File.Exists(text2))
                        {
                            LogVerify.Deleted("File: " + text2);
                            File.Delete(text2);
                        }
                        new WebClient().DownloadFile(address, text2);
                        LogVerify.Downloaded("File: " + text2);
                        redownloadedCount++;
                        Application.DoEvents();
                    }
                    catch { }
                    this.BeginInvoke((MethodInvoker) delegate
                    {
                        DownloadProgressText.Text = "Downloaded File [ " + redownloadedCount + " / " + currentCount + " ]:\n" + text;
                        DownloadProgressBar.Value = redownloadedCount * 100 / files.Length;
                    });
                }
                DownloadProgressText.Text = "\n" + redownloadedCount + " Invalid/Missing File(s) were Redownloaded";
                VerifyHashText.ForeColor  = Theming.WinFormWarningTextForeColor;
                VerifyHashText.Location   = new System.Drawing.Point(99, 300);
                VerifyHashText.Size       = new System.Drawing.Size(215, 28);
                VerifyHashText.Text       = "Yay! Scanning and Downloading \nis now completed on Gamefiles";
                GameScanner(false);
                StartScanner.Visible = false;
                StopScanner.Visible  = false;
            }
        }
        private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            StillDownloading = false;

            if (e.Error != null && IsVerifyHashOpen && !ForceStopScan)
            {
                redownloadErrorCount++;
                LogVerify.Downloaded("File: " + CurrentDownloadingFile);
                DiscordLauncherPresence.Status("Verify Bad", redownloadedCount + redownloadErrorCount + " out of " + currentCount);

                DownloadProgressText.SafeInvokeAction(() =>
                                                      DownloadProgressText.Text = "Failed To Download File [ " +
                                                                                  redownloadedCount + redownloadErrorCount + " / " + currentCount + " ]:" + "\n" + CurrentDownloadingFile);

                DownloadProgressBar.SafeInvokeAction(() =>
                                                     DownloadProgressBar.Value = redownloadedCount + redownloadErrorCount * 100 / currentCount);

                LogVerify.Error("Download for [" + CurrentDownloadingFile + "] - " +
                                (e.Error != null ? (string.IsNullOrWhiteSpace(e.Error.Message) ? e.Error.ToString() : e.Error.Message) : "No Exception Error Provided"));

                if (redownloadedCount + redownloadErrorCount == currentCount)
                {
                    StartScanner.SafeInvokeAction(() => StartScanner.Visible = false);
                    StopScanner.SafeInvokeAction(() => StopScanner.Visible   = false);

                    DownloadProgressText.SafeInvokeAction(() =>
                                                          DownloadProgressText.Text = "\n" + redownloadedCount + " Invalid/Missing File(s) were Redownloaded");

                    VerifyHashText.SafeInvokeAction(() =>
                    {
                        VerifyHashText.ForeColor = Theming.WinFormWarningTextForeColor;
                        VerifyHashText.Text      = redownloadErrorCount + " Files Failed to Download. Check Log for Details";
                    }, this);

                    DownloadErrorEncountered = true;
                    GameScanner(false);
                }
            }
            else if (IsVerifyHashOpen && !ForceStopScan)
            {
                redownloadedCount++;

                DiscordLauncherPresence.Status("Verify Bad", redownloadedCount + " out of " + currentCount);
                LogVerify.Downloaded("File: " + CurrentDownloadingFile);

                DownloadProgressText.SafeInvokeAction(() =>
                                                      DownloadProgressText.Text = "Downloaded File [ " + redownloadedCount + " / " + currentCount + " ]:\n" + CurrentDownloadingFile);
                DownloadProgressBar.SafeInvokeAction(() =>
                                                     DownloadProgressBar.Value = redownloadedCount * 100 / currentCount);

                if (redownloadedCount == currentCount)
                {
                    Integrity();
                    Log.Info("VERIFY HASH: Re-downloaded Count: " + redownloadedCount + " Current File Count: " + currentCount);
                    DownloadProgressText.SafeInvokeAction(() =>
                                                          DownloadProgressText.Text = "\n" + redownloadedCount + " Invalid/Missing File(s) were downloaded");

                    VerifyHashText.SafeInvokeAction(() =>
                    {
                        VerifyHashText.ForeColor = Theming.WinFormWarningTextForeColor;
                        VerifyHashText.Text      = "Yay! Scanning and Downloading\n is now completed on Gamefiles";
                    }, this);

                    StartScanner.SafeInvokeAction(() => StartScanner.Visible = false);
                    StopScanner.SafeInvokeAction(() => StopScanner.Visible   = false);

                    GameScanner(false);
                }
                else if (redownloadedCount + redownloadErrorCount == currentCount)
                {
                    DownloadProgressText.SafeInvokeAction(() =>
                                                          DownloadProgressText.Text = "\n" + redownloadedCount + " Invalid/Missing File(s) were downloaded");

                    VerifyHashText.SafeInvokeAction(() =>
                    {
                        VerifyHashText.ForeColor = Theming.WinFormWarningTextForeColor;
                        VerifyHashText.Text      = redownloadErrorCount + " Files Failed to Download. Check Log for Details";
                    }, this);

                    StartScanner.SafeInvokeAction(() => StartScanner.Visible = false);
                    StopScanner.SafeInvokeAction(() => StopScanner.Visible   = false);

                    DownloadErrorEncountered = true;
                    GameScanner(false);
                }
            }
            else if (IsVerifyHashOpen && ForceStopScan)
            {
                Log.Info("VERIFY HASH: Download Process has Stopped");
                DiscordLauncherPresence.Status("Verify Bad", redownloadedCount + " out of " + currentCount);

                DownloadProgressText.SafeInvokeAction(() =>
                                                      DownloadProgressText.Text = "Download Stopped on File [ " +
                                                                                  redownloadedCount + " / " + currentCount + " ]:" + "\n" + CurrentDownloadingFile);

                DownloadProgressBar.SafeInvokeAction(() => DownloadProgressBar.Value = redownloadedCount * 100 / currentCount);

                LogVerify.Error("Download for [" + CurrentDownloadingFile + "] -  has been Cancelled");

                StartScanner.SafeInvokeAction(() => StartScanner.Visible = false);
                StopScanner.SafeInvokeAction(() => StopScanner.Visible   = false);
                VerifyHashText.SafeInvokeAction(() =>
                {
                    VerifyHashText.Text = "Verify Hash Download Process has been Terminated";
                }, this);
            }
            else if (ForceStopScan)
            {
                Log.Info("VERIFY HASH: Download Process has Stopped");
                LogVerify.Error("Download for [" + CurrentDownloadingFile + "] -  has been Cancelled");
            }
        }