Example #1
0
        private void CheckPhoneCallHistory(SLMDBEntities slmdb, kkslm_tr_lead lead, ExtSystemCurrentStatusData data)
        {
            try
            {
                if (!string.IsNullOrEmpty(data.StatusDesc))
                {
                    if (data.StatusDesc.Trim().Length > 4000)
                    {
                        throw new Exception("Field kkslm_ext_StatusDesc exceeds 4000 character limitation");
                    }

                    kkslm_phone_call pc = new kkslm_phone_call()
                    {
                        slm_TicketId           = lead.slm_ticketId,
                        slm_ContactDetail      = data.StatusDesc.Trim(),
                        slm_CreateBy           = "SYSTEM",
                        slm_CreatedBy_Position = null,
                        slm_CreateDate         = DateTime.Now,
                        slm_Status             = lead.slm_Status,
                        slm_Owner          = lead.slm_Owner,
                        slm_Owner_Position = lead.slm_Owner_Position,
                        slm_ContactPhone   = null,
                        is_Deleted         = 0
                    };
                    slmdb.kkslm_phone_call.AddObject(pc);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        //public static void UpdateStatusBackEnd(string batchCode)
        //{
        //    Int64 batchMonitorId = 0;
        //    int totalRecord = 0;
        //    int totalSuccess = 0;
        //    int totalFail = 0;
        //    int i = 1;
        //    int countCheck = GetCountCheck();
        //    int interval_second = (GetInterval() * 60) * 1000;
        //    bool success = false;

        //    try
        //    {
        //        while (i <= countCheck && success == false)
        //        {
        //            if (CheckViewReady())
        //            {
        //                batchMonitorId = BizUtil.SetStartTime(batchCode);

        //                var list = GetExtSystemCurrentStatusViewList();
        //                totalRecord = list.Count;

        //                foreach (ExtSystemCurrentStatusData data in list)
        //                {
        //                    try
        //                    {
        //                        SLMDBEntities slmdb = AppUtil.GetSlmDbEntities();
        //                        var lead = slmdb.kkslm_tr_lead.Where(p => p.slm_ticketId == data.TicketId && p.is_Deleted == 0).FirstOrDefault();
        //                        if (lead == null) { throw new Exception("Ticket Id " + data.TicketId + " not found in SLM"); }

        //                        CheckStatus(slmdb, lead, data);
        //                        slmdb.SaveChanges();

        //                        totalSuccess += 1;
        //                        Console.WriteLine("TicketId " + data.TicketId + ": SUCCESS");
        //                    }
        //                    catch (Exception ex)
        //                    {
        //                        totalFail += 1;
        //                        string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
        //                        string errorDetail = "TicketId=" + data.TicketId + ", Error=" + message;

        //                        BizUtil.InsertLog(batchMonitorId, data.TicketId, "", errorDetail);
        //                        Util.WriteLogFile(logfilename, batchCode, errorDetail);

        //                        Console.WriteLine("TicketId " + data.TicketId + ": FAIL");
        //                    }
        //                }

        //                BizUtil.SetEndTime(batchCode, batchMonitorId, AppConstant.Success, totalRecord, totalSuccess, totalFail);

        //                success = true;
        //            }
        //            else
        //            {
        //                System.Threading.Thread.Sleep(interval_second);
        //            }

        //            i += 1;
        //        }

        //        if (success == false)
        //        {
        //            batchMonitorId = BizUtil.SetStartTime(batchCode);
        //            BizUtil.SetEndTime(batchCode, batchMonitorId, AppConstant.Fail, totalRecord, totalSuccess, totalFail);

        //            BizUtil.InsertLog(batchMonitorId, "", "", "View v_kkslm_ext_sys_status is not ready");
        //            Util.WriteLogFile(logfilename, batchCode, "View v_kkslm_ext_sys_status is not ready");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine("All FAIL");
        //        string message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;

        //        Util.WriteLogFile(logfilename, batchCode, message);
        //        BizUtil.InsertLog(batchMonitorId, "", "", message);
        //        BizUtil.SetEndTime(batchCode, batchMonitorId, AppConstant.Fail, totalRecord, totalSuccess, totalFail);
        //        throw ex;
        //    }
        //}

        private void CheckStatus(SLMDBEntities slmdb, kkslm_tr_lead lead, ExtSystemCurrentStatusData data, string batchCode)
        {
            try
            {
                string newExternalSystem        = "";
                string newExternalStatus        = "";
                string newExternalSubStatus     = "";
                string newExternalSubStatusDesc = "";
                string oldExternalSystem        = "";
                string oldExternalStatus        = "";
                string oldExternalSubStatus     = "";
                string oldExternalSubStatusDesc = "";
                string slmOldStatus             = "";

                slmOldStatus             = lead.slm_Status;
                oldExternalSystem        = lead.slm_ExternalSystem;                                                              //add 15/10/2015
                oldExternalStatus        = lead.slm_ExternalStatus;                                                              //add 15/10/2015
                oldExternalSubStatus     = string.IsNullOrEmpty(lead.slm_ExternalSubStatus) ? null : lead.slm_ExternalSubStatus; //add 15/10/2015
                oldExternalSubStatusDesc = lead.slm_ExternalSubStatusDesc;                                                       //add 15/10/2015

                if (string.IsNullOrEmpty(data.StatusSystem))
                {
                    throw new Exception("System Name in view is null or blank");
                }

                string slmNewStatus = GetSlmStatusCode(slmdb, data.StatusSystem, data.StatusCode, data.SubStatusCode, lead.slm_Product_Id);
                if (slmNewStatus == "")
                {
                    throw new Exception("Cannot find slmStatusCode from the specified " + data.StatusSystem + " mapping statusCode=" + data.StatusCode + ", subStatusCode=" + data.SubStatusCode + ", slmProductId=" + lead.slm_Product_Id);
                }

                var statusBy_username = slmdb.kkslm_ms_staff.Where(p => p.slm_EmpCode == data.StatusBy && p.is_Deleted == 0).Select(p => p.slm_UserName).FirstOrDefault();

                //Change 15/10/2015
                newExternalSystem    = data.StatusSystem.Trim().ToUpper();
                newExternalStatus    = data.StatusCode;
                newExternalSubStatus = string.IsNullOrEmpty(data.SubStatusCode) ? null : data.SubStatusCode;

                if (!string.IsNullOrEmpty(data.StatusName) && !string.IsNullOrEmpty(data.SubStatusCode))
                {
                    newExternalSubStatusDesc = data.StatusName + " - " + data.SubStatusCode;
                }
                else if (!string.IsNullOrEmpty(data.StatusName))
                {
                    newExternalSubStatusDesc = data.StatusName;
                }
                else if (!string.IsNullOrEmpty(data.SubStatusCode))
                {
                    newExternalSubStatusDesc = data.SubStatusCode;
                }

                if (slmNewStatus != slmOldStatus || newExternalStatus != oldExternalStatus || newExternalSubStatus != oldExternalSubStatus || newExternalSystem != oldExternalSystem)
                {
                    DateTime updateDate = DateTime.Now;

                    kkslm_tr_activity activity = new kkslm_tr_activity()
                    {
                        slm_TicketId           = data.TicketId,
                        slm_OldStatus          = slmOldStatus,
                        slm_NewStatus          = slmNewStatus,
                        slm_CreatedBy          = "SYSTEM",
                        slm_CreatedBy_Position = null,
                        slm_CreatedDate        = updateDate,
                        slm_Type                      = "09",
                        slm_SystemAction              = data.StatusSystem.Trim().ToUpper(), //System ที่เข้ามาทำ action (19/03/2015)
                        slm_SystemActionBy            = "SLM",                              //action เกิดขึ้นที่ระบบอะไร (19/03/2015)
                        slm_ExternalSystem_Old        = oldExternalSystem,                  //add 15/10/2015
                        slm_ExternalStatus_Old        = oldExternalStatus,                  //add 15/10/2015
                        slm_ExternalSubStatus_Old     = oldExternalSubStatus,               //add 15/10/2015
                        slm_ExternalSubStatusDesc_Old = oldExternalSubStatusDesc,           //add 15/10/2015
                        slm_ExternalSystem_New        = newExternalSystem,                  //add 15/10/2015
                        slm_ExternalStatus_New        = newExternalStatus,                  //add 15/10/2015
                        slm_ExternalSubStatus_New     = newExternalSubStatus,               //add 15/10/2015
                        slm_ExternalSubStatusDesc_New = newExternalSubStatusDesc            //add 15/10/2015
                    };
                    slmdb.kkslm_tr_activity.AddObject(activity);

                    AppUtil.CalculateTotalSLA(slmdb, lead, activity, data.StatusDate.Value, logfilename, batchCode);           //add 25/03/2016
                    lead.slm_Status           = slmNewStatus;
                    lead.slm_StatusBy         = (!string.IsNullOrEmpty(statusBy_username) ? statusBy_username : data.StatusBy);
                    lead.slm_StatusDate       = data.StatusDate;
                    lead.slm_StatusDateSource = data.StatusDate;
                    lead.slm_Counting         = 0;
                    lead.slm_UpdatedBy        = "SYSTEM";
                    lead.slm_UpdatedDate      = updateDate;

                    lead.slm_ExternalSystem        = newExternalSystem;
                    lead.slm_ExternalStatus        = newExternalStatus;
                    lead.slm_ExternalSubStatus     = newExternalSubStatus;
                    lead.slm_ExternalSubStatusDesc = newExternalSubStatusDesc;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }