private static void Bg_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (!((BackgroundWorker)sender).CancellationPending)
     {
         if (++updateContactsFromCRM % 12 == 0)
         {
             ContactCount += CrmRecordCounter.Execute("contact");
             var extraInfo =
                 $" (Info : {ContactCount} contacts enregistrés)";
             ConsoleHelper.DrawTextProgressBar(ProgressMessage + $" {extraInfo}", currentCount, expectedCount);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bgWorkerCrmCounter_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker = (BackgroundWorker)sender;

            if (worker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            int crmContactCount = CrmRecordCounter.Execute("contact");

            worker.ReportProgress(crmContactCount);
        }
        static void Main(string[] args)
        {
            PrintHeader();
            JobSettings      = new JobSettings();
            CrmRecordCounter = new CrmRecordCounter(JobSettings);

            // Pre-check -> Contacts in my CRM
            ConsoleHelper.Log("Nombre de contact dans mon CRM", withoutReturn: true);
            var previousCount = CrmRecordCounter.Execute("contact");

            System.Console.Write(previousCount);
            ConsoleHelper.Log("");

            var countContacts = AskForHowManyContacts();
            var contactLoader = new ContactLoader(countContacts, JobSettings.ServiceBusQueueKey);

            contactLoader.Run();
            ConsoleHelper.Log("Contacts chargés. Appuyez sur une touche pour quitter.", ConsoleHelper.LogStatus.Success);
            System.Console.ReadKey();
        }