public static void Update(JobLog obj) { repository.Update(obj); }
public string AddLogAndExcuteJob(JobLogEnum key, bool status, DateTime?dateLog) { string message = ""; if (!dateLog.HasValue) { dateLog = DateTime.Now.Date; } bool sendMailFlag = false; JobLog jobLog = _jobLogRepository.GetSingleByCondition(x => x.Date == dateLog); if (jobLog != null) { // Update switch (key) { case JobLogEnum.ImportTimeSheet: if (jobLog.ImportTimeSheet) { return("Job Import TimeSheet Had Done(" + dateLog.Value.ToShortDateString() + "). Dont Need Excute Again!"); } jobLog.ImportTimeSheet = _scheduleService.ImportTimeSheet(out message, dateLog.Value); sendMailFlag = !jobLog.ImportTimeSheet; _jobLogRepository.Update(jobLog); break; case JobLogEnum.ChangeStatus: if (jobLog.ChangeStatus) { return("Job Change Status Had Done(" + dateLog.Value.ToShortDateString() + "). Dont Need Excute Again!"); } jobLog.ChangeStatus = _scheduleService.JobChangeStatus(out message); sendMailFlag = !jobLog.ChangeStatus; _jobLogRepository.Update(jobLog); break; case JobLogEnum.UpdateEntitleDay: if (jobLog.UpdateEntitleDay) { return("Job Update Entitle Day Had Done(" + dateLog.Value.ToShortDateString() + "). Dont Need Excute Again!"); } jobLog.UpdateEntitleDay = _scheduleService.JobUpdateEntitleDayByRequest(out message, dateLog.Value); sendMailFlag = !jobLog.UpdateEntitleDay; _jobLogRepository.Update(jobLog); break; case JobLogEnum.ResetEntitleDay: if (jobLog.ResetEntitleDay) { return("Job Reset Entitle Day Had Done(" + dateLog.Value.ToShortDateString() + "). Dont Need Excute Again!"); } jobLog.ResetEntitleDay = _scheduleService.JobEntitleDay(out message, dateLog.Value); sendMailFlag = !jobLog.ResetEntitleDay; _jobLogRepository.Update(jobLog); break; } } else { // Insert switch (key) { case JobLogEnum.ImportTimeSheet: _jobLogRepository.Add(InitJobLogAndExcuteJob(JobLogEnum.ImportTimeSheet, status, dateLog.Value, ref message, ref sendMailFlag)); break; case JobLogEnum.ChangeStatus: _jobLogRepository.Add(InitJobLogAndExcuteJob(JobLogEnum.ChangeStatus, status, dateLog.Value, ref message, ref sendMailFlag)); break; case JobLogEnum.UpdateEntitleDay: _jobLogRepository.Add(InitJobLogAndExcuteJob(JobLogEnum.UpdateEntitleDay, status, dateLog.Value, ref message, ref sendMailFlag)); break; case JobLogEnum.ResetEntitleDay: _jobLogRepository.Add(InitJobLogAndExcuteJob(JobLogEnum.ResetEntitleDay, status, dateLog.Value, ref message, ref sendMailFlag)); break; } } _unitOfWork.Commit(); if (sendMailFlag) { SendMailJob(key, dateLog.Value); } return(message); }