private static void CalculateMoE(DateTime?moeLastDateXbox, DateTime?moeLastDatePs, DbProvider provider, DbRecorder recorder, MailSender mailSender, string resultDirectoryXbox, string resultDirectoryPs, FtpPutter ftpPutterXbox, FtpPutter ftpPutterPs, int utcShiftToCalculate) { var csw = Stopwatch.StartNew(); recorder.CalculateMoE(utcShiftToCalculate); csw.Stop(); Log.Debug($"Cálculo das MoE feito em {csw.Elapsed.TotalSeconds:N0}."); if (csw.Elapsed.TotalMinutes > 1) { mailSender.Send("Cálculo das MoE", $"Cálculo das MoE feito em {csw.Elapsed.TotalSeconds:N0}."); } if (moeLastDateXbox.HasValue) { PutMoEOnPlataform(Platform.XBOX, moeLastDateXbox, provider, mailSender, resultDirectoryXbox, ftpPutterXbox); } if (moeLastDatePs.HasValue) { PutMoEOnPlataform(Platform.PS, moeLastDatePs, provider, mailSender, resultDirectoryPs, ftpPutterPs); } }
public ValueTask ExecuteAsync(IConsole console) { Log.Info($"Starting {nameof(CalculateMoe)}..."); var csw = Stopwatch.StartNew(); _recorder.CalculateMoE(UtcShiftToCalculate); csw.Stop(); Log.Debug($"MoEs calculated in {csw.Elapsed.TotalSeconds:N0}s."); // Get the last one to see of there's the need to upload to the remote site var siteDiagnostic = _fetcher.GetSiteDiagnostic(); var lastOnSite = siteDiagnostic.TanksMoELastDate; Log.Info($"Last MoEs on site: {lastOnSite:yyyy-MM-dd}"); var dbDate = _provider.GetMoe().First().Date; Log.DebugFormat("MoEs on Database: {0:yyyy-MM-dd}", dbDate); var date = lastOnSite.AddDays(1); while (date <= dbDate) { Log.InfoFormat("Doing upload for {0:yyyy-MM-dd}...", date); var tankMarks = _provider.GetMoe(date).ToDictionary(t => t.TankId); if (tankMarks.Count > 0) { if (!_putter.Put(date, tankMarks)) { Log.Error($"Couldn't upload MoE file!"); } } else { Log.Error($"There are 0 tanks with calculated MoEs in {date:yyyy-MM-dd}!"); } date = date.AddDays(1); } console.Output.WriteLine("Done!"); Log.Info($"Done {nameof(CalculateMoe)}."); return(default);