Пример #1
0
 public SalesController(IUserSalesService userSalesService, IDataCache userSalesCache, IMemoryCache memoryCache, IFileService fileService)
 {
     _userSalesService = userSalesService;
     _userSalesCache   = userSalesCache;
     _userSalesCache.SetCache(memoryCache);
     _userSalesService.UseCache(_userSalesCache);
     _fileService = fileService;
     _fileService.UseCache(_userSalesCache);
 }
Пример #2
0
 public async Task ProcessAsync(List <Stream> files, IUserSalesService userSalesService)
 {
     userSalesService.UseCache(_userSalesCache);
     foreach (Stream file in files)
     {
         using (StreamReader reader = new StreamReader(file))
         {
             bool   isHeader = true;
             string line;
             while ((line = await reader.ReadLineAsync()) != null)
             {
                 if (isHeader)
                 {
                     isHeader = false;
                     userSalesService.SetHeader(line);
                 }
                 else
                 {
                     userSalesService.Record(line);
                 }
             }
         }
     }
 }