示例#1
0
        public BaseResponse UpdatePassword(string userName, string newPassword, bool debug)
        {
            methodName = "UpdatePassword";
            
            try
            {
                #region validate input
                // All params are required.
                if ((userName.Trim() == "") || (newPassword.Trim() == ""))
                {
                    baseResponse.Messages.Add(new Message("ImproperValidationCriteriaException"));
                    return baseResponse;
                }
                #endregion

                UpdatePasswordRequest request = new UpdatePasswordRequest(userName, newPassword, debug);
                baseResponse = UserMaintenance.UpdatePassword(request);
                if (baseResponse != null
                    && baseResponse.TypedResponse != null
                    && baseResponse.TypedResponse.GetType().Name == "UpdatePasswordResponse"
                    && (baseResponse.TypedResponse as UpdatePasswordResponse).Success)
                {
                    HarperACL.Authenticator.UpdateAHPassword(userName, newPassword);
                }
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }        
示例#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;
        }
示例#4
0
        public BaseResponse UpdateUsername(string newUserName, string oldUserName, string password, bool debug)
        {
            methodName = "UpdateUsername";
            
            try
            {
                #region validate input
                // All params are required
                if ((newUserName.Trim() == "") || (oldUserName.Trim() == "") || (password.Trim() == ""))
                {
                    baseResponse.Messages.Add(new Message("ImproperValidationCriteriaException"));
                    return baseResponse;
                }
                #endregion

                UpdateUsernameRequest request = new UpdateUsernameRequest(newUserName, oldUserName, password, debug);
                baseResponse = UserMaintenance.UpdateUsername(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }
        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;
        }    
 public BaseResponse UpdateUserName(string newusername, string oldusername, string hashed_password)
 {
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         baseResponse = new MembershipLogic().UpdateUsername(newusername, oldusername, Cryptography.DeHash(hashed_password, true), false);
     }
     catch (Exception ex)
     {
         EventLogger.LogError("SecureServices.UpdateUsername",
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }
        public BaseResponse Ping()
        {
            BaseResponse baseResponse = new BaseResponse();
            try
            {
                baseResponse = new HeartbeatLogic().Ping();                              

            }
            catch (Exception ex)
            {
                EventLogger.LogError("MembershipService.Ping",
                    string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
            return baseResponse;
        }
        public BaseResponse GetMemberByCusId(string hashed_cusid)
        {
            bool debug = false;
            BaseResponse baseResponse = new BaseResponse();
            try
            {
                baseResponse = new MembershipLogic().GetMemberById(Cryptography.DeHash(hashed_cusid, true), false);

            }
            catch (Exception ex)
            {
                EventLogger.LogError("MembershipService.GetMemberByCusId",
                    string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
            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;
        }
示例#12
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;
        }
示例#14
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;
 }
示例#16
0
        public BaseResponse CreateSubscription(int subscriptionlength, 
            float amountpaid, string verifoneroutingid, 
            string publicationcode, string keycode, 
            string renewingmemberid, string salutation, string firstname, string middleinitial, string lastname, string suffix,
            string professionaltitle, string email, bool optin, string businessname, string address1, string address2, string address3,
            string city, string state, string postalcode, string country,
            string phone, string fax, string altcity, 
            bool giftflag, 
            string renewinggiftmemberid, string giftsalutation, string giftfirstname, string giftmiddleinitial, string giftlastname, string giftsuffix,
            string giftprofessionaltitle, string giftemail, bool giftoptin, string giftbusinessname, string giftaddress1, string giftaddress2, string giftaddress3,
            string giftcity, string giftstate, string giftpostalcode, string giftcountry,
            string giftphone, string giftfax, string giftaltcity)
        {
            try
            {
                #region set member data
                Member memberData = new Member();
                memberData.MemberId = renewingmemberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.MiddleInitial = middleinitial;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                memberData.Address.Fax = fax;
                memberData.Address.AltCity = altcity;

                Member giftData = new Member();
                //giftData.MemberId = renewinggiftmemberid;
                //giftData.Salutation = salutation;
                //giftData.FirstName = firstname;
                //giftData.MiddleInitial = middleinitial;
                //giftData.LastName = lastname;
                //giftData.Suffix = suffix;
                //giftData.ProfessionalTitle = professionaltitle;
                //giftData.OptIn = optin;
                //giftData.Email = email;

                //giftData.Address = new Address();
                //giftData.Address.BusinessName = businessname;
                //giftData.Address.Address1 = address1;
                //giftData.Address.Address2 = address2;
                //giftData.Address.Address3 = address3;
                //giftData.Address.City = city;
                //giftData.Address.State = state;
                //giftData.Address.PostalCode = postalcode;
                //giftData.Address.Country = country;
                //giftData.Address.Phone = phone;
                //giftData.Address.Fax = fax;
                //giftData.Address.AltCity = altcity;
                #endregion

                #region set cc data
                CreditCard creditCardData = new CreditCard();
                creditCardData.Price = amountpaid;
                creditCardData.AmountPaid = amountpaid;
                creditCardData.VerifoneRoutingId = verifoneroutingid;
                #endregion

                SubscriptionServiceRequest request = new SubscriptionServiceRequest(memberData, giftData, creditCardData, 
                        publicationcode, keycode, giftflag, subscriptionlength);
                baseResponse = SubOrderInsert.CreateSubscription(request);       
            }
            catch (Exception ex)
            {
                EventLogger.LogError("SubscriptionLogic.CreateSubscription", ex.Message);
            }
            return baseResponse;
        }
示例#17
0
        public BaseResponse RedeemReferralSubscription(int referralid, string firstname, string lastname,
            string emailaddress, string countrycode, string address1, string address2,
            string city, string region, string postal, bool optin, string username, string password)
        {
            List<Message> errors = new List<Message>();
            string errortext = string.Empty;
            try
            {
                HarperLINQ.Referral referral;

                #region input validation
                using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    referral = context.Referrals.SingleOrDefault(r => r.id == referralid);
                }
                if (referral == null)
                {
                    errortext = string.Format(BusinessLogicStrings.invalidReferralIdError, referralid);
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null));
                }
                else if (referral.dateredeemed != null || referral.friendid > 0)
                {
                    errortext = string.Format(BusinessLogicStrings.RedeemedReferralError, referralid);
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null));
                }
                else if (referral.dateexpires <= DateTime.Now)
                {
                    errortext = string.Format(BusinessLogicStrings.expiredReferralError, referralid);
                    errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null));
                }
                #endregion
                
                else
                {
                    #region sub order insert
                    Member giftData = new Member();
                    giftData.FirstName = firstname;
                    giftData.LastName = lastname;
                    giftData.OptIn = optin;
                    giftData.Email = emailaddress;

                    giftData.Address = new Address();
                    giftData.Address.Address1 = address1;
                    giftData.Address.Address2 = address2;
                    giftData.Address.City = city;
                    giftData.Address.State = region;
                    giftData.Address.PostalCode = postal;
                    giftData.Address.Country = countrycode;

                    SubscriptionServiceRequest request = new SubscriptionServiceRequest(referral, giftData);
                    baseResponse = SubOrderInsert.RedeemReferralSubscription(request);
                    foreach (Message err in baseResponse.Messages)
                    {
                        errors.Add(err);
                    }
                    #endregion

                    MembershipLogic memberlogic = new MembershipLogic();
                    BaseResponse memberResponse = null;
                    if (errors.Count <= 0)
                    {
                        memberResponse = memberlogic.GetMemberByUserName(emailaddress);
                    }

                    if (!(errors.Count > 0 
                        || memberResponse == null
                        || memberResponse.TypedResponse == null
                        || memberResponse.TypedResponse.Success == false))
                    {
                        using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                        {
                            GetMemberResponse getMemberResponse = memberResponse.TypedResponse as GetMemberResponse;
                            if (getMemberResponse.MemberFound && getMemberResponse.MemberData != null)
                            {
                                string newMemberId = getMemberResponse.MemberData.MemberId;

                                #region create the user at AH
                                object[] create_response = tbl_Customer.CreateCustomer(address1, address2, "", city, region, 
                                    countrycode, postal, "Z1", password, "PERSONAL", "", 
                                    firstname, "", lastname, "", emailaddress, username, newMemberId, referral.pubcode, DateTime.Now.AddMonths(referral.subscriptionlength).ToShortDateString(), DateTime.Now.ToShortDateString(), username, "");
                                tbl_Customer customer = (tbl_Customer)create_response[1];
                                #endregion

                                #region referral data at AH
                                referral = context.Referrals.SingleOrDefault(r => r.id == referralid);
                                referral.dateredeemed = DateTime.Now;
                                referral.friendid = customer.cusID;
                                context.SubmitChanges();
                                #endregion

                                #region send email
                                Mailer mailer = new Mailer();

                                mailer.SendEmail(
                                    ConfigurationManager.AppSettings["mailserviceuser"], 
                                    ConfigurationManager.AppSettings["mailservicepwd"],
                                    "Welcome to the Andrew Harper Community!", 
                                    ConfigurationManager.AppSettings["referemailfrom"],
                                    referral.friendemail,
                                    string.Empty, 
                                    string.Empty,
                                    referral.GetReferralUserCreatedEmailBody(), 
                                    true, 
                                    ConfigurationManager.AppSettings["smtpserver"]);
                                #endregion
                            }
                        }
                    }
                    else
                    {
                        errortext = string.Format(BusinessLogicStrings.RetrieveMemeberError, new object[] { referralid, emailaddress });
                        errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null));
                    }
                }

                baseResponse.TypedResponse = new AHResponse();
                if (errors.Count == 0)
                {
                    baseResponse.TypedResponse.Success = true;
                }
                else
                {
                    baseResponse.TypedResponse.Success = false;
                }
            }
            
            catch (Exception ex)
            {
                baseResponse.TypedResponse.Success = false;
                errortext = string.Format(BusinessLogicStrings.UnknownReferralError, ex.Message);
                errors.Add(new Message(MessageSources.AndrewHarper, 0, "RedeemReferralException", errortext, "", "", null));
            }
            foreach (Message error in errors)
            {
                if (baseResponse == null)
                {
                    baseResponse = new BaseResponse();
                }
                baseResponse.Messages.Add(error);

                StringBuilder error_text = new StringBuilder();
                error_text.AppendLine("REFERRAL ERROR LOGGED");
                error_text.AppendLine(string.Format("REFERRALID {0}", referralid));
                baseResponse.Messages.Add(error);
                error_text.AppendLine(string.Format("ERROR: ", new object[] { }));
                EventLogger.LogError("SubscriptionLogic.RedeemReferralSubscription", error_text.ToString(), true);
            }
            return baseResponse;
        }        
示例#18
0
        public BaseResponse CreateLogin(string memberId, string userName, string initialPassword, string postalCode)
        {
            methodName = "CreateLogin";
            
            List<Message> errors = new List<Message>();
            string errortext = string.Empty;
            try
            {
                #region validate input
                // All params are required 
                if ((memberId.Trim() == "") 
                    || (userName.Trim() == "") 
                    || (initialPassword.Trim() == "") 
                    || (postalCode.Trim() == ""))
                {
                    errors.Add(new Message("ImproperValidationCriteriaException"));
                }
                using (HarperLINQ.AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    string exception = string.Empty;
                    bool exists = false;    
                    int existing = (from a in context.tbl_Customers
                                    join b in context.SFG_CustomerNumbers
                                    on a.cusID equals b.cusID
                                    where a.cusUserName == userName.Trim()
                                    && b.SFGCustNum != memberId.Trim()
                                    select a).Count();
                    if (existing > 0)
                    {
                        exists = true;
                        exception = "User name is in use.";
                    }
                    existing = 0;
                    existing = (from a in context.tbl_Customers
                                join b in context.SFG_CustomerNumbers
                                on a.cusID equals b.cusID
                                where a.cusDisplayName == userName.Trim()
                                && b.SFGCustNum != memberId.Trim()
                                select a).Count();
                    if (existing > 0)
                    {
                        exists = true;
                        exception += "  Screen name is in use.";
                    }
                    existing = 0;
                    existing = (from a in context.tbl_Customers
                                join b in context.SFG_CustomerNumbers
                                on a.cusID equals b.cusID
                                where a.cusEmail == userName.Trim()
                                && b.SFGCustNum != memberId.Trim()
                                select a).Count();
                    if (existing > 0)
                    {
                        exists = true;
                        exception += "Email address is in use.";
                    }
                    if (exists)
                    {
                        throw new Exception(exception);
                    }
                }
                #endregion

                CreateLoginRequest request = new CreateLoginRequest(memberId.Trim(), userName.Trim(), initialPassword.Trim(), postalCode.Trim(), false);
                baseResponse = UserMaintenance.CreateLogin(request);
                if (baseResponse != null
                    && baseResponse.TypedResponse != null
                    && baseResponse.TypedResponse.GetType().Name == "CreateLoginResponse"
                    && (baseResponse.TypedResponse as CreateLoginResponse).Success)
                {
                    HarperACL.Authenticator auth = new Authenticator(userName.Trim(), Cryptography.Hash(initialPassword.Trim(),true), true, true, false, memberId.Trim());
                    if (!auth.CreateUsername(userName.Trim(), initialPassword.Trim(), memberId.Trim()))
                    {
                        throw new Exception("User created at SFG, could not create user at AH");
                    }
                }
            }
            catch (Exception ex)
            {
                errortext = string.Format("Error creating login. Memberid: {0} Username: {1} Password: {2} PostalCode: {3} \r\nException message: {4}\r\nException stacktrace: {5}", new object[] { memberId, userName, initialPassword, postalCode, ex.Message, ex.StackTrace });
                errors.Add(new Message(MessageSources.AndrewHarper, 0, "CreateLoginException", errortext, "", "", null));
            }
            foreach (Message error in errors)
            {
                if (baseResponse == null)
                {
                    baseResponse = new BaseResponse();
                }
                baseResponse.Messages.Add(error);

                StringBuilder error_text = new StringBuilder();
                error_text.AppendLine("CREATELOGIN ERROR LOGGED");
                error_text.AppendLine(string.Format("MEMBERID {0}", memberId));
                baseResponse.Messages.Add(error);
                error_text.AppendLine(string.Format("ERROR: {0}", new object[] { error.AhMessage}));
                EventLogger.LogError("MembershipLogic.CreateLogin", error_text.ToString(), true);                
            }
            
            return baseResponse;
        }
