Exemplo n.º 1
0
 public bool SendEmail(string username, string password, string subject, string fromaddress, string toaddress, string cc, string bcc, string body, bool isbodyhtml, string smtp)
 {
     if (username == ConfigurationManager.AppSettings["mailserviceuser"]
         && password == ConfigurationManager.AppSettings["mailservicepwd"])
     {
  
         HarperLINQ.SimpleMail mail = new SimpleMail();
         try
         {
             mail.bccemail = bcc;
             mail.body = body;
             mail.ccemail = cc;
             mail.datecreated = DateTime.Now;
             mail.fromemail = fromaddress;
             mail.isHtml = isbodyhtml;
             mail.ishtml = isbodyhtml;
             mail.smtpAddress = smtp;
             mail.subject = subject;
             mail.toemail = toaddress;
             using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
             {
                 context.SimpleMails.InsertOnSubmit(mail);
                 context.SubmitChanges();
             }
             return true;
         }
         catch
         {
             return false;
         }
     }
     else { return false; }
 }
Exemplo n.º 2
0
 public void Save()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         context.SimpleMails.InsertOnSubmit(this);
         context.SubmitChanges();
     }
 }
Exemplo n.º 3
0
 public void Save()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         if (this.addID > 0)
         {
             tbl_AddressCustomer address = (from a in context.tbl_AddressCustomers
                                      where a.addID == this.addID
                                      select a).SingleOrDefault();
             GetData(address);
             context.SubmitChanges();
         }
         else
         {
             context.tbl_AddressCustomers.InsertOnSubmit(this);
             context.SubmitChanges();
         }
     }
 }
Exemplo n.º 4
0
 public void Save()
 {
     try
     {
         using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         {
             context.ReferralOffers.InsertOnSubmit(this);
             context.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         throw new ObjectSaveException(ex.Message);
     }
 }
Exemplo n.º 5
0
 public void Save()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         tbl_NetMembership netmembership = (from a in context.tbl_NetMemberships
                                            where a.cusID == this.cusID
                                            && a.mtyCode == this.mtyCode
                                            select a).SingleOrDefault();
         if (netmembership == null)
         {
             netmembership = new tbl_NetMembership();
             context.tbl_NetMemberships.InsertOnSubmit(netmembership);
         }
         netmembership.cusID = this.cusID;
         netmembership.mtyCode = this.mtyCode;
         netmembership.nmbDateCreated = this.nmbDateCreated;
         netmembership.nmbDateEnd = this.nmbDateEnd;
         netmembership.nmbDateStart = this.nmbDateStart;
         netmembership.nmbRenewalCode = this.nmbRenewalCode;
         context.SubmitChanges();
     }
 }
Exemplo n.º 6
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;
        }        
Exemplo n.º 7
0
 public void Save()
 {
     try
     {
         using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         {
             if (this.id > 0)
             {
                 Referral referral = (from a in context.Referrals
                                          where a.id == this.id
                                          select a).SingleOrDefault();
                 GetData(referral);
             }
             else
             {
                 context.Referrals.InsertOnSubmit(this);
             }
             context.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         throw new ObjectSaveException(ex.Message);
     }
 }
 public void Save()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         tbl_DrupalCartRequest cart = (from a in context.tbl_DrupalCartRequests
                                            where a.id == this.id
                                            select a).SingleOrDefault();
         if (cart == null)
         {
             cart = new tbl_DrupalCartRequest();
             context.tbl_DrupalCartRequests.InsertOnSubmit(cart);
         }
         cart.username = this.username;
         cart.salutation = this.salutation;
         cart.firstname = this.firstname;
         cart.middleinitial = this.middleinitial;
         cart.lastname = this.lastname;
         cart.suffix = this.suffix;
         cart.protitle = this.protitle;
         cart.email = this.email;
         cart.optin = this.optin;
         cart.business = this.business;
         cart.add1 = this.add1;
         cart.add2 = this.add2;
         cart.add3 = this.add3;
         cart.city = this.city;
         cart.state = this.state;
         cart.zip = this.zip;
         cart.country = this.country;
         cart.phone = this.phone;
         cart.fax = this.fax;
         cart.altcity = this.altcity;
         cart.ccnum = this.ccnum;
         cart.ccmonth = this.ccmonth;
         cart.ccyear = this.ccyear;
         cart.amtpaid = this.amtpaid;
         cart.ccname = this.ccname;
         cart.ccadd = this.ccadd;
         cart.cccity = this.cccity;
         cart.ccstate = this.ccstate;
         cart.cczip = this.cczip;
         cart.pubcode = this.pubcode;
         cart.keycode = this.keycode;
         cart.sublen = this.sublen;
         cart.source = this.source;
         cart.customertype = this.customertype;
         cart.expiredate = this.expiredate;
         cart.startdate = this.startdate;
         cart.newsletters = this.newsletters;
         cart.errors = this.errors;
         cart.responsecode = this.responsecode;
         cart.mobilephone = this.mobilephone;
         cart.secondemail = this.secondemail;
         cart.methodofpayment = this.methodofpayment;
         cart.cccountry = this.cccountry;
         cart.ccaddress2 = this.ccaddress2;
         cart.screenname = this.screenname;
         cart.newmemberid = this.newmemberid;
         context.SubmitChanges();
     }
 }
