Exemple #1
0
        public JsonResult SaveProposalPaymentInfo(PaymentModel objPaymentModel)
        {
            objPaymentModel.UserName = Username;

            objPaymentModel.QuoteNo = CrossCutting.CrossCutting_EncryptDecrypt.Decrypt(objPaymentModel.QuoteNo);

            objPaymentModel = objPaymentBusiness.SaveProposalPaymentInfo(objPaymentModel);

            #region policy issuance triggers
            if (!string.IsNullOrEmpty(objPaymentModel.Message) && objPaymentModel.Message == "Success" && string.IsNullOrEmpty(objPaymentModel.UWMessage))
            {
                AIA.Life.Business.Policy.PolicyBusiness objPolicyBusiness = new AIA.Life.Business.Policy.PolicyBusiness();
                ReportsController objReportController = new ReportsController();
                List <byte[]>     lstBytes            = new List <byte[]>();
                try
                {
                    if (objPaymentModel.lstPaymentItems.Count > 0)
                    {
                        int prdID       = objPaymentModel.lstPaymentItems[0].ProductID;
                        var obj         = Context.tblMasProductPlans.Where(a => a.ProductId == prdID).FirstOrDefault();
                        var ProductCode = Context.tblProducts.Where(a => a.ProductId == prdID).Select(a => a.ProductCode).FirstOrDefault();
                        if (obj != null)
                        {
                            byte[] quoteBytes = objReportController.ReportQuotation(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            if (quoteBytes != null)
                            {
                                lstBytes.Add(quoteBytes);
                            }

                            byte[]        a  = objReportController.ReportForIllustrationPDF(objPaymentModel.QuoteNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage, objPaymentModel.ProposalNo);
                            byte[]        b  = objReportController.ReportForPolicySchedule(objPaymentModel.ProposalNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            byte[]        c  = objReportController.ReportForCoveringLetter(objPaymentModel.ProposalNo, obj.PlanCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                            List <byte[]> vs = new List <byte[]>();
                            if (c != null)
                            {
                                vs.Add(c);
                            }
                            if (b != null)
                            {
                                vs.Add(b);
                            }
                            if (a != null)
                            {
                                vs.Add(a);
                            }
                            objPaymentModel.ByteArray2 = concatAndAddContent(vs);
                        }
                        objPaymentModel.ByteArray3 = objReportController.ProposalReport(objPaymentModel.QuoteNo, ProductCode, objPaymentModel.lstPaymentItems[0].PreferredLanguage);
                        if (objPaymentModel.ByteArray2 != null)
                        {
                            lstBytes.Add(objPaymentModel.ByteArray2);
                        }
                        if (objPaymentModel.ByteArray3 != null)
                        {
                            lstBytes.Add(objPaymentModel.ByteArray3);
                        }
                    }


                    objPolicyBusiness.PostPolicyIssuanceTriggers(objPaymentModel);
                }
                catch (Exception e)
                {
                    log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                    Logger.Error(e);
                }
                try
                {
                    for (int i = 0; i < lstBytes.Count; i++)
                    {
                        LdmsDocuments documents = new LdmsDocuments();
                        documents.SourcePath = ConfigurationManager.AppSettings["DocumentUploadPath"];
                        documents.DocCode    = i == 0 ? "PRD004" : (i == 1 ? "PRD009" : (i == 2 ? "PRD001" : ""));
                        documents.AgentCode  = Username;
                        documents.ProposalNo = objPaymentModel.ProposalNo;
                        documents.SourcePath = documents.SourcePath + @"\UW\" + documents.AgentCode + @"\" + documents.ProposalNo + @"\";
                        if (!Directory.Exists(documents.SourcePath))
                        {
                            Directory.CreateDirectory(documents.SourcePath);
                        }
                        documents.SourcePath = documents.SourcePath + documents.DocCode + ".pdf";
                        System.IO.File.WriteAllBytes(documents.SourcePath, lstBytes[i]);
                        objPolicyBusiness.UploadDocumentsLDMS(documents);
                    }
                }
                catch (Exception ex)
                {
                    log4net.GlobalContext.Properties["ErrorCode"] = Codes.GetErrorCode();
                    Logger.Error(ex);
                }
            }
            #endregion

            var ObjResponse = new { Message = objPaymentModel.Message, ProposalNo = objPaymentModel.ProposalNo, UWMessage = objPaymentModel.UWMessage, ErrorMessage = objPaymentModel.Error.ErrorMessage };
            return(Json(ObjResponse, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public PaymentModel SaveProposalPaymentInfo(PaymentModel objPaymentModel)
        {
            PaymentBusiness objPaymentBusiness = new PaymentBusiness();

            return(objPaymentBusiness.SaveProposalPaymentInfo(objPaymentModel));
        }