public DateTime RetrieveLastDateJob(IConfiguration config)
        {
            DateTime dt = DateTime.MinValue;

            _log("retrieve last date");
            var roundEndDateMinutesValue = int.Parse(config.Get("RoundEndDateMintuesValue").ToString());
            var lastXDays = int.Parse(config.Get("LastXDays").ToString()) * -1;

            using (DWAuditLog context = new DWAuditLog())
            {
                var dateLast = context.Jobs.Take(1).OrderByDescending(j => j.EndDate).FirstOrDefault();
                if (dateLast == null)
                {
                    dt = DateTime.UtcNow.AddDays(lastXDays);
                    _log("dateLast is null then" + dt.ToString("yyyyMMdd hh:mm:ss"));
                }
                else
                {
                    dt = dateLast.EndDate;
                }

                roundEndDateMinutesValue = roundEndDateMinutesValue * -1;
                dt = dt.AddMinutes(roundEndDateMinutesValue);
                _log(" last date on db is " + dt.ToString("yyyyMMdd hh:mm:ss"));
            }
            _log("end last date" + dt.ToString("yyyyMMdd hh:mm:ss"));
            return(dt);
        }
 public int RemoveDuplicate()
 {
     _log("begin RemoveDuplicate ");
     using (DWAuditLog context = new DWAuditLog())
     {
         int countsDelsDup = context.RemoveDuplicate();
         _log("end RemoveDuplicate " + countsDelsDup.ToString());
         return(countsDelsDup);
     }
 }
 public void BulkAdd(IEnumerable <DataModel.AuditLogModel> entitiesLog)
 {
     _log("begin bulkadd " + entitiesLog.Count());
     using (DWAuditLog context = new DWAuditLog())
     {
         context.Configuration.AutoDetectChangesEnabled = false;
         context.Configuration.ValidateOnSaveEnabled    = false;
         context.Audits.AddRange(entitiesLog);
         context.SaveChanges();
     }
     _log("end bulkadd " + entitiesLog.Count());
 }
        public void UpdateEndDateOnComplete(int fieldsChangeCount, int countCrm, int?countCountDups, DateTime endDate)
        {
            _log("UpdateEndDateOnComplete fieldsChangeCount=" + fieldsChangeCount.ToString() + " countCrm=" + countCrm.ToString() + " enddate" + endDate.ToString("yyyyMMdd hh:mm:ss"));

            using (DWAuditLog context = new DWAuditLog())
            {
                Job job = new Job();
                job.JobId             = JobId;
                job.CountCrmLogs      = countCrm;
                job.CountFieldsChange = fieldsChangeCount;
                job.CountDuplicates   = countCountDups;
                job.EndDate           = endDate;
                context.Jobs.Add(job);
                context.SaveChanges();
            }
            _log("End UpdateEndDateOnComplete");
        }