public void WriteLogForEditResult(STT_RefResult newInfo, ELogAction action) { try { if (newInfo == null) { return; } bool isUpdated = false; MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT oldSTTInfo = new STTDao().GetById(newInfo.SttID); STT_RefResult oldInfo = new STTRefResultDao().GetById(newInfo.SttID); if ((oldSTTInfo != null) && (newInfo != null) && (logId != null)) { if (oldInfo.Remarks != newInfo.Remarks) { commonDao.InsertLogDetail(logId, "Remarks", "Remarks", oldInfo.Remarks, newInfo.Remarks); isUpdated = true; } if (oldInfo.Attachfile != newInfo.Attachfile) { //string[] arrayNew = newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX); //foreach (string fileNew in arrayNew) //{ // if (!oldInfo.Attachfile.Contains(fileNew)) // { // commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", "", fileNew); // isUpdated = true; // } //} string[] Attachfile = newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX); foreach (string item in oldInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX))//case delete file { if (!newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX).Contains(item)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", item, ""); isUpdated = true; } } foreach (string fileNew in Attachfile) //case add new file { if (!oldInfo.Attachfile.Contains(fileNew)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", "", fileNew); isUpdated = true; } } } if (oldInfo.ResultId != newInfo.ResultId) { if (newInfo.ResultId == Constants.STT_RESULT_FAIL) { isUpdated = true; commonDao.InsertLogDetail(logId, "ResultId", "Result", oldInfo.STT_Result.Name,new STTResultDao().GetById(newInfo.ResultId).Name); commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_REJECTED).Name); } if (newInfo.ResultId == Constants.STT_RESULT_PASS) { isUpdated = true; commonDao.InsertLogDetail(logId, "ResultId", "Result", oldInfo.STT_Result.Name, new STTResultDao().GetById(newInfo.ResultId).Name); commonDao.InsertLogDetail(logId, "STTStatusId", "Status", oldSTTInfo.STT_Status.Name, new STTStatusDao().GetById(Constants.STT_STATUS_NEED_TO_PROMOTED).Name); } } if (oldInfo.EndDate != newInfo.EndDate) { isUpdated = true; commonDao.InsertLogDetail(logId, "EndDate", "End Date", oldInfo.EndDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.EndDate.ToString(Constants.DATETIME_FORMAT_VIEW)); } // Insert Key Name if (isUpdated) { string key = oldSTTInfo.ID + " [" + oldSTTInfo.FirstName + " " + oldSTTInfo.MiddleName + " " + oldSTTInfo.LastName + "]"; commonDao.InsertLogDetail(logId, "STT_ID", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }
public void WriteLogForRemoveAttachFile(STT_RefResult newInfo, ELogAction action) { try { bool isUpdated = false; if (newInfo == null) { return; } MasterLog objMasterLog = new MasterLog(); string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.STT.ToString(), action.ToString()); STT_RefResult oldInfo = new STTRefResultDao().GetById(newInfo.SttID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { foreach (string item in oldInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX)) { if (!newInfo.Attachfile.TrimEnd(Constants.FILE_CHAR_PREFIX).Split(Constants.FILE_CHAR_PREFIX).Contains(item)) { commonDao.InsertLogDetail(logId, "AttachFile", "Attach File", item, ""); isUpdated = true; } } if (isUpdated) { // Insert Key Name STT obj = new STTDao().GetById(oldInfo.SttID); string key = oldInfo.SttID + " [" + obj.FirstName + " " + obj.MiddleName + " " + obj.LastName + "]"; commonDao.InsertLogDetail(logId, "STT_ID", "Key for Delete", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }