private void PaycomTask_OnRunLoop() { Log.Info("Starting Process to create punches for Paycom..."); PaycomAPIAdapter.SendPunchesToPaycom(); Log.Info("Updating LastRunFile..."); LastRecordedTime.UpdateLastRunFile(DateTime.UtcNow); Log.Info($"Running CsvTask at {DateTime.Now}"); IEnumerable <DutyStatusLog> geotabLogs = logcycle.LogRecordsToCompare(); IEnumerable <GeotabInfoModel> geotabInfo = logcycle.GetGeotabInfo(geotabLogs.ToList()); IEnumerable <PaycomInfoModel> paycomInfo = timeCardsUtility.CreatePaycomInfoModel(geotabInfo); IEnumerable <TimeCardModel> mismatchPunches = timeCardsUtility.CompareGeoToPay(paycomInfo, geotabInfo); //Create a new method for csvManip.ExportResultsToCsv(mismatchPunches); emailUtility.SendEmailWithCsvAttached(); }
// change to the one method above public IEnumerable <TimeCardModel> CreatePunches() { Log.MethodStart(); Log.Info("Creating log punches...."); List <DutyStatusLogType> bindLogTypes = new List <DutyStatusLogType>(); bindLogTypes.Add(DutyStatusLogType.D); bindLogTypes.Add(DutyStatusLogType.ON); bindLogTypes.Add(DutyStatusLogType.YM); bindLogTypes.Add(DutyStatusLogType.OFF); bindLogTypes.Add(DutyStatusLogType.SB); bindLogTypes.Add(DutyStatusLogType.PC); bindLogTypes.Add(DutyStatusLogType.WT); DutyStatusLogSearch logSearch = new DutyStatusLogSearch { FromDate = lastRunTime.ReadLastRunFile(), // last run datetime, store in a temp file to obtain this, a separate have window service create it. once ask finshes, update file with last run date (dattimenow). Create new class (potentially interface) for it, separate methods that grabs stores and update ToDate = DateTime.UtcNow, Statuses = bindLogTypes, IncludeBoundaryLogs = true }; Log.Info($"Logsearch for {logSearch.FromDate} to {logSearch.ToDate}..."); List <DutyStatusLog> listOfLogs = geotabCalls.GetLogList(logSearch).OrderBy(y => y.DateTime).OrderBy(x => x.Driver.Id).ToList(); Log.Info($"{listOfLogs.Count()} logs were found..."); List <GeotabInfoModel> listOfGeotabInfo = logcycle.GetGeotabInfo(listOfLogs).ToList(); //TODO: not duplicating the duty status log types List <TimeCardModel> punches = CreateTimeCard(listOfGeotabInfo); Log.MethodEnd(); return(punches); }