Example #1
0
        private static BaseResponse GetResponse(Methods methodCalled, PingRequest ahRequest)
        {
            string       className    = "SFGWrapper.Heartbeat";
            BaseResponse baseResponse = new BaseResponse();

            try
            {
                using (HeartbeatService svc = new HeartbeatService())
                {
                    svc.Timeout     = 20000;
                    svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword);
                    argtype sfgRequest = HeartbeatTranslators.TranslateToSfgRequest(ahRequest);
                    switch (methodCalled)
                    {
                    case Methods.PING:
                        baseResponse = HeartbeatTranslators.Ping(svc.process_wsdl(sfgRequest));
                        break;
                    }
                }
                if (baseResponse == null)
                {
                    baseResponse = new BaseResponse();
                    FatalErrorResponse fatalError = new FatalErrorResponse();
                    baseResponse.TypedResponse = fatalError;
                    baseResponse.Messages.Add(new Message("SFGFatalError"));
                }
            }
            catch (Exception ex)
            {
                baseResponse = new BaseResponse();
                FatalErrorResponse fatalError = new FatalErrorResponse();
                baseResponse.TypedResponse = fatalError;
                Message error = new Message("UnknownException");
                baseResponse.DebugStringLog.Add(ex.TargetSite.Name);
                baseResponse.DebugStringLog.Add(ex.Message);
                baseResponse.DebugStringLog.Add(ex.StackTrace);
                baseResponse.Messages.Add(error);
                EventLogger.LogError(string.Format("{0}.{1}()", new object[] { className, methodCalled.ToString() }),
                                     string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
            return(baseResponse);
        }