示例#1
0
        public void InsertCampaignList(List <ProductData> productList, string ticketId, string username)
        {
            try
            {
                DateTime createdDate = DateTime.Now;
                foreach (ProductData campaign in productList)
                {
                    kkslm_tr_campaignfinal camfinal = new kkslm_tr_campaignfinal();
                    camfinal.slm_TicketId           = ticketId;
                    camfinal.slm_CampaignId         = campaign.CampaignId;
                    camfinal.slm_CampaignName       = campaign.CampaignName;
                    camfinal.slm_Description        = campaign.CampaignDesc;
                    camfinal.slm_CreatedBy          = username;
                    camfinal.slm_CreatedBy_Position = GetPositionId(username, slmdb);
                    camfinal.slm_CreatedDate        = createdDate;
                    slmdb.kkslm_tr_campaignfinal.AddObject(camfinal);

                    KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.AddCampaignFinal, "", campaign.CampaignId, username, createdDate);
                }
                slmdb.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void UpdateData(LeadData leadData, string updateByUsername, DateTime updateDate)
        {
            var info = slmdb.kkslm_tr_cusinfo.Where(p => p.slm_TicketId.Equals(leadData.TicketId)).FirstOrDefault();

            if (info != null)
            {
                try
                {
                    string oldCitizenId = info.slm_CitizenId;
                    info.slm_LastName      = leadData.LastName;
                    info.slm_Email         = leadData.Email;
                    info.slm_TelNo_2       = leadData.TelNo_2;
                    info.slm_TelNo_3       = leadData.TelNo_3;
                    info.slm_Ext_2         = leadData.Ext_2;
                    info.slm_Ext_3         = leadData.Ext_3;
                    info.slm_BuildingName  = leadData.BuildingName;
                    info.slm_AddressNo     = leadData.AddressNo;
                    info.slm_Floor         = leadData.Floor;
                    info.slm_Soi           = leadData.Soi;
                    info.slm_Street        = leadData.Street;
                    info.slm_Tambon        = leadData.Tambon;
                    info.slm_Amphur        = leadData.Amphur;
                    info.slm_Province      = leadData.Province;
                    info.slm_PostalCode    = leadData.PostalCode;
                    info.slm_Occupation    = leadData.Occupation;
                    info.slm_BaseSalary    = leadData.BaseSalary;
                    info.slm_IsCustomer    = leadData.IsCustomer;
                    info.slm_CusCode       = leadData.CusCode;
                    info.slm_Birthdate     = leadData.Birthdate;
                    info.slm_CardType      = leadData.CardType;
                    info.slm_CitizenId     = string.IsNullOrEmpty(leadData.CitizenId) ? null : leadData.CitizenId;
                    info.slm_Topic         = leadData.Topic;
                    info.slm_Detail        = leadData.Detail;
                    info.slm_PathLink      = leadData.PathLink;
                    info.slm_ContactBranch = leadData.ContactBranch;
                    info.slm_UpdatedBy     = updateByUsername;
                    info.slm_UpdatedDate   = updateDate;

                    if (oldCitizenId != leadData.CitizenId)
                    {
                        KKSlmTrHistoryModel.InsertHistory(slmdb, leadData.TicketId, SLMConstant.HistoryTypeCode.UpdateCardId, oldCitizenId, leadData.CitizenId, updateByUsername, updateDate);
                    }

                    slmdb.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#3
0
        public void InsertPhoneCallHistory(string ticketId, string cardType, string cardId, string leadStatusCode, string oldstatus, string ownerBranch, string owner, string oldOwner, string delegateLeadBranch, string delegateLead, string oldDelegateLead, string contactPhone, string contactDetail, string createBy)
        {
            try
            {
                kkslm_tr_lead lead                = null;
                DateTime      createDate          = DateTime.Now;
                int?          createdByPositionId = null;
                int?          ownerPositionId     = null;

                var cusinfo = slmdb.kkslm_tr_cusinfo.Where(p => p.slm_TicketId == ticketId).FirstOrDefault();
                if (cusinfo != null)
                {
                    if (cardType != "")
                    {
                        cusinfo.slm_CardType = int.Parse(cardType);
                    }
                    else
                    {
                        cusinfo.slm_CardType = null;
                    }

                    string oldCitizenId = string.IsNullOrEmpty(cusinfo.slm_CitizenId) ? null : cusinfo.slm_CitizenId;
                    cusinfo.slm_CitizenId = cardId != "" ? cardId : null;

                    if (oldCitizenId != cusinfo.slm_CitizenId)
                    {
                        KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.UpdateCardId, oldCitizenId, cusinfo.slm_CitizenId, createBy, createDate);
                    }
                }

                kkslm_phone_call phone = new kkslm_phone_call();
                phone.slm_TicketId           = ticketId;
                phone.slm_ContactPhone       = contactPhone;
                phone.slm_ContactDetail      = contactDetail;
                phone.slm_Status             = leadStatusCode;
                phone.slm_Owner              = owner;
                ownerPositionId              = GetPositionId(owner);
                phone.slm_Owner_Position     = ownerPositionId;
                phone.slm_CreateDate         = createDate;
                phone.slm_CreateBy           = createBy;
                createdByPositionId          = GetPositionId(createBy);
                phone.slm_CreatedBy_Position = createdByPositionId;
                phone.is_Deleted             = 0;
                slmdb.kkslm_phone_call.AddObject(phone);

                if (lead == null)
                {
                    lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                }

                if (leadStatusCode != oldstatus)
                {
                    kkslm_tr_activity activity = new kkslm_tr_activity();
                    activity.slm_TicketId           = ticketId;
                    activity.slm_OldStatus          = oldstatus;
                    activity.slm_NewStatus          = leadStatusCode;
                    activity.slm_CreatedBy          = createBy;
                    activity.slm_CreatedBy_Position = createdByPositionId;
                    activity.slm_CreatedDate        = createDate;
                    activity.slm_Type           = SLMConstant.ActionType.ChangeStatus;       //02
                    activity.slm_SystemAction   = SLMConstant.SystemName;                    //System ที่เข้ามาทำ action (19/03/2015)
                    activity.slm_SystemActionBy = SLMConstant.SystemName;                    //action เกิดขึ้นที่ระบบอะไร (19/03/2015)

                    activity.slm_ExternalSystem_Old        = lead.slm_ExternalSystem;        //add 14/10/2015
                    activity.slm_ExternalStatus_Old        = lead.slm_ExternalStatus;        //add 14/10/2015
                    activity.slm_ExternalSubStatus_Old     = lead.slm_ExternalSubStatus;     //add 14/10/2015
                    activity.slm_ExternalSubStatusDesc_Old = lead.slm_ExternalSubStatusDesc; //add 14/10/2015

                    lead.slm_ExternalSystem        = null;                                   //add 14/10/2015
                    lead.slm_ExternalStatus        = null;                                   //add 14/10/2015
                    lead.slm_ExternalSubStatus     = null;                                   //add 14/10/2015
                    lead.slm_ExternalSubStatusDesc = null;                                   //add 14/10/2015

                    slmdb.kkslm_tr_activity.AddObject(activity);

                    if (lead == null)
                    {
                        lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                    }

                    if (lead != null)
                    {
                        lead.slm_Status      = leadStatusCode;
                        lead.slm_StatusBy    = createBy;
                        lead.slm_StatusDate  = createDate;
                        lead.slm_Counting    = 0;
                        lead.slm_UpdatedBy   = createBy;
                        lead.slm_UpdatedDate = createDate;
                    }

                    KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.UpdateStatus, oldstatus, leadStatusCode, createBy, createDate);
                }

                if (owner != oldOwner)
                {
                    kkslm_tr_activity activity = new kkslm_tr_activity();
                    activity.slm_TicketId = ticketId;
                    if (!string.IsNullOrEmpty(oldOwner))
                    {
                        activity.slm_OldOwner          = oldOwner;
                        activity.slm_OldOwner_Position = GetPositionId(oldOwner);
                    }
                    activity.slm_NewOwner           = owner;
                    activity.slm_NewOwner_Position  = ownerPositionId;
                    activity.slm_CreatedBy          = createBy;
                    activity.slm_CreatedBy_Position = createdByPositionId;
                    activity.slm_CreatedDate        = createDate;
                    activity.slm_Type           = SLMConstant.ActionType.ChangeOwner;
                    activity.slm_SystemAction   = SLMConstant.SystemName;      //System ที่เข้ามาทำ action (19/03/2015)
                    activity.slm_SystemActionBy = SLMConstant.SystemName;      //action เกิดขึ้นที่ระบบอะไร (19/03/2015)
                    slmdb.kkslm_tr_activity.AddObject(activity);

                    if (lead == null)
                    {
                        lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                    }

                    if (lead != null)
                    {
                        lead.slm_StaffId        = slmdb.kkslm_ms_staff.Where(p => p.slm_UserName == owner).Select(p => p.slm_StaffId).FirstOrDefault();
                        lead.slm_Owner          = owner;
                        lead.slm_Owner_Branch   = ownerBranch;
                        lead.slm_Owner_Position = ownerPositionId;
                        lead.slm_AssignedFlag   = "0";
                        lead.slm_AssignedDate   = null;
                        lead.slm_AssignedBy     = null;
                        lead.slm_OldOwner       = oldOwner;
                    }

                    KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.UpdateOwner, oldOwner, owner, createBy, createDate);
                }

                if (delegateLead != oldDelegateLead)
                {
                    kkslm_tr_activity activity = new kkslm_tr_activity();
                    activity.slm_TicketId = ticketId;
                    if (!string.IsNullOrEmpty(oldDelegateLead))
                    {
                        activity.slm_OldDelegate          = oldDelegateLead;
                        activity.slm_OldDelegate_Position = GetPositionId(oldDelegateLead);
                    }
                    activity.slm_NewDelegate          = delegateLead;
                    activity.slm_NewDelegate_Position = GetPositionId(delegateLead);
                    activity.slm_CreatedBy            = createBy;
                    activity.slm_CreatedBy_Position   = createdByPositionId;
                    activity.slm_CreatedDate          = createDate;
                    activity.slm_Type           = SLMConstant.ActionType.Delegate;
                    activity.slm_SystemAction   = SLMConstant.SystemName;      //System ที่เข้ามาทำ action (19/03/2015)
                    activity.slm_SystemActionBy = SLMConstant.SystemName;      //action เกิดขึ้นที่ระบบอะไร (19/03/2015)
                    slmdb.kkslm_tr_activity.AddObject(activity);

                    if (lead == null)
                    {
                        lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                    }

                    if (lead != null)
                    {
                        lead.slm_Delegate_Flag = string.IsNullOrEmpty(delegateLead) ? 0 : 1;
                        if (!string.IsNullOrEmpty(delegateLead))
                        {
                            lead.slm_DelegateDate = createDate;
                        }
                        else
                        {
                            lead.slm_DelegateDate = null;
                        }

                        lead.slm_Delegate          = string.IsNullOrEmpty(delegateLead) ? null : delegateLead;
                        lead.slm_Delegate_Branch   = string.IsNullOrEmpty(delegateLead) ? null : delegateLeadBranch;
                        lead.slm_Delegate_Position = string.IsNullOrEmpty(delegateLead) ? null : GetPositionId(delegateLead);
                    }

                    KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.UpdateDelegate, oldDelegateLead, delegateLead, createBy, createDate);
                }

                slmdb.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public void InsertNoteHistory(string ticketId, bool sendEmail, string emailSubject, string noteDetail, List <string> emailList, string createBy)
        {
            try
            {
                kkslm_prepare_email email = null;
                string     emailTemplate  = "";
                DateTime   createDate     = DateTime.Now;
                kkslm_note note           = new kkslm_note();
                note.slm_TicketId           = ticketId;
                note.slm_NoteDetail         = noteDetail;
                note.slm_CreateBy           = createBy;
                note.slm_CreatedBy_Position = GetPositionId(createBy);
                note.slm_CreateDate         = createDate;
                note.slm_SendEmailFlag      = sendEmail;

                if (sendEmail)
                {
                    note.slm_EmailSubject = emailSubject;
                    OwnerDelegateEmailData data = GetOwnerOrDelegateEmail(ticketId);
                    if (data != null)
                    {
                        if (data.Owner != null && !string.IsNullOrEmpty(data.OwnerEmail))
                        {
                            emailTemplate          = GetEmailTemplate(ticketId, noteDetail);
                            email                  = new kkslm_prepare_email();
                            email.slm_EmailAddress = data.OwnerEmail;
                            email.slm_EmailContent = emailTemplate;
                            email.slm_EmailSubject = emailSubject;
                            email.slm_EmailSender  = createBy;
                            email.slm_ticketId     = ticketId;
                            email.slm_ExportStatus = "0";
                            email.is_Deleted       = 0;
                            email.slm_CreatedBy    = createBy;
                            email.slm_CreatedDate  = createDate;
                            slmdb.kkslm_prepare_email.AddObject(email);
                        }
                        if (data.Delegate != null && !string.IsNullOrEmpty(data.DelegateEmail))
                        {
                            email = new kkslm_prepare_email();
                            email.slm_EmailAddress = data.DelegateEmail;
                            if (emailTemplate == "")
                            {
                                emailTemplate = GetEmailTemplate(ticketId, noteDetail);
                            }
                            email.slm_EmailContent = emailTemplate;
                            email.slm_EmailSubject = emailSubject;
                            email.slm_EmailSender  = createBy;
                            email.slm_ticketId     = ticketId;
                            email.slm_ExportStatus = "0";
                            email.is_Deleted       = 0;
                            email.slm_CreatedBy    = createBy;
                            email.slm_CreatedDate  = createDate;
                            slmdb.kkslm_prepare_email.AddObject(email);
                        }
                    }

                    foreach (string email_address in emailList)
                    {
                        kkslm_prepare_email prepare_eamil = new kkslm_prepare_email();
                        prepare_eamil.slm_EmailAddress = email_address;
                        if (emailTemplate == "")
                        {
                            emailTemplate = GetEmailTemplate(ticketId, noteDetail);
                        }
                        prepare_eamil.slm_EmailContent = emailTemplate;
                        prepare_eamil.slm_EmailSubject = emailSubject;
                        prepare_eamil.slm_EmailSender  = createBy;
                        prepare_eamil.slm_ticketId     = ticketId;
                        prepare_eamil.slm_ExportStatus = "0";
                        prepare_eamil.is_Deleted       = 0;
                        prepare_eamil.slm_CreatedBy    = createBy;
                        prepare_eamil.slm_CreatedDate  = createDate;
                        slmdb.kkslm_prepare_email.AddObject(prepare_eamil);
                    }
                }

                slmdb.kkslm_note.AddObject(note);

                var lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == ticketId).FirstOrDefault();
                if (lead != null)
                {
                    lead.slm_NoteFlag    = "1";
                    lead.slm_UpdatedBy   = createBy;
                    lead.slm_UpdatedDate = createDate;
                }

                KKSlmTrHistoryModel.InsertHistory(slmdb, ticketId, SLMConstant.HistoryTypeCode.InsertNote, "", "", createBy, createDate);

                slmdb.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }