/// <summary> /// Write Update Log For Job Request /// </summary> /// <param name="newInfo"></param> /// <param name="logId"></param> /// <returns></returns> private bool WriteUpdateLogForJobRequest(JobRequest newInfo, string logId) { bool isUpdated = false; try { // Get old info JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFStatusID != oldInfo.WFStatusID) { if (newInfo.WFStatusID != 0) { commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name); isUpdated = true; } } if (newInfo.CCList != oldInfo.CCList) { commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.CCList, newInfo.CCList); isUpdated = true; } if (newInfo.RequestTypeId != oldInfo.RequestTypeId) { commonDao.InsertLogDetail(logId, "CCList", "CC List", oldInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace", newInfo.RequestTypeId == Constants.JR_REQUEST_TYPE_NEW ? "New":"Replace"); isUpdated = true; } if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { if (newInfo.WFResolutionID != 0) { WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID); if (objRes != null) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name); isUpdated = true; } } } if (newInfo.RequestDate != oldInfo.RequestDate) { commonDao.InsertLogDetail(logId, "RequestDate", "Request Date", oldInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW), newInfo.RequestDate.ToString(Constants.DATETIME_FORMAT_VIEW)); isUpdated = true; } if (newInfo.DepartmentId != oldInfo.DepartmentId) { Department objDepart = new DepartmentDao().GetById(newInfo.DepartmentId); if (objDepart != null) { commonDao.InsertLogDetail(logId, "DepartmentId", "Sub Department", oldInfo.Department.DepartmentName, objDepart.DepartmentName); commonDao.InsertLogDetail(logId, "Department", "Department", deptDao.GetDepartmentNameBySub(oldInfo.DepartmentId), deptDao.GetDepartmentNameBySub(newInfo.DepartmentId)); isUpdated = true; } } //if (newInfo.PositionFrom != oldInfo.PositionFrom) //{ // JobTitleLevel objJobFrom = new JobTitleLevelDao().GetById(newInfo.PositionFrom); // if (objJobFrom != null) // { // commonDao.InsertLogDetail(logId, "PositionFrom", "Position From", oldInfo.JobTitleLevel.DisplayName, objJobFrom.DisplayName); // isUpdated = true; // } //} //if (newInfo.PositionTo != oldInfo.PositionTo) //{ // if (newInfo.PositionTo.HasValue) // { // JobTitleLevel objJobTo = new JobTitleLevelDao().GetById(newInfo.PositionTo.Value); // if (objJobTo != null) // { // commonDao.InsertLogDetail(logId, "PositionTo", "Position To", oldInfo.PositionTo.HasValue?oldInfo.JobTitleLevel1.DisplayName:"", objJobTo.DisplayName); // isUpdated = true; // } // } //} string oldSalarySuggestionValue = string.IsNullOrEmpty(oldInfo.SalarySuggestion) ? null : EncryptUtil.Decrypt(oldInfo.SalarySuggestion); if (newInfo.SalarySuggestion != oldSalarySuggestionValue) { if (!string.IsNullOrEmpty(newInfo.SalarySuggestion)) { commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion, EncryptUtil.Encrypt(newInfo.SalarySuggestion)); isUpdated = true; } else { commonDao.InsertLogDetail(logId, "SalarySuggestion", "Salary Suggestion", oldInfo.SalarySuggestion,newInfo.SalarySuggestion); isUpdated = true; } } if (newInfo.AssignRole != oldInfo.AssignRole || newInfo.AssignID != oldInfo.AssignID) { if (newInfo.AssignRole.HasValue) { WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value); if (obj != null) { UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value); if (objUserAdmin != null) { commonDao.InsertLogDetail(logId, "AssignID", "Forward to", oldInfo.UserAdmin1.UserName + " ( " + oldInfo.WFRole.Name + " )", objUserAdmin.UserName + " ( " + obj.Name + " )"); isUpdated = true; } } } } if (isUpdated) { // Insert Key Name string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null); } } } catch (Exception ex) { throw ex; } return isUpdated; }
/// <summary> /// Write Update Log For When Role Manager /// </summary> /// <param name="newInfo"></param> /// <param name="logId"></param> /// <returns></returns> public void WriteUpdateLogForRoleManager(JobRequest newInfo,ELogAction action) { bool isUpdated = false; try { // Get old info string logId = commonDao.UniqueId; commonDao.InsertMasterLog(logId, newInfo.UpdatedBy, ELogTable.JobRequest.ToString(), action.ToString()); JobRequest oldInfo = new JobRequestDao().GetById(newInfo.ID); if ((oldInfo != null) && (newInfo != null) && (logId != null)) { if (newInfo.WFStatusID != oldInfo.WFStatusID) { commonDao.InsertLogDetail(logId, "WFStatusID", "Status", oldInfo.WFStatus.Name, new WFStatusDao().GetByID(newInfo.WFStatusID).Name); isUpdated = true; } if (newInfo.WFResolutionID != oldInfo.WFResolutionID) { WFResolution objRes = new ResolutionDao().GetByID(newInfo.WFResolutionID); if (objRes != null) { commonDao.InsertLogDetail(logId, "WFResolutionID", "Resolution", oldInfo.WFResolution.Name, objRes.Name); isUpdated = true; } } if (newInfo.AssignRole != oldInfo.AssignRole) { if (newInfo.AssignRole.HasValue) { WFRole obj = new RoleDao().GetByID(newInfo.AssignRole.Value); if (obj != null) { UserAdmin objUserAdmin = new UserAdminDao().GetById(newInfo.AssignID.Value); if (objUserAdmin != null) { commonDao.InsertLogDetail(logId, "AssignID", " Forward to", oldInfo.UserAdmin1.UserName + " (" + oldInfo.WFRole.Name + ")", objUserAdmin.UserName + " (" + obj.Name + ")"); isUpdated = true; } } } } if (isUpdated) { // Insert Key Name string key = Constants.JOB_REQUEST_PREFIX + oldInfo.ID.ToString(); commonDao.InsertLogDetail(logId, "EmployeeId", "Key for Update", key, null); } else { commonDao.DeleteMasterLog(logId); } } } catch (Exception ex) { throw ex; } }