private IEnumerable <T> Process <T>(DWControleSocialContext dbContext, Microsoft.AspNetCore.Http.FormFile file, AddRangeObserver observer) where T : IFT_Staging <T> { var idSeedHistory = default(long); var rows = Enumerable.Empty <T>(); var hashs = new Dictionary <string, string>(); using (var fileStream = file.OpenReadStream()) { using (var md5 = new MD5CryptoServiceProvider()) { var hash = BitConverter.ToString(md5.ComputeHash(fileStream)) .Replace("-", string.Empty) .ToUpperInvariant(); var seedHistory = dbContext.SeedHistory.FirstOrDefault(o => o.Hash == hash); if (seedHistory == default) { seedHistory = new __SeedHistory { Arquivo = file.FileName, Hash = hash }; dbContext.Add(seedHistory); dbContext.SaveChanges(); } //else //{ // throw new InvalidOperationException("Este arquivo já foi carregado"); //} hashs.Add(file.FileName, hash); idSeedHistory = seedHistory.Id; } fileStream.Seek(0, SeekOrigin.Begin); rows = ParseCSV <T>(idSeedHistory, fileStream, observer); } return(rows); }
public DatabaseController(DWControleSocialContext dwControleSocialContext, ControleSocialContext controleSocialContext) { DWControleSocialContext = dwControleSocialContext; ControleSocialContext = controleSocialContext; }