示例#19
0
        public BaseResponse UpdateMember(string memberid,
            string salutation, string firstname, string lastname, string suffix,
            string professionaltitle, string email, bool optin, string businessname, string address1, string address2, string address3,
            string city, string state, string postalcode, string country,
            string phone, string screenname,
            bool debug)
        {
            methodName = "UpdateMember";
            
            try
            {
                #region  set member data
                Member memberData = new Member();
                memberData.MemberId = memberid;
                memberData.Salutation = salutation;
                memberData.FirstName = firstname;
                memberData.LastName = lastname;
                memberData.Suffix = suffix;
                memberData.ProfessionalTitle = professionaltitle;
                memberData.OptIn = optin;
                memberData.Email = email;

                memberData.Address = new Address();
                memberData.Address.BusinessName = businessname;
                memberData.Address.Address1 = address1;
                memberData.Address.Address2 = address2;
                memberData.Address.Address3 = address3;
                memberData.Address.City = city;
                memberData.Address.State = state;
                memberData.Address.PostalCode = postalcode;
                memberData.Address.Country = country;
                memberData.Address.Phone = phone;
                #endregion

                //TODO :  Error handling for dupe email or screenname

                #region update ah db here
                using (HarperACL.ACLDataDataContext context = new ACLDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {

                    HarperACL.Customer customer = (from a in context.Customers
                                                   join b in context.SFG_CustomerNumbers
                                                   on a.cusID equals b.cusID
                                                   where b.SFGCustNum == memberid
                                                   select a).Single();

                    int existing = (from a in context.Customers
                                    where
                                    (a.cusEmail == email || a.cusDisplayName == screenname)
                                    && a.cusID != customer.cusID
                                    select a).Count();
                    if (existing > 0)
                    {
                        throw new Exception("Unable to update member data, screen name or email already in use.");
                    }
                    customer.cusPrefix = salutation;
                    customer.cusFirstName = firstname;
                    customer.cusLastName = lastname;
                    customer.cusSuffix = suffix;
                    customer.cusTitle = professionaltitle;
                    customer.cusEmail = email;
                    customer.cusCompany = businessname;
                    customer.cusPhone1 = phone;
                    customer.cusDateUpdated = DateTime.Now;
                    customer.cusDisplayName = screenname;

                    HarperACL.AddressCustomer address = (from a in context.AddressCustomers
                                                         where a.addID == customer.addID
                                                         select a).Single();
                    address.addAddress1 = address1;
                    address.addAddress2 = address2;
                    address.addAddress3 = address3;
                    address.addCity = city;
                    address.addCountry = country;
                    address.addDateUpdated = DateTime.Now;
                    address.addPostalCode = postalcode;
                    address.addRegion = state;

                    context.SubmitChanges();
                }
                #endregion

                //update at SFG
                UpdateMemberRequest request = new UpdateMemberRequest(memberData, debug);
                baseResponse = CustomerUpdate.UpdateMember(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }
示例#20
0
        public BaseResponse GetMemberById(string memberId, bool issfgid)
        {
            methodName = "GetMemberByMemberId";
            
            if (!issfgid)
            {
                try
                {
                    using (SupportDataDataContext context = new SupportDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                    {
                        memberId = (from a in context.SFG_CustomerNumbers
                                    where a.cusID.ToString() == memberId
                                    select a.SFGCustNum).Single();
                    }
                }
                catch
                {
                    baseResponse.Messages.Add(new Message(MessageSources.AndrewHarper, 0, "ImproperValidationCriteriaException", "Unable to get SFG id for cusid", "", "", null));
                    baseResponse.TypedResponse = new GetMemberResponse();
                    baseResponse.TypedResponse.Success = false;
                    return baseResponse;
                }
            }            
            try
            {
                
                #region validate input
                // All params are required 
                if (memberId.Trim() == "")
                {
                    baseResponse.Messages.Add(new Message("ImproperValidationCriteriaException"));
                    baseResponse.TypedResponse = new GetMemberResponse();
                    baseResponse.TypedResponse.Success = false;
                    return baseResponse;
                }
                #endregion

                GetMemberByMemberIdRequest request = new GetMemberByMemberIdRequest(memberId.Trim(), false);
                baseResponse = Gatekeeper.GetMemberByMemberId(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            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;
        }
 public BaseResponse UpdateMember(string hashed_memberid,
     string salutation, string firstname, string lastname, string suffix,
     string professionaltitle, string email, bool optin, string businessname, string address1, 
     string address2, string address3,
     string city, string state, string postalcode, string country,
     string phone, string screenname)
 {
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         baseResponse = new MembershipLogic().UpdateMember(Cryptography.DeHash(hashed_memberid, true),
             salutation, firstname, lastname, suffix,
             professionaltitle, email, optin, businessname, address1, address2, address3,
             city, state, postalcode, country,
             phone, screenname,
             false);
     }
     catch (Exception ex)
     {
         EventLogger.LogError("MembershipService.UpdateMember",
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }
 public BaseResponse CreateReferral(string enccusid, string membername, string memeberemail, string keycode, string pubcode, string friendname, string emailaddress, bool ccmember)
 {
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         string cusid = Cryptography.DecryptData(enccusid);
         baseResponse = new MembershipLogic().CreateReferral(cusid, membername, memeberemail, keycode, pubcode, friendname, emailaddress, ccmember);
     }
     catch (Exception ex)
     {
         EventLogger.LogError("MembershipService.CreateReferral",
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;            
 }
        public BaseResponse GetMemberByUserName(string username)
        {
            BaseResponse baseResponse = new BaseResponse();
            try
            {
                baseResponse = new MembershipLogic().GetMemberByUserName(username);                      

            }
            catch (Exception ex)
            {
                EventLogger.LogError("MembershipService.GetMemberByUserName",
                    string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
            return baseResponse;
        }
 public BaseResponse RedeemReferral(string encreferralid, string firstname, string lastname, 
     string emailaddress, string countrycode, string address1, string address2, string city, 
     string region, string postal, bool optin, string username, string encpassword)
 {
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         int referralid = int.Parse(Cryptography.DecryptData(encreferralid));
         string password = Cryptography.DecryptData(encpassword);
         baseResponse = new SubscriptionLogic().RedeemReferralSubscription(referralid, firstname, lastname, emailaddress, countrycode, address1, address2, city, region, postal, optin, username, password);
     }
     catch (Exception ex)
     {
         EventLogger.LogError("MembershipService.RedeemReferral",
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }
示例#26
0
        public BaseResponse GetMemberByUserName(string userName)
        {
            methodName = "GetMemberByUserName";
            
            try
            {
                #region validate input
                // All params are required 
                if (userName.Trim() == "")
                {
                    baseResponse.Messages.Add(new Message("ImproperValidationCriteriaException"));
                    return baseResponse;
                }
                #endregion

                GetMemberByUserNameRequest request = new GetMemberByUserNameRequest(userName.Trim(), false);
                baseResponse = Gatekeeper.GetMemberByUserName(request);
            }
            catch (Exception ex)
            {
                LogMethodError(methodName, ex);
            }
            
            return baseResponse;
        }   
 public BaseResponse StoreCompHRData()
 {
     throw new NotImplementedException();            
     BaseResponse baseResponse = new BaseResponse();
     try
     {
         //baseResponse = new MembershipLogic().UpdateMember(memberid,
         //    salutation, firstname, middleinitial, lastname, suffix,
         //    professionaltitle, email, optin, businessname, address1, address2, address3,
         //    city, state, postalcode, country,
         //    phone, fax, altcity,
         //    debug);
     }
     catch (Exception ex)
     {
         EventLogger.LogError("MembershipService.StoreCompHRData",
             string.Format("Message: {0} \r\nStackTrace: {1}", ex.Message, ex.StackTrace));
     }
     return baseResponse;
 }