public Result TCLCallInfoUpdate(string infomation) { // Logs var log = new TmpLogServiceInfo { Time = DateTime.Now, Description = infomation, CallType = (int)CallType.IncomingUpdate, }; if (string.IsNullOrEmpty(infomation)) { // Logs log.Status = 1; log.Description = "Thông tin cuộc gọi đến rỗng"; TmpLogServiceRepository.Create(log); // Return return(new Result { Code = (int)ErrorServiceType.NullOrEmpty, Description = "Thông tin cuộc gọi đến rỗng", }); } infomation = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><CallInforUpdate>" + infomation + "</CallInforUpdate>"; var callInfo = ObjectHelper.CreateObject <CallInforUpdate>(infomation); if (callInfo == null) { // Logs log.Status = 1; log.Description = "Thông tin cuộc gọi không đúng định dạng: " + infomation; TmpLogServiceRepository.Create(log); // Return return(new Result { Code = (int)ErrorServiceType.NotFormat, Description = "Thông tin cuộc gọi không đúng định dạng", }); } try { if (callInfo.station_id.IsStringNullOrEmpty()) { var arr = callInfo.agent_code.Split('/'); if (arr.Length > 1) { callInfo.station_id = arr[1]; } } callInfo.mobile_phone = callInfo.mobile_phone.Trim(); if (callInfo.mobile_phone.StartsWith("0")) { callInfo.mobile_phone = callInfo.mobile_phone.Substring(1); } var contactInfo = ContactRepository.GetByMobile(callInfo.mobile_phone); var callHitoryInfo = CallHistoryRepository.GetInfoIdentifyTcl(callInfo.call_id, (int)EmployeeType.Collaborator) ?? new CallHistoryInfo(); callHitoryInfo.CallTimeLength = 0; callHitoryInfo.CallTime = DateTime.Now; callHitoryInfo.Status = callInfo.status; callHitoryInfo.CallId = callInfo.call_id; callHitoryInfo.CreatedDate = DateTime.Now; callHitoryInfo.Duration = callInfo.duration; callHitoryInfo.RingTime = callInfo.ringtime; callHitoryInfo.CallCenterInfo = string.Empty; callHitoryInfo.StationId = callInfo.station_id; callHitoryInfo.AgentCode = callInfo.agent_code; callHitoryInfo.ErrorCode = callInfo.error_code; callHitoryInfo.ErrorDesc = callInfo.error_desc; callHitoryInfo.MessageCode = callInfo.message_code; callHitoryInfo.MobilePhone = callInfo.mobile_phone; callHitoryInfo.CallType = (int)CallType.IncomingUpdate; callHitoryInfo.StatusUpdate = contactInfo == null ? -1 : 2; callHitoryInfo.UserLogType = (int)EmployeeType.Collaborator; callHitoryInfo.LinkRecord = callInfo.link_down_record.IsStringNullOrEmpty() ? string.Empty : callInfo.link_down_record.Replace("/var/spool/asterisk/monitor/5678/", StoreData.LinkRecordTCL(contactInfo == null ? 0 : contactInfo.BranchId)); callHitoryInfo.EndTime = callInfo.end_time.ToDateTime("yyyyMMddHHmmss"); callHitoryInfo.StartTime = callInfo.start_time.ToDateTime("yyyyMMddHHmmss"); callHitoryInfo.ResponseTime = callInfo.datetime_response.ToDateTime("yyyyMMddHHmmss"); if (callHitoryInfo.ContactId.IsIntegerNull()) { callHitoryInfo.ContactId = contactInfo == null ? 0 : contactInfo.Id; } if (callHitoryInfo.LevelId.IsIntegerNull()) { callHitoryInfo.LevelId = contactInfo == null ? 0 : contactInfo.LevelId; } if (callHitoryInfo.CreatedBy.IsIntegerNull()) { callHitoryInfo.CreatedBy = contactInfo == null ? 0 : contactInfo.UserConsultantId; } if (callHitoryInfo.RecallTime == null) { callHitoryInfo.RecallTime = contactInfo == null ? null : contactInfo.AppointmentConsultantDate; } if (callHitoryInfo.StatusMapId.IsIntegerNull()) { callHitoryInfo.StatusMapId = contactInfo == null ? 0 : contactInfo.StatusMapConsultantId; } if (callHitoryInfo.StatusCareId.IsIntegerNull()) { callHitoryInfo.StatusCareId = contactInfo == null ? 0 : contactInfo.StatusCareConsultantId; } if (callHitoryInfo.CallCenterInfo.IsStringNullOrEmpty()) { callHitoryInfo.CallCenterInfo = contactInfo == null ? string.Empty : contactInfo.CallInfoConsultant; } CallHistoryRepository.Create(callHitoryInfo); // Logs log.Status = 0; log.Description = infomation + " ==> BranchId: " + (contactInfo == null ? 0 : contactInfo.BranchId); TmpLogServiceRepository.Create(log); // Return return(new Result { Code = (int)ErrorServiceType.Success, Description = "Cập nhật cuộc gọi đến thành công", }); } catch (Exception ex) { // Logs log.Status = 0; log.Description = ex + " ---- input" + infomation; TmpLogServiceRepository.Create(log); // Return return(new Result { Code = (int)ErrorServiceType.Exception, Description = "Cập nhật cuộc gọi đến không thành công, lỗi hệ thống", }); } }
public CallHistoryInfo Call(int id, string mobile) { #region "Log Checkpoint - Begin Goi Den CallCenter 28/10/2016" int SessionLog = TmpJobReportRepository.GetSessionLog(); DateTime TimeBegin = DateTime.Now; var logbegin = new LogDashBoard { Date = DateTime.Now.Date, Time = TimeBegin.ToString("dd/MM/yyyy HH:mm:ss:fff"), Name = "BEGIN_CALL_CONTACT_TVTS", ContactId = id, CreatedBy = UserContext.GetCurrentUser().UserID, Runtime = "0", Session = SessionLog, }; LogDashBoardRepository.CreateLogDashBoard(logbegin); #endregion if (string.IsNullOrEmpty(mobile)) { return(null); } var user = UserRepository.GetCurrentUserInfo(); // Logs var log = new TmpLogServiceInfo { Time = DateTime.Now, CallType = (int)CallType.Incoming, }; try { //var item = HelpUtils.Call(mobile, user.StationId, user.UserName, StoreData.CallCenterSoapBinding); var item = HelpUtils.CallNew(mobile, user.StationId, user.UserName, StoreData.LinkCallCenter); #region "Log Checkpoint - End Goi Den CallCenter 28/10/2016" DateTime TimeEnd = DateTime.Now; var logend = new LogDashBoard { Date = DateTime.Now.Date, Time = TimeEnd.ToString("dd/MM/yyyy HH:mm:ss:fff"), Name = "END_CALL_CONTACT_TVTS", ContactId = id, CreatedBy = UserContext.GetCurrentUser().UserID, Runtime = "0", Session = SessionLog, CallId = item.call_id }; LogDashBoardRepository.CreateLogDashBoard(logend); #endregion var entity = new CallHistoryInfo { ContactId = id, StatusMapId = 0, StatusUpdate = 1, StatusCareId = 0, CallHistoryId = 0, RecallTime = null, CallTimeLength = 0, Status = item.status, CallId = item.call_id, CreatedBy = user.UserID, CallTime = DateTime.Now, RingTime = item.ringtime, Duration = item.duration, CreatedDate = DateTime.Now, AgentCode = item.agent_code, ErrorCode = item.error_code, ErrorDesc = item.error_desc, StationId = item.station_id, CallCenterInfo = string.Empty, MessageCode = item.message_code, MobilePhone = item.mobile_phone, LinkRecord = item.link_down_record, EndTime = item.end_time.ToDateTime("yyyyMMddHHmmss"), StartTime = item.start_time.ToDateTime("yyyyMMddHHmmss"), ResponseTime = item.datetime_response.ToDateTime("yyyyMMddHHmmss"), LogCallCenter = item.log_callcenter }; entity.CallHistoryId = CallHistoryRepository.Create(entity); // Logs log.Description = entity.LogCallCenter; log.Status = 1; // ko lỗi TmpLogServiceRepository.Create(log); // Return return(entity); } catch (Exception ex) { // Logs log.Status = 0; //lỗi log.Description = "CallHistories/Call, Mobile: " + mobile + ": " + ex.Message.ToString(); TmpLogServiceRepository.Create(log); // Return return(null); } }
public ResultMissCall Incoming(string infomation) { // Logs var log = new TmpLogServiceInfo { Time = DateTime.Now, Description = infomation, CallType = (int)CallType.Incoming, }; if (string.IsNullOrEmpty(infomation)) { // Logs log.Status = 1; log.Description = "Thông tin cuộc gọi đến rỗng"; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.NullOrEmpty, Description = "Thông tin cuộc gọi đến rỗng", }); } infomation = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><CallInfor>" + infomation + "</CallInfor>"; var callInfo = ObjectHelper.CreateObject <CallInfor>(infomation); if (callInfo == null) { // Logs log.Status = 1; log.Description = "Thông tin cuộc gọi không đúng định dạng: " + infomation; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.NotFormat, Description = "Thông tin cuộc gọi không đúng định dạng", }); } try { callInfo.mobile_phone = callInfo.mobile_phone.Trim(); if (callInfo.mobile_phone.StartsWith("0")) { callInfo.mobile_phone = callInfo.mobile_phone.Substring(1); } var contactInfo = ContactRepository.GetByMobile(callInfo.mobile_phone); var entity = new CallHistoryInfo { // Info call CallTimeLength = 0, CallTime = DateTime.Now, Status = callInfo.status, CallId = callInfo.call_id, CreatedDate = DateTime.Now, Duration = callInfo.duration, RingTime = callInfo.ringtime, CallCenterInfo = string.Empty, StationId = callInfo.station_id, AgentCode = callInfo.agent_code, ErrorCode = callInfo.error_code, ErrorDesc = callInfo.error_desc, CallType = (int)CallType.Incoming, MessageCode = callInfo.message_code, MobilePhone = callInfo.mobile_phone, UserLogType = (int)EmployeeType.Consultant, StatusUpdate = contactInfo == null ? -1 : 2, LinkRecord = callInfo.link_down_record.IsStringNullOrEmpty() ? string.Empty : callInfo.link_down_record.Replace("/var/spool/asterisk/monitor", StoreData.LinkRecordCRM(contactInfo == null ? 0 : contactInfo.BranchId)), EndTime = callInfo.end_time.ToDateTime("yyyyMMddHHmmss"), StartTime = callInfo.start_time.ToDateTime("yyyyMMddHHmmss"), ResponseTime = callInfo.datetime_response.ToDateTime("yyyyMMddHHmmss"), // Info contact ContactId = contactInfo == null ? 0 : contactInfo.Id, LevelId = contactInfo == null ? 0 : contactInfo.LevelId, CreatedBy = contactInfo == null ? 0 : contactInfo.UserConsultantId, StatusMapId = contactInfo == null ? 0 : contactInfo.StatusMapConsultantId, StatusCareId = contactInfo == null ? 0 : contactInfo.StatusCareConsultantId, RecallTime = contactInfo == null ? null : contactInfo.AppointmentConsultantDate, }; CallHistoryRepository.Create(entity); // Logs log.Status = 0; log.Description = infomation + " ==> BranchId: " + (contactInfo == null ? 0 : contactInfo.BranchId); TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.Success, Description = "Cập nhật cuộc gọi đến thành công", }); } catch (Exception ex) { // Logs log.Status = 0; log.Description = ex + " ---- input" + infomation; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.Exception, Description = "Cập nhật cuộc gọi đến không thành công, lỗi hệ thống", }); } }