示例#1
0
 public WorkGroupController(ApplicationContext context,
                            IMyCallsAPIService myCallsApiService,
                            IMyCallsAPIServiceAstrics myCallsAPIServiceAstrics)
 {
     _context                  = context;
     _myCallsApiService        = myCallsApiService;
     _myCallsAPIServiceAstrics = myCallsAPIServiceAstrics;
 }
示例#2
0
 public ManagerController(IManagerService managerService,
                          IClientService clientService,
                          IMyCallsAPIService myCallsApiService)
 {
     _managerService    = managerService;
     _myCallsApiService = myCallsApiService;
     _clientService     = clientService;
 }
示例#3
0
 public ClientController(ApplicationContext context,
                         IAccountInformationService accountInformationService,
                         IMyCallsAPIService myCallsApiService,
                         IMyCallsAPIServiceAstrics myCallsAPIServiceAstrics)
 {
     _context = context;
     _accountInformationService = accountInformationService;
     _myCallsApiService         = myCallsApiService;
     _myCallsAPIServiceAstrics  = myCallsAPIServiceAstrics;
 }
示例#4
0
 public MonthlyCallService(IMyCallsAPIService myCallsApiService,
                           IMemoryCache memoryCache)
 {
     _myCallsApiService = myCallsApiService;
     _memoryCache       = memoryCache;
 }
示例#5
0
        private void ReloadClientsCalls(string id)
        {
            _myCallsApiService        = new MyCallsAPIService(_context);
            _myCallsAPIServiceAstrics = new MyCallsAPIServiceAstrics(_context);
            _myCallsApiService.SaveNewCalls();
            _myCallsAPIServiceAstrics.SaveNewCalls();
            ClientInfo clientInfo = _context.Set <ClientInfo>().FirstOrDefault(c => c.OneCId.ToString() == id);

            var managersPhone = _context.Set <Manager>()
                                .Select(x => new Manager()
            {
                Id    = x.Id,
                Phone = PhoneHelper.ConvertToPhone(x.Phone)
            }).ToList();

            var clientPhone = _context.Set <ClientPhone>()
                              .Where(c => c.ClientId == clientInfo.ClientId)
                              .Select(x => new
            {
                ClientId = x.ClientId,
                Phone    = x.Phone
            }).ToList();
            List <CallLog> callsLog = _context.Set <CallLog>().ToList();
            var            a        = callsLog.Where(x => (x.SrcNumber != "" && x.ClientNumber != "")
                ? managersPhone.Select(z => PhoneHelper.ConvertToPhone(z.Phone)).Contains(PhoneHelper.ConvertToPhone(x.SrcNumber)) &&
                                                     clientPhone.Select(z => PhoneHelper.ConvertToPhone(z.Phone)).Contains(PhoneHelper.ConvertToPhone(x.ClientNumber))
                : false).ToList();
            var dt             = new DateTime(1970, 1, 1);
            var clientContacts = new List <ClientContact>();
            var workGroups     = _context.Set <WorkGroup>().ToList();
            var calls          = new List <CallInfo>();
            List <CallClient>    callClients     = _context.Set <CallClient>().ToList();
            List <ClientContact> clientContacts1 = _context.Set <ClientContact>().ToList();

            foreach (var call in a)
            {
                try
                {
                    CallInfo callInfo = _context.Set <CallInfo>().FirstOrDefault(c => c.CallLogId == call.Id);
                    if (callInfo == null)
                    {
                        calls.Add(new CallInfo()
                        {
                            Call = new CallClient()
                            {
                                ClientId = clientPhone
                                           .FirstOrDefault(x => x.Phone.Contains(PhoneHelper.ConvertToPhone(call.ClientNumber))).ClientId,
                                ManagerId = managersPhone
                                            .FirstOrDefault(x => x.Phone.Contains(PhoneHelper.ConvertToPhone(call.SrcNumber))).Id,
                                Duration  = call.Duration,
                                Recording = call.Recording,
                                DateTime  = dt + TimeSpan.FromSeconds(call.StartTime),
                                Direction = call.Direction
                            },
                            CallLog = call
                        });
                    }
                }
                catch (Exception e)
                {
                }
            }
            _context.Set <CallInfo>()
            .AddRange(calls);
            _context.SaveChanges();
            foreach (var call in calls)
            {
                try
                {
                    var clientContact = new ClientContact(
                        new ClientContactCreate()
                    {
                        ClientId    = ((CallClient)call.Call).ClientId,
                        ContactType = ClientContactType.NoAcceptCall,
                        ManagerId   = ((CallClient)call.Call).ManagerId,
                        ManagerType = workGroups.FirstOrDefault(x => x.EscortManagerId == ((CallClient)call.Call).ManagerId) != null
                            ? ManagerType.EscortManager
                            : workGroups.FirstOrDefault(x => x.RegionalManagerId == ((CallClient)call.Call).ManagerId) != null
                                ? ManagerType.RegionalManager
                                : ManagerType.Undefined,
                    });
                    clientContact.Date      = dt + TimeSpan.FromSeconds(call.CallLog.StartTime);
                    clientContact.Direction = ((CallClient)call.Call).Direction;
                    clientContact.CallId    = call.Call.Id;
                    clientContacts.Add(clientContact);
                }
                catch (Exception e)
                {
                }
            }
            _context.Set <ClientContact>()
            .AddRange(clientContacts);
            _context.SaveChanges();
        }
示例#6
0
 public HomeController(IMyCallsAPIService myCallsApiService,
                       ApplicationContext context)
 {
     _myCallsApiService = myCallsApiService;
     _context           = context;
 }