public static string GetEngineFiles(string URL, int LanguageID)
    {
        string errorMessage = "";

        PendingFiles files = null;
        List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >();
        IRestServiceHelper RESTServiceHelper          = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
        KeyValuePair <PendingFiles, string> result    = RESTServiceHelper.CallService <PendingFiles>(RESTServiceList.ServerHealthService, URL, LanguageID, HttpMethod.Get, String.Empty, false, headers);

        files        = result.Key;
        errorMessage = result.Value;

        var pendingFiles = new List <object>();

        if (errorMessage == "")
        {
            if (files != null && files.Files.Count > 0)
            {
                foreach (var file in files.Files)
                {
                    pendingFiles.Add(new { OfferID = file.ID, FileName = file.FileName, Age = file.CreatedOn.ConvertToAge(), Created = file.CreatedOn.ConvertToLocalDateTime().ToString(), Path = files.FilesPath });
                }
                return(JsonConvert.SerializeObject(pendingFiles));
            }
            else
            {
                return(JsonConvert.SerializeObject(PhraseLibExtension.PhraseLib.Lookup("term.nomorerecords", LanguageID)));
            }
        }
        else
        {
            return(JsonConvert.SerializeObject(errorMessage));
        }
    }
    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 BindFiles(string url, GridView gvFiles, HtmlInputHidden pageSize, HtmlInputHidden pageCount, HtmlGenericControl loader)
    {
        try
        {
            List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >();
            IRestServiceHelper RESTServiceHelper          = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
            KeyValuePair <PendingFiles, string> result    = RESTServiceHelper.CallService <PendingFiles>(RESTServiceList.ServerHealthService, url, LanguageID, HttpMethod.Get, string.Empty, false, headers);
            PendingFiles files = result.Key;
            string       error = result.Value;
            pageCount.Value = "0";

            if (error != string.Empty)
            {
                loader.InnerHtml = "<center>" + error + "</center>";
            }
            else if (files.Files.Count > 0)
            {
                //Engines

                DataTable dtFiles = new DataTable();
                dtFiles.Columns.AddRange(new DataColumn[] { new DataColumn("OfferID"), new DataColumn("FileName"), new DataColumn("Age"), new DataColumn("Created"), new DataColumn("Path") });

                foreach (PendingFile file in files.Files)
                {
                    dtFiles.Rows.Add(file.ID.ToString(), file.FileName, file.CreatedOn.ConvertToAge(), file.CreatedOn.ConvertToLocalDateTime().ToString(), files.FilesPath);
                }

                if (dtFiles.Rows.Count > 0)
                {
                    gvFiles.DataSource = dtFiles;
                    gvFiles.DataBind();
                }
                if (files.RowCount <= pageSize.Value.ConvertToInt16())
                {
                    pageCount.Value = "1";
                }
                else
                {
                    decimal value = (files.RowCount.ConvertToDecimal() / pageSize.Value.ConvertToDecimal());
                    pageCount.Value = Math.Ceiling(value).ToString();
                }
            }
            if (pageCount.Value == "0")
            {
                loader.InnerHtml = "<center>" + PhraseLib.Lookup("term.norecords", LanguageID) + "</center>";
            }
            else if (pageCount.Value == "1")
            {
                loader.InnerHtml = "<center>" + PhraseLib.Lookup("term.nomorerecords", LanguageID) + "</center>";
            }
        }
        catch (Exception ex)
        {
            loader.InnerHtml = "<center>" + ex.Message + "</center>";
            Logger.WriteError(ex.ToString());
        }
    }
    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());
        }
    }
