public static BaseResponse UpdateCustomer(returntype sfgReturn)
        {
            string className = "SFGWrapper.CustomerUpdateTranslators";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.CustomerUpdate);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }

            UpdateMemberResponse updateMemberResponse = new UpdateMemberResponse();
            updateMemberResponse.MemberUpdated = (sfgReturn.response.CUSTOMER_UPDATED != "N");
            baseResponse.TypedResponse = updateMemberResponse;

            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }    
Esempio n. 2
0
        public BaseResponse Ping()
        {
            methodName = "Ping";
            
            try
            {
                PingRequest request = new PingRequest();
                baseResponse = Heartbeat.Ping(request);
            }
            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);

                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }
        private static BaseResponse GetResponse(Methods methodCalled, returntype sfgReturn)
        {
            string className = "SFGWrapper.HeartbeatTranslators";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.Heartbeat);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }

            switch (methodCalled)
            {
                case Methods.PING:
                    PingResponse heartbeatServiceResponse = new PingResponse();
                    heartbeatServiceResponse.Success = sfgReturn.success;
                    baseResponse.TypedResponse = heartbeatServiceResponse;
                    break;
            }
            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }
        public static BaseResponse GetMemberByMemberId(returntype sfgReturn)
        {
            string className = "SFGWrapper.GateKeeperTranslators.GetMemberByMemberId()";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.Gatekeeper);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }

            GetMemberResponse getMemberResponse = new GetMemberResponse();
            getMemberResponse.Authenticated = (sfgReturn.response.AUTH == "Y");
            getMemberResponse.MemberFound = (sfgReturn.response.CUST_FOUND == "Y");
            if (getMemberResponse.MemberFound)
            {
                //    baseResponse.Messages.Add(new Message("MemberNotFoundException"));
                getMemberResponse.WebAccountFound = (sfgReturn.response.USER_FOUND == "Y");
                getMemberResponse.ShipToAddress = GetAddress(sfgReturn.response.SHIP_TO);
                getMemberResponse.SubscriptionValidationData = GetSubscriptionValidation(sfgReturn.response);
                getMemberResponse.MemberData = GetMember(sfgReturn.response.CUSTOMER_INFO);
                getMemberResponse.MemberData.UserName = sfgReturn.response.USERID;
                foreach (Subscription sub in GetSubscriptions(sfgReturn.response.ORDER_HISTORY))
                {
                    getMemberResponse.MemberData.Subscriptions.Add(sub);
                }
                foreach (RenewalOffer item in GetRenewalOffers(sfgReturn.response.SUB_OFFERS))
                {
                    getMemberResponse.RenewalOffers.Add(item);
                }
            }
            baseResponse.TypedResponse = getMemberResponse;

            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }
        public static BaseResponse CreateSubscription(returntype sfgReturn)
        {
            string className = "SubOrderInsertTranslators.CreateSubscription";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.SubOrderInsert);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }
            SubscriptionServiceResponse createSubscriptionResponse = new SubscriptionServiceResponse();
            foreach (var item in sfgReturn.response.C_EMAIL_RESULTS)
            {
                createSubscriptionResponse.MemberEmailResults.Add(GetEmailResultType(item));
            }
            foreach (var item in sfgReturn.response.C_OPTIN_RESULTS)
            {
                createSubscriptionResponse.MemberOptinResults.Add(GetOptionResults(item));
            }
            createSubscriptionResponse.MemberId = sfgReturn.response.CUSTOMER_NUMBER;
            createSubscriptionResponse.MemberUpdated = sfgReturn.response.CUSTOMER_UPDATED;
            foreach (var item in sfgReturn.response.G_EMAIL_RESULTS)
            {
                createSubscriptionResponse.GifteeEmailResults.Add(GetEmailResultType(item));
            }
            foreach (var item in sfgReturn.response.G_OPTIN_RESULTS)
            {
                createSubscriptionResponse.GifteeOptinResults.Add(GetOptionResults(item));
            }
            createSubscriptionResponse.OrderAdded = sfgReturn.response.ORDER_ADDED == "Y";
            baseResponse.TypedResponse = createSubscriptionResponse;

            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }
        public static BaseResponse GetResponse(UserMaintenance.Methods methodCalled, returntype sfgReturn)
        {
            string className = "SFGWrapper.UserMaintTranslators";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.UserMaint);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }

            switch (methodCalled)
            {
                case UserMaintenance.Methods.CREATELOGIN:
                    CreateLoginResponse createLoginResponse = new CreateLoginResponse();
                    createLoginResponse.UpdateSucceeded = sfgReturn.response.UPDATE_SUCCEEDED == "Y";
                    baseResponse.TypedResponse = createLoginResponse;
                    break;
                case UserMaintenance.Methods.UPDATEPASSWORD:
                    UpdatePasswordResponse updatePasswordResponse = new UpdatePasswordResponse();
                    updatePasswordResponse.UpdateSucceeded = sfgReturn.response.UPDATE_SUCCEEDED == "Y";
                    baseResponse.TypedResponse = updatePasswordResponse;
                    break;
                case UserMaintenance.Methods.UPDATEUSERNAME:
                    UpdateUsernameResponse updateUserName = new UpdateUsernameResponse();
                    updateUserName.UpdateSucceeded = sfgReturn.response.UPDATE_SUCCEEDED == "Y";
                    baseResponse.TypedResponse = updateUserName;
                    break;
            }
            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }
