Esempio n. 1
0
        private OutboundCallQueueViewModel OutboundCallQueueViewModel(CallQueueCustomer cqc, Customer customer, ProspectCustomer prospectCustomer, string email, PhoneNumber mobilePhoneNumber, PhoneNumber officePhoneNumber, Event theEvent, Host host, AddressViewModel eventLocation, string customTags)
        {
            var outboundModel = new OutboundCallQueueViewModel
            {
                CallQueueCustomerId = cqc.Id,
                ProspectCustomerId  = cqc.ProspectCustomerId,
                CustomerId          = cqc.CustomerId,
                FirstName           = customer != null ? customer.Name.FirstName : prospectCustomer.FirstName,
                MiddleName          = customer != null ? customer.Name.MiddleName : "",
                LastName            = customer != null ? customer.Name.LastName : prospectCustomer.LastName,
                Gender = customer != null ? customer.Gender : prospectCustomer.Gender,
                Email  = email,
                CallBackPhoneNumber = customer != null ? customer.HomePhoneNumber : prospectCustomer.CallBackPhoneNumber,
                MobilePhoneNumber   = mobilePhoneNumber,
                OfficePhoneNumber   = officePhoneNumber,
                DateOfBirth         = customer != null ? customer.DateOfBirth : prospectCustomer.BirthDate,
                CreatedOn           = cqc.DateCreated,
                ProspectCreatedOn   =
                    prospectCustomer != null && prospectCustomer.CreatedOn != DateTime.MinValue
                         ? prospectCustomer.CreatedOn
                         : (DateTime?)null,
                EventId                                                             = theEvent != null ? theEvent.Id : (long?)null,
                EventDate                                                           = theEvent != null ? theEvent.EventDate : (DateTime?)null,
                HostName                                                            = host != null ? host.OrganizationName : string.Empty,
                EventLocation                                                       = eventLocation,
                Tag                                                                 = prospectCustomer != null?prospectCustomer.Tag.GetDescription() : string.Empty,
                                                          ZipCode                   = customer != null ? customer.Address.ZipCode.Zip : prospectCustomer.Address.ZipCode.Zip,
                                                          IsDoNotCallCustomer       = (prospectCustomer != null && prospectCustomer.Status == (long)ProspectCustomerConversionStatus.Declined) || (customer != null && customer.DoNotContactTypeId.HasValue && (customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotContact || customer.DoNotContactTypeId.Value == (long)DoNotContactType.DoNotCall)), //customer.DoNotContactReasonId != null
                                                          RequestedCallBackDateTime = prospectCustomer != null && prospectCustomer.IsQueuedForCallBack ? prospectCustomer.CallBackRequestedDate : (DateTime?)null,
                                                          CustomCorporateTags       = customTags
            };

            return(outboundModel);
        }
Esempio n. 2
0
        public Notes RemoveFromQueue(CallQueueCustomer callQueueCustomer, Notes notes)
        {
            notes = ((IRepository <Notes>)_notesRepository).Save(notes);

            callQueueCustomer.NotesId = notes.Id;
            _callQueueCustomerRepository.Save(callQueueCustomer);
            return(notes);
        }
