Exemplo n.º 1
0
        public void Execute()
        {
            int  packageIndex      = 1;
            int  allCustomers      = _oldNiisDictionaryService.GetDicCustomersCount();
            int  customersCommited = _newNiisDictionaryService.GetDicCustomersCount();
            int  customersCount    = allCustomers - customersCommited;
            bool isStop            = false;

            var stopwatch = Stopwatch.StartNew();

            while (!isStop)
            {
                ActionTransaction(() =>
                {
                    var lastId = _newNiisDictionaryService.GetLastDicCustomerId();
                    var(customers, customerAttorneyInfos) = _oldNiisDictionaryService.GetDicCustomersAndCustomerAttorneyInfos(_appConfiguration.BigPackageSize, lastId ?? 0);

                    if (!customers.Any())
                    {
                        isStop = true;
                        return;
                    }

                    _newNiisDictionaryService.CreateRangeDictionaries(customers);
                    _newNiisDictionaryService.CreateRangeCustomerAttorneyInfos(customerAttorneyInfos);

                    Console.Write($"\rCustomers commited - {packageIndex * _appConfiguration.BigPackageSize}/{customersCount}. Time elapsed: {stopwatch.Elapsed}");
                    packageIndex++;
                });
            }
        }