Esempio n. 7
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;
        }
        public static BaseResponse GetResponse(returntype sfgReturn)
        {
            string className = "SFGWrapper.CreditCardTranslators";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.CreditCard);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }

            CreditCardServiceResponse chargeCardResponse = new CreditCardServiceResponse();
            chargeCardResponse.AuthorizationCode = sfgReturn.response.CC_AUTH_CODE;
            chargeCardResponse.ResponseCode = sfgReturn.response.CC_RESPONSE_CODE;
            chargeCardResponse.VerifoneRoutingId = sfgReturn.response.CC_ROUTE_NO;
            chargeCardResponse.TransactionSucceeded = sfgReturn.response.CC_TRANS_SUCCEEDED == "Y";
            chargeCardResponse.MemberId = sfgReturn.response.CUSTOMER_NUMBER;
            chargeCardResponse.MemberUpdated = sfgReturn.response.CUSTOMER_UPDATED == "Y";
            foreach (var item in sfgReturn.response.EMAIL_RESULTS)
            {
                chargeCardResponse.EmailResults.Add(GetEmailResults(item));
            }
            foreach (var item in sfgReturn.response.OPTIN_RESULTS)
            {
                chargeCardResponse.OptinResults.Add(GetOptinResults(item));
            }
            baseResponse.TypedResponse = chargeCardResponse;

            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;
            return baseResponse;
        }
