예제 #1
0
        private static async Task MainAsync()
        {
            var fileReader  = new StreamReader(@"..\..\..\..\Data\my data\Takeout - 1\YouTube\history\search-history.html");
            var parseResult = await VideoSearchHistoryParser.ParseFile(fileReader.BaseStream).ConfigureAwait(false);

            if (parseResult == null)
            {
                return;
            }

            foreach (var item in parseResult)
            {
                System.Console.WriteLine($"{item.Key}: {item.Value}");
            }
        }
예제 #2
0
        private static async Task HandleVideoSearchHistoryAsync(Stream stream, Guid userId)
        {
            var wordResult = await VideoSearchHistoryParser.ParseFile(stream).ConfigureAwait(false);

            var models = wordResult.Select(i => new YoutubeSearchHistoryEntity
            {
                Id     = Guid.NewGuid(),
                Count  = i.Value,
                Word   = i.Key,
                UserId = userId
            }).ToArray();

            using (var unitOfWork = new UnitOfWork())
            {
                unitOfWork.YoutubeSearchHistoryRepository.DeleteForUser(userId);
                unitOfWork.YoutubeSearchHistoryRepository.InsertAll(models);
            }
        }