Esempio n. 3
0
        public ActionResult RegisterForEvent(long callQueueCustomerId, long eventId, long callId, long attemptId, bool isGmsCall = false, bool isViciCall = false, long previousEventId = 0)
        {
            var guid = Guid.NewGuid().ToString();
            CallQueueCustomer callQueueCustomer = null;
            long customerId         = 0;
            long prospectCustomerId = 0;
            long campaignId         = 0;

            if (callQueueCustomerId > 0)
            {
                callQueueCustomer  = _callQueueCustomerRepository.GetById(callQueueCustomerId);
                customerId         = callQueueCustomer.CustomerId.HasValue ? callQueueCustomer.CustomerId.Value : 0;
                prospectCustomerId = callQueueCustomer.ProspectCustomerId.HasValue ? callQueueCustomer.ProspectCustomerId.Value : 0;
                campaignId         = callQueueCustomer.CampaignId.HasValue ? callQueueCustomer.CampaignId.Value : 0;
            }
            else
            {
                var call = _callCenterCallRepository.GetById(callId);
                customerId = call.CalledCustomerId;
            }

            var registrationFlow = new RegistrationFlowModel
            {
                GuId                = guid,
                CallId              = callId,
                EventId             = eventId,
                CallQueueCustomerId = callQueueCustomerId,
                CustomerId          = customerId,
                ProspectCustomerId  = prospectCustomerId,
                CampaignId          = campaignId,
                AttempId            = attemptId,
                IsGmsCall           = isGmsCall,
                IsViciCall          = isViciCall
            };

            Session[guid] = registrationFlow;


            if (registrationFlow.CustomerId > 0)
            {
                if (previousEventId > 0)
                {
                    _eventCustomerQuestionAnswerService.UpdatePreQualifiedTestAnswers(customerId, eventId, previousEventId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
                }
                _callCenterCallRepository.UpdateCallCenterCallStatus(CallType.Existing_Customer.ToString().Replace("_", " "), callId);
                string redirectUrl = _settings.AppUrl + "/App/CallCenter/CallCenterRep/ExistingCustomer/ExistingCustomer.aspx?CustomerType=Existing&CustomerID=" + registrationFlow.CustomerId + "&guid=" + guid;
                Response.RedirectUser(redirectUrl);
                return(null);
            }
            if (registrationFlow.ProspectCustomerId > 0)
            {
                _callCenterCallRepository.UpdateCallCenterCallStatus(CallType.Register_New_Customer.ToString().Replace("_", " "), callId);
                string redirectUrl = _settings.AppUrl + "/App/CallCenter/CallCenterRep/ExistingCustomer/ExistingCustomer.aspx?CustomerType=New&guid=" + guid;
                Response.RedirectUser(redirectUrl);
                return(null);
            }
            return(null);
        }
Esempio n. 4
0
        public CallQueueCustomerLock GetCallQueueCustomerLock(CallQueueCustomer callqueueCustomer)
        {
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                var linqMetaData = new LinqMetaData(adapter);

                var callQueueLock = (from cqucl in linqMetaData.CallQueueCustomerLock
                                     where
                                     (cqucl.CustomerId == callqueueCustomer.CustomerId && cqucl.ProspectCustomerId == callqueueCustomer.ProspectCustomerId)
                                     select cqucl).FirstOrDefault();
                if (callQueueLock == null)
                {
                    return(null);
                }

                return(Mapper.Map <CallQueueCustomerLockEntity, CallQueueCustomerLock>(callQueueLock));
            }
        }
        private CallQueueCustomer SaveCallQueueCustomer(long callQueueId, CallUploadLog callUploadLog, long healthPlanId, List <CallQueueCustomer> callQueueCustomers)
        {
            if (callQueueCustomers.IsNullOrEmpty())
            {
                callQueueCustomers = new List <CallQueueCustomer>();
            }

            var existingCallQueueCustomer = callQueueCustomers.FirstOrDefault(x => x.CustomerId.HasValue && x.CustomerId.Value == callUploadLog.CustomerId);

            var callQueueCustomer = new CallQueueCustomer
            {
                CallQueueId  = callQueueId,
                CustomerId   = callUploadLog.CustomerId,
                HealthPlanId = healthPlanId
            };

            if (existingCallQueueCustomer == null)
            {
                callQueueCustomer.IsActive    = true;
                callQueueCustomer.Attempts    = 0;
                callQueueCustomer.DateCreated = callUploadLog.OutreachDateTime.Value;
                callQueueCustomer.Status      = CallQueueStatus.Initial;
                callQueueCustomer.CallDate    = callUploadLog.OutreachDateTime.Value;
            }
            else
            {
                callQueueCustomer.IsActive     = existingCallQueueCustomer.IsActive;
                callQueueCustomer.Attempts     = existingCallQueueCustomer.Attempts + 1;
                callQueueCustomer.DateCreated  = existingCallQueueCustomer.DateCreated;
                callQueueCustomer.DateModified = callUploadLog.OutreachDateTime.Value;
                callQueueCustomer.Status       = existingCallQueueCustomer.Status;
                callQueueCustomer.CallDate     = existingCallQueueCustomer.CallDate;
                callQueueCustomer.Id           = existingCallQueueCustomer.Id;
            }

            var newCallQueueCustomer = _callQueueCustomerRepository.Save(callQueueCustomer);

            if (existingCallQueueCustomer == null && !callQueueCustomers.IsNullOrEmpty())
            {
                callQueueCustomers.Add(newCallQueueCustomer);
            }

            return(newCallQueueCustomer);
        }
        public void SaveCallQueueCustomerForFillEvent(IEnumerable <CallQueueCustomer> callQueueCustomers, long criteriaId)
        {
            if (callQueueCustomers != null && callQueueCustomers.Any())
            {
                long?eventId = 0;
                List <CallQueueCustomer> existingCustomers = null;
                callQueueCustomers = callQueueCustomers.OrderBy(x => x.EventId);

                foreach (var callQueueCustomer in callQueueCustomers)
                {
                    if (eventId != callQueueCustomer.EventId)
                    {
                        existingCustomers = _callQueueCustomerRepository.GetCallQueueCustomerByEventId(callQueueCustomer.EventId.Value, callQueueCustomer.CallQueueId, _noofdaysToIncludeRemoved).ToList();
                        eventId           = callQueueCustomer.EventId;
                    }

                    var prospectId = callQueueCustomer.ProspectCustomerId.HasValue ? callQueueCustomer.ProspectCustomerId.Value : 0;
                    var customerId = callQueueCustomer.CustomerId.HasValue ? callQueueCustomer.CustomerId.Value : 0;
                    var cust       = existingCustomers.FirstOrDefault(cq => (cq.ProspectCustomerId == prospectId || cq.CustomerId == customerId));
                    CallQueueCustomer newCallQueueCustomer = null;
                    if (cust == null)
                    {
                        callQueueCustomer.IsActive    = true;
                        callQueueCustomer.Attempts    = 0;
                        callQueueCustomer.DateCreated = DateTime.Now;
                        callQueueCustomer.Status      = CallQueueStatus.Initial;
                        callQueueCustomer.CallDate    = DateTime.Now;
                        newCallQueueCustomer          = _callQueueCustomerRepository.Save(callQueueCustomer);

                        existingCustomers.Add(callQueueCustomer);
                    }
                    var callQueueCustomerId = cust != null ? cust.Id : 0;

                    if (callQueueCustomerId == 0 && newCallQueueCustomer != null)
                    {
                        callQueueCustomerId = newCallQueueCustomer.Id;
                    }
                    _systemGeneratedCallQueueAssignmentRepository.Save(new SystemGeneratedCallQueueAssignment {
                        CallQueueCustomerId = callQueueCustomerId, CallQueueId = callQueueCustomer.CallQueueId, CriteriaId = criteriaId
                    });
                }
            }
        }
