public static int Create(MissedCallInfo info) { return(DataProvider.Instance().MissedCall_Insert(info.UserId, info.ContactId, info.PhoneNumber, info.OldCallId, info.AgentCode, info.MissedCallTime, info.CreatedTime, info.Status)); }
public ResultMissCall MissCall(string infomation) { // Logs var log = new TmpLogServiceInfo { Time = DateTime.Now, Description = infomation, CallType = (int)CallType.MissCall, }; //" <dien_thoai></dien_thoai> <thoi_gian></thoi_gian> <call_id_truoc> </call_id_truoc> <agent_code></agent_code>. "; if (string.IsNullOrEmpty(infomation)) { // Logs log.Status = 1; log.Description = "Thông tin cuộc gọi nhỡ rỗng"; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.NullOrEmpty, Description = "Thông tin cuộc gọi nhỡ rỗng", }); } var rg = new Regex("<dien_thoai>(?<phone>.*?)</dien_thoai>.*?" + "<thoi_gian>(?<time>.*?)</thoi_gian>.*?" + "<call_id_truoc>(?<call_id>.*?)</call_id_truoc>.*?" + "<agent_code>(?<agent_code>.*?)</agent_code>"); var mt = rg.Match(infomation); if (!mt.Success) { // 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", }); } var phone = mt.Groups["phone"].Value; if (string.IsNullOrEmpty(phone)) { // Logs log.Status = 1; log.Description = "Số điện thoại rỗng:" + infomation; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Description = "Số điện thoại rỗng", Code = (int)ErrorServiceType.NullOrEmpty, }); } try { phone = phone.Trim(); if (phone.StartsWith("0")) { phone = phone.Substring(1); } var contactEntity = ContactRepository.GetByMobile(phone); var entity = new MissedCallInfo { PhoneNumber = phone, CreatedTime = DateTime.Now, OldCallId = mt.Groups["call_id"].Value, Status = contactEntity == null ? -1 : 1, AgentCode = mt.Groups["agent_code"].Value, ContactId = contactEntity == null ? 0 : contactEntity.Id, UserId = contactEntity == null ? 0 : contactEntity.UserConsultantId, MissedCallTime = mt.Groups["time"].Value.ToDateTime("yyyyMMddHHmmss") ?? DateTime.Now, }; entity.Id = MissedCallRepository.Create(entity); // Logs log.Status = 0; log.Description = infomation; TmpLogServiceRepository.Create(log); // Return return(new ResultMissCall { Code = (int)ErrorServiceType.Success, Description = "Cập nhật cuộc gọi nhỡ 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 nhỡ không thành công, lỗi hệ thống", }); } }