コード例 #1
0
        public async void Run()
        {
            // Get new batch to check
            _isRunning = true;
            var newLeads = LeadMonitoringSevice.GetRequestedLeads();

            if (newLeads.Count == 0)
            {
                return;
            }
            var allLeads = new LeadCollection(newLeads);

            if (TelegramService.IsConnected && TelegramService.IsAuthorized)
            {
                TelegramService.VerifyNumbers(allLeads, LeadMonitoringSevice.GetNewRequests(newLeads));
                foreach (var lead in allLeads.Leads)
                {
                    if (LeadMonitoringSevice.LeadCachedCollection.TryGetLead(lead.Key, out Lead cachedLead))
                    {
                        lead.Value.IsTelegram   = cachedLead.IsTelegram;
                        lead.Value.IsViber      = cachedLead.IsViber;
                        lead.Value.IsWhatsApp   = cachedLead.IsWhatsApp;
                        lead.Value.TelegramUser = cachedLead.TelegramUser;
                    }
                }

                if (LeadMonitoringSevice.SendResponce(allLeads))
                {
                    // TODO: logger
                    LeadMonitoringSevice.Cache(allLeads.Leads.Values.ToList());
                }
            }

            _isRunning = false;
        }
コード例 #2
0
 public Services(Settings settings, TelegramSettings telegramSettings)
 {
     LeadMonitoringSevice = new LeadMonitoringSevice(settings);
     TelegramService      = new TelegramService(telegramSettings, LeadMonitoringSevice);
     Settings             = settings;
     SerilogSetup();
     Reset();
 }