Example #1
0
        // GET: /Monitoring/MessageAction/InitDataForMeesageAction/
        public ActionResult InitDataForMeesageAction()
        {
            try
            {
                var serviceClient = new MessageActionService().messsageActionService;
                var result        = serviceClient.InitDataForMeesageAction();

                var data = new
                {
                    status       = (result.IsSuccess) ? 1 : 0,
                    messageGroup = result.MessageGroup,
                    error        = result.ErrorMessage
                };

                return(Json(data));
            }
            catch (Exception ex)
            {
                var data = new
                {
                    status = 0,
                    error  = ex.Message
                };
                new RMSWebException(this, "0500", "InitDataForMeesageAction failed. " + ex.Message, ex, true);

                return(Json(data));
            }
        }
Example #2
0
        // GET: /Monitoring/ActionProfile/UpdateMessage/
        public ActionResult UpdateMessage(int?id, string m, int?messageGroupID, string message, int?severityLevelID, bool activeList, bool activeStatus)
        {
            try
            {
                if (messageGroupID == null)
                {
                    throw new ArgumentNullException("messageGroupID");
                }
                if (string.IsNullOrEmpty(message))
                {
                    throw new ArgumentNullException("message");
                }

                if (m == "e" && id == null)
                {
                    throw new ArgumentNullException("id");
                }
            }
            catch (ArgumentNullException ex)
            {
                new RMSWebException(this, "0500", "UpdateMessage failed. " + ex.Message, ex, true);
                throw;
            }

            try
            {
                var serviceClient = new MessageActionService().messsageActionService;
                var result        = serviceClient.UpdateMessage(id, m, messageGroupID, message, severityLevelID, activeList, activeStatus);

                var ret = new
                {
                    status = (result.IsSuccess) ? 1 : 0,
                    error  = (result.IsSuccess) ? "" : result.ErrorMessage
                };

                return(Json(ret));
            }
            catch (Exception ex)
            {
                var ret = new
                {
                    status = 0,
                    error  = ex.Message
                };

                new RMSWebException(this, "0500", "UpdateMessage failed. " + ex.Message, ex, true);

                return(Json(ret));
            }
        }
Example #3
0
        // GET: /Monitoring/ActionProfile/GetMessage/
        public ActionResult GetMessage(int?id)
        {
            try
            {
                if (id == null)
                {
                    throw new ArgumentNullException("MessageID");
                }
            }
            catch (ArgumentNullException ex)
            {
                new RMSWebException(this, "0500", "GetMessage failed. " + ex.Message, ex, true);
                throw;
            }
            try
            {
                var serviceClient = new MessageActionService().messsageActionService;
                var result        = serviceClient.Get(id);

                var ret = new
                {
                    status = (result.IsSuccess) ? 1 : 0,
                    data   = JsonConvert.SerializeObject(result.Message)
                };
                return(Json(ret));
            }
            catch (Exception ex)
            {
                var ret = new
                {
                    status = -1,
                    error  = ex.Message
                };
                new RMSWebException(this, "0500", "GetMessage failed. " + ex.Message, ex, true);

                return(Json(ret));
            }
        }