Esempio n. 9
0
        public static BaseResponse GetMemberByMemberId(GetMemberByMemberIdRequest ahRequest)
        {
            string className = "SFGWrapper.Gatekeeper.GetMemberByMemberId";
            BaseResponse baseResponse = new BaseResponse();
            try
            {
                using (GateKeeperService svc = new GateKeeperService())
                {
                    svc.Timeout = 20000;
                    System.Net.ServicePointManager.Expect100Continue = false;
                    svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword);
                    argtype sfgRequest = GateKeeperTranslators.TranslateToGetMemberByMemberIdRequest(ahRequest);
                    baseResponse = GateKeeperTranslators.GetMemberByMemberId(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(className,
                    string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
            return baseResponse;
        }
 public static BaseResponse GetResponse(CreditCardServiceRequest ahRequest)
 {
     string className = "SFGWrapper.CreditCardProcessing";
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         using (CCProcessorService svc = new CCProcessorService())
         {
             svc.Timeout = 20000;
             svc.Credentials = new System.Net.NetworkCredential(ahRequest.ServiceUsername, ahRequest.ServicePassword);
             argtype sfgRequest = CreditCardTranslators.TranslateToSfgRequest(ahRequest);
             baseResponse = CreditCardTranslators.GetResponse(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}()", new object[] { className }),
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }
        public static BaseResponse GetOffer(returntype sfgReturn)
        {
            string className = "SFGWrapper.GateKeeperTranslators.GetOffer()";
            BaseResponse baseResponse = new BaseResponse();
            foreach (var item in sfgReturn.error)
            {
                Message ahError = new Message(item.errno, MessageSources.Gatekeeper);
                foreach (string message in item.errmsg)
                {
                    ahError.SfgMessages.Add(message);
                }
                baseResponse.Messages.Add(ahError);
            }
            GetMemberResponse getOfferResponse = new GetMemberResponse();            
            foreach (RenewalOffer item in GetRenewalOffers(sfgReturn.response.SUB_OFFERS))
            {
                getOfferResponse.RenewalOffers.Add(item);
            }
            baseResponse.TypedResponse = getOfferResponse;
            baseResponse.TypedResponse.Success = sfgReturn.success;
            baseResponse.TypedResponse.Info = Utilities.GetInfo(sfgReturn.response.INFO);
            baseResponse.TypedResponse.MemoryUsed = sfgReturn.response.MEMORY_USED;
            baseResponse.TypedResponse.Protocol = sfgReturn.response.PROTOCOL;
            baseResponse.TypedResponse.RoundtripTime = sfgReturn.response.ROUNDTRIP_TIME;
            baseResponse.TypedResponse.Server = sfgReturn.response.SERVER;
            baseResponse.TypedResponse.TimeElapsed = sfgReturn.response.TIME_ELAPSED;
            baseResponse.TypedResponse.Version = sfgReturn.response.VERSION;

            return baseResponse;
        }
Esempio n. 12
0
        /// <summary>
        /// Loads the messaging XML file into a generic list of messages.  This is accessed from the Message 
        /// class constructor to translate messages from SFG messages description to AH specific error messages.  
        /// </summary>
        /// <returns>List of Message objects.</returns>
        private static List<Message> LoadPredefinedMessages()
        {
            List<Message> rtMessageList = new List<Message>();
            MessageSources messageSource = MessageSources.Unspecified;
            String SfgCode = String.Empty;
            String SfgName = String.Empty;
            String AhCode = String.Empty;
            String AhName = String.Empty;
            String AhMessage = String.Empty;

            XmlTextReader rdr = new XmlTextReader(ConfigurationManager.AppSettings["messagelist-filename"]);
            string currentService = string.Empty;

            while (rdr.Read())
            {
                if (rdr.NodeType == XmlNodeType.Element)
                {
                    switch (rdr.Name)
                    {
                        case "service":
                            {
                                while (rdr.MoveToNextAttribute())
                                    switch (rdr.Value)
                                    {
                                        case "ahmessages":
                                            messageSource = MessageSources.AndrewHarper;
                                            break;
                                        case "common":
                                            messageSource = MessageSources.SfgCommon;
                                            break;
                                        case "ccproc":
                                            messageSource = MessageSources.CreditCard;
                                            break;
                                        case "customerupdate":
                                            messageSource = MessageSources.CustomerUpdate;
                                            break;
                                        case "gatekeeper":
                                            messageSource = MessageSources.Gatekeeper;
                                            break;
                                        case "suborder":
                                            messageSource = MessageSources.SubOrderInsert;
                                            break;
                                        case "usermaintenance":
                                            messageSource = MessageSources.UserMaint;
                                            break;
                                        default:
                                            break;
                                    }
                                break;
                            }
                        case "message":
                            {
                                while (rdr.MoveToNextAttribute())
                                    switch (rdr.Name)
                                    {
                                        case "sfgcode":
                                            SfgCode = rdr.GetAttribute(rdr.Name);
                                            break;
                                        case "sfgname":
                                            SfgName = rdr.GetAttribute(rdr.Name);
                                            break;
                                        case "sfgmessage":
                                            break;
                                        case "ahcode":
                                            AhCode = rdr.GetAttribute(rdr.Name);
                                            break;
                                        case "ahname":
                                            AhName = rdr.GetAttribute(rdr.Name);
                                            break;
                                        case "ahmessage":
                                            AhMessage = rdr.GetAttribute(rdr.Name);
                                            break;
                                        default:
                                            break;
                                    }
                                Message msg = new Message();
                                msg.MessageSource = messageSource;
                                msg.SfgCode = SfgCode;
                                msg.SfgName = SfgName;
                                msg.AhCode = Convert.ToInt16(AhCode);
                                msg.AhName = AhName;
                                msg.AhMessage = AhMessage;
                                rtMessageList.Add(msg);
                                break;
                            }
                        default:
                            break;
                    }
                }
            }
            rdr.Close();
            return rtMessageList;
        }
Esempio n. 13
0
        /// <summary>
        /// Used for all SFG messages.
        /// </summary>
        /// <param name="sfgCode">SFG generated message code.  Ignored if messageSource is AndrewHarper</param>
        /// <param name="messageSource">Enumeration of available message sources.</param>
        public Message(string sfgCode, MessageSources messageSource)
        {
            //error numbers < 100 are common messages
            //error numbers >= 100 are service specific messages 
            //error numbers > 9000 are Andrew Harper specific
            try
            {
                SfgCode = sfgCode;

                if (Convert.ToInt16(sfgCode) < 100)
                    messageSource = MessageSources.SfgCommon;
                else
                    MessageSource = messageSource;

                List<Message> predefinedMessageList = new List<Message>();
                Message predefinedMessage = new Message();
                if (predefinedMessage != null)
                {
                    predefinedMessageList = PredefinedMessages.FindAll(delegate(Message msg) { return msg.SfgCode == sfgCode; });
                    predefinedMessage = predefinedMessageList.Find(delegate(Message msg) { return msg.MessageSource == messageSource; });
                    if (predefinedMessage != null)
                    {
                        SfgName = predefinedMessage.SfgName;
                        AhCode = predefinedMessage.AhCode;
                        AhName = predefinedMessage.AhName;
                        AhMessage = predefinedMessage.AhMessage;
                        if (MessageSource == MessageSources.AndrewHarper)
                            SfgCode = "";
                    }
                    else
                    {
                        SfgName = "";
                        AhCode = 0;
                        AhName = "";
                        AhMessage = "Undefined message.";
                    }
                }
            }
            catch
            {
                SfgName = "";
                AhCode = 0;
                AhName = "";
                AhMessage = "Undefined message.";
            }
        }