Esempio n. 7
0
        public void SaveHealthPlanConfirmationCustomerCallQueue(CorporateAccount corporateAccount, HealthPlanCallQueueCriteria queueCriteria, CallQueue callQueue, ILogger logger)
        {
            try
            {
                logger.Info(string.Format("Starting confirmation call queue generation for HealthPlanId: {0} CallQueueId: {1} CriteriaId : {2}", corporateAccount.Id, callQueue.Id, queueCriteria.Id));

                var customersList = _customerRepository.GetHealthPlanConfirmationQueueCustomers(corporateAccount);

                if (!customersList.IsNullOrEmpty())
                {
                    var callQueueCustomerList = new List <CallQueueCustomer>();
                    foreach (var customer in customersList)
                    {
                        var appointmentTime   = customer.EventDate.Date.Add(customer.AppointmentTime.TimeOfDay);
                        var callQueueCustomer = new CallQueueCustomer
                        {
                            CallQueueId     = callQueue.Id,
                            CustomerId      = customer.CustomerId,
                            HealthPlanId    = corporateAccount.Id,
                            EventId         = customer.EventId,
                            EventCustomerId = customer.EventCustomerId,
                            AppointmentDate = appointmentTime,
                            AppointmentDateTimeWithTimeZone = _smsHelper.ConvertToServerTime(appointmentTime, customer.TimeZone, !SmsHelper.DaylightSavingNotApplicableStates.Contains(customer.StateCode))
                        };

                        callQueueCustomerList.Add(callQueueCustomer);
                    }

                    logger.Info(" Count " + callQueueCustomerList.Count());
                    _healthPlanCallQueueCustomerHelper.SaveCallQueueCustomersForConfirmation(callQueueCustomerList, corporateAccount.Id, queueCriteria.Id, callQueue.Id);
                }

                logger.Info(string.Format("Completed confirmation call queue generation for HealthPlanId: {0} CallQueueId: {1} CriteriaId : {2}", corporateAccount.Id, callQueue.Id, queueCriteria.Id));
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("Error generating confirmation queue for HealthPlanId: {0} CallQueueId: {1} CriteriaId : {2}", corporateAccount.Id, callQueue.Id, queueCriteria.Id));
                logger.Error(string.Format("Message : {0} \nStack Trace : {1}", ex.Message, ex.StackTrace));
            }
        }
