private static byte[] createTheHeaderForPdfPrinting(AddressVerificationHdr addressVerificationHdr, string mailerName, string logoAddressAbsolute, string addressMailFrom, string website, string userName, string printDate, string letter_Instructions, string letter_welcomePara, string letter_body, string letter_Title, string sum_Title, string sum_body, string sum_Instructions, string sum_Welcome, string batchNumber, MailLocalOrForiegnENUM mailLocalOrForiegnEnum, MailServiceENUM mailServiceENUM) { LetterClass summaryLetter; LetterClass verificationLetter; initializeTheLetterCommonText(letter_Instructions, letter_welcomePara, letter_body, letter_Title, sum_Title, sum_body, sum_Instructions, sum_Welcome, out summaryLetter, out verificationLetter); //create the letters List <AddressVerificationModel> letterList = createLetters(addressVerificationHdr); //initialize the header AddressVerificationModel_Header header = new AddressVerificationModel_Header(); //load the header header.Load(batchNumber, logoAddressAbsolute, addressMailFrom, website, mailLocalOrForiegnEnum, mailServiceENUM, printDate, mailerName, userName, summaryLetter, verificationLetter, letterList); var factory = new CustomerAddressVerificationFactory(); byte[] pdf = factory.Build(header); return(pdf); }
/// <summary> /// These are the number of pieces allowed to the mailer per mailing. /// </summary> private int numberOfMailPcsAllowedPerMailingToMailer(Mailer mailer, MailServiceENUM mailServiceEnum) { if (mailServiceEnum == MailServiceENUM.Post) { switch (getMailerTrustLevel_Helper(mailer)) { case TrustLevelENUM.Level1: return(MailersTrustLevelConfig.Level1_Postal); case TrustLevelENUM.Level2: return(MailersTrustLevelConfig.Level2_Postal); case TrustLevelENUM.Level3: return(MailersTrustLevelConfig.Level3_Postal); case TrustLevelENUM.Level4: return(MailersTrustLevelConfig.Level4_Postal); case TrustLevelENUM.Level5: return(MailersTrustLevelConfig.Level5_Postal); case TrustLevelENUM.Unknown: case TrustLevelENUM.BlackListed: default: return(0); } } if (mailServiceEnum == MailServiceENUM.Courier) { switch (getMailerTrustLevel_Helper(mailer)) { case TrustLevelENUM.Level1: return(MailersTrustLevelConfig.Level1_Courier); case TrustLevelENUM.Level2: return(MailersTrustLevelConfig.Level2_Courier); case TrustLevelENUM.Level3: return(MailersTrustLevelConfig.Level3_Courier); case TrustLevelENUM.Level4: return(MailersTrustLevelConfig.Level4_Courier); case TrustLevelENUM.Level5: return(MailersTrustLevelConfig.Level5_Courier); case TrustLevelENUM.Unknown: case TrustLevelENUM.BlackListed: default: return(0); } } throw new Exception( string.Format("No such mail serivice! {0}", mailServiceEnum .ToString() .ToTitleSentance())); }
private double getVerificaionCharges(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum, out string btnCaption) { string error = ""; double verificationCost = 0; btnCaption = "Error"; switch (mailServiceEnum) { case MailServiceENUM.Post: switch (mailLocalOrForiegnEnum) { case MailLocalOrForiegnENUM.InPakistan: //is in Pakistan verificationCost = VerificationConfig.Sale_Postal_Local; btnCaption = string.Format("POST [pkrs {0}]", verificationCost); break; case MailLocalOrForiegnENUM.OutOfPakistan: //is foreign verificationCost = VerificationConfig.Sale_Postal_International; btnCaption = string.Format("POST [pkrs {0}]", verificationCost); break; case MailLocalOrForiegnENUM.Unknown: default: error = string.Format("No such option"); throw new Exception(error); } break; case MailServiceENUM.Courier: switch (mailLocalOrForiegnEnum) { case MailLocalOrForiegnENUM.InPakistan: //is in Pakistan verificationCost = VerificationConfig.Sale_Courier_Local; btnCaption = string.Format("COURIER [pkrs {0}]", verificationCost); break; case MailLocalOrForiegnENUM.OutOfPakistan: verificationCost = VerificationConfig.Sale_Courier_International; btnCaption = string.Format("COURIER [pkrs {0}]", verificationCost); //is foreign break; case MailLocalOrForiegnENUM.Unknown: default: error = string.Format("No such option"); throw new Exception(error); } break; default: error = string.Format("No such option: {0}", mailServiceEnum.ToString().ToTitleSentance()); throw new Exception(error); } return(verificationCost); }
/// <summary> /// This takes the mailers request to create a list according to what he wants. /// </summary> /// <param name="mailServiceEnum"></param> /// <param name="mailLocalOrForiegnEnum"></param> /// <returns></returns> private IQueryable <AddressVerificationTrx> getVerificationTrxFor_SQL(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum) { var dataForMailServiceType = AddressVerificationTrxBiz.FindAll() .Where(x => x.MailServiceEnum == mailServiceEnum && x.MailLocalOrForiegnEnum == mailLocalOrForiegnEnum); //var test = dataForMailServiceType.ToList(); return(dataForMailServiceType); }
int getVerificationListCountFor(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum) { var lst = verfTrxRequestListExceptSelfUser.Where( x => x.MailServiceEnum == mailServiceEnum && x.MailLocalOrForiegnEnum == mailLocalOrForiegnEnum).ToList(); return(lst.Count()); }
private int NoOfDaysAllowed(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum) { string err = ""; switch (mailLocalOrForiegnEnum) { case MailLocalOrForiegnENUM.InPakistan: switch (mailServiceEnum) { case MailServiceENUM.Post: return(VerificationConfig.Number_Of_Days_Allowed_For_Local_Post); case MailServiceENUM.Courier: return(VerificationConfig.Number_Of_Days_Allowed_For_Local_Courier); case MailServiceENUM.Unknown: default: err = string.Format("No such choice for No. of days allowed: Service: {0}, Local/Foreign: {1}", mailServiceEnum.ToString().ToTitleSentance(), mailLocalOrForiegnEnum.ToString().ToTitleSentance()); throw new Exception(err); } ; case MailLocalOrForiegnENUM.OutOfPakistan: switch (mailServiceEnum) { case MailServiceENUM.Post: return(VerificationConfig.Number_Of_Days_Allowed_For_Foreign_Post); case MailServiceENUM.Courier: return(VerificationConfig.Number_Of_Days_Allowed_For_Foreign_Courier); case MailServiceENUM.Unknown: default: err = string.Format("No such choice for No. of days allowed: Service: {0}, Local/Foreign: {1}", mailServiceEnum.ToString().ToTitleSentance(), mailLocalOrForiegnEnum.ToString().ToTitleSentance()); throw new Exception(err); } ; case MailLocalOrForiegnENUM.Unknown: default: err = string.Format("No such choice for No. of days allowed: Service: {0}, Local/Foreign: {1}", mailServiceEnum.ToString().ToTitleSentance(), mailLocalOrForiegnEnum.ToString().ToTitleSentance()); throw new Exception(err); } }
//public override void BusinessRulesFor(ModelsClassLibrary.ModelsNS.SharedNS.ControllerCreateEditParameter parm) //{ // base.BusinessRulesFor(parm); // Mailer mailer = parm.Entity as Mailer; // mailer.IsNullThrowException("Could not box mailer"); // mailer.Name.IsNullOrWhiteSpaceThrowException("mailer Name is empty"); //} public byte[] PrintVerificationLetters(string id) { //AddressVerificationModel_Header hdr = getVerificationLetterData(addressVerificationHdr); id.IsNullOrWhiteSpaceThrowException("id"); AddressVerificationHdr addressVerificationHdr = AddressVerificationHdrBiz.Find(id); addressVerificationHdr.IsNullThrowException("addressVerificationHdr"); addressVerificationHdr.Mailer.IsNullThrowException("Mailer"); //gather data string mailerName = addressVerificationHdr.Mailer.Name; string logoAddressAbsolute = System.Web.HttpContext.Current.Server.MapPath(MyConstants.LOGO_LOCATION); string addressMailFrom = CompanyConfig.CompanyAddress; string website = CompanyConfig.CompanyNameForWebPage; string userName = UserName; string printDate = DateTime.Now.ToShortDateString(); string letter_Instructions = VerificationConfig.Letter_Instruction_Para; string letter_welcomePara = VerificationConfig.Letter_Welcome_Para; string letter_body = VerificationConfig.Letter_Body; string letter_Title = VerificationConfig.Letter_Title; string sum_Title = VerificationConfig.Summary_Title; string sum_body = VerificationConfig.Summary_Body; string sum_Instructions = VerificationConfig.Summary_Instruction_Para; string sum_Welcome = VerificationConfig.Summary_Welcome_Para; //need to initialize string batchNumber = addressVerificationHdr.BatchNo.ToString(); MailLocalOrForiegnENUM mailLocalOrForiegnEnum = addressVerificationHdr.MailLocalOrForiegnEnum; MailServiceENUM mailServiceENUM = addressVerificationHdr.MailServiceEnum; byte[] hdr = createTheHeaderForPdfPrinting(addressVerificationHdr, mailerName, logoAddressAbsolute, addressMailFrom, website, userName, printDate, letter_Instructions, letter_welcomePara, letter_body, letter_Title, sum_Title, sum_body, sum_Instructions, sum_Welcome, batchNumber, mailLocalOrForiegnEnum, mailServiceENUM); return(hdr); }
public void CreatMailingList(MailLocalOrForiegnENUM mailLocalOrForiegnEnum, MailServiceENUM mailServiceEnum) { if (mailLocalOrForiegnEnum == MailLocalOrForiegnENUM.Unknown) { throw new Exception("Mail Local Or Foriegn is UNKNOWN."); } if (mailServiceEnum == MailServiceENUM.Unknown) { throw new Exception("Mail Service is UNKNOWN."); } var verificationHdr = CreateVerificationMailingList_Helper(mailLocalOrForiegnEnum, mailServiceEnum); AddressVerificationHdrBiz.CreateAndSave(verificationHdr); }
private AddressVerificationHdr CreateVerificationMailingListFor(Mailer mailer, MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum, VerificaionStatusENUM VerificaionStatusEnum) { List <AddressVerificationTrx> mailingList = createVerificationListFor(mailer, mailLocalOrForiegnEnum, mailServiceEnum, VerificaionStatusEnum); if (mailingList.IsNullOrEmpty()) { return(null); } updateTrxs(mailingList); AddressVerificationHdr header = AddressVerificationHdrBiz.Factory() as AddressVerificationHdr; string dateTickStr = DateTime.UtcNow.Ticks.ToString(); dateTickStr = dateTickStr.Substring(dateTickStr.Length - 5); //gets last 5 digits header.Name = string.Format("{1} -{0} ", dateTickStr, UserName); header.AddBeginAndEndDateController(mailLocalOrForiegnEnum, mailServiceEnum, UserName, UserId); header.MailLocalOrForiegnEnum = mailLocalOrForiegnEnum; header.MailServiceEnum = mailServiceEnum; header.BatchNo = getNextBatchNo(); header.BeginDate.SetToTodaysDate(UserName, UserId); header.EndDate.SetToTodaysDate(UserName, UserId); int timeAllowed = NoOfDaysAllowed(mailServiceEnum, mailLocalOrForiegnEnum); header.EndDate.Date = header.EndDate.Date.Value.AddDays(timeAllowed); header.Verification.SetTo(VerificaionStatusENUM.SelectedForProcessing); //header.SuccessEnum = SuccessENUM.Inproccess; //db stuff header.MailerId = mailer.Id; header.Mailer = mailer; mailer.AddressVerificationHdrs.Add(header); header.AddressVerificationTrxs = mailingList; return(header); }
private AddressVerificationHdr CreateVerificationMailingList_Helper(MailLocalOrForiegnENUM mailLocalOrForiegnEnum, MailServiceENUM mailServiceEnum) { //mv.MailerId.IsNullOrWhiteSpaceThrowArgumentException("View lost the data of Mailer Id"); //always a mailer will be logged in and the mailer id will be with the User id. UserId.IsNullOrWhiteSpaceThrowException("You are not logged in"); Person person = UserBiz.GetPersonFor(UserId); person.IsNullThrowException("Person not found for user"); person.Mailers.IsNullOrEmptyThrowException("You are not an authorized mailer"); Mailer mailer = person.Mailers.FirstOrDefault(x => x.MetaData.IsDeleted == false); mailer.IsNullThrowException("You are not an authourized mailer"); var verificationHdr = CreateVerificationMailingListFor(mailer, mailServiceEnum, mailLocalOrForiegnEnum, VerificaionStatusENUM.Requested); return(verificationHdr); }
private int getNumbrOfLettersAllowedToUserIfZeroThrowException_Helper(Mailer mailer, MailServiceENUM mailServiceEnum) { int qtyAllowedToUser = numberOfMailPcsAllowedPerMailingToMailer(mailer, mailServiceEnum); if (qtyAllowedToUser == 0) { throw new Exception(string.Format("You are not allowed any mails for this Trust Level = '{0}'", getMailerTrustLevel_Helper(mailer).ToString().ToTitleSentance())); } return(qtyAllowedToUser); }
private bool areThereAnyAddressesForVerificationFor_Helper(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum) { bool exists = getVerificationTrxFor_SQL(mailServiceEnum, mailLocalOrForiegnEnum).Any(); return(exists); }
private List <AddressVerificationTrx> createVerificationListFor(Mailer mailer, MailLocalOrForiegnENUM mailLocalOrForiegnEnum, MailServiceENUM mailServiceEnum, VerificaionStatusENUM VerificaionStatusEnum) { checkIfMailerIsAllowedAnyMoreMailingsIfNotThrowException_Helper(mailer); //Check to see if there are any mails for verification if (areThereAnyAddressesForVerificationFor_Helper(mailServiceEnum, mailLocalOrForiegnEnum)) { //get the number allowed to the user int qtyAllowedToUser = getNumbrOfLettersAllowedToUserIfZeroThrowException_Helper(mailer, mailServiceEnum); //this gets the list List <AddressVerificationTrx> list = getVerificationTrxFor_SQL(mailServiceEnum, mailLocalOrForiegnEnum) .Where(x => x.Verification.VerificaionStatusEnum == VerificaionStatusEnum) .ToList(); list.IsNullOrEmptyThrowException("Sorry. There are no open verification requests for Pakistan."); List <AddressVerificationTrx> lstOfAddys = createListOfVerificationAddresses(qtyAllowedToUser, list); return(lstOfAddys); } throw new Exception(string.Format("Sorry. There are no open verification requests.")); }
//private void updateAllTheAddresses(AddressVerificationHdr addyVerfHdr) //{ // addyVerfHdr.AddressVerificationTrxs.IsNullOrEmptyThrowException("No verification transactions. Programming error"); // foreach (AddressVerificationTrx trx in addyVerfHdr.AddressVerificationTrxs) // { // trx.Address.IsNullThrowException("Address is null. Progamming error."); // AddressWithId address = trx.Address; // address.Verification.SetTo(VerificaionStatusENUM.Printed); // AddressBiz.Update(address); // } //} private static double GetBugetedCost(MailLocalOrForiegnENUM mailLocalOrForiegnEnum, MailServiceENUM mailServiceEnum) { string error = ""; double verificationCost = 0; switch (mailServiceEnum) { case MailServiceENUM.Post: switch (mailLocalOrForiegnEnum) { case MailLocalOrForiegnENUM.InPakistan: //is in Pakistan verificationCost = VerificationConfig.Expected_Cost_Postal_Local; break; case MailLocalOrForiegnENUM.OutOfPakistan: //is foreign verificationCost = VerificationConfig.Expected_Cost_Postal_International; break; default: error = string.Format("No such option: {0}", mailLocalOrForiegnEnum); throw new Exception(error); } break; case MailServiceENUM.Courier: switch (mailLocalOrForiegnEnum) { case MailLocalOrForiegnENUM.InPakistan: //is in Pakistan verificationCost = VerificationConfig.Expected_Cost_Courier_Local; break; case MailLocalOrForiegnENUM.OutOfPakistan: //is foreign verificationCost = VerificationConfig.Expected_Cost_Courier_International; break; default: error = string.Format("No such option: {0}", mailLocalOrForiegnEnum); throw new Exception(error); } break; default: error = string.Format("No such option: {0}", mailServiceEnum); throw new Exception(error); } return(verificationCost); }
/// <summary> /// This /// </summary> /// <param name="avr"></param> /// <returns></returns> public AddressVerificationRequest GetAddressVerificationRequestConfirmationHttp(string addressId, MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnENUM) { var avr2 = GetAddressVerificationRequest(addressId); avr2.MailServiceEnum = mailServiceEnum; avr2.IsSure1 = true; avr2.DateIsSure1 = DateTime.UtcNow; string btnCaption; avr2.PaymentAmount = getVerificaionCharges(avr2, out btnCaption); return(avr2); }