public static int CompareOnDateStarted(ActionBase action1, ActionBase action2)
 {
     int result = DateTime.Compare(action1.Started, action2.Started);
     if (result == 0)
         result = CompareOnStatus(action1, action2);
     return result;
 }
        void action_Completed(ActionBase sender)
        {
            ActivationRequestAction action = (ActivationRequestAction)sender;
            if (action.Succeeded)
                Program.OpenURL(string.Format(InvisibleMessages.ACTIVATION_FORM_URL, InvisibleMessages.ACTIVATION_SERVER, action.Result));
            else
            {
                if (DialogResult.Cancel == ShowSaveDialog())
                    throw action.Exception;

                SaveFileDialog fd = new SaveFileDialog();
                Program.Invoke(Program.MainWindow,
                    delegate()
                    {
                        fd.AddExtension = true;
                        fd.DefaultExt = "txt";
                        fd.Filter = string.Format("{0} (*.*)|*.*", Messages.ALL_FILES);
                        fd.FilterIndex = 0;
                        fd.RestoreDirectory = true;
                        if (DialogResult.Cancel == fd.ShowDialog(Program.MainWindow))
                            throw action.Exception;

                        using (FileStream fs = File.Open(fd.FileName, FileMode.Create))
                        {
                            byte[] bytes = Encoding.UTF8.GetBytes(_request);
                            fs.Write(bytes, 0, bytes.Length);
                        }
                    });

                //Description = string.Format(Messages.ACTIVATION_REQUEST_SAVED, fd.FileName);
            }
        }
示例#3
0
        protected override void action_Completed(ActionBase sender)
        {
            EventHandler handler = Completed;

            if (handler != null)
                handler(this, new EventArgs());

            base.action_Completed(sender);
        }
        public static int CompareOnLocation(ActionBase action1, ActionBase action2)
        {
            string location1 = action1.GetLocation();
            string location2 = action2.GetLocation();

            int result = string.Compare(location1, location2);
            if (result == 0)
                result = CompareOnStatus(action1, action2);
            return result;
        }
示例#5
0
 protected virtual void action_Completed(ActionBase sender)
 {
     var action = (AsyncAction)sender;
     if (action.Result == false.ToString())
         MainWindowCommandInterface.Invoke(() =>
         new ThreeButtonDialog(
                 new ThreeButtonDialog.Details(
                     SystemIcons.Information,
                     Messages.VIF_HOTPLUG_FAILED_MESSAGE,
                     Messages.VIF_HOTPLUG_FAILED_TITLE)).ShowDialog(Program.MainWindow));
 }
示例#6
0
        private void Action_NewAction(ActionBase action)
        {
            if (action == null)
                return;

            Program.BeginInvoke(Program.MainWindow,
                           () =>
                           {
                               int count = ConnectionsManager.History.Count;
                               if (count >= MAX_HISTORY_ITEM)
                                   ConnectionsManager.History.RemoveAt(0);
                               ConnectionsManager.History.Add(action);
                           });
        }