Esempio n. 8
0
        public CallQueueCustomerNotesViewModel GetCustomerNotes(long callId, long callQueueCustomerId)
        {
            var callHistoryModel = new List <CallHistoryViewModel>();

            CallQueueCustomer callQueueCustomer = null;
            long customerId         = 0;
            long prospectCustomerId = 0;

            if (callQueueCustomerId > 0)
            {
                callQueueCustomer  = _callQueueCustomerRepository.GetById(callQueueCustomerId);
                customerId         = callQueueCustomer.CustomerId ?? 0;
                prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0;
            }
            else
            {
                var call = _callCenterCallRepository.GetById(callId);
                customerId = call != null ? call.CalledCustomerId : 0;
            }

            var calls = _callCenterCallRepository.GetCallsForCallQueueCustomer(callId, customerId, prospectCustomerId);

            if (calls != null && calls.Any())
            {
                var callCenterNotes = _callCenterNotesRepository.GetByCallIds(calls.Select(x => x.CallId));
                var agentNameIds    = _organizationRoleUserRepository.GetNameIdPairofUsers(calls.Select(x => x.CreatedByOrgRoleUserId).ToArray());

                var callHistoryList = new List <CallHistoryViewModel>();

                foreach (var customerCall in calls)
                {
                    var agentNameId = agentNameIds.First(c => c.FirstValue == customerCall.CreatedByOrgRoleUserId);

                    var dispositionValue = "N/A";

                    if (!string.IsNullOrEmpty(customerCall.Disposition))
                    {
                        ProspectCustomerTag disposition;
                        Enum.TryParse(customerCall.Disposition, out disposition);

                        if (Enum.IsDefined(typeof(ProspectCustomerTag), disposition))
                        {
                            dispositionValue = disposition.GetDescription();
                        }
                    }

                    var callHistory = new CallHistoryViewModel()
                    {
                        CallId              = customerCall.CallId,
                        DateCreated         = customerCall.CallDateTime,
                        CallOutcome         = ((CallStatus)customerCall.Status).GetDescription(),
                        RequestedCallBack   = callQueueCustomer != null ? callQueueCustomer.CallDate : (DateTime?)null,
                        CreatedBy           = agentNameId.SecondValue,
                        Disposition         = dispositionValue,
                        NotInterestedReason = customerCall.NotInterestedReasonId.HasValue ? ((NotInterestedReason)customerCall.NotInterestedReasonId).GetDescription() : "N/A"
                    };

                    if (callCenterNotes != null && callCenterNotes.Any())
                    {
                        var customerNotes = callCenterNotes.Where(ccn => ccn.CallId == customerCall.CallId).Select(ccn => ccn).ToArray();
                        callHistory.Notes = customerNotes.Select(cn => new NotesViewModel()
                        {
                            Note = cn.Notes, EnteredOn = cn.DateCreated
                        }).OrderByDescending(x => x.EnteredOn);
                    }

                    callHistoryList.Add(callHistory);
                }

                callHistoryModel.AddRange(callHistoryList.OrderByDescending(x => x.DateCreated).ToList());
            }
            var mailHistoryList = new List <DirectMailViewModel>();

            if (customerId > 0)
            {
                var directMails = _directMailRepository.GetByCustomerId(customerId);

                if (directMails != null && directMails.Any())
                {
                    var agentNameIds    = _organizationRoleUserRepository.GetNameIdPairofUsers(directMails.Select(x => x.Mailedby).ToArray());
                    var directMailTypes = _directMailTypeRepository.GetAll();

                    foreach (var directMail in directMails)
                    {
                        var agentNameId = agentNameIds.First(c => c.FirstValue == directMail.Mailedby);
                        var directMailSentToCustomer = "N/A";

                        if (directMail.DirectMailTypeId.HasValue)
                        {
                            directMailSentToCustomer = directMailTypes.Single(x => x.Id == directMail.DirectMailTypeId.Value).Name;
                        }
                        mailHistoryList.Add(new DirectMailViewModel()
                        {
                            DateCreated    = directMail.MailDate,
                            CreatedBy      = agentNameId.SecondValue,
                            DirectMailType = directMailSentToCustomer,
                            Notes          = directMail.IsInvalidAddress ? directMail.Notes : "N/A"
                        });
                    }
                }
            }

            var customerCallNotesViewModel = new List <CustomerCallNotesViewModel>();

            if (customerId > 0)
            {
                var customerCallNotes = _customerCallNotesRepository.GetCustomerNotes(customerId).ToList();

                var orders = _orderRepository.GetAllOrdersForCustomer(customerId);
                if (orders != null && orders.Count() > 0)
                {
                    var refundRequests = _refundRequestRepository.GeRefundRequestByOrderIds(orders.Select(oec => oec.Id).ToArray(), RefundRequestType.CustomerCancellation);

                    if (refundRequests != null && refundRequests.Count() > 0)
                    {
                        var refundRequestNotes = new List <CustomerCallNotes>();
                        foreach (var refundRequest in refundRequests)
                        {
                            refundRequestNotes.Add(new CustomerCallNotes
                            {
                                CustomerId           = customerId,
                                Notes                = refundRequest.Reason,
                                NotesType            = CustomerRegistrationNotesType.CancellationNote,
                                DataRecorderMetaData = new DataRecorderMetaData(refundRequest.RequestedByOrgRoleUserId, refundRequest.RequestedOn, null)
                            });
                        }
                        customerCallNotes = customerCallNotes.Concat(refundRequestNotes).ToList();
                    }
                }

                if (!customerCallNotes.IsNullOrEmpty())
                {
                    customerCallNotes = customerCallNotes.OrderByDescending(x => x.DataRecorderMetaData.DateCreated).ToList();
                    var orgRoleUserIds = customerCallNotes.Select(x => x.DataRecorderMetaData.DataRecorderCreator.Id).ToArray();
                    orgRoleUserIds = orgRoleUserIds.Distinct().ToArray();

                    var agentNameIds = _organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds);

                    customerCallNotesViewModel.AddRange(from notes in customerCallNotes
                                                        let createdBy = agentNameIds.First(x => x.FirstValue == notes.DataRecorderMetaData.DataRecorderCreator.Id).SecondValue
                                                                        select GetCustomerCallNotesViewModel(notes, createdBy));
                }
            }

            var notesViewModel = new CallQueueCustomerNotesViewModel
            {
                CallHistory       = callHistoryModel,
                CustomerCallNotes = customerCallNotesViewModel,
                DirectMail        = mailHistoryList
            };

            return(notesViewModel);
        }