Exemplo n.º 9
0
 private void RecordError(string method, string message1, Exception ex)
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         int col_len = 2500;
         string msg = ex.Message;
         if (msg.Length > col_len)
         {
             msg = msg.Substring(0, col_len);
         }
         string stack_trace = ex.StackTrace;
         if (stack_trace.Length > col_len)
         {
             stack_trace = stack_trace.Substring(0, col_len);
         }
         if (message1.Length > col_len)
         {
             message1 = message1.Substring(0, col_len);
         }
         string message2 = string.Format("Exception Message: {0}", msg);
         string message3 = string.Format("Exception Stack Trace: {0}", stack_trace);
         tbl_AppEventLog ael = new tbl_AppEventLog();
         ael.aelAppName = "CustomerWebService";
         ael.aelSection = method;
         ael.aelSeverity = "ERROR";
         ael.aelEvent = "Unknown Error";
         ael.aelMessage1 = message1.Length > 2500 ? message1.Substring(0, 2499) : message1;
         ael.aelMessage2 = message2.Length > 2500 ? message2.Substring(0,2499) : message2;
         ael.aelMessage3 = message3.Length > 2500 ? message3.Substring(0, 2499) : message3;
         ael.aelDateCreated = DateTime.Now;
         context.tbl_AppEventLogs.InsertOnSubmit(ael);
         context.SubmitChanges();
     }
 }
Exemplo n.º 10
0
 private void RecordLoginAttempt(string enc_username, string enc_password, ResponseObject response, CustomerResponseCode response_code)
 {
     string u = response.ResponseCode == (int)CustomerResponseCode.CANNOT_DECRYPT_INPUT ? string.Empty : Cryptography.Decrypt256FromHEX(enc_username);
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         tbl_AppEventLog ael = new tbl_AppEventLog();
         ael.aelUserName = u;
         ael.aelSection = "Login";
         ael.aelAppName = "CustomerWebService";
         ael.aelSeverity = response.ResponseCode > 0 ? "ERROR" : "INFO";
         ael.aelEvent = response.ResponseCode == (int)CustomerResponseCode.SUCCESS ? "LOGIN_SUCCEEDED" : "LOGIN_FAILED";
         ael.aelMessage1 = string.Format("U:{0} P:{1}", new object[] { enc_username, enc_password });
         ael.aelMessage2 = string.Format(response_code.ToString());
         ael.aelDateCreated = DateTime.Now;
         context.tbl_AppEventLogs.InsertOnSubmit(ael);
         context.SubmitChanges();
     }
 }
Exemplo n.º 11
0
 public void SaveSfgId()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         try
         {
             SFG_CustomerNumber sfg = (from a in context.SFG_CustomerNumbers
                                       where a.cusID == this.cusID
                                       select a).Single();
             sfg.SFGCustNum = this.SfgId.ToString();
             context.SubmitChanges();
         }
         catch { }
     }
 }