示例#7
0
 void action_CompletedTimeServer(ActionBase sender)
 {
     GetServerTimeAction action = (GetServerTimeAction)sender;
     Program.Invoke(Program.MainWindow, () =>
     {
         string serverLocalTimeString = action.Result;
         if (serverLocalTimeString != "")
         {
             DateTime serverLocalTime = DateTime.Parse(serverLocalTimeString, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
             serverLocalTimeString = HelpersGUI.DateTimeToString(serverLocalTime, Messages.DATEFORMAT_WDMY_HM_LONG, true);
         }
         labelServerTime.Text = string.Format(Messages.SERVER_TIME, serverLocalTimeString);
     });
 }
示例#8
0
        public ActionRow(ActionBase action)
        {
            AppliesTo = action.AppliesTo;
            Action = action;
            Image = action.GetImage();
            TimeOccurred = HelpersGUI.DateTimeToString(Action.Started, Messages.DATEFORMAT_DMY_HMS, true);
            CancelButtonClicked += CancelAction;
            setupRowDetails();

            if (!Action.IsCompleted)
            {
                Action.Changed += Action_Changed;
                Action.Completed += Action_Completed;
            }
        }
示例#9
0
 public ActionRow(ActionBase action)
 {
     Type = action.Type;
     AppliesTo = action.AppliesTo;
     Action = action;
     this.Image = getImage();
     TimeOccurred = HelpersGUI.DateTimeToString(Action.Started, Messages.DATEFORMAT_DMY_HMS, true);
     this.CancelButtonClicked += new EventHandler<EventArgs>(CancelAction);
     setupRowDetails();
     if (!Action.IsCompleted)
     {
         Action.Changed += new EventHandler<EventArgs>(Action_Changed);
         Action.Completed += new EventHandler<EventArgs>(Action_Completed);
     }
 }
        /// <summary>
        /// Ascending order:
        /// 1. cancelled/failed
        /// 2. lower state of completeness (smaller percentage completed)
        /// 3. completed successfully
        /// </summary>
        /// <param name="action1"></param>
        /// <param name="action2"></param>
        /// <returns></returns>
        public static int CompareOnStatus(ActionBase action1, ActionBase action2)
        {
            if (action1.IsCompleted && action2.IsCompleted)
            {
                if (action1.Succeeded && action2.Succeeded)
                    return 0;
                if (!action1.Succeeded && !action2.Succeeded)
                    return 0;
                if (!action1.Succeeded && action2.Succeeded)
                    return -1;
                if (action1.Succeeded && !action2.Succeeded)
                    return 1;
            }

            if (!action1.IsCompleted && action2.IsCompleted)
                return -1;

            if (action1.IsCompleted && !action2.IsCompleted)
                return 1;

            return action1.PercentComplete.CompareTo(action2.PercentComplete);
        }
示例#11
0
        void getDataSorucesAction_Completed(ActionBase sender)
        {
            Program.Invoke(this, delegate
            {
                GetDataSourcesAction action = sender as GetDataSourcesAction;
                if (action != null)
                {
                    List<DataSourceItem> dataSources = DataSourceItemList.BuildList(action.IXenObject, action.DataSources);
                    foreach (DataSourceItem dataSourceItem in dataSources)
                    {
                        bool displayOnGraph = designedGraph.DataSources.Contains(dataSourceItem);
                        dataGridView.Rows.Add(new DataSourceGridViewRow(dataSourceItem, displayOnGraph));
                    }

                    dataGridView.Sort(dataGridView.Columns[DisplayOnGraphColumnIndex], ListSortDirection.Ascending);
                    if (dataGridView.Rows.Count > 0)
                    {
                        dataGridView.Rows[0].Cells[DisplayOnGraphColumnIndex].Selected = true;
                    }
                }
                EnableControls();
            });
        }
 private void PatchingWizard_PatchingPage_Changed(ActionBase sender)
 {
     AsyncAction action = (AsyncAction)sender;
     Program.Invoke(Program.MainWindow, delegate { progressBar.Value = oemActionsDone * 100 + action.PercentComplete; });
 }
 private void PatchingWizard_PatchingPage_Completed(ActionBase sender)
 {
     autoResetEvent.Set();
 }
示例#14
0
 protected override void MultipleAction_Completed(ActionBase sender)
 {
     base.MultipleAction_Completed(sender);
     _queuePC.StopWorkers(false);
 }
示例#15
0
 private void action_Completed(ActionBase sender)
 {
     var action = sender as ExecuteContainerPluginAction;
     if (action == null || action.Container != container)
         return;
     Program.Invoke(Program.MainWindow, () =>
     {
         if (action.Succeeded)
             UpdateList(action.Result);
         else
             ShowInvalidInfo();
         RefreshButton.Enabled = true;
     });
 }
示例#16
0
 void a_Completed(ActionBase sender)
 {
     Program.Invoke(Program.MainWindow, RefreshButtons);
 }
 private void action_Completed(ActionBase sender)
 {
     _nextEnabled = true;
     _cancelEnabled = false;
     
     try
     {
         if (sender.Exception != null)
         {
             Program.Invoke(Program.MainWindow, () => FinishedWithErrors(new Exception(sender.Title, sender.Exception)));
         }
         else
             Program.Invoke(Program.MainWindow, FinishedSuccessfully);
     }
     catch (Exception except)
     {
         Program.Invoke(Program.MainWindow, () => FinishedWithErrors(except));
     }
     Program.Invoke(Program.MainWindow, OnPageUpdated);
     _thisPageHasBeenCompleted = true;
 }
示例#18
0
 private void SaveGraphs(ActionBase sender)
 {
     Program.Invoke(Program.MainWindow, delegate
     {
         var action = sender as GetDataSourcesAction;
         if (action != null)
         {
             var dataSources = DataSourceItemList.BuildList(action.IXenObject, action.DataSources);
             GraphList.SaveGraphs(dataSources);
         }
     });
 }
 private void action_Completed(ActionBase sender)
 {
     Thread.Sleep(1000);
     Program.Invoke(Program.MainWindow, RefreshRechecks);
 }
 private void action_Changed(ActionBase sender)
 {
     AsyncAction action = (AsyncAction)sender;
     Program.Invoke(Program.MainWindow, delegate { progressBar.Value = action.PercentComplete; });
 }
示例#21
0
        /// <summary>
        /// Retrieve wlb optimize pool recommendation action complete handler. 
        /// Populate optimize pool listview and enable controls properly.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">e</param>
        protected void OptRecRetrieveAction_Completed(ActionBase sender)
        {
            AsyncAction action = (AsyncAction)sender;
            if (action.IsCompleted)
            {
                action.Completed -= OptRecRetrieveAction_Completed;

                if (action is WlbRetrieveRecommendationAction)
                {
                    WlbRetrieveRecommendationAction thisAction = (WlbRetrieveRecommendationAction)action;
                    _recommendations = thisAction.WLBOptPoolRecommendations;
                    if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == action.Connection)
                    {
                        Program.Invoke(this, delegate()
                        {
                            PopulateData(_recommendations);

                            // In case optimizePoolListView is empty
                            if (optimizePoolListView.Items.Count == 0)
                            {
                                statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION;
                                EnableControls(true, false);
                            }
                            else
                                EnableControls(false, true);
                        });
                    }
                    else
                    {
                        Program.Invoke(this, delegate()
                        {
                            statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION;
                            EnableControls(true, false);
                        });
                    }
                }
            }
        }