Example #4
0
        private void DoChecking()
        {
            string ret = "";

            #region Check Web Server - Web.config

            try
            {
                /*
                 *  <add key="RMS.OverrideProxy" value="false" />
                 *  <add key="RMS.WebServicURL_ActionProfileService" value="http://localhost/RMS.Centralize.WebService/ActionProfileService.svc" />
                 *  <add key="RMS.WebServicURL_MessageActionService" value="http://localhost/RMS.Centralize.WebService/MessageActionService.svc" />
                 *  <add key="RMS.WebServicURL_ClientService" value="http://localhost/RMS.Centralize.WebService/ClientService.svc" />
                 *  <add key="RMS.WebServicURL_MonitoringService" value="http://localhost/RMS.Centralize.WebService/MonitoringService.svc" />
                 *  <add key="RMS.WebServicURL_SummaryReportService" value="http://localhost/RMS.Centralize.WebService/SummaryReportService.svc" />
                 *  <add key="RMS.WebServicURL_SelfTestingService" value="http://localhost/RMS.Centralize.WebService/SelfTestingService.svc" />
                 *
                 */
                var nameValueCollection = ConfigurationManager.AppSettings;
                foreach (string s in nameValueCollection.AllKeys)
                {
                    var value = ConfigurationManager.AppSettings[s];
                    ret += "<b>" + s + "</b> = " + value + "<br/>";
                }
                rWebConfig.InnerHtml = ret;

                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.OverrideProxy"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.OverrideProxy\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_ActionProfileService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_ActionProfileService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_MessageActionService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_MessageActionService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_ClientService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_ClientService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_MonitoringService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_MonitoringService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_SummaryReportService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_SummaryReportService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_SelfTestingService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_SelfTestingService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_LocationService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_LocationService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_ClientMonitoringService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_ClientMonitoringService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_MonitoringProfileService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_MonitoringProfileService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_SeverityLevelService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_SeverityLevelService\"] not found or empty.";
                //}
                //if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["RMS.WebServicURL_MasterTableService"]))
                //{
                //    ret += "<br/>AppSettings[\"RMS.WebServicURL_MasterTableService\"] not found or empty.";
                //}

                //if (ret == "")
                //{
                //    rWebConfig.InnerHtml = "<span class=\"txt-green\">Passed</span>";
                //}
                //else
                //{
                //    rWebConfig.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
                //}
            }
            catch (Exception ex)
            {
                rWebConfig.InnerHtml = "Internal error while checking Web.config. " + ex.Message;
            }

            #endregion

            #region Check Web Server -> Web Service Server Connection

            ret = "";

            try
            {
                var service = new ActionProfileService();
                service.actionProfileService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>ActionProfileService failed. " + ex.Message;
            }
            try
            {
                var service = new ClientService();
                service.clientService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>ClientService failed. " + ex.Message;
            }
            try
            {
                var service = new MessageActionService();
                service.messsageActionService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>MessageActionService failed. " + ex.Message;
            }
            try
            {
                var service = new MonitoringService();
                service.monitoringService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>MonitoringService failed. " + ex.Message;
            }
            try
            {
                var service = new SummaryReportService();
                service.summaryReportService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>SummaryReportService failed. " + ex.Message;
            }
            try
            {
                var service = new SelfTestingService();
                service.selfTestingService.TestConnection();
            }
            catch (Exception ex)
            {
                ret += "<br/>SelfTestingService failed. " + ex.Message;
            }
            if (ret == "")
            {
                rWebToWsConnection.InnerHtml = "<span class=\"txt-green\">Passed</span>";
            }
            else
            {
                rWebToWsConnection.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
            }


            #endregion

            #region Check Web Service Server - Web.Config

            ret = "";

            try
            {
                var service = new SelfTestingService();
                ret = service.selfTestingService.TestWebConfig();
                rWebServiceConfig.InnerHtml = ret;
                //if (ret == "")
                //{
                //    rWebServiceConfig.InnerHtml = "<span class=\"txt-green\">Passed</span>";
                //}
                //else
                //{
                //    rWebServiceConfig.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
                //}
            }
            catch (Exception ex)
            {
                rWebServiceConfig.InnerHtml = "Internal error while checking Web Service Web.config. " + ex.Message;
            }

            #endregion

            #region Check Web Service Server -> Database Server Connection

            ret = "";

            try
            {
                var service = new SelfTestingService();
                ret = service.selfTestingService.TestDatabaseConnection();

                if (ret == "")
                {
                    rWSToDbConnection.InnerHtml = "<span class=\"txt-green\">Passed</span>";
                }
                else
                {
                    rWSToDbConnection.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
                }
            }
            catch (Exception ex)
            {
                rWSToDbConnection.InnerHtml = "Internal error while checking Database Connection. " + ex.Message;
            }

            #endregion

            #region Check Web Service Server -> Monitoring Agent Connection

            ret = "";

            try
            {
                var ipAddress = Request["ipAddress"];

                if (string.IsNullOrEmpty(ipAddress))
                {
                    rWsToAgentConnection.InnerHtml = "Please specify agent IP address via URL.<br/>eg. SelfTesting.aspx?ipaddress=127.0.0.1&[email protected]&sms=0812345678";
                }
                else
                {
                    var service = new SelfTestingService();
                    ret = service.selfTestingService.TestAgentConnection(ipAddress);

                    if (ret == "")
                    {
                        rWsToAgentConnection.InnerHtml = "<span class=\"txt-green\">Passed</span>";
                    }
                    else
                    {
                        rWsToAgentConnection.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
                    }
                }
            }
            catch (Exception ex)
            {
                rWsToAgentConnection.InnerHtml = "Internal error while checking Monitoring Agent Connection. " + ex.Message;
            }

            #endregion

            #region Check Web Service Server -> Email & SMS Server Connection

            ret = "";

            try
            {
                var email = Request["email"];
                var sms   = Request["sms"];

                if (string.IsNullOrEmpty(email))
                {
                    rWsToEmailConnection.InnerHtml = "Please specify email via URL.";
                }

                if (string.IsNullOrEmpty(sms))
                {
                    if (rWsToEmailConnection.InnerText != "")
                    {
                        rWsToEmailConnection.InnerHtml += "<br/>";
                    }
                    rWsToEmailConnection.InnerHtml += "Please specify sms via URL.";
                }

                if (rWsToEmailConnection.InnerText != "")
                {
                    rWsToEmailConnection.InnerHtml += "<br/>eg. SelfTesting.aspx?ipaddress=127.0.0.1&[email protected]&sms=0812345678";
                }

                else
                {
                    var service = new SelfTestingService();
                    ret = service.selfTestingService.TestEmailSmsConnection(email, sms);

                    if (ret == "")
                    {
                        rWsToEmailConnection.InnerHtml = "<span class=\"txt-green\">Passed</span>";
                    }
                    else
                    {
                        rWsToEmailConnection.InnerHtml = "<span class=\"txt-red\">Failed</span>" + ret;
                    }
                }
            }
            catch (Exception ex)
            {
                rWsToEmailConnection.InnerHtml = "Internal error while checking Email & SMS Server Connection. " + ex.Message;
            }

            #endregion
        }