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()); } } } }
protected void Page_Load(object sender, EventArgs e) { string appID = Convert.ToString(Request.QueryString["appID"]); if (!string.IsNullOrEmpty(appID)) { isEdit = true; } else { isEdit = false; } if (!IsPostBack) { appList = ComponentDb.GetAll(); BindData(); if (isEdit) { Component application = ComponentLogic.GetByAppId(appID); AppNameTxt.Value = application.AppName; // AppIDTxt.Value = application.AppID; if (application.ChildrenComponents != null && application.ChildrenComponents.Count > 0) { foreach (var item in application.ChildrenComponents) { ListItem listItem = new ListItem(item.AppName, item.Id.ToString()); listItem.Selected = true; AppsDrpDown.Items.Add(listItem); } } SaveButton.Text = "Update"; ID = application.Id.ToString(); } } }
public void LoadApplicationInfo(string appId) { Component component = ComponentLogic.GetByAppId(appId); string data = JsonConvert.SerializeObject(component); Clients.All.loadApplicationInfo(data); }
protected void SaveButton_Click(object sender, EventArgs e) { Component application; Dictionary <string, Component> appListDic = new Dictionary <string, Component>(); appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString()); string appName = AppNameTxt.Value; string appID = AppIDTxt.Value; var selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value]; application = ComponentLogic.GetByAppId(appID); if (!isEdit) { application = new Component(); application.Status = AppStatus.Down; application.HeartBeatStatus = HeartBeatStatus.Down; } application.AppID = appID; application.AppName = appName; application.ChildrenComponents = selectedItems.ToList(); if (isEdit) { ComponentLogic.EditEntity(application); Response.Redirect("view-applications.html"); } else { ComponentLogic.AddNewEntity(application); Response.Redirect(Request.RawUrl); } }
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); }
protected void SaveButton_Click(object sender, EventArgs e) { Component application; Dictionary <string, Component> appListDic = new Dictionary <string, Component>(); appListDic = appList.ToDictionary <Component, string>(x => x.Id.ToString()); string appName = AppNameTxt.Value; string appID = string.Empty; // string appID = AppIDTxt.Value; if (!isEdit) { appID = new ComponentLogic().GenerateAppID(); } else { appID = Convert.ToString(Request.QueryString["appID"]); } var selectedItems = from item in AppsDrpDown.Items.Cast <ListItem>() where item.Selected select appListDic[item.Value]; string state; bool isExists = ComponentLogic.isExist(appID, appName, ID, out state); if (isExists) { ShowNotification(false, string.Format("An Application with this {0} already exists", state), ""); return; } application = ComponentLogic.GetByAppId(appID); if (!isEdit) { application = new Component(); application.Status = AppStatus.Down; application.HeartBeatStatus = HeartBeatStatus.Down; } application.AppID = appID; application.AppName = appName; application.ChildrenComponents = selectedItems.ToList(); if (isEdit) { ComponentLogic.EditEntity(application); ShowNotification(true, "Sucessfully Updated", "view-applications.html"); //Response.Redirect("view-applications.html"); } else { ComponentLogic.AddNewEntity(application); ShowNotification(true, string.Format("Sucessfully Created, APPLICATION ID: {0}", application.AppID), "AddApplication.aspx"); //Response.Redirect(Request.RawUrl); } }
public void UpdateHeartBeat(string appId, string status) { //we save the heartbeat status Component component = ComponentLogic.GetByAppId(appId); if (component != null) { component.HeartBeatStatus = (HeartBeatStatus)Enum.Parse(typeof(HeartBeatStatus), status); if ((HeartBeatStatus)Enum.Parse(typeof(HeartBeatStatus), status) == HeartBeatStatus.Down) { component.Status = AppStatus.Down; } ComponentLogic.EditEntity(component); } }
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 "); }