Beispiel #1
0
        private void DisplayPackagePath()
        {
            if (this.cboProductName.SelectedItem == null || this.cboProductVersion.SelectedItem == null)
            {
                return;
            }

            Package package;
            var     fileName = string.Empty;

            package  = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == ((ComboItem)this.cboProductVersion.SelectedItem).Value);
            fileName = package.url.Split('/').Last();

            var downloadDirectory = FileSystemController.GetDownloadDirectory();
            var packageFullpath   = downloadDirectory + fileName;

            if (File.Exists(packageFullpath))
            {
                this.txtLocalInstallPackage.Text = packageFullpath;
            }
            else
            {
                this.txtLocalInstallPackage.Text = null;
            }
        }
Beispiel #2
0
        private void GetOnlineVersion()
        {
            if (this.cboProductName.SelectedItem == null || this.cboProductVersion.SelectedItem == null)
            {
                return;
            }

            Package package;

            package = this.Packages.FirstOrDefault(p => p.did == ((ComboItem)this.cboProductName.SelectedItem).Value && p.version == ((ComboItem)this.cboProductVersion.SelectedItem).Value);
            var url      = package.url;
            var fileName = package.url.Split('/').Last();

            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.client_DownloadProgressChanged);
                client.DownloadFileCompleted   += new AsyncCompletedEventHandler(this.client_DownloadFileCompleted);
                var downloadDirectory = FileSystemController.GetDownloadDirectory();
                if (!Directory.Exists(downloadDirectory))
                {
                    Directory.CreateDirectory(downloadDirectory);
                }

                var dlContinue = true;
                if (File.Exists(downloadDirectory + fileName))
                {
                    var result = DialogController.ShowMessage(
                        "Get Online Version",
                        "Install Package is already downloaded. Would you like to download\nit again? This will replace the existing download.",
                        SystemIcons.Warning,
                        DialogController.DialogButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        dlContinue = false;
                    }
                }

                if (dlContinue)
                {
                    Log.Logger.Information("Downloading package from {url}", url);
                    this.downloadProgressLogTimer.Start();
                    client.DownloadFileAsync(new Uri(url), downloadDirectory + fileName);
                    this.progressBarDownload.BackColor = Color.WhiteSmoke;
                    this.progressBarDownload.Visible   = true;
                }
                else
                {
                    this.txtLocalInstallPackage.Text = Directory.GetCurrentDirectory() + "\\Downloads\\" + Path.GetFileName(url);
                    Properties.Settings.Default.LocalInstallPackageRecent = downloadDirectory;
                    Properties.Settings.Default.Save();
                    Log.Logger.Information("Using local install package {filePath}", this.txtLocalInstallPackage.Text);
                    this.ValidateInstallPackage();
                }
            }
        }