Beispiel #1
0
        private void ArchiveDownloadCompleted(FileDownloadInfo info)
        {
            stopwatch.Reset();
            ZipArchive archive = null;

            try
            {
                SetStatus("Extracting files..\r\nThis may take a while..");
                SevenZipExtractor extractor = new SevenZipExtractor(Directory.GetCurrentDirectory() + "\\" + info.fileName);
                if (extractor.TestArchive())
                {
                    extractor.ProgressUpdated += Extractor_ProgressUpdated;
                    if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\" + info.version))
                    {
                        Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\" + info.version);
                    }
                    extractor.ExtractAll(Directory.GetCurrentDirectory() + "\\" + info.version, true);

                    if (info.replaceAsLatest)
                    {
                        string path = GetInstalledVersionPath(info.version);
                        if (path.Length > 0)
                        {
                            // Remove the yuzu.exe from the path
                            path = path.Substring(0, path.Length - 8);
                        }
                        SetStatusAndProgress("Transferring Files", 75);
                        Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\Yuzu Early Access\\");
                        Copy(path, Directory.GetCurrentDirectory() + "\\Yuzu Early Access\\");
                        settings.Version = info.version;
                        settings.Save();
                    }
                    SetStatusAndProgress("Cleaning Up", 75);
                    File.Delete(Directory.GetCurrentDirectory() + "\\" + info.fileName);
                    SetStatusAndProgress("Done!", 100);
                    Invoke(new MethodInvoker(() =>
                    {
                        InstallLaunchButton.Text = "Launch";
                    }));
                    FinishUp();
                }
                else
                {
                    SetStatusAndProgress("The archive file was invalid, please try again later.", 0);
                    SetControlsEnabled(true);
                }
            }
            catch (Exception ex)
            {
                SetStatusAndProgress("An error occurred, please check the logs for the issue", 0);
                if (null != archive)
                {
                    archive.Dispose();
                }
                logger.Log(LogLevel.ERROR, ex.Message);
                logger.Log(LogLevel.ERROR, ex.StackTrace);
                SetControlsEnabled(true);
            }
        }
Beispiel #2
0
 private void WebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     try
     {
         FileDownloadInfo info = e.UserState as FileDownloadInfo;
         DownloadCompleted(info);
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.ERROR, ex.Message);
         logger.Log(LogLevel.ERROR, ex.StackTrace);
     }
 }
Beispiel #3
0
        private void DownloadCompleted(FileDownloadInfo info)
        {
            ZipArchive archive = null;

            try
            {
                SetStatusAndProgress("Extracting files..\r\nThis may take a while..", 0);
                SevenZipNET.SevenZipExtractor extractor = new SevenZipNET.SevenZipExtractor(info.fileName);
                if (extractor.TestArchive())
                {
                    extractor.ProgressUpdated += Extractor_ProgressUpdated;
                    extractor.ExtractAll(Directory.GetCurrentDirectory(), true);
                    SetStatusAndProgress("Cleaning Up", 75);
                    File.Delete(info.fileName);
                    settings.Version = info.version;
                    settings.Save();
                    SetStatusAndProgress("Done!", 100);
                    Invoke(new MethodInvoker(() =>
                    {
                        InstallLaunchButton.Text = "Launch";
                    }));
                    FinishUp();
                }
                else
                {
                    SetStatusAndProgress("The archive file was invalid, please try again later.", 0);
                    SetControlsEnabled(true);
                    logger.Log("The archive file was invalid, please try again later.");
                }
            }
            catch (Exception ex)
            {
                SetStatusAndProgress("An error occurred, please check the logs for the issue", 0);
                if (null != archive)
                {
                    archive.Dispose();
                }
                logger.Log(LogLevel.ERROR, ex.Message);
                logger.Log(LogLevel.ERROR, ex.StackTrace);
                SetControlsEnabled(true);
            }
        }
Beispiel #4
0
        private void ArchiveWebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
        {
            FileDownloadInfo info = e.UserState as FileDownloadInfo;

            ArchiveDownloadCompleted(info);
        }