Esempio n. 9
0
        public void SendCustomersOnCallQueue()
        {
            try
            {
                var callQueues = _callQueueRepository.GetAll().Where(x => x.IsActive && (x.IsQueueGenerated == false || (DateTime.Now >= (x.LastQueueGeneratedDate.HasValue ? x.LastQueueGeneratedDate.Value.AddMinutes(x.QueueGenerationInterval.Value) : DateTime.Now))));

                foreach (CallQueue queue in callQueues)
                {
                    var callAssignMents = _callQueueAssignmentRepository.GetByCallQueueId(queue.Id);

                    _callQueueCustomerRepository.DeleteForInActiveCallQueueCriteria(queue.Id);

                    var customerList = _outboundCallQueueService.GetCallQueueCustomers(queue);

                    //int callsToInsert = customerList.Count > 1000 ? 1000 : customerList.Count;//only this number of calls to be inserted at a time
                    if (!queue.IsQueueGenerated)
                    {
                        //var shortList = customerList.Take(callsToInsert);
                        //customerList = shortList.ToList();
                        _outboundCallQueueService.ChangeAssignmentOfExistingQueue(queue, callAssignMents);
                    }
                    int totalRecords = customerList.Count;

                    //assigning each call centre user with number of customer based on percentage
                    var callDivision = (from ca in callAssignMents
                                        let count = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalRecords * ca.Percentage) / 100))
                                                    select new
                    {
                        AssignedTo = ca.AssignedOrgRoleUserId,
                        callCount = count > 0 ? count : 1
                    }).ToList();
                    int startCount = 0;
                    for (int i = 0; i < callDivision.Count; i++)
                    {
                        int endCount = callDivision[i].callCount;

                        int thresholdCount = customerList.Count < (startCount + endCount) ? customerList.Count : (startCount + endCount);

                        for (int j = startCount; j < thresholdCount; j++)
                        {
                            CallQueueCustomer callQueueCustomer = customerList[j];

                            if (_callQueueCustomerRepository.IsCallQueueExist(queue.Id, callQueueCustomer.ProspectCustomerId.HasValue ? callQueueCustomer.ProspectCustomerId.Value : 0, callQueueCustomer.CustomerId.HasValue ? callQueueCustomer.CustomerId.Value : 0, callQueueCustomer.EventId, _settings.NoOfDaysToIncludeRemovedFromQueue))
                            {
                                continue;
                            }

                            callQueueCustomer.CallQueueId = queue.Id;

                            callQueueCustomer.IsActive                = true;
                            callQueueCustomer.Attempts                = 0;
                            callQueueCustomer.DateCreated             = DateTime.Now;
                            callQueueCustomer.Status                  = CallQueueStatus.Initial;
                            callQueueCustomer.AssignedToOrgRoleUserId = callDivision[i].AssignedTo;
                            callQueueCustomer.CallDate                = DateTime.Now;
                            _callQueueCustomerRepository.Save(callQueueCustomer);
                        }
                        //Once the quota for 1 user is complete next user will start from that
                        startCount = startCount + endCount;
                    }

                    queue.IsQueueGenerated       = true;
                    queue.LastQueueGeneratedDate = DateTime.Now;
                    _callQueueRepository.Save(queue);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
        }
 private void SaveCallQueueCustomerCall(CallQueueCustomer callQueueCustomer, Call call)
 {
     _callQueueCustomerCallRepository.Save(new CallQueueCustomerCall {
         CallId = call.Id, CallQueueCustomerId = callQueueCustomer.Id
     });
 }
        private CallQueueCustomer CreateCustomerCallQueueCustomerModel(CallQueueCustomer existingCallQueueCustomer, CallQueueCustomer callQueueCustomer, Customer customer,
                                                                       IEnumerable <Call> customerCalls, int callAttempts, Appointment futureAppointment, ProspectCustomer prospectCustomer, EventAppointmentCancellationLog eacl,
                                                                       bool isConfirmationCallQueue, CustomerEligibility customerEligibility, IEnumerable <EventCustomer> eventCustomers, CustomerTargeted customerTargeted)
        {
            var lastCall = (from cc in customerCalls
                            where cc.Status != (long)CallStatus.CallSkipped &&
                            (isConfirmationCallQueue == false || cc.CallQueueId == callQueueCustomer.CallQueueId)
                            orderby cc.DateCreated descending
                            select cc).FirstOrDefault();

            if (existingCallQueueCustomer == null)
            {
                existingCallQueueCustomer             = callQueueCustomer;
                existingCallQueueCustomer.DateCreated = DateTime.Now;
                existingCallQueueCustomer.CallDate    = DateTime.Now;
            }
            else
            {
                existingCallQueueCustomer.CallDate = DateTime.Now;
            }

            existingCallQueueCustomer.IsActive = true;
            existingCallQueueCustomer.Status   = CallQueueStatus.Initial;

            existingCallQueueCustomer.FirstName  = customer.Name.FirstName;
            existingCallQueueCustomer.LastName   = customer.Name.LastName;
            existingCallQueueCustomer.MiddleName = customer.Name.MiddleName;

            existingCallQueueCustomer.PhoneHome   = customer.HomePhoneNumber;
            existingCallQueueCustomer.PhoneCell   = customer.MobilePhoneNumber;
            existingCallQueueCustomer.PhoneOffice = customer.OfficePhoneNumber;

            existingCallQueueCustomer.ZipId     = customer.Address.ZipCode.Id;
            existingCallQueueCustomer.ZipCode   = customer.Address.ZipCode.Zip;
            existingCallQueueCustomer.Tag       = customer.Tag;
            existingCallQueueCustomer.IsEligble = customerEligibility != null ? customerEligibility.IsEligible : null;
            existingCallQueueCustomer.IsIncorrectPhoneNumber = customer.IsIncorrectPhoneNumber;
            existingCallQueueCustomer.IsLanguageBarrier      = customer.IsLanguageBarrier;
            existingCallQueueCustomer.ActivityId             = customer.ActivityId;
            existingCallQueueCustomer.DoNotContactTypeId     = customer.DoNotContactTypeId;
            existingCallQueueCustomer.DoNotContactUpdateDate = customer.DoNotContactUpdateDate;

            existingCallQueueCustomer.AppointmentDate = futureAppointment != null ? futureAppointment.StartTime : (DateTime?)null;
            existingCallQueueCustomer.NoShowDate      = futureAppointment == null ? (eventCustomers.Any() ? eventCustomers.OrderByDescending(x => x.NoShowDate).First().NoShowDate : null) : null;

            if (!isConfirmationCallQueue)
            {
                existingCallQueueCustomer.CallCount = customerCalls.Count(x => x.IsContacted.HasValue && x.IsContacted.Value);
                existingCallQueueCustomer.Attempts  = callAttempts;

                existingCallQueueCustomer.CallStatus  = lastCall != null ? lastCall.Status : (long?)null;
                existingCallQueueCustomer.Disposition = lastCall != null ? lastCall.Disposition : string.Empty;
            }
            //confirm call queue - called then registered for another event, and queue regenerated
            existingCallQueueCustomer.ContactedDate = lastCall != null ? lastCall.DateCreated : (DateTime?)null;

            existingCallQueueCustomer.CallBackRequestedDate = null;
            if (prospectCustomer != null && lastCall != null && lastCall.Status == (long)CallStatus.Attended && lastCall.Disposition == ProspectCustomerTag.CallBackLater.ToString())
            {
                existingCallQueueCustomer.CallBackRequestedDate = prospectCustomer.CallBackRequestedDate;
            }

            existingCallQueueCustomer.AppointmentCancellationDate = (DateTime?)null;
            if (eacl != null && (lastCall == null || lastCall.DateCreated < eacl.DateCreated))
            {
                existingCallQueueCustomer.AppointmentCancellationDate = eacl.DateCreated;
            }

            existingCallQueueCustomer.DoNotContactUpdateSource       = customer.DoNotContactUpdateSource;
            existingCallQueueCustomer.LanguageBarrierMarkedDate      = customer.LanguageBarrierMarkedDate;
            existingCallQueueCustomer.IncorrectPhoneNumberMarkedDate = customer.IncorrectPhoneNumberMarkedDate;
            existingCallQueueCustomer.LanguageId = customer.LanguageId;

            if (customerTargeted != null)
            {
                existingCallQueueCustomer.TargetedYear = customerTargeted.ForYear;
                existingCallQueueCustomer.IsTargeted   = customerTargeted.IsTargated;
            }

            existingCallQueueCustomer.ProductTypeId = customer.ProductTypeId;

            return(existingCallQueueCustomer);
        }