Beispiel #5
0
    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 ToggleReportAlert(string URL, int LanguageID, bool Enabled)
    {
        string returnMessage = "";

        try
        {
            List <KeyValuePair <string, string> > headers   = new List <KeyValuePair <string, string> >();
            IRestServiceHelper            RESTServiceHelper = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
            KeyValuePair <string, string> result            = RESTServiceHelper.CallService <string>(RESTServiceList.ServerHealthService, URL, LanguageID, HttpMethod.Post, "{\"enabled\": " + Enabled.ToJSON() + "}", false, headers);
            returnMessage = result.Value;
        }
        catch (Exception ex)
        {
            returnMessage = ex.Message;
        }
        return(returnMessage);
    }
 public string HttpPost(string URL, int offerId, string storeNames)
 {
     try
     {
         IRestServiceHelper restservice = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
         OfferData          ofd         = new OfferData()
         {
             offerId = offerId, storeNames = storeNames.Split(',')
         };
         var PostData = Newtonsoft.Json.JsonConvert.SerializeObject(ofd);
         KeyValuePair <String, String> response = restservice.CallService <String>(RESTServiceList.PromotionBrokerService, URL, 1, System.Net.Http.HttpMethod.Post, PostData, false);
         return(response.Key);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Beispiel #8
0
    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));
        }
    }
    private void PopulateServerSummary()
    {
        string messagePhraseTerm = m_health.CheckForIPL(LocationID);

        if (messagePhraseTerm != string.Empty)
        {
            ucServerHealthTabs.SetInfoMessage(Copient.PhraseLib.Lookup(messagePhraseTerm, LanguageID), true);
        }


        //Bind Health
        List <KeyValuePair <string, string> > headers   = new List <KeyValuePair <string, string> >();
        IRestServiceHelper RESTServiceHelper            = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
        KeyValuePair <HealthSummaryList, string> result = RESTServiceHelper.CallService <HealthSummaryList>(RESTServiceList.ServerHealthService, (hdnURL.Value != string.Empty ? hdnURL.Value + "/offerdistributionstatus" : ""), LanguageID, HttpMethod.Get, "", true, headers);
        string errorMessage = result.Value;

        serverHealthList = result.Key;

        if (errorMessage == string.Empty)
        {
            BindData(serverHealthList);
            BindWarnings(hdnURL.Value + "/allerrors?&report=true&offset=0&pagesize=" + hdnPageSize1.Value, gvWarnings, hdnPageSize1, hdnPageCount1, loadmoreajaxloader1);
            BindFiles(hdnURL.Value + "/allfiles?offset=0&pagesize=" + hdnPageSize.Value, gvFiles, hdnPageSize, hdnPageCount, loadmoreajaxloader);
        }
        else
        {
            ucServerHealthTabs.SetInfoMessage(errorMessage, true, false);

            var storedServerHealth = GetStoredJSONResponse();
            serverHealthList = storedServerHealth.Item1;
            DateTime HealthOn = storedServerHealth.Item2;

            if (serverHealthList != null && HealthOn != null && HealthOn != DateTime.MinValue)
            {
                ucServerHealthTabs.SetInfoMessage(PhraseLib.Lookup("serverhealth.msg", LanguageID) + " " + HealthOn.ToString("dd/MM/yyyy") + ".", true, true);
                BindData(serverHealthList);
            }
            loadmoreajaxloader.InnerHtml = loadmoreajaxloader1.InnerHtml = "<center>" + PhraseLib.Lookup("term.data", LanguageID) + " " + PhraseLib.Lookup("term.unavailable", LanguageID).ToLower() + "." + "</center>";
        }
    }
    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 void PopulateNodesPage()
    {
        //Bind Health
        List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >();
        IRestServiceHelper RESTServiceHelper          = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
        KeyValuePair <NodeHealth, string> result      = RESTServiceHelper.CallService <NodeHealth>(RESTServiceList.ServerHealthService, (m_health.HealthServiceURL != string.Empty? m_health.HealthServiceURL + "/nodes/" + Request.QueryString["NodeName"]:""), LanguageID, HttpMethod.Get, String.Empty, false, headers);
        string errorMessage = result.Value;

        nodeHealth = result.Key;

        //Errors
        DataTable dtErrors = new DataTable();

        dtErrors.Columns.AddRange(new DataColumn[] { new DataColumn("Severity"), new DataColumn("ParamID"), new DataColumn("Description"), new DataColumn("Duration") });
        gvNodeWarnings.Columns[0].HeaderText = PhraseLib.Lookup("term.severity", LanguageID);
        gvNodeWarnings.Columns[1].HeaderText = PhraseLib.Lookup("term.code", LanguageID);
        gvNodeWarnings.Columns[2].HeaderText = PhraseLib.Lookup("term.description", LanguageID);
        gvNodeWarnings.Columns[3].HeaderText = PhraseLib.Lookup("term.duration", LanguageID);

        if (errorMessage == string.Empty && nodeHealth != null)
        {
            Alert.Checked  = nodeHealth.Machine.Alert;
            Report.Checked = nodeHealth.Machine.Report;

            bool hasPromotionBroker = false;
            bool hasCustomerBroker  = false;

            foreach (var component in nodeHealth.Machine.Components)
            {
                if (!component.Alive)
                {
                    component.Attributes.Insert(0, new CMS.AMS.Models.Attribute {
                        Severity = component.Severity, Code = RequestStatusConstants.Failure, ParamID = (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker) ? (component.IsPromoFetchNode ? ServerHealthErrorCodes.PromoFecthNode_Disconnected: ServerHealthErrorCodes.PromotionBroker_Disconnected) : ServerHealthErrorCodes.CustomerBroker_Disconnected), Description = (PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID)), LastUpdate = component.LastHeard
                    });
                }

                foreach (var error in component.Attributes.Where(e => e.Code == RequestStatusConstants.Failure))
                {
                    dtErrors.Rows.Add(PhraseLib.Lookup("term." + error.Severity, LanguageID), error.ParamID, ServerHealthHelper.GetErrorDescription(error.ParamID, LanguageID), error.LastUpdate.ConvertToDuration(LanguageID));
                }

                if (component.ComponentName.ToUpper().Contains(BrokerNameConstants.PromotionBroker))
                {
                    lblPBStatus.Text    = component.Alive ? PhraseLib.Lookup("term.connected", LanguageID) : "<font color=\"red\">" + PhraseLib.Lookup("term.disconnected", LanguageID) + "</font>";
                    lblPBLastHeard.Text = component.LastHeard.ConvertToLocalDateTime().ToString();

                    foreach (var attr in component.Attributes)
                    {
                        if (attr.Description.ToUpper().Contains("FETCH"))
                        {
                            lblLastUpdateOffer.Text = attr.LastUpdate.ConvertToLocalDateTime().ToString();
                        }
                        if (attr.Description.ToUpper().Contains("IPL"))
                        {
                            lblLastIPL.Text = attr.LastUpdate.ConvertToLocalDateTime().ToString();
                        }
                    }
                    if (lblLastUpdateOffer.Text == "")
                    {
                        lblLastUpdateOffer.Text = "-";
                    }
                    if (lblLastIPL.Text == "")
                    {
                        lblLastIPL.Text = "-";
                    }
                    hasPromotionBroker = true;
                }
                else if (component.ComponentName.ToUpper().Contains(BrokerNameConstants.CustomerBroker))
                {
                    lblCBStatus.Text          = component.Alive ? PhraseLib.Lookup("term.connected", LanguageID) : "<font color=\"red\">" + PhraseLib.Lookup("term.disconnected", LanguageID) + "</font>";
                    lblCBLastHeard.Text       = component.LastHeard.ConvertToLocalDateTime().ToString();
                    lblLastLookUp.Text        = ServerHealthHelper.RetrieveAttribute(component.Attributes, ServerHealthErrorCodes.CustomerBroker_LastCustomerLookup);
                    lblLastTransDownload.Text = ServerHealthHelper.RetrieveAttribute(component.Attributes, ServerHealthErrorCodes.CustomerBroker_LastTransactionDownload);
                    lblLastTransUpload.Text   = ServerHealthHelper.RetrieveAttribute(component.Attributes, ServerHealthErrorCodes.CustomerBroker_LastTransactionUpload);
                    hasCustomerBroker         = true;
                }
            }
            divCB.Visible         = hasCustomerBroker;
            divPB.Visible         = hasPromotionBroker;
            communication.Visible = hasPromotionBroker;

            if (dtErrors.Rows.Count > 0)
            {
                gvNodeWarnings.DataSource = dtErrors;
                gvNodeWarnings.DataBind();
            }
            else
            {
                lblError.Text = "<center>" + PhraseLib.Lookup("term.norecords", LanguageID) + "</center>";
            }

            //Identification
            lblNodeName.Text  = Server.HtmlEncode(nodeHealth.Machine.NodeName);
            lblIpAddress.Text = Server.HtmlEncode(nodeHealth.Machine.NodeIP);
        }
        else
        {
            ucServerHealthTabs.SetInfoMessage(errorMessage, true, true);
        }
    }
    private void PopulateEnginesPage()
    {
        //Bind Health
        string errorMessage = "";
        List <KeyValuePair <string, string> > headers = new List <KeyValuePair <string, string> >();
        IRestServiceHelper RESTServiceHelper          = CurrentRequest.Resolver.Resolve <IRestServiceHelper>();
        KeyValuePair <NodeHealth, string> result      = RESTServiceHelper.CallService <NodeHealth>(RESTServiceList.ServerHealthService, (hdnURL.Value != string.Empty? hdnURL.Value + "/engines/":"") + Request.QueryString["NodeName"], LanguageID, HttpMethod.Get, String.Empty, false, headers);

        engineHealth = result.Key;
        errorMessage = result.Value;

        if (errorMessage == string.Empty && engineHealth != null)
        {
            //Identification
            lblEngineName.Text        = Server.HtmlEncode(engineHealth.Machine.NodeName);
            lblIpAddress.Text         = Server.HtmlEncode(engineHealth.Machine.NodeIP);
            lblStatus.Text            = engineHealth.Machine.Components[0].Alive ? PhraseLib.Lookup("term.connected", LanguageID) : "<font color=\"red\">" + PhraseLib.Lookup("term.disconnected", LanguageID) + "</font>";
            lblType.Text              = (engineHealth.Machine.Components[0].EnterpriseEngine) ? PhraseLib.Lookup("serverhealth.enterpriseengine", LanguageID) : PhraseLib.Lookup("serverhealth.storeengine", LanguageID);
            Alert.Checked             = engineHealth.Machine.Alert;
            Report.Checked            = engineHealth.Machine.Report;
            hdnLocationID.Value       = engineHealth.Machine.StoreID;
            hdnEnterpriseEngine.Value = engineHealth.Machine.Components[0].EnterpriseEngine.ToString().ToLower();

            if (engineHealth.Machine.Components[0].EnterpriseEngine)
            {
                linkConfig.Visible = false;
            }
            else
            {
                linkConfig.Text        = PhraseLib.Lookup("term.storeconfiguration", LanguageID);
                linkConfig.NavigateUrl = "../store-edit.aspx?LocationID=" + hdnLocationID.Value;
                linkConfig.Visible     = true;
            }

            lblStore.Text = Server.HtmlEncode((engineHealth.Machine.Components[0].EnterpriseEngine) ? PhraseLib.Lookup("term.all", LanguageID) + " " + PhraseLib.Lookup("term.stores", LanguageID) : engineHealth.Machine.StoreName);

            //Last CardHolder Look-Up
            lblCardholderlookup.Text = ServerHealthHelper.RetrieveAttribute(engineHealth.Machine.Components[0].Attributes, (engineHealth.Machine.Components[0].EnterpriseEngine == true ? ServerHealthErrorCodes.EnterpriseEngine_LastCustomerLookup : ServerHealthErrorCodes.PromotionEngine_LastCustomerLookup));

            //Last TransUpload
            lblTransactionupload.Text = ServerHealthHelper.RetrieveAttribute(engineHealth.Machine.Components[0].Attributes, (engineHealth.Machine.Components[0].EnterpriseEngine == true ? ServerHealthErrorCodes.EnterpriseEngine_LastTransactionUpload : ServerHealthErrorCodes.PromotionEngine_LastTransactionUpload));

            //Last Sync
            lblsync.Text = ServerHealthHelper.RetrieveAttribute(engineHealth.Machine.Components[0].Attributes, (engineHealth.Machine.Components[0].EnterpriseEngine == true ? ServerHealthErrorCodes.EnterpriseEngine_LastSync: ServerHealthErrorCodes.PromotionEngine_LastSync));

            //Last Heard
            lblLastHeard.Text = engineHealth.Machine.Components[0].LastHeard.ConvertToLocalDateTime().ToString();

            //Broker to Engine Pending Files
            //BindFiles(hdnURL.Value + "/engines/" + engineHealth.Machine.NodeName + "/files?offset=0&pagesize=" + hdnPageSize.Value, gvEngineFiles, hdnPageSize, hdnPageCount, loadmoreajaxloader);
            BindFiles(engineHealth.PendingFilesURL + "?offset=0&pagesize=" + hdnPageSize.Value, gvEngineFiles, hdnPageSize, hdnPageCount, loadmoreajaxloader);
            hdnPendingFilesURL.Value = engineHealth.PendingFilesURL;

            //Logix to Broker Pending Files
            if (engineHealth.Machine.Components[0].EnterpriseEngine)
            {
                BindFiles(hdnURL.Value + "/enterprise/logixfiles?offset=0&pagesize=" + hdnPageSize1.Value, gvBrokerFiles, hdnPageSize1, hdnPageCount1, loadmoreajaxloader1);
            }
            else
            {
                BindFiles(hdnURL.Value + "/stores/" + hdnLocationID.Value + "/logixfiles?offset=0&pagesize=" + hdnPageSize1.Value, gvBrokerFiles, hdnPageSize1, hdnPageCount1, loadmoreajaxloader1);
            }

            //Errors
            if (!engineHealth.Machine.Components[0].Alive)
            {
                engineHealth.Machine.Components[0].Attributes.Insert(0, new CMS.AMS.Models.Attribute {
                    Severity = engineHealth.Machine.Components[0].Severity, Code = RequestStatusConstants.Failure, ParamID = (engineHealth.Machine.Components[0].EnterpriseEngine ? ServerHealthErrorCodes.EnterpriseEngine_Disconnected : ServerHealthErrorCodes.PromotionEngine_Disconnected), Description = (PhraseLibExtension.PhraseLib.Lookup("term.engine", LanguageID) + " " + PhraseLibExtension.PhraseLib.Lookup("term.disconnected", LanguageID)), LastUpdate = engineHealth.Machine.Components[0].LastHeard
                });
            }

            DataTable dtErrors = new DataTable();
            dtErrors.Columns.AddRange(new DataColumn[] { new DataColumn("Severity"), new DataColumn("ParamID"), new DataColumn("Description"), new DataColumn("Duration") });

            foreach (var error in engineHealth.Machine.Components[0].Attributes.Where(e => e.Code == RequestStatusConstants.Failure))
            {
                dtErrors.Rows.Add(PhraseLib.Lookup("term." + error.Severity, LanguageID), error.ParamID, ServerHealthHelper.GetErrorDescription(error.ParamID, LanguageID), error.LastUpdate.ConvertToDuration(LanguageID));
            }

            gvEngineWarnings.Columns[0].HeaderText = PhraseLib.Lookup("term.severity", LanguageID);
            gvEngineWarnings.Columns[1].HeaderText = PhraseLib.Lookup("term.code", LanguageID);
            gvEngineWarnings.Columns[2].HeaderText = PhraseLib.Lookup("term.description", LanguageID);
            gvEngineWarnings.Columns[3].HeaderText = PhraseLib.Lookup("term.duration", LanguageID);

            if (dtErrors.Rows.Count == 0)
            {
                lblError.Text = "<center>" + PhraseLib.Lookup("term.norecords", LanguageID) + "</center>";
            }
            else
            {
                gvEngineWarnings.DataSource = dtErrors;
                gvEngineWarnings.DataBind();
            }
        }
        else
        {
            ucServerHealthTabs.SetInfoMessage(errorMessage, true, true);
            loadmoreajaxloader.Visible  = false;
            loadmoreajaxloader1.Visible = false;
        }
    }