Ejemplo n.º 1
0
 public AccountInfo(int? customerNumber, AccountPersonPair people, string businessTitle,
     string email, bool? canReceiveHtmlEmail, string phone, int? phoneId, string phone2, 
     int? phone2Id, string fax, int? faxId, string address, string subAddress, string city,
     string stateId, string postalCode, int? countryId, string countryDesc,
     int? addressTypeId, string addressTypeDesc, bool? wantsEmail, bool? wantsMail,
     bool? wantsPhone)
 {
     CustomerNumber = customerNumber;
     People = people;
     BusinessTitle = businessTitle;
     Email = email;
     CanReceiveHtmlEmail = canReceiveHtmlEmail;
     Phone = phone;
     this.phoneId = phoneId;
     Phone2 = phone2;
     this.phone2Id = phone2Id;
     Fax = fax;
     this.faxId = faxId;
     Address = address;
     SubAddress = subAddress;
     City = city;
     StateId = stateId;
     PostalCode = postalCode;
     CountryId = countryId;
     this.countryDesc = countryDesc;
     AddressTypeId = addressTypeId;
     this.addressTypeDesc = addressTypeDesc;
     WantsEmail = wantsEmail;
     WantsMail = wantsMail;
     WantsPhone = wantsPhone;
 }
Ejemplo n.º 2
0
 public static AccountInfo GetAccountInformation()
 {
     if (!IsLoggedIn())
         throw new ApplicationException("GetAccountInformation() was called out of "
             + "sequence. An authenticated Tessitura session is required.");
     string cacheKey = AccountInfoCacheKeyBase + "["
         + HttpContext.Current.Session[UsernameSessionKey].ToString() + "]";
     AccountInfo info = (AccountInfo)HttpContext.Current.Cache[cacheKey];
     if (info == null)
     {
         DataSet accountResults = unsecuredClient.GetAccountInfo(
             HttpContext.Current.Session[TessSessionKeySessionKey].ToString());
         DataRow data = accountResults.Tables["AccountInformation"].Rows[0];
         AccountPerson person1 = null;
         AccountPerson person2 = null;
         if (data["name_status"].ToString() != "Deceased"
             && data["lname"].ToString() != "")
         {
             char? gender = null;
             if (data["gender_1"] != DBNull.Value)
                 gender = Convert.ToChar(data["gender_1"]);
             person1 = new AccountPerson(
                 data["prefix"].ToString(),
                 data["fname"].ToString(),
                 data["mname"].ToString(),
                 data["lname"].ToString(),
                 data["suffix"].ToString(),
                 gender,
                 false);
         }
         if (data["name2_status"].ToString() != "Deceased"
             && data["lname2"].ToString() != "")
         {
             char? gender = null;
             if (data["gender_2"] != DBNull.Value)
                 gender = Convert.ToChar(data["gender_2"]);
             person2 = new AccountPerson(
                 data["prefix2"].ToString(),
                 data["fname2"].ToString(),
                 data["mname2"].ToString(),
                 data["lname2"].ToString(),
                 data["suffix2"].ToString(),
                 gender,
                 false);
         }
         AccountPersonPair personPair = null;
         if (person1 != null || person2 != null)
             personPair = new AccountPersonPair(person1, person2);
         info = new AccountInfo();
         info.CustomerNumber = Convert.ToInt32(data["customer_no"]);
         info.People = personPair;
         info.Address = data["street1"].ToString();
         info.SubAddress = data["street2"].ToString();
         info.City = data["city"].ToString();
         info.StateId = data["state"].ToString();
         info.PostalCode = data["postal_code"].ToString();
         info.SetNewCountryIdWithDesc(
             Convert.ToInt32(data["country"]), data["country_name"].ToString());
         string phone = data["phone"].ToString();
         info.EmailUnprotected = data["email"].ToString();
         // data["use_avs"]
         string phone2 = data["phone2"].ToString();
         string fax = data["fax_phone"].ToString();
         // data["esal1_desc"]
         // data["esal2_desc"]
         // data["lsal_desc"]
         info.BusinessTitle = data["business_title"].ToString();
         info.CanReceiveHtmlEmail = data["html_ind"].ToString() == "Y";
         // data["original_source"]
         info.WantsMail = data["mail_ind_id"] == DBNull.Value
                          || Convert.ToInt32(data["mail_ind_id"]) == 3;
         info.WantsPhone = data["phone_ind_id"] == DBNull.Value
                           || Convert.ToInt32(data["phone_ind_id"]) == 3;
         info.WantsEmail = data["emarket_ind_id"] == DBNull.Value
                           || Convert.ToInt32(data["emarket_ind_id"]) == 3;
         // data["email_inactive"]
         DataSet constituentResults = unsecuredClient.GetConstituentInfoEx(
             HttpContext.Current.Session[TessSessionKeySessionKey].ToString(), null);
         if (constituentResults.Tables["Addresses"].Rows.Count > 0)
         {
             foreach (DataRow address in constituentResults.Tables["Addresses"].Rows)
             {
                 if (address["primary_ind"].ToString() == "Y")
                 {
                     info.SetAddressTypeIdWithDesc(
                         Convert.ToInt32(address["address_type"]),
                         address["address_type_desc"].ToString());
                     break;
                 }
             }
         }
         int? phoneId = null;
         int? phone2Id = null;
         int? faxId = null;
         if (constituentResults.Tables["Phones"].Rows.Count > 0)
         {
             foreach (DataRow phoneNumber in constituentResults.Tables["Phones"].Rows)
             {
                 string number =
                     Regex.Replace(phoneNumber["phone"].ToString(), "[^0-9]", "");
                 if (!String.IsNullOrWhiteSpace(phone) && number == phone)
                     phoneId = Convert.ToInt32(phoneNumber["phone_no"]);
                 if (!String.IsNullOrWhiteSpace(phone2) && number == phone2)
                     phone2Id = Convert.ToInt32(phoneNumber["phone_no"]);
                 if (!String.IsNullOrWhiteSpace(fax) && number == fax)
                     faxId = Convert.ToInt32(phoneNumber["phone_no"]);
             }
             if (phoneId != null)
                 info.SetPhoneWithId(phone, phoneId);
             else
                 info.Phone = phone;
             if (phone2Id != null)
                 info.SetPhone2WithId(phone2, phone2Id);
             else
                 info.Phone2 = phone2;
             if (faxId != null)
                 info.SetFaxWithId(fax, faxId);
             else
                 info.Fax = fax;
         }
         HttpContext.Current.Cache.Insert(cacheKey, info, null,
             DateTime.MaxValue, new TimeSpan(0, 10, 0));
     }
     return info;
 }
 protected bool SubmitUpdate()
 {
     AccountPerson person1 = null;
     AccountPerson person2 = null;
     if (/*FirstNameField.Text.Trim() != "" &&*/ LastNameField.Text.Trim() != "")
     {
         char? gender = null;
         if (GenderField.SelectedValue != "0")
             gender = GenderField.SelectedValue[0];
         person1 = new AccountPerson(
             PrefixField.SelectedValue,
             FirstNameField.Text,
             MiddleNameField.Text,
             LastNameField.Text,
             SuffixField.Value,
             gender);
     }
     if (/*FirstName2Field.Text.Trim() != "" &&*/ LastName2Field.Text.Trim() != "")
     {
         char? gender = null;
         if (Gender2Field.SelectedValue != "0")
             gender = Gender2Field.SelectedValue[0];
         person2 = new AccountPerson(
             Prefix2Field.SelectedValue,
             FirstName2Field.Text,
             MiddleName2Field.Text,
             LastName2Field.Text,
             Suffix2Field.Value,
             gender);
     }
     AccountPersonPair pair = new AccountPersonPair(person1, person2);
     AccountInfo newInfo = new AccountInfo();
     newInfo.BusinessTitle = BusinessTitleField.Value;
     newInfo.CanReceiveHtmlEmail = Boolean.Parse(CanReceiveHtmlEmailField.Value);
     if (CountryField.SelectedValue != "0")
     {
         newInfo.CountryId = Int32.Parse(CountryField.SelectedValue);
         newInfo.PostalCode = ZipField.Text;
         if (StateField.SelectedValue != "0")
             newInfo.StateId = StateField.SelectedValue;
         newInfo.SubAddress = SubAddressField.Text;
         newInfo.City = CityField.Text;
         newInfo.Address = AddressField.Text;
         if (AddressTypeField.SelectedValue != "0")
             newInfo.AddressTypeId = Int32.Parse(AddressTypeField.SelectedValue);
     }
     newInfo.Email = EmailField.Text;
     newInfo.Fax = FaxField.Text;
     newInfo.People = pair;
     newInfo.Phone = PhoneField.Text;
     newInfo.Phone2 = Phone2Field.Text;
     newInfo.WantsEmail = Boolean.Parse(WantEmailField.Value);
     newInfo.WantsMail = Boolean.Parse(WantMailField.Value);
     newInfo.WantsPhone = Boolean.Parse(WantPhoneField.Value);
     return WebClient.UpdateAccountInfo(newInfo, true);
 }