示例#22
0
 private void action_Completed(ActionBase sender)
 {
     Program.Invoke(Program.MainWindow.GeneralPage, Program.MainWindow.GeneralPage.EnableDisableEdit);
 }
示例#23
0
 private void CreateActionCompleted(ActionBase senderAction)
 {
     senderAction.Completed -= CreateActionCompleted;
     ActionBase action = ConnectionsManager.History.Find(SpinningPredicate());
     if (action == null)
     {
         Program.Invoke(Program.MainWindow, () => TreeView.ChangeVMToSpinning(false, null));
     }
 }
 private void snapshotAction_Completed(ActionBase sender)
 {
     OnCompleted(new TakeSnapshotCommandCompletedEventArgs(sender.Succeeded));
 }
示例#25
0
        private static void actionCompleted(ActionBase sender)
        {
            Program.AssertOffEventThread();

            DownloadUpdatesXmlAction action = sender as DownloadUpdatesXmlAction;
            if (action == null)
                return;

            bool succeeded = action.Succeeded;
            string errorMessage = string.Empty;

            lock (updateAlertsLock)
                updateAlerts.Clear();

            if (succeeded)
            {
                lock (downloadedUpdatesLock)
                {
                    var xcvs = action.XenCenterVersions.Where(v => !XenCenterVersions.Contains(v));
                    XenCenterVersions.AddRange(xcvs);

                    var versForAutoCheck = action.XenServerVersionsForAutoCheck.Where(v => !XenServerVersionsForAutoCheck.Contains(v));
                    XenServerVersionsForAutoCheck.AddRange(versForAutoCheck);

                    var vers = action.XenServerVersions.Where(v => !XenServerVersions.Contains(v));
                    XenServerVersions.AddRange(vers);

                    var patches = action.XenServerPatches.Where(p => !XenServerPatches.Contains(p));
                    XenServerPatches.AddRange(patches);
                }

                var xenCenterAlert = NewXenCenterUpdateAlert(XenCenterVersions, Program.Version);
                if (xenCenterAlert != null && !xenCenterAlert.IsDismissed())
                    updateAlerts.Add(xenCenterAlert);

                var xenServerUpdateAlert = NewXenServerVersionAlert(XenServerVersionsForAutoCheck);
                if (xenServerUpdateAlert != null && !xenServerUpdateAlert.CanIgnore)
                    updateAlerts.Add(xenServerUpdateAlert);

                var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
                if (xenServerPatchAlerts != null)
                    updateAlerts.AddRange(xenServerPatchAlerts.Where(alert => !alert.CanIgnore));
            }
            else
            {
                if (action.Exception != null)
                {
                    if (action.Exception is System.Net.Sockets.SocketException)
                    {
                        errorMessage = Messages.AVAILABLE_UPDATES_NETWORK_ERROR;
                    }
                    else
                    {
                        // Clean up and remove excess newlines, carriage returns, trailing nonsense
                        string errorText = action.Exception.Message.Trim();
                        errorText = System.Text.RegularExpressions.Regex.Replace(errorText, @"\r\n+", "");
                        errorMessage = string.Format(Messages.AVAILABLE_UPDATES_ERROR, errorText);
                    }
                }

                if (string.IsNullOrEmpty(errorMessage))
                    errorMessage = Messages.AVAILABLE_UPDATES_INTERNAL_ERROR;
            }

            if (CheckForUpdatesCompleted != null)
                CheckForUpdatesCompleted(succeeded, errorMessage);
        }
