private DataTable FormatNodes(NodeHealthSummary nodeSummary) { DataTable dtNodes = new DataTable(); dtNodes.Columns.AddRange(new DataColumn[] { new DataColumn("RowNum"), new DataColumn("NodeIP"), new DataColumn("NodeName"), new DataColumn("StoreID"), new DataColumn("StoreName"), new DataColumn("Errors") }); int RowNum = 0; foreach (var machine in nodeSummary.Machines) { string errorString = ""; List <CMS.AMS.Models.Attribute> allComponentsErrors = new List <CMS.AMS.Models.Attribute>(); foreach (var component in machine.Components) { if (!component.Alive) { component.Attributes.Insert(0, new CMS.AMS.Models.Attribute { Severity = component.Severity, ParamID = (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) ? (component.IsPromoFetchNode ? ServerHealthErrorCodes.PromoFecthNode_Disconnected : ServerHealthErrorCodes.PromotionBroker_Disconnected) : ServerHealthErrorCodes.CustomerBroker_Disconnected), Code = RequestStatusConstants.Failure, Description = ((component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) ? PhraseLibExtension.PhraseLib.Lookup("term.promotionbroker", LanguageID) : PhraseLibExtension.PhraseLib.Lookup("term.customerbroker", LanguageID)) + " " + PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID)), LastUpdate = component.LastHeard }); } allComponentsErrors.AddRange(component.Attributes.Where(e => e.Code == RequestStatusConstants.Failure)); } errorString = ServerHealthHelper.FormatErrors(allComponentsErrors, LanguageID); RowNum++; machine.RowNum = RowNum; dtNodes.Rows.Add(RowNum, machine.NodeIP, machine.NodeName, machine.StoreID, machine.StoreName, errorString); } return(dtNodes); }
private DataTable FormatEngines(NodeHealthSummary engineSummary) { DataTable dtEngines = new DataTable(); dtEngines.Columns.AddRange(new DataColumn[] { new DataColumn("RowNum"), new DataColumn("NodeIP"), new DataColumn("NodeName"), new DataColumn("StoreID"), new DataColumn("StoreName"), new DataColumn("Errors") }); int RowNum = 0; foreach (var machine in engineSummary.Machines) { if (!machine.Components[0].Alive) { machine.Components[0].Attributes.Insert(0, new CMS.AMS.Models.Attribute { Severity = machine.Components[0].Severity, Code = RequestStatusConstants.Failure, ParamID = (machine.Components[0].EnterpriseEngine ? ServerHealthErrorCodes.EnterpriseEngine_Disconnected : ServerHealthErrorCodes.PromotionEngine_Disconnected), Description = PhraseLib.Lookup("term.engine", LanguageID) + " " + PhraseLib.Lookup("term.disconnected", LanguageID), LastUpdate = machine.Components[0].LastHeard }); } string errorString = ServerHealthHelper.FormatErrors(machine.Components[0].Attributes.Where(e => e.Code == RequestStatusConstants.Failure), LanguageID); RowNum++; machine.RowNum = RowNum; dtEngines.Rows.Add(RowNum, machine.NodeIP, machine.NodeName, machine.StoreID, (machine.Components[0].EnterpriseEngine) ? PhraseLib.Lookup("term.all", LanguageID) + " " + PhraseLib.Lookup("term.stores", LanguageID) : machine.StoreName, errorString); } return(dtEngines); }
public static string GetNodes(string URL, int LanguageID) { List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >(); IRestServiceHelper RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>(); KeyValuePair <NodeHealthSummary, string> result = RESTServiceHelper.CallService <NodeHealthSummary>(RESTServiceList.ServerHealthService, URL, LanguageID, HttpMethod.Get, String.Empty, false, headers); NodeHealthSummary nodeSummary = result.Key; string errorMessage = result.Value; if (errorMessage == string.Empty) { var nodes = new List <object>(); if (nodeSummary.Machines.Count > 0) { foreach (var machine in nodeSummary.Machines) { List <CMS.AMS.Models.Attribute> allComponentsErrors = new List <CMS.AMS.Models.Attribute>(); string PBerrorHtml = "", CBerrorHtml = ""; bool HasPB = false, HasCB = false; foreach (var component in machine.Components) { if (!component.Alive) { component.Attributes.Insert(0, new CMS.AMS.Models.Attribute { Severity = component.Severity, ParamID = (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) ? (component.IsPromoFetchNode ? ServerHealthErrorCodes.PromoFecthNode_Disconnected : ServerHealthErrorCodes.PromotionBroker_Disconnected) : ServerHealthErrorCodes.CustomerBroker_Disconnected), Code = RequestStatusConstants.Failure, Description = ((component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) ? PhraseLibExtension.PhraseLib.Lookup("term.promotionbroker", LanguageID) : PhraseLibExtension.PhraseLib.Lookup("term.customerbroker", LanguageID)) + " " + PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID)), LastUpdate = component.LastHeard }); } var errors = component.Attributes.Where(e => e.Code == RequestStatusConstants.Failure); allComponentsErrors.AddRange(errors); if (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker)) { PBerrorHtml = ServerHealthHelper.GenerateErrorTable(errors, LanguageID); HasPB = true; } else if (component.ComponentName.ToUpper().Contains(BrokerNameConstants.CustomerBroker)) { CBerrorHtml = ServerHealthHelper.GenerateErrorTable(errors, LanguageID); HasCB = true; } } string errorString = ServerHealthHelper.FormatErrors(allComponentsErrors, LanguageID); nodes.Add(new { nodeIp = machine.NodeIP, storeName = machine.StoreName, nodeName = machine.NodeName, storeId = machine.StoreID, errorString = errorString, PBerrorHtml = PBerrorHtml, CBerrorHtml = CBerrorHtml, hasCB = HasCB, hasPB = HasPB, Report = machine.Report, Alert = machine.Alert }); } return(JsonConvert.SerializeObject(nodes)); } else { return(JsonConvert.SerializeObject(PhraseLibExtension.PhraseLib.Lookup("term.nomorerecords", LanguageID))); } } else { return(JsonConvert.SerializeObject(errorMessage)); } }
private void BindWarnings(string url, GridView gvFiles, HtmlInputHidden pageSize, HtmlInputHidden pageCount, HtmlGenericControl loader) { try { gvWarnings.Columns[0].HeaderText = PhraseLib.Lookup("term.description", LanguageID); gvWarnings.Columns[1].HeaderText = PhraseLib.Lookup("term.duration", LanguageID); List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >(); IRestServiceHelper RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>(); KeyValuePair <NodeHealthSummary, string> result = RESTServiceHelper.CallService <NodeHealthSummary>(RESTServiceList.ServerHealthService, url, LanguageID, HttpMethod.Get, String.Empty, false, headers); NodeHealthSummary summary = result.Key; string error = result.Value; pageCount.Value = "0"; if (error != string.Empty) { loader.InnerHtml = "<center>" + error + "</center>"; } else if (summary.RowCount > 0) { gvWarnings.DataSource = GetErrors(summary, LanguageID); gvWarnings.DataBind(); if (summary.RowCount <= pageSize.Value.ConvertToInt16()) { pageCount.Value = "1"; } else { decimal value = (summary.RowCount.ConvertToDecimal() / pageSize.Value.ConvertToDecimal()); pageCount.Value = Math.Ceiling(value).ToString(); } if (pageCount.Value == "1") { loader.InnerHtml = "<center>" + PhraseLib.Lookup("term.nomorerecords", LanguageID) + "</center>"; } } if (pageCount.Value == "0") { loader.InnerHtml = "<center>" + PhraseLib.Lookup("term.norecords", LanguageID) + "</center>"; } } catch (Exception ex) { loader.InnerHtml = "<center>" + ex.Message + "</center>"; Logger.WriteError(ex.ToString()); } }
private void PopulateEnginesPage() { hdnPageCount.Value = "0"; List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >(); IRestServiceHelper RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>(); KeyValuePair <NodeHealthSummary, string> result = RESTServiceHelper.CallService <NodeHealthSummary>(RESTServiceList.ServerHealthService, (hdnURL.Value != string.Empty? hdnURL.Value + "/engines?offset=0&pagesize=" + PAGESIZE.ToString() + "&sort=" + SORTBY + "&sortdir=" + SORTDIR + "&search=" + Server.UrlEncode(SEARCH) + "&filter=" + GetFilter(FILTER.ConvertToInt16()) + (FILTER.ConvertToInt16() == 0 || FILTER.ConvertToInt16() == 4 ? "&report=true" : "&report=all") :""), LanguageID, HttpMethod.Get, String.Empty, false, headers); engineSummary = result.Key; string error = result.Value; if (error == string.Empty) { if (engineSummary == null) { ucServerHealthTabs.SetInfoMessage(error, true); } else if (engineSummary.Machines.Count > 0) { //Engines gvEngines.DataSource = FormatEngines(engineSummary); gvEngines.DataBind(); if (engineSummary.RowCount <= PAGESIZE) { hdnPageCount.Value = "1"; } else { decimal value = (engineSummary.RowCount.ConvertToDecimal() / PAGESIZE.ConvertToDecimal()); hdnPageCount.Value = Math.Ceiling(value).ToString(); } } } else { ucServerHealthTabs.SetInfoMessage(error, true); } if (hdnPageCount.Value == "0") { loadmoreajaxloader.InnerHtml = "<center>" + PhraseLib.Lookup("term.norecords", LanguageID) + "</center>"; } else if (hdnPageCount.Value == "1") { loadmoreajaxloader.InnerHtml = "<center>" + PhraseLib.Lookup("term.nomorerecords", LanguageID) + "</center>"; } }
public static string GetEngines(string URL, int LanguageID) { List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >(); IRestServiceHelper RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>(); KeyValuePair <NodeHealthSummary, string> result = RESTServiceHelper.CallService <NodeHealthSummary>(RESTServiceList.ServerHealthService, URL, LanguageID, HttpMethod.Get, String.Empty, false, headers); string errorMessage = result.Value; NodeHealthSummary engineSummary = result.Key; if (errorMessage == string.Empty) { var engines = new List <object>(); if (engineSummary.Machines.Count > 0) { foreach (var machine in engineSummary.Machines) { if (!machine.Components[0].Alive) { machine.Components[0].Attributes.Insert(0, new CMS.AMS.Models.Attribute { Severity = machine.Components[0].Severity, Code = RequestStatusConstants.Failure, ParamID = (machine.Components[0].EnterpriseEngine ? ServerHealthErrorCodes.EnterpriseEngine_Disconnected : ServerHealthErrorCodes.PromotionEngine_Disconnected), Description = (PhraseLibExtension.PhraseLib.Lookup("term.engine", LanguageID) + " " + PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID)), LastUpdate = machine.Components[0].LastHeard }); } string errorHtml = ""; var errors = machine.Components[0].Attributes.Where(e => e.Code == RequestStatusConstants.Failure); string errorString = ServerHealthHelper.FormatErrors(errors, LanguageID); errorHtml = ServerHealthHelper.GenerateErrorTable(errors, LanguageID); engines.Add(new { nodeIp = machine.NodeIP, storeName = (machine.Components[0].EnterpriseEngine) ? PhraseLibExtension.PhraseLib.Lookup("term.all", LanguageID) + " " + PhraseLibExtension.PhraseLib.Lookup("term.stores", LanguageID) : machine.StoreName, nodeName = machine.NodeName, storeId = machine.StoreID, errorString = errorString, errorHtml = errorHtml, Report = machine.Report, Alert = machine.Alert }); } return(JsonConvert.SerializeObject(engines)); } else { return(JsonConvert.SerializeObject(PhraseLibExtension.PhraseLib.Lookup("term.nomorerecords", LanguageID))); } } else { return(JsonConvert.SerializeObject(errorMessage)); } }
public static string GetWarnings(string URL, int LanguageID) { NodeHealthSummary summary = null; List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >(); IRestServiceHelper RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>(); KeyValuePair <NodeHealthSummary, string> result = RESTServiceHelper.CallService <NodeHealthSummary>(RESTServiceList.ServerHealthService, URL, LanguageID, HttpMethod.Get, String.Empty, false, headers); summary = result.Key; string errorMessage = result.Value; var errors = new DataTable(); if (errorMessage == "") { if (summary != null && summary.RowCount > 0) { errors = GetErrors(summary, LanguageID); } if (errors.Rows.Count > 0) { var listErrors = new List <object>(); foreach (DataRow row in errors.Rows) { listErrors.Add(new { Description = "<a title='" + row["tooltip"] + "' href='" + row["URL"] + "'>" + row["NodeIP"] + "</a> <span title='" + row["tooltip"] + "'>" + row["Description"] + "</span>", Duration = row["Duration"] }); } return(JsonConvert.SerializeObject(listErrors)); } else { return(JsonConvert.SerializeObject(PhraseLibExtension.PhraseLib.Lookup("term.nomorerecords", LanguageID))); } } else { return(JsonConvert.SerializeObject(errorMessage)); } }
private static DataTable GetErrors(NodeHealthSummary summary, int LanguageID) { //Errors DataTable dtErrors = new DataTable(); dtErrors.Columns.AddRange(new DataColumn[] { new DataColumn("NodeIP"), new DataColumn("Description"), new DataColumn("Duration"), new DataColumn("URL"), new DataColumn("tooltip") }); foreach (var machine in summary.Machines) { string errorMessage = ""; long errorDate = 0; int errorsHigh = 0, errorsMedium = 0, errorsLow = 0; string term = ""; string nodeURL = ""; bool isAlive = true; foreach (var component in machine.Components) { if (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) || component.ComponentName.ToUpper().Contains(BrokerNameConstants.CustomerBroker)) { term = PhraseLibExtension.PhraseLib.Lookup("term.node", LanguageID); nodeURL = "UENodeHealth.aspx?NodeName=" + machine.NodeName; } else { term = PhraseLibExtension.PhraseLib.Lookup("term.engine", LanguageID); nodeURL = "UEEngineHealth.aspx?NodeName=" + machine.NodeName; } if (!component.Alive) { isAlive = false; if (errorDate <= 0 || errorDate > component.LastHeard) { errorDate = component.LastHeard; } } List <CMS.AMS.Models.Attribute> errors = component.Attributes.Where(e => e.Code == RequestStatusConstants.Failure).ToList(); errorsHigh += errors.Where(e => e.Severity.ToLower() == SeverityConstants.High.ToLower()).Count(); errorsMedium += errors.Where(e => e.Severity.ToLower() == SeverityConstants.Medium.ToLower()).Count(); errorsLow += errors.Where(e => e.Severity.ToLower() == SeverityConstants.Low.ToLower()).Count(); foreach (var item in errors) { if (errorDate <= 0 || errorDate > item.LastUpdate) { errorDate = item.LastUpdate; } } } if (!isAlive) { errorMessage = " " + term + " " + PhraseLibExtension.PhraseLib.Lookup("term.is", LanguageID) + " " + PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID); } string tooltip = ""; if ((errorsHigh + errorsMedium + errorsLow) > 0) { tooltip = PhraseLibExtension.PhraseLib.Lookup("term.high", LanguageID) + ": " + errorsHigh.ToString() + " " + PhraseLibExtension.PhraseLib.Lookup("term.medium", LanguageID) + ": " + errorsMedium.ToString() + " " + PhraseLibExtension.PhraseLib.Lookup("term.low", LanguageID) + ": " + errorsLow.ToString(); errorMessage = (errorMessage != string.Empty ? errorMessage + " " + PhraseLibExtension.PhraseLib.Lookup("term.and", LanguageID).ToLower() : term) + " " + PhraseLibExtension.PhraseLib.Lookup("term.has", LanguageID) + " " + (errorsHigh + errorsMedium + errorsLow).ToString() + " " + PhraseLibExtension.PhraseLib.Lookup("term.error(s)", LanguageID); } dtErrors.Rows.Add(machine.NodeIP, errorMessage, errorDate.ConvertToDuration(LanguageID), nodeURL, tooltip); } return(dtErrors); }