Esempio n. 1
0
        private async Task <Dictionary <DateTime, List <DecklistWithName> > > _getUnzippedDecklists()
        {
            var unzippedDecklists = new Dictionary <DateTime, List <DecklistWithName> >();
            var listOfDecklists   = _fTPDownloader
                                    .DownloadListOfFilesFromFTP(_adminConfig.ServerDataEndpointURL + "/decks_saves/");
            AnalysisMetadata metaData = _getMetaData();

            DateTime dateOfNewestDecklistPack = metaData.LastDecklistsPackDate;

            foreach (string decklistZipName in listOfDecklists)
            {
                DateTime dateOfDecklistsPack = DateTime.ParseExact(_extractDate(decklistZipName, "decks_save_"),
                                                                   "dd MM yy",
                                                                   CultureInfo.InvariantCulture);
                if (dateOfDecklistsPack > metaData.LastDecklistsPackDate)
                {
                    string pathToDecklistsZip = await _fTPDownloader
                                                .DownloadDeckFromFTP(_adminConfig.ServerDataEndpointURL + "/decks_saves/" + decklistZipName);

                    if (dateOfDecklistsPack > dateOfNewestDecklistPack)
                    {
                        dateOfNewestDecklistPack = dateOfDecklistsPack;
                    }
                    unzippedDecklists.Add(
                        dateOfDecklistsPack,
                        _unzipper.GetDecksFromZip(pathToDecklistsZip)
                        );
                }
            }

            metaData.LastDecklistsPackDate = dateOfNewestDecklistPack;
            await _db.SaveChangesAsync();

            return(unzippedDecklists);
        }
Esempio n. 2
0
        private async Task <Dictionary <DateTime, List <DuelLog> > > _getConvertedDuelLogs()
        {
            var convertedDuelLogs                = new Dictionary <DateTime, List <DuelLog> >();
            var listOfDuelLogs                   = _fTPDownloader.DownloadListOfFilesFromFTP(_adminConfig.ServerDataEndpointURL + "/duel_logs/");
            AnalysisMetadata metaData            = _getMetaData();
            DateTime         dateOfNewestDuelLog = metaData.LastDuelLogDateAnalyzed;

            foreach (string duelLogName in listOfDuelLogs)
            {
                DateTime dateOfDuelLog = DateTime.ParseExact(
                    _extractDate(duelLogName, "duel_log"),
                    "dd MM yy",
                    CultureInfo.InvariantCulture);
                if (dateOfDuelLog > metaData.LastDuelLogDateAnalyzed)
                {
                    if (dateOfDuelLog > dateOfNewestDuelLog)
                    {
                        dateOfNewestDuelLog = dateOfDuelLog;
                    }
                    convertedDuelLogs.Add(
                        dateOfDuelLog,
                        await _getDuelLogs(duelLogName)
                        );
                }
            }

            metaData.LastDuelLogDateAnalyzed = dateOfNewestDuelLog;
            await _db.SaveChangesAsync();

            return(convertedDuelLogs);
        }
Esempio n. 3
0
        private AnalysisMetadata _getMetaData()
        {
            var metaData = _db.AnalysisMetadata.FirstOrDefault();

            if (metaData == null)
            {
                metaData = new AnalysisMetadata();
                _db.AnalysisMetadata.Add(metaData);
            }

            return(metaData);
        }