Esempio n. 12
0
        private void SetHistoryViewModelList(IEnumerable <CallQueueCustomerCallViewModel> callQueueCustomerCalls, IEnumerable <CallCenterNotes> callCenterNoteses, CallQueueCustomer cqc, OutboundCallQueueViewModel outboundModel)
        {
            if (callQueueCustomerCalls != null && callQueueCustomerCalls.Any())
            {
                var calls = callQueueCustomerCalls.Where(
                    cqcc => (cqc.CustomerId.HasValue && cqcc.CustomerId == cqc.CustomerId.Value) ||
                    (cqc.ProspectCustomerId.HasValue && cqcc.ProspectCustomerId == cqc.ProspectCustomerId.Value))
                            .Select(cqcc => cqcc).ToArray();

                if (calls.Any())
                {
                    calls = calls.OrderByDescending(x => x.CallDateTime).ToArray();
                    var callHistoryList = new List <CallHistoryViewModel>();
                    foreach (var customerCall in calls)
                    {
                        var callHistory = new CallHistoryViewModel()
                        {
                            CallId      = customerCall.CallId,
                            DateCreated = customerCall.CallDateTime
                        };

                        if (callCenterNoteses != null && callCenterNoteses.Any())
                        {
                            var customerNotes = callCenterNoteses.Where(ccn => ccn.CallId == customerCall.CallId).Select(ccn => ccn).ToArray();
                            callHistory.Notes = customerNotes.Select(cn => new NotesViewModel()
                            {
                                Note = cn.Notes, EnteredOn = cn.DateCreated
                            }).OrderByDescending(x => x.EnteredOn);
                        }

                        callHistoryList.Add(callHistory);
                    }

                    outboundModel.CallHistory = callHistoryList;
                }
            }
        }
        private CustomerCallQueueCallAttempt SetCustomerCallQueueAttempt(CallQueueCustomer callQueueCustomer)
        {
            try
            {
                var lockedCustomer = _callQueueCustomerLockRepository.GetCallQueueCustomerLock(callQueueCustomer);

                if (lockedCustomer != null)
                {
                    return(null);
                }

                var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(callQueueCustomer.CustomerId.Value);

                Customer customer = null;
                if (prospectCustomer == null)
                {
                    customer = _customerRepository.GetCustomer(callQueueCustomer.CustomerId.Value);
                }

                using (var scope = new TransactionScope())
                {
                    //lock customer in call queue so that other agent not be able to call them;
                    var domain = new CallQueueCustomerLock
                    {
                        CallQueueCustomerId = callQueueCustomer.Id,
                        CustomerId          = callQueueCustomer.CustomerId,
                        ProspectCustomerId  = callQueueCustomer.ProspectCustomerId,
                        CreatedBy           = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                        CreatedOn           = DateTime.Now
                    };

                    _callQueueCustomerLockRepository.SaveCallQueueCustomerLock(domain);                                     //Lock Customer

                    callQueueCustomer.Status                  = CallQueueStatus.InProcess;
                    callQueueCustomer.DateModified            = DateTime.Now;
                    callQueueCustomer.ModifiedByOrgRoleUserId = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId;

                    _callQueueCustomerRepository.Save(callQueueCustomer, false);                                                  //Update CallQueueCustomer Status



                    if (prospectCustomer == null && customer != null)
                    {
                        prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, false);
                        ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer);
                    }

                    var customerCallQueueCallAttempt = new CustomerCallQueueCallAttempt
                    {
                        DateCreated              = DateTime.Now,
                        IsCallSkipped            = false,
                        IsNotesReadAndUnderstood = false,
                        CreatedBy             = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId,
                        CustomerId            = callQueueCustomer.CustomerId.Value,
                        CallId                = null,
                        CallQueueCustomerId   = callQueueCustomer.Id,
                        NotInterestedReasonId = null
                    };

                    var callAttempt = _customerCallQueueCallAttemptRepository.Save(customerCallQueueCallAttempt);           //CustomerCallQueueCallAttempt Entry
                    scope.Complete();
                    return(callAttempt);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Some Error occured");
                _logger.Error("Message: " + ex.Message);
                _logger.Error("Stack Trace: " + ex.StackTrace);
            }
            return(null);
        }