Пример #1
0
        private static BaseResponse GetResponse(Methods methodCalled, UserMaintenanceServiceRequest ahRequest)
        {
            string       className    = "SFGWrapper.UserMaintenance";
            BaseResponse baseResponse = new BaseResponse();

            try
            {
                using (UserMaintService svc = new UserMaintService())
                {
                    svc.Timeout     = 20000;
                    svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword);
                    argtype sfgRequest = UserMaintTranslators.TranslateToSfgRequest(methodCalled, ahRequest);
                    baseResponse = UserMaintTranslators.GetResponse(methodCalled, svc.process_wsdl(sfgRequest));
                }
                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);
        }
        public static argtype TranslateToSfgRequest(UserMaintenance.Methods methodCalled, UserMaintenanceServiceRequest ahRequest)
        {
            EventLogger.LogEvent("ENTERING -> SFGWrapper.UserMaintTranslators.TranslateToSfgRequest()");
            argtype sfgRequest = new argtype();

            #region common readonly properties
            sfgRequest.org             = ahRequest.Org;
            sfgRequest.test_mode       = ahRequest.TestMode ? "Y" : "N";
            sfgRequest.app_version     = ahRequest.AppVersion;
            sfgRequest.program_type_id = ahRequest.ProgramTypeId;
            #endregion

            switch (methodCalled)
            {
            case UserMaintenance.Methods.CREATELOGIN:
                sfgRequest.customer_number = ahRequest.MemberId;
                sfgRequest.new_user        = ahRequest.NewUser ? "Y" : "N";
                sfgRequest.userid          = ahRequest.UserName;
                sfgRequest.pw  = ahRequest.Password;
                sfgRequest.zip = ahRequest.PostalCode;
                break;

            case UserMaintenance.Methods.UPDATEPASSWORD:
                sfgRequest.validation_userid = ahRequest.ValidationUserName;
                sfgRequest.userid            = ahRequest.UserName;
                sfgRequest.pw = ahRequest.Password;
                break;

            case UserMaintenance.Methods.UPDATEUSERNAME:
                sfgRequest.userid = ahRequest.UserName;
                if (string.IsNullOrEmpty(ahRequest.ValidationUserName))
                {
                    sfgRequest.zip             = ahRequest.PostalCode;
                    sfgRequest.customer_number = ahRequest.MemberId;
                }
                else
                {
                    sfgRequest.validation_userid = ahRequest.ValidationUserName;
                }
                sfgRequest.pw = ahRequest.Password;
                break;
            }
            EventLogger.LogEvent("LEAVING -> SFGWrapper.UserMaintTranslators.TranslateToSfgRequest()");
            return(sfgRequest);
        }