Exemplo n.º 12
0
        public void UnDeleteUser()
        {
            using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
            {
                bool exists = false;
                string errormsg = string.Empty;

                #region check email
                int existing = (from a in context.tbl_Customers
                                where a.cusIsDeleted == false
                                && a.cusID != this.cusID
                                && a.cusEmail == this.cusArchiveEmail
                                select a).Count();
                if (existing > 0)
                {
                    exists = true;
                    errormsg = "Email in use.";
                }
                #endregion

                #region check user name
                existing = 0;
                existing = (from a in context.tbl_Customers
                            where a.cusIsDeleted == false
                            && a.cusID != this.cusID
                            && a.cusUserName == this.cusArchiveUsername
                            select a).Count();
                if (existing > 0)
                {
                    exists = true;
                    errormsg += "User Name in use.";
                }
                #endregion

                #region check screen name
                existing = 0;
                existing = (from a in context.tbl_Customers
                            where a.cusIsDeleted == false
                            && a.cusID != this.cusID
                            && a.cusDisplayName == this.cusArchiveDisplayName
                            select a).Count();
                if (existing > 0)
                {
                    exists = true;
                    errormsg += "Screen Name in use.";
                }
                #endregion

                if (exists)
                {
                    throw new Exception(string.Format("Unable to un-delete user, {0}", errormsg));
                }
                else
                {
                    tbl_Customer me = (from a in context.tbl_Customers
                                   where a.cusID == this.cusID
                                   select a).Single();
                    me.cusIsDeleted = false;
                    me.cusEmail = me.cusArchiveEmail;
                    me.cusUserName = me.cusArchiveUsername;
                    me.cusDisplayName = me.cusArchiveDisplayName;
                    me.cusArchiveEmail = string.Empty;
                    me.cusArchiveUsername = string.Empty;
                    me.cusArchiveDisplayName = string.Empty;
                    context.SubmitChanges();
                }
            }
        }
Exemplo n.º 13
0
 //needed for C360
 public void DeleteUser()
 {
     using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
     {
         tbl_Customer me = (from a in context.tbl_Customers
                        where a.cusID == this.cusID
                        select a).Single();
         me.cusIsDeleted = true;
         me.cusArchiveEmail = me.cusEmail;
         me.cusArchiveUsername = me.cusUserName;
         me.cusArchiveDisplayName = me.cusDisplayName;
         me.cusEmail = string.Empty;
         me.cusUserName = string.Empty;
         me.cusDisplayName = string.Empty;
         context.SubmitChanges();
     }
 }
