Beispiel #1
0
        private void CreateCASActivityLog(kkslm_tr_renewinsurance reins, SLMDBEntities slmdb, string batchCode, Int64 batchMonitorId, int phonecall_id, LeadDataForCARLogService data)
        {
            try
            {
                string policyStartCoverDate = "";
                string policyEndCoverDate   = "";
                string actStartCoverDate    = "";
                string actEndCoverDate      = "";
                string preleadId            = "";

                if (data != null)
                {
                    preleadId = data.PreleadId != null?data.PreleadId.Value.ToString() : "";

                    if (data.PolicyStartCoverDate != null)
                    {
                        policyStartCoverDate = data.PolicyStartCoverDate.Value.ToString("dd-MM-") + data.PolicyStartCoverDate.Value.Year.ToString();
                    }
                    if (data.PolicyEndCoverDate != null)
                    {
                        policyEndCoverDate = data.PolicyEndCoverDate.Value.ToString("dd-MM-") + data.PolicyEndCoverDate.Value.Year.ToString();
                    }
                    if (data.ActStartCoverDate != null)
                    {
                        actStartCoverDate = data.ActStartCoverDate.Value.ToString("dd-MM-") + data.ActStartCoverDate.Value.Year.ToString();
                    }
                    if (data.ActEndCoverDate != null)
                    {
                        actEndCoverDate = data.ActEndCoverDate.Value.ToString("dd-MM-") + data.ActEndCoverDate.Value.Year.ToString();
                    }
                }

                //Activity Info
                List <CARService.DataItem> actInfoList = new List <CARService.DataItem>();
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 1, DataLabel = "เลขที่สัญญา", DataValue = data != null ? data.ContractNo : ""
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 2, DataLabel = "บริษัทประกันภัยรถยนต์", DataValue = data != null ? data.InsuranceCompany : ""
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 3, DataLabel = "เลขเล่มกรมธรรม์", DataValue = data != null ? data.PolicyNo : ""
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 4, DataLabel = "เลขลงทะเบียน", DataValue = ""
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 5, DataLabel = "วันที่คุ้มครอง", DataValue = policyStartCoverDate
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 6, DataLabel = "วันที่สิ้นสุดกรมธรรม์", DataValue = policyEndCoverDate
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 7, DataLabel = "เลขที่พรบ.", DataValue = data != null ? data.ActNo : ""
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 8, DataLabel = "วันที่เริ่มต้นพรบ.", DataValue = actStartCoverDate
                });
                actInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 9, DataLabel = "วันที่สิ้นสุดพรบ.", DataValue = actEndCoverDate
                });

                //Customer Info
                List <CARService.DataItem> cusInfoList = new List <CARService.DataItem>();
                cusInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 1, DataLabel = "Subscription ID", DataValue = data != null ? data.CitizenId : ""
                });
                cusInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 2, DataLabel = "Subscription Type", DataValue = data != null ? data.CardTypeName : ""
                });
                cusInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 3, DataLabel = "ชื่อ-นามสกุลของลูกค้า", DataValue = data != null ? data.CustomerName : ""
                });

                //Product Info
                List <CARService.DataItem> prodInfoList = new List <CARService.DataItem>();
                prodInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 1, DataLabel = "Product Group", DataValue = data != null ? data.ProductGroupName : ""
                });
                prodInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 2, DataLabel = "Product", DataValue = data != null ? data.ProductName : ""
                });
                prodInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 3, DataLabel = "Campaign", DataValue = data != null ? data.CampaignName : ""
                });

                //Contract Info
                List <CARService.DataItem> contInfoList = new List <CARService.DataItem>();
                contInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 1, DataLabel = "เลขที่สัญญา", DataValue = data != null ? data.ContractNo : ""
                });
                contInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 2, DataLabel = "ระบบที่บันทึกสัญญา", DataValue = preleadId != "" ? "HP" : ""
                });
                contInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 3, DataLabel = "ทะเบียนรถ", DataValue = data != null ? data.LicenseNo : ""
                });

                //Officer Info
                List <CARService.DataItem> offInfoList = new List <CARService.DataItem>();
                offInfoList.Add(new CARService.DataItem()
                {
                    SeqNo = 1, DataLabel = "Officer", DataValue = "SYSTEM"
                });

                CARService.CARServiceData logdata = new CARService.CARServiceData()
                {
                    ReferenceNo         = reins.slm_RenewInsureId.ToString(),
                    SecurityKey         = preleadId != "" ? AppConstant.CARLogService.OBTSecurityKey : AppConstant.CARLogService.SLMSecurityKey,
                    ServiceName         = "CreateActivityLog",
                    SystemCode          = preleadId != "" ? AppConstant.CARLogService.CARLoginOBT : AppConstant.CARLogService.CARLoginSLM,  //ถ้ามี preleadid ให้ถือว่าเป็น OBT ทั้งหมด ถึงจะมี TicketId ก็ตาม
                    TransactionDateTime = DateTime.Now,
                    ActivityInfoList    = actInfoList,
                    CustomerInfoList    = cusInfoList,
                    ProductInfoList     = prodInfoList,
                    ContractInfoList    = contInfoList,
                    OfficerInfoList     = offInfoList,
                    ActivityDateTime    = DateTime.Now,
                    CampaignId          = data != null ? data.CampaignId : "",
                    ChannelId           = data != null ? data.ChannelId : "",
                    PreleadId           = preleadId,
                    ProductGroupId      = data != null ? data.ProductGroupId : "",
                    ProductId           = data != null ? data.ProductId : "",
                    Status         = data != null ? data.StatusName : "",
                    SubStatus      = data != null ? data.SubStatusName : "",
                    TicketId       = data != null ? data.TicketId : "",
                    SubscriptionId = data != null ? data.CitizenId : "",
                    TypeId         = AppConstant.CARLogService.Data.TypeId,
                    AreaId         = AppConstant.CARLogService.Data.AreaId,
                    SubAreaId      = AppConstant.CARLogService.Data.SubAreaId,
                    ActivityTypeId = AppConstant.CARLogService.Data.ActivityType.TodoId,
                    ContractNo     = data != null ? data.ContractNo : ""
                };

                if (data != null && !string.IsNullOrEmpty(data.SubScriptionTypeId))
                {
                    logdata.SubscriptionTypeId = data.SubScriptionTypeId;
                }

                bool ret = CARService.CreateActivityLog(logdata, batchMonitorId, batchCode, reins.slm_TicketId, logfilename);
                AppUtil.UpdatePhonecallCASFlag(slmdb, phonecall_id, ret ? "1" : "2");
            }
            catch (Exception ex)
            {
                AppUtil.UpdatePhonecallCASFlag(slmdb, phonecall_id, "2");

                //Error ให้ลง Log ไว้ ไม่ต้อง Throw
                string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                BizUtil.InsertLog(batchMonitorId, reins.slm_TicketId, "", message);
                Util.WriteLogFile(logfilename, batchCode, message);
            }
        }
Beispiel #2
0
        private kkslm_phone_call InsertPhonecallHistory(SLMDBEntities slmdb, string ticketId, DateTime createdDate, LeadDataForCARLogService data)
        {
            try
            {
                string content = "";
                string policyStartCoverDate = "";
                string policyEndCoverDate   = "";
                string actStartCoverDate    = "";
                string actEndCoverDate      = "";

                if (data.PolicyStartCoverDate != null)
                {
                    policyStartCoverDate = data.PolicyStartCoverDate.Value.ToString("dd-MM-") + data.PolicyStartCoverDate.Value.Year.ToString();
                }
                if (data.PolicyEndCoverDate != null)
                {
                    policyEndCoverDate = data.PolicyEndCoverDate.Value.ToString("dd-MM-") + data.PolicyEndCoverDate.Value.Year.ToString();
                }
                if (data.ActStartCoverDate != null)
                {
                    actStartCoverDate = data.ActStartCoverDate.Value.ToString("dd-MM-") + data.ActStartCoverDate.Value.Year.ToString();
                }
                if (data.ActEndCoverDate != null)
                {
                    actEndCoverDate = data.ActEndCoverDate.Value.ToString("dd-MM-") + data.ActEndCoverDate.Value.Year.ToString();
                }

                content  = "เลขที่สัญญา:" + (data != null ? data.ContractNo : "");
                content += ", บริษัทประกันภัยรถยนต์:" + (data != null ? data.InsuranceCompany : "");
                content += ", เลขเล่มกรมธรรม์:" + (data != null ? data.PolicyNo : "");
                content += ", เลขลงทะเบียน:";
                content += ", วันที่คุ้มครอง:" + policyStartCoverDate;
                content += ", วันที่สิ้นสุดกรมธรรม์:" + policyEndCoverDate;
                content += ", เลขที่พรบ.:" + (data != null ? data.ActNo : "");
                content += ", วันที่เริ่มต้นพรบ.:" + actStartCoverDate;
                content += ", วันที่สิ้นสุดพรบ.:" + actEndCoverDate;

                var lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                if (lead != null)
                {
                    kkslm_phone_call phone = new kkslm_phone_call()
                    {
                        slm_TicketId           = ticketId,
                        slm_Status             = lead.slm_Status,
                        slm_SubStatus          = lead.slm_SubStatus,
                        slm_SubStatusName      = lead.slm_ExternalSubStatusDesc,
                        slm_Owner              = lead.slm_Owner,
                        slm_Owner_Position     = lead.slm_Owner_Position,
                        slm_ContactDetail      = content,
                        slm_CreateBy           = "SYSTEM",
                        slm_CreatedBy_Position = null,
                        slm_CreateDate         = createdDate,
                        is_Deleted             = 0
                    };
                    slmdb.kkslm_phone_call.AddObject(phone);
                    slmdb.SaveChanges();

                    return(phone);
                }
                else
                {
                    throw new Exception("ไม่พบ TicketId " + ticketId + " ในระบบ");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }