Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        int getVerificationListCountFor(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum)
        {
            var lst = verfTrxRequestListExceptSelfUser.Where(
                x => x.MailServiceEnum == mailServiceEnum &&
                x.MailLocalOrForiegnEnum == mailLocalOrForiegnEnum).ToList();

            return(lst.Count());
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        //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);
        }
Exemple #6
0
        //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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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 AddressVerificationRequest load_AddressVerificationRequestModel(string addressId, AddressMain address)
        {
            addressId.IsNullOrWhiteSpaceThrowArgumentException("addressId");
            AddressVerificationRequest avr = new AddressVerificationRequest();

            avr.AddressMailForm = address.ToPostalHTML();

            avr.AddressId = addressId;
            //tod
            //avr.CountryId = address.CountryId;
            //avr.CourierInternationalPayment = VerificationConfig.Sale_Courier_International.ToString();
            //avr.CourierLocalPayment = VerificationConfig.Sale_Courier_Local.ToString();
            //avr.PostalInternationalPayment = VerificationConfig.Sale_Postal_International.ToString();
            //avr.PostalLocalPayment = VerificationConfig.Sale_Postal_Local.ToString();

            avr.CourierBtnCaption = "";
            MailLocalOrForiegnENUM mailLocalOrForiegnEnum = IsAddressInPakistan(addressId) ? MailLocalOrForiegnENUM.InPakistan : MailLocalOrForiegnENUM.OutOfPakistan;

            string postBtnCaption;

            getVerificaionCharges(MailServiceENUM.Post, mailLocalOrForiegnEnum, out postBtnCaption);
            avr.PostalBtnCaption = postBtnCaption;

            string courierBtnCaption;

            getVerificaionCharges(MailServiceENUM.Courier, mailLocalOrForiegnEnum, out courierBtnCaption);
            avr.CourierBtnCaption = courierBtnCaption;



            avr.MailLocalOrForeignEnum = IsAddressInPakistan(addressId) ?
                                         MailLocalOrForiegnENUM.InPakistan :
                                         MailLocalOrForiegnENUM.OutOfPakistan;

            return(avr);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        private bool areThereAnyAddressesForVerificationFor_Helper(MailServiceENUM mailServiceEnum, MailLocalOrForiegnENUM mailLocalOrForiegnEnum)
        {
            bool exists = getVerificationTrxFor_SQL(mailServiceEnum, mailLocalOrForiegnEnum).Any();

            return(exists);
        }
Exemple #12
0
        /// <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);
        }
Exemple #13
0
        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."));
        }
Exemple #14
0
        /// <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);
        }