Exemplo n.º 14
0
 public void Save()
 {
     try
     {                
         using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
         {
             tbl_CustomerSource source = (from a in context.tbl_CustomerSources 
                                          where a.csoCode == this.csoCode 
                                          select a).SingleOrDefault();
             this.csoCode = source == null ? null : source.csoCode;
             if (this.cusID > 0)
             {
                 tbl_Customer customer = (from a in context.tbl_Customers
                                          where a.cusID == this.cusID
                                          select a).SingleOrDefault();                        
                 GetData(customer);
                 context.SubmitChanges();
             }
             else
             {
                 context.tbl_Customers.InsertOnSubmit(this);
                 context.SubmitChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw new ObjectSaveException(ex.Message);
     }
 }
Exemplo n.º 15
0
        public static object[] CreateCustomer(string address1, string address2, string address3, 
            string city, string region, string country, string postal, string source, 
            string password, string customertype, string salutation, string firstname, 
            string middleinitial, string lastname, string suffix, string emailaddress, 
            string username, string newmemberid, string pubcode, string expiredate, 
            string startdate, string screenname, string mobilephone, string secondemail, string keycode)
        {
            CustomerResponseCode responsecode = 0;
            tbl_Customer Customer = new tbl_Customer();
            tbl_NetMembership NetMembership = new tbl_NetMembership();
            tbl_AddressCustomer Address = new tbl_AddressCustomer();

            #region convert string input to correct types
            DateTime dt_expiredate = new DateTime();
            DateTime dt_startdate = new DateTime();

            if (!DateTime.TryParse(expiredate, out dt_expiredate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_EXPIREDATE;
            }
            if (!DateTime.TryParse(startdate, out dt_startdate))
            {
                responsecode = CustomerResponseCode.CANNOT_CONVERT_STARTDATE;
            }             
            #endregion

            if (responsecode == 0)
            {
                #region check user name availability
                switch (tbl_Customer.CheckUserName(username))
                {
                    case 0:
                        responsecode = 0;
                        break;
                    case 1:
                        responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                        break;
                    case 2:
                        responsecode = CustomerResponseCode.DUPLICATE_EMAIL_ADDRESS;
                        break;
                    case 3:
                        responsecode = CustomerResponseCode.DUPLICATE_USER_NAME;
                        break;
                }
                #endregion
                if (responsecode == 0)
                {
                    using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                    {
                        #region get cuscustnum
                        long newcustnum = 0;
                        try
                        {
                            long lastcustomer = (from a in context.tbl_Customers select a.cusCustNum).Select(x => Convert.ToInt64(x)).Max();
                            newcustnum = lastcustomer + 1;
                        }
                        catch
                        {
                            responsecode = CustomerResponseCode.CANNOT_CREATE_CUSCUSTNUM;
                        }
                        #endregion

                        if (responsecode == 0)
                        {
                            #region address data at AH
                            Address = new tbl_AddressCustomer();
                            Address.addAddress1 = address1;
                            Address.addAddress2 = address2;
                            Address.addAddress3 = address3;
                            Address.addCity = city;
                            Address.addCountry = country;
                            Address.addDateCreated = DateTime.Now;
                            Address.addDateUpdated = DateTime.Now;
                            Address.addPostalCode = postal;
                            Address.addRegion = string.IsNullOrEmpty(region) ? "" : region;
                            Address.addSource = string.Empty;
                            context.tbl_AddressCustomers.InsertOnSubmit(Address);
                            context.SubmitChanges();
                            #endregion

                            #region customer data at AH
                            Customer.cusEncryptedPassword = HarperCRYPTO.Cryptography.EncryptData(password);
                            Customer.cusPassword = HarperCRYPTO.Cryptography.Encrypt256(password);
                            Customer.cusPasswordSalt = HarperCRYPTO.Cryptography.Salt;
                            Customer.addID = Address.addID;
                            Customer.cusCustNum = newcustnum.ToString();
                            Customer.cusCustType = customertype;
                            Customer.cusFirstName = firstname;
                            Customer.cusLastName = lastname;
                            Customer.cusPriFirstName = firstname;
                            Customer.cusPriLastName = lastname;
                            Customer.cusEmail = emailaddress;
                            Customer.cusUserName = username;
                            Customer.cusIsCharterMem = false;
                            Customer.cusDateCreated = DateTime.Now;
                            Customer.cusDateUpdated = DateTime.Now;
                            Customer.cusIsDeleted = false;
                            Customer.cusSex = 'U';
                            Customer.cusGUID = Guid.NewGuid();
                            Customer.cusDisplayName = screenname;
                            Customer.cusMobile = mobilephone;
                            Customer.cusHasDisplayName = true;
                            Customer.cusSecondEmail = secondemail;
                            Customer.cusMemberSince = DateTime.Now;
                            Customer.cusSource = source;
                            Customer.cusKeyCode = keycode;
                            Customer.csoCode = source;
                            long.TryParse(newmemberid, out Customer.SfgId);
                            context.tbl_Customers.InsertOnSubmit(Customer);
                            context.SubmitChanges();
                            #endregion

                            #region sfg customer number data at AH
                            HarperLINQ.SFG_CustomerNumber SfgData = new HarperLINQ.SFG_CustomerNumber();
                            SfgData.cusID = Customer.cusID;
                            SfgData.SFGCustNum = newmemberid;
                            context.SFG_CustomerNumbers.InsertOnSubmit(SfgData);
                            context.SubmitChanges();
                            #endregion

                            #region net membership data at AH
                            NetMembership = new tbl_NetMembership();
                            NetMembership.cusID = Customer.cusID;
                            NetMembership.mtyCode = HarperLINQ.SFG_ProdCode.GetFromExtCode(pubcode).IntCode;
                            NetMembership.nmbDateCreated = DateTime.Now;
                            NetMembership.nmbDateEnd = dt_expiredate;
                            NetMembership.nmbDateStart = dt_startdate;
                            context.tbl_NetMemberships.InsertOnSubmit(NetMembership);
                            context.SubmitChanges();
                            #endregion

                        }
                    }
                }
            }
            return new object[] { responsecode, Customer, Address, NetMembership };
        }