示例#26
0
        private static void actionCompleted(ActionBase sender)
        {
            Program.AssertOffEventThread();

            DownloadUpdatesXmlAction action = sender as DownloadUpdatesXmlAction;
            if (action == null)
                return;

            bool succeeded = action.Succeeded;
            string errorMessage = string.Empty;

            lock (updateAlertsLock)
                updateAlerts.Clear();

            if (succeeded)
            {
                XenServerVersions = action.XenServerVersions;
                XenServerPatches = action.XenServerPatches;

                var xenCenterAlert = NewXenCenterUpdateAlert(action.XenCenterVersions, Program.Version);
                if (xenCenterAlert != null)
                    updateAlerts.Add(xenCenterAlert);

                var xenServerUpdateAlert = NewXenServerUpdateAlert(action.XenServerVersions);
                if (xenServerUpdateAlert != null)
                    updateAlerts.Add(xenServerUpdateAlert);

                var xenServerPatchAlerts = NewXenServerPatchAlerts(action.XenServerVersions, action.XenServerPatches);
                if (xenServerPatchAlerts != null)
                {
                    foreach (var xenServerPatchAlert in xenServerPatchAlerts)
                        updateAlerts.Add(xenServerPatchAlert);
                }
            }
            else
            {
                if (action.Exception != null)
                {
                    if (action.Exception is System.Net.Sockets.SocketException)
                    {
                        errorMessage = Messages.AVAILABLE_UPDATES_NETWORK_ERROR;
                    }
                    else
                    {
                        // Clean up and remove excess newlines, carriage returns, trailing nonsense
                        string errorText = action.Exception.Message.Trim();
                        errorText = System.Text.RegularExpressions.Regex.Replace(errorText, @"\r\n+", "");
                        errorMessage = string.Format(Messages.AVAILABLE_UPDATES_ERROR, errorText);
                    }
                }

                if (string.IsNullOrEmpty(errorMessage))
                    errorMessage = Messages.AVAILABLE_UPDATES_INTERNAL_ERROR;
            }

            if (CheckForUpdatesCompleted != null)
                CheckForUpdatesCompleted(succeeded, errorMessage);
        }
 private void IscsiPopulateIqnsAction_Completed(ActionBase sender)
 {
     Program.Invoke(this, (System.Threading.WaitCallback)IscsiPopulateIqnsAction_Completed_, sender);
 }
