예제 #1
0
 /// <summary>
 /// Raises popup for hosts file if attached
 /// Called by OnCmCommandComplete
 /// </summary>
 /// <param name="args">CmHelperEvenArgs</param>
 internal void PopupHostsFile(CmHelperEventArgs args)
 {
     if (!string.IsNullOrEmpty(args.HostsFile))
     {
         Application.Current.Dispatcher.Invoke((Action) delegate
         {
             HostsFileDisplayView popup = new HostsFileDisplayView(args.HostsFile);
             popup.Show();
         });
     }
 }
예제 #2
0
 /// <summary>
 /// Event handler for a completed HTTP poll
 /// Will update GUI for the CM modified
 /// </summary>
 /// <param name="sender">Sender of event, expected to be null</param>
 /// <param name="e">CmHelperEventArgs with relevant details</param>
 private void OnPollComplete(object sender, CmHelperEventArgs e)
 {
     try
     {
         // This VM is not the sender, return
         if (GetHashCode() != e.SubscriberHashCode)
         {
             return;
         }
         // Set CM Status
         if (CmsDisplayExec.Any(c => c.Id == e.Cm.Id))
         {
             CmsDisplayExec.Single(c => c.Id == e.Cm.Id).CmStatus = e.CmStatus == HttpStatusCode.OK ? CmStates.Alive : CmStates.Offline;
         }
         else if (CmsDisplayOperDb.Any(c => c.Id == e.Cm.Id))
         {
             CmsDisplayOperDb.Single(c => c.Id == e.Cm.Id).CmStatus = e.CmStatus == HttpStatusCode.OK ? CmStates.Alive : CmStates.Offline;
         }
         else if (CmsDisplayOperAppOne.Any(c => c.Id == e.Cm.Id))
         {
             CmsDisplayOperAppOne.Single(c => c.Id == e.Cm.Id).CmStatus = e.CmStatus == HttpStatusCode.OK ? CmStates.Alive : CmStates.Offline;
         }
         else if (CmsDisplayOperAppTwo.Any(c => c.Id == e.Cm.Id))
         {
             CmsDisplayOperAppTwo.Single(c => c.Id == e.Cm.Id).CmStatus = e.CmStatus == HttpStatusCode.OK ? CmStates.Alive : CmStates.Offline;
         }
         else if (CmsDisplayMs.Any(c => c.Id == e.Cm.Id))
         {
             CmsDisplayMs.Single(c => c.Id == e.Cm.Id).CmStatus = e.CmStatus == HttpStatusCode.OK ? CmStates.Alive : CmStates.Offline;
         }
     }
     catch (Exception ex)
     {
         LogAndReportException(ex, $"Error updating VIBES Swap GUI with HTTP status: {ex.Message}", false);
     }
 }
예제 #3
0
        /// <summary>
        /// Event handler for a completed SSH command
        /// Will update GUI for the CM changed
        /// </summary>
        /// <param name="sender">Sender of event, expected to be null</param>
        /// <param name="e">CmHelperEventArgs with relevant details</param>
        private void OnCmCommandComplete(object sender, CmHelperEventArgs e)
        {
            try
            {
                // This VM is not the sender, return
                if (e.SubscriberHashCode != GetHashCode())
                {
                    return;
                }

                // Set CM Status
                if (CmsDisplayExec.Contains(e.CmChanged))
                {
                    switch (e.CmStatus)
                    {
                    case HttpStatusCode.OK:
                        CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Alive;
                        break;

                    case HttpStatusCode.ServiceUnavailable:
                        CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Offline;
                        break;

                    case HttpStatusCode.NoContent:
                        CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Altered;
                        break;

                    case HttpStatusCode.Continue:
                        CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Updated;
                        break;

                    default:
                        CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Unchecked;
                        PollCmAsync(CmsDisplayExec.Single(c => c.Id == e.CmChanged.Id));
                        break;
                    }
                }
                else if (CmsDisplayOperDb.Contains(e.CmChanged))
                {
                    switch (e.CmStatus)
                    {
                    case HttpStatusCode.OK:
                        CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Alive;
                        break;

                    case HttpStatusCode.ServiceUnavailable:
                        CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Offline;
                        break;

                    case HttpStatusCode.NoContent:
                        CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Altered;
                        break;

                    case HttpStatusCode.Continue:
                        CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Updated;
                        break;

                    default:
                        CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Unchecked;
                        PollCmAsync(CmsDisplayOperDb.Single(c => c.Id == e.CmChanged.Id));
                        break;
                    }
                }
                else if (CmsDisplayOperAppOne.Contains(e.CmChanged))
                {
                    switch (e.CmStatus)
                    {
                    case HttpStatusCode.OK:
                        CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Alive;
                        break;

                    case HttpStatusCode.ServiceUnavailable:
                        CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Offline;
                        break;

                    case HttpStatusCode.NoContent:
                        CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Altered;
                        break;

                    case HttpStatusCode.Continue:
                        CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Updated;
                        break;

                    default:
                        CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Unchecked;
                        PollCmAsync(CmsDisplayOperAppOne.Single(c => c.Id == e.CmChanged.Id));
                        break;
                    }
                }
                else if (CmsDisplayOperAppTwo.Contains(e.CmChanged))
                {
                    switch (e.CmStatus)
                    {
                    case HttpStatusCode.OK:
                        CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Alive;
                        break;

                    case HttpStatusCode.ServiceUnavailable:
                        CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Offline;
                        break;

                    case HttpStatusCode.NoContent:
                        CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Altered;
                        break;

                    case HttpStatusCode.Continue:
                        CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Updated;
                        break;

                    default:
                        CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Unchecked;
                        PollCmAsync(CmsDisplayOperAppTwo.Single(c => c.Id == e.CmChanged.Id));
                        break;
                    }
                }
                else if (CmsDisplayMs.Contains(e.CmChanged))
                {
                    switch (e.CmStatus)
                    {
                    case HttpStatusCode.OK:
                        CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Alive;
                        break;

                    case HttpStatusCode.ServiceUnavailable:
                        CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Offline;
                        break;

                    case HttpStatusCode.NoContent:
                        CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Altered;
                        break;

                    case HttpStatusCode.Continue:
                        CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Updated;
                        break;

                    default:
                        CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id).CmStatus = CmStates.Unchecked;
                        PollCmAsync(CmsDisplayMs.Single(c => c.Id == e.CmChanged.Id));
                        break;
                    }
                }

                // Update properties
                if (e.DeploymentProperties != null && (e.Host.HostType == HostTypes.EXEC || e.Host.HostType == HostTypes.OPERDB || e.Host.HostType == HostTypes.OPERAPP1 || e.Host.HostType == HostTypes.OPERAPP2 || e.Host.HostType == HostTypes.MS))
                {
                    StoreDeploymentProperties(e.CmChanged, e.DeploymentProperties);
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        LoadData(e.CmChanged);
                    });
                }

                // Popup hosts
                if (e.HostsFile != null && e.Host != null && (e.Host.HostType == HostTypes.EXEC || e.Host.HostType == HostTypes.OPERAPP1 || e.Host.HostType == HostTypes.OPERAPP2))
                {
                    PopupHostsFile(e);
                }
            }
            catch (Exception ex)
            {
                LogAndReportException(ex, $"Error updating Vibes CM swap GUI with CM changes: {ex.Message}", false);
            }
        }