Ejemplo n.º 1
0
        private void DownloadPatchFile(XenServerPatchAlert patch)
        {
            if(string.IsNullOrEmpty(patch.Patch.PatchUrl))
            {
                Results.Add("Patch conatined no URL: " + patch.Patch.Name);
                return;
            }

            string tempFileName = NewTempPath();
            DownloadAndUnzipXenServerPatchAction action = new DownloadAndUnzipXenServerPatchAction(patch.Patch.Name, 
                                                                    new Uri(patch.Patch.PatchUrl), 
                                                                    tempFileName);
            try
            {
                Status = "Download and unzip patch " + patch.Patch.Name;

                ConsoleSpinner spinner = new ConsoleSpinner();
                action.RunAsync();
                while(!action.IsCompleted)
                {
                    spinner.Turn(action.PercentComplete);
                }
                
                if(!action.Succeeded)
                    Results.Add("Patch download and unzip unsuccessful: " + action.Exception.Message);
            }
            catch (Exception ex)
            {
                Results.Add("Patch download error: " + ex.Message);
            }

        }
        private void DownloadFile()
        {
            string patchUri = ((XenServerPatchAlert)SelectedUpdateAlert).Patch.PatchUrl;
            if (string.IsNullOrEmpty(patchUri))
                return;

            Uri address = new Uri(patchUri);
            string tempFile = Path.GetTempFileName();

            bool isIso = SelectedUpdateType == UpdateType.ISO;

            downloadAction = new DownloadAndUnzipXenServerPatchAction(SelectedUpdateAlert.Name, address, tempFile, isIso ? Branding.UpdateIso : Branding.Update);

            if (downloadAction != null)
            {
                downloadAction.Changed += singleAction_Changed;
                downloadAction.Completed += singleAction_Completed;
            }

            downloadAction.RunAsync();

            flickerFreeListBox1.Items.Clear();
            flickerFreeListBox1.Items.Add(downloadAction);
            flickerFreeListBox1.Refresh();
            OnPageUpdated();

            UpdateActionProgress(downloadAction);
        }