示例#28
0
 /// <summary>
 /// After the Delete action is completed the page is refreshed and the restore dismissed 
 /// button is enabled again.
 /// </summary>
 /// <param name="sender"></param>
 private void DeleteAllAllertAction_Completed(ActionBase sender)
 {
     Program.Invoke(Program.MainWindow, () =>
     {                
         Rebuild();
         toolStripButtonRestoreDismissed.Enabled = true;
     });
 }
 private void IscsiPopulateLunsAction_Completed(ActionBase sender)
 {
     Program.Invoke(this, (WaitCallback)IscsiPopulateLunsAction_Completed_, sender);
 }
        private void action_Completed(ActionBase sender)
        {
            Thread.Sleep(1000);
            Program.Invoke(Program.MainWindow, RefreshRechecks);

            var drTaskCreateAction = sender as DrTaskCreateAction;
            if (drTaskCreateAction != null && drTaskCreateAction.Succeeded)
            {
                if (NewDrTaskIntroduced != null)
                    NewDrTaskIntroduced(drTaskCreateAction.Result);
                return;
            }

            var srIntroduceAction = sender as SrIntroduceAction;
            if (srIntroduceAction != null && srIntroduceAction.Succeeded)
            {
                if (SrIntroduced != null)
                    SrIntroduced(new XenRef<SR>(srIntroduceAction.Result));
            }
        }
        private void singleAction_Completed(ActionBase sender)
        {
            var action = sender as AsyncAction;
            if (action == null)
                return;

            action.Changed -= singleAction_Changed;
            action.Completed -= singleAction_Completed;

            Program.Invoke(this, () =>
            {
                if (action.Succeeded)
                {
                    Host master = Helpers.GetMaster(action.Connection);

                    if (action is UploadPatchAction)
                    {
                        _patch = (action as UploadPatchAction).PatchRefs[master];
                        _poolUpdate = null;
                        AddToUploadedUpdates(SelectedNewPatchPath, master);
                    }

                    if (action is CopyPatchFromHostToOther && action.Host != null)
                    {
                        _poolUpdate = null;
                        _patch = action.Host.Connection.Cache.Resolve((action as CopyPatchFromHostToOther).NewPatchRef);
                    }

                    if (_patch != null && !NewUploadedPatches.ContainsKey(_patch))
                    {
                        NewUploadedPatches.Add(_patch, SelectedNewPatchPath);
                        _poolUpdate = null;
                    }

                    if (action is UploadSupplementalPackAction)
                    {
                        _patch = null;

                        foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefsToCleanUp)
                        {
                            SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value);
                        }

                        AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi)));

                        AddToUploadedUpdates(SelectedNewPatchPath, master);

                        if (Helpers.ElyOrGreater(action.Connection))
                        {
                            var newPoolUpdate = ((UploadSupplementalPackAction)action).PoolUpdate;

                            if (newPoolUpdate != null)
                            {
                                _poolUpdate = newPoolUpdate;
                                AllIntroducedPoolUpdates.Add(PoolUpdate);
                            }
                        }
                    }

                    if (action is DownloadAndUnzipXenServerPatchAction)
                    {
                        SelectedNewPatchPath = ((DownloadAndUnzipXenServerPatchAction)action).PatchPath;
                        if (SelectedUpdateAlert is XenServerPatchAlert && (SelectedUpdateAlert as XenServerPatchAlert).Patch != null)
                        {
                            AllDownloadedPatches.Add((SelectedUpdateAlert as XenServerPatchAlert).Patch.Uuid, SelectedNewPatchPath);
                        }
                        _patch = null;
                        PrepareUploadActions();
                        TryUploading();
                    }
                }
                else // if !action.Succeeded
                {
                    if (action is UploadSupplementalPackAction)
                    {
                        _patch = null;
                        _poolUpdate = null;

                        foreach (var vdiRef in (action as UploadSupplementalPackAction).VdiRefsToCleanUp)
                        {
                            SuppPackVdis[vdiRef.Key] = action.Connection.Resolve(vdiRef.Value);
                        }

                        AllCreatedSuppPackVdis.AddRange(SuppPackVdis.Values.Where(vdi => !AllCreatedSuppPackVdis.Contains(vdi)));
                    }
                }
            });
        }