public CallHistoryListModel GetAllByContactId(int contactId, int employeeTypeId) { var list = CallHistoryRepository.GetAllByContactId(contactId, employeeTypeId) ?? new List <CallHistoryInfo>(); // Repear call var task = new Task(() => RepairCall(list.Where(c => !c.CallId.IsStringNullOrEmpty()) .Where(c => c.Duration.IsStringNullOrEmpty()))); //var task = new Task(() => RepairCall(list)); task.Start(); //list = list.Where(c => c.StatusMapId > 0).ToList(); list = list.ToList(); var model = new CallHistoryListModel { Rows = list, }; var second = model.Rows.ToList().Sum(c => ConvertHelper.ToInt32(c.Duration)); var strTime = second >= 60 ? (second / 60) + " phút, " + (second % 60) + " giây" : second + " giây"; model.UserData = new List <string> { "Tổng số lượng gọi: " + model.Rows.Count(c => !string.IsNullOrEmpty(c.CallId)) + " cuộc", "Tổng thời gian gọi: " + strTime, }; return(model); }
public static T Create <T>(ContactInfo info) where T : BCModelContact { var objModel = Activator.CreateInstance(typeof(T)) as BCModelContact; if (objModel == null) { return(default(T)); } objModel.Id = info.Id; objModel.Code = info.Code; objModel.Email = info.Email; objModel.Location = info.Address; objModel.Fullname = info.Fullname; objModel.Level = Enum.GetName(typeof(LevelType), info.LevelId); objModel.SourceType = Enum.GetName(typeof(SourceType), info.TypeId); objModel.HandoverDate = info.HandoverConsultantDate != null ? info.HandoverConsultantDate.Value.ToString("dd/MM/yyyy") : string.Empty; objModel.HandoverDistributorDate = info.HandoverCollaboratorDate != null ? info.HandoverCollaboratorDate.Value.ToString("dd/MM/yyyy") : info.RegisteredDate != null?info.RegisteredDate.Value.ToString("dd/MM/yyyy") : string.Empty; // Phone var phones = PhoneRepository.GetByContact(info.Id); if (phones != null) { var phoneEntity = phones.FirstOrDefault(phone => phone.IsPrimary > 0) ?? phones.FirstOrDefault(); if (phoneEntity != null) { objModel.Mobile = phoneEntity.PhoneNumber; } } // StatusCare var statusCare = StatusCareRepository.GetAll().FirstOrDefault(c => c.Id == info.StatusCareConsultantId); if (statusCare != null) { objModel.StatusCare = statusCare.Name; } // StatusMap var statusMap = StatusMapRepository.GetAll().FirstOrDefault(c => c.Id == info.StatusMapConsultantId) ?? StatusMapRepository.GetInfo(info.StatusMapConsultantId); if (statusMap != null) { objModel.StatusMap = statusMap.Name; } // Notes if (info.CallInfoConsultant.IsStringNullOrEmpty()) { var callHistories = CallHistoryRepository.GetAllByContactId(info.Id); if (!callHistories.IsNullOrEmpty()) { objModel.Notes = callHistories.Last().CallCenterInfo; } } else { objModel.Notes = info.CallInfoConsultant; } // Channel if (objModel.SourceType == Enum.GetName(typeof(SourceType), Core.SourceType.MO)) { var channel = ChannelRepository.GetAll().FirstOrDefault(c => c.ChannelId == info.ChannelId) ?? ChannelRepository.GetInfo(info.ChannelId); if (channel != null) { objModel.Channel = channel.Name; } } else if (objModel.SourceType == Enum.GetName(typeof(SourceType), Core.SourceType.CC)) { if (info.UserCollaboratorId > 0) { var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId); if (user != null) { objModel.Channel = user.FullName; } } } else { if (info.ChannelId == 1) { if (info.UserCollaboratorId > 0) { var user = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserCollaboratorId); if (user != null) { objModel.Channel = user.FullName; } } } if (objModel.Channel.IsStringNullOrEmpty()) { var channel = ChannelRepository.GetAll().FirstOrDefault(c => c.ChannelId == info.ChannelId) ?? ChannelRepository.GetInfo(info.ChannelId); if (channel != null) { objModel.Channel = channel.Name; } } } // Consultant var consultant = StoreData.ListUser.FirstOrDefault(c => c.UserID == info.UserConsultantId) ?? UserRepository.GetInfo(info.UserConsultantId); if (consultant != null) { objModel.Consultant = consultant.FullName; } return((T)objModel); }