Пример #1
0
        public List <SaveResultData> InsertNewLeads(string ticketId, List <ProductData> productList, string username, string staffNameTH, string channelId, string channelDesc)
        {
            List <SaveResultData> resultList = new List <SaveResultData>();
            DateTime createdDate             = DateTime.Now;

            string               jobOnHand = "";
            KKSlmMsStaffModel    staff     = new KKSlmMsStaffModel();
            StaffAmountJobOnHand tmp       = staff.GetAmountJobOnHand(username);

            if (tmp != null)
            {
                jobOnHand = " (" + (tmp.AmountOwner + tmp.AmountDelegate).ToString() + " งาน)";
            }

            foreach (ProductData product in productList)
            {
                try
                {
                    SLM_DBEntities slmdb        = new SLM_DBEntities();
                    StoreProcedure store        = new StoreProcedure();
                    string         new_ticketId = store.GenerateTicketId();

                    KKSlmTrLeadModel lead = new KKSlmTrLeadModel(slmdb);
                    lead.InsertData(ticketId, new_ticketId, product, username, createdDate, channelId);

                    KKSlmTrCusInfoModel customerInfo = new KKSlmTrCusInfoModel(slmdb);
                    customerInfo.InsertData(ticketId, new_ticketId, username, createdDate);

                    KKSlmTrProductInfoModel productInfo = new KKSlmTrProductInfoModel(slmdb);
                    productInfo.InsertData(ticketId, new_ticketId, username, createdDate);

                    KKSlmTrChannelInfoModel channelInfo = new KKSlmTrChannelInfoModel(slmdb);
                    channelInfo.InsertData(ticketId, new_ticketId, username, createdDate, channelId);

                    KKSLMTrCampaignFinalModel camFinal = new KKSLMTrCampaignFinalModel(slmdb);
                    camFinal.InsertData(new_ticketId, product, username, createdDate);

                    KKSlmTrHistoryModel.InsertHistory(slmdb, new_ticketId, SLMConstant.HistoryTypeCode.CreateLead, "", "", username, createdDate);

                    slmdb.SaveChanges();

                    SaveResultData data = new SaveResultData()
                    {
                        TicketId     = new_ticketId,
                        CampaignName = product.CampaignName,
                        ChannelDesc  = channelDesc,
                        Ownername    = staffNameTH + jobOnHand
                    };
                    resultList.Add(data);
                }
                catch (Exception ex)
                {
                    _errList.Add(product.CampaignId, ex.Message);
                }
            }

            return(resultList);
        }
Пример #2
0
        //public bool InsertLeadData(LeadData leadData, List<CampaignWSData> camDataList, string createbyUsername)
        //{
        //    string ticketId = "";
        //    try
        //    {
        //        StoreProcedure store = new StoreProcedure();
        //        ticketId = store.GenerateTicketId();
        //        leadData.TicketId = ticketId;

        //        foreach (CampaignWSData cpdata in camDataList)
        //        {
        //            cpdata.TicketId = ticketId;
        //        }

        //        using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
        //        {
        //            KKSlmTrLeadModel lead = new KKSlmTrLeadModel();
        //            lead.InsertData(leadData, createbyUsername);

        //            KKSlmTrCusInfoModel customerInfo = new KKSlmTrCusInfoModel();
        //            customerInfo.InsertData(leadData, createbyUsername);

        //            KKSlmTrProductInfoModel productInfo = new KKSlmTrProductInfoModel();
        //            productInfo.InsertData(leadData, createbyUsername);

        //            KKSlmTrChannelInfoModel channelInfo = new KKSlmTrChannelInfoModel();
        //            channelInfo.InsertData(leadData, createbyUsername);

        //            KKSLMTrCampaignFinalModel camFinal = new KKSLMTrCampaignFinalModel();
        //            camFinal.InsertCampaignList(camDataList, createbyUsername);

        //            ts.Complete();
        //        }
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        _Error = ex.Message.ToString();
        //        return false;
        //    }
        //}

        public string InsertLeadSuggestCampaign(LeadData leadData, CampaignWSData cpdata, string createByUsername)
        {
            string ticketId = "";

            try
            {
                DateTime createDate = DateTime.Now;
                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    StoreProcedure store = new StoreProcedure();
                    ticketId          = store.GenerateTicketId();
                    leadData.TicketId = ticketId;
                    cpdata.TicketId   = ticketId;

                    List <ProductData> prodList = SlmScr016Biz.GetProductCampaignDataForSuggestCampaign(cpdata.CampaignId);
                    if (prodList.Count > 0)
                    {
                        leadData.ProductGroupId = prodList[0].ProductGroupId;
                        leadData.ProductId      = prodList[0].ProductId;
                        leadData.ProductName    = prodList[0].ProductName;
                    }

                    KKSlmTrLeadModel lead = new KKSlmTrLeadModel();
                    lead.InsertData(leadData, createByUsername, createDate);

                    KKSlmTrCusInfoModel customerInfo = new KKSlmTrCusInfoModel();
                    customerInfo.InsertData(leadData, createByUsername, createDate);

                    KKSlmTrProductInfoModel productInfo = new KKSlmTrProductInfoModel();
                    productInfo.InsertData(leadData, createByUsername);

                    KKSlmTrChannelInfoModel channelInfo = new KKSlmTrChannelInfoModel();
                    channelInfo.InsertData(leadData, createByUsername, createDate);

                    KKSLMTrCampaignFinalModel camFinal = new KKSLMTrCampaignFinalModel();
                    camFinal.InsertData(cpdata, createByUsername, createDate);

                    KKSlmTrHistoryModel history = new KKSlmTrHistoryModel();
                    history.InsertData(ticketId, SLMConstant.HistoryTypeCode.CreateLead, "", "", createByUsername, createDate);

                    ts.Complete();
                }
                return(ticketId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #3
0
        public static string InsertLeadData(LeadData leadData, CampaignWSData camData, string createbyUsername)
        {
            string ticketId = "";

            try
            {
                StoreProcedure store = new StoreProcedure();
                ticketId          = store.GenerateTicketId();
                leadData.TicketId = ticketId;
                camData.TicketId  = ticketId;

                DateTime createDate = DateTime.Now;

                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    KKSlmTrLeadModel lead = new KKSlmTrLeadModel();
                    lead.InsertData(leadData, createbyUsername, createDate);

                    KKSlmTrCusInfoModel customerInfo = new KKSlmTrCusInfoModel();
                    customerInfo.InsertData(leadData, createbyUsername, createDate);

                    KKSlmTrProductInfoModel productInfo = new KKSlmTrProductInfoModel();
                    productInfo.InsertData(leadData, createbyUsername);

                    KKSlmTrChannelInfoModel channelInfo = new KKSlmTrChannelInfoModel();
                    channelInfo.InsertData(leadData, createbyUsername, createDate);

                    KKSLMTrCampaignFinalModel camFinal = new KKSLMTrCampaignFinalModel();
                    camFinal.InsertData(camData, createbyUsername, createDate);

                    KKSlmTrHistoryModel history = new KKSlmTrHistoryModel();
                    history.InsertData(ticketId, SLMConstant.HistoryTypeCode.CreateLead, "", "", createbyUsername, createDate);

                    ts.Complete();
                }
                return(ticketId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }