public void SendChildStatusMessageToParentApps(string appId, string status)
        {
            Component component = ComponentLogic.GetByAppId(appId);

            if (component != null)
            {
                var parentComponents = ComponentLogic.GetParentComponents(component);
                if (parentComponents != null && parentComponents.Count > 0)
                {
                    foreach (var parent in parentComponents)
                    {
                        AppStatus AggregatedStatus = AppStatus.Up;
                        if (status == "Down" || parent.HeartBeatStatus == HeartBeatStatus.Down)
                        {
                            AggregatedStatus = AppStatus.Down;
                        }
                        else
                        {
                            //check through health message status and other children component messages to determine final status
                            //what of if the parent app is down, not sending heart beats this check would then not be sufficient
                            var checkStatus = HealthMessageUtility.GetStatusBasedOnHealthChecks(parent.AppID);
                            var appStatus   = HealthMessageUtility.GetStatusBasedOnChildrenApps(parent);
                            // AggregatedStatus = HealthMessageUtility.ReturnAggregateStatus(checkStatus, appStatus);
                        }
                        //Update the Status of the Application in the database
                        parent.Status     = AggregatedStatus;
                        parent.LastUpdate = DateTime.Now;
                        ComponentLogic.EditEntity(parent);
                        Clients.All.reportAppStatus(parent.AppID, AggregatedStatus.ToString());
                    }
                }
            }
        }
        public static void SendHealthMessage(SelfHealthMessage healthMessage)
        {
            AppStatus AggregatedStatus   = AppStatus.Up;
            string    failedMessagesJson = string.Empty;

            //Step 1: Get Aggregate Status of AppID depeding on status of related health messages
            var checkStatus = GetStatusBasedOnHealthChecks(healthMessage.AppID);

            //Step 2: Check if there is a App set up with this ID if there is, get agg status of APP depending on status of Child Apps.
            Component component = ComponentLogic.GetByAppId(healthMessage.AppID);

            if (component != null)
            {
                var appStatus = GetStatusBasedOnChildrenApps(component, AggregatedStatus);
                AggregatedStatus = ReturnAggregateStatus(checkStatus, appStatus);
                //Update the Status of the Application in the database
                component.Status     = AggregatedStatus;
                component.LastUpdate = DateTime.Now;
                ComponentLogic.EditEntity(component);
            }

            string status = AggregatedStatus.ToString();

            GlobalHost.ConnectionManager.GetHubContext <HealthMessageHub>().Clients.All.addHealthMessage(healthMessage.AppID,
                                                                                                         healthMessage.Results[0].Title,
                                                                                                         String.Format("{0:d/M/yyyy HH:mm:ss}", healthMessage.DateChecked),
                                                                                                         String.Format("{0:HH:mm:ss}", healthMessage.DateChecked),
                                                                                                         Convert.ToString(healthMessage.OverallStatus),
                                                                                                         healthMessage.Results[0].TimeElasped,
                                                                                                         healthMessage.Results[0].AdditionalInformation,
                                                                                                         AggregatedStatus.ToString(),
                                                                                                         failedMessagesJson);
        }
예제 #3
0
파일: AppResult.cs 프로젝트: mennsah/DaaS
        public static AppResult Result(AppStatus status, string message = null, object data = null)
        {
            var result = new AppResult {
                Status = status, Message = message ?? status.ToString(), Data = data, IsSuccessful = status == AppStatus.Success ? true : false
            };

            return(result);
        }
예제 #4
0
        /// <summary>
        /// 格式化
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("AppStatus: ");
            builder.Append(AppStatus.ToString());
            builder.Append(" ProtocolStatus: ");
            builder.Append(ProtocolStatus.ToString());
            return(builder.ToString());
        }
예제 #5
0
        public void UpdateStatus(int id, AppStatus status)
        {
            var dic = new Dictionary <string, object>();

            dic.Add("Status", (int)status);
            dic.Add(PrimaryKey, id);
            var sqlClause = BuildUpdateSql(dic);

            ExcuteSql(sqlClause);

            _logger.Information("修改状态,ID:" + id + " status:" + status.ToString());
        }
        public static void SendHealthMessage(SelfHealthMessage healthMessage)
        {
            //  new HealthMessageLogic().SaveOrUpdateHealthStatus(healthMessage);
            Trace.TraceInformation("Health Messaged Received " + healthMessage.AppID + "Status is " + healthMessage.OverallStatus);
            AppStatus AggregatedStatus   = AppStatus.Up;
            string    failedMessagesJson = string.Empty;

            Trace.TraceInformation("About to get status based on health checks " + healthMessage.AppID);

            //Step 1: Get Aggregate Status of AppID depeding on status of related health messages
            var checkStatus = GetStatusBasedOnHealthChecks(healthMessage.AppID, healthMessage.IPAddress);

            Trace.TraceInformation("Check Status is " + checkStatus);

            Trace.TraceInformation("About to get Component " + healthMessage.AppID);

            //Step 2: Check if there is an App set up with this ID if there is, get agg status of APP depending on status of Child Apps.
            Component component = ComponentLogic.GetByAppId(healthMessage.AppID);

            if (component != null)
            {
                var appStatus = GetStatusBasedOnChildrenApps(component, AggregatedStatus);
                AggregatedStatus = ReturnAggregateStatus(checkStatus, appStatus);
                //Update the Status of the Application in the database
                component.Status     = AggregatedStatus;
                component.LastUpdate = DateTime.Now;
                ComponentLogic.EditEntity(component);
            }
            Trace.TraceInformation("About to send info to client  " + healthMessage.AppID);
            string status  = AggregatedStatus.ToString();
            var    connect = GlobalHost.ConnectionManager.GetHubContext <HealthMessageHub>();

            connect.Clients.All.test();

            var message = JsonConvert.SerializeObject(healthMessage);

            connect.Clients.All.sendHealthMessage(message);                             // to health message ui
            connect.Clients.All.sendHealthStatus(message, AggregatedStatus.ToString()); //to monitor ui
            Trace.TraceInformation("Health Info has been sent to client ");
        }
예제 #7
0
        internal string Dump()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendLine("StartupPath:" + mStartupPath);
            sb.AppendLine("SystemStatus:" + SystemStatus.ToString());
            sb.AppendLine("ResetTimerOnMouseDown:" + ResetTimerOnMouseDown);
            sb.AppendLine("TimerConfigString:" + mTimerConfigString);
            sb.AppendLine(mApplicationInfo.ToString());
            sb.AppendLine("CurrentActivity:" + currentActivity);
            sb.Append("PreviousActivity:" + previousActivity);
            Log.Debug(sb.ToString());
            return(sb.ToString());
        }
예제 #8
0
 /// <summary>
 /// Return the otiKiosk status
 /// NotReady, Ready, PaymentTransaction, Update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _btnGetStatus_Click(object sender, EventArgs e)
 {
     try
     {
         AppStatus status = _kioskHandler.GetStatus();
         _Logger.AddText("Status: " + status, Messagetype.Message);
         _lblGetStatus.Text = status.ToString();
     }
     catch (KioskCommException jex)
     {
         _Logger.AddText(
             string.Format("GetStatus failed with code: {0} and message: {1}", jex.Code, jex.Message),
             Messagetype.Error);
     }
     catch (Exception ex)
     {
         _Logger.AddText(ex.ToString(), Messagetype.Error);
     }
 }
예제 #9
0
        private async void  Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (_pageAlreadyLoaded)
            {
                return;
            }

            _pageAlreadyLoaded = true;

            Categories = await MainPageViewModel.GetCategoriesAsync();

            OnPropertyChanged("Categories");

            // Отражение в заголовке окна статуса работы приложения
            Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Title = AppStatus.ToString();

            Weather = await WeatherService.GetWeather();

            OnPropertyChanged("Weather");
        }
예제 #10
0
 private void UpdateStatus(AppStatus status)
 {
     StatusTB.Text = status.ToString();
 }