Esempio n. 1
0
        private async Task HandleDownloadedData(ServiceUser serviceUser, OldDataManager oldDataManager,
                                                AllegroDataContainer newData,
                                                AllegroDataContainer oldData, List <AllegroDataContainer> allUsersData)
        {
            oldDataManager.StoreData(newData);

            AllegroDataContainer consolidatedData =
                AllegroDataContainer.Consolidate(new List <AllegroDataContainer>()
            {
                newData, oldData
            });

            allUsersData.Add(consolidatedData);

            if (!processedUsers.Contains(serviceUser.UserName))
            {
                processedUsers.Add(serviceUser.UserName);
                this.logger.Info($"Processed user {serviceUser.UserName}");
                if (processedUsers.Count == this.config.Users.Count)
                {
                    allUsersCompletionCallback(allUsersData);
                }
                else
                {
                    this.currentUserIndex++;
                    await this.GetDataForUser();
                }
            }
        }
Esempio n. 2
0
        private async Task GetDataForUser()
        {
            ServiceUser          serviceUser    = this.config.Users[currentUserIndex];
            OldDataManager       oldDataManager = new OldDataManager(serviceUser, this.logger);
            AllegroDataContainer oldData        = oldDataManager.GetOldData();

            DateTime oldestEntryAdjusted = AdjustOldestEntryToDownloadBasedOnOldData(this.oldestEntryToDownload, oldData);

            await this.dataLoader.GetData(serviceUser, oldestEntryAdjusted, async newData
                                          => await HandleDownloadedData(serviceUser, oldDataManager, newData, oldData, allUsersData)
                                          );
        }