Esempio n. 1
0
        /// <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;
        }
Esempio n. 2
0
        /// <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;
            }
        }
Esempio n. 3
0
 public List<ListItem> GetListWithRole(int roleId)
 {
     var list = GetListByRole(roleId);
     RoleDao roleDao = new RoleDao();
     List<ListItem> result = new List<ListItem>();
     foreach (var item in list)
     {
         result.Add(new ListItem(
             item.UserName + "(" + roleDao.GetByID(roleId).Name + ")",
             item.UserAdminId + Constants.SEPARATE_USER_ADMIN_ID_STRING + roleId));
     }
     return result;
 }
Esempio n. 4
0
        private bool WriteUpdateLogForWorkflowAdmin(UserAdmin_WFRole newInfo, string logId)
        {
            bool isUpdated = false;
            try
            {
                // Get old info
                UserAdmin_WFRole oldInfo = new JRAdminDao().GetById(newInfo.ID);

                if ((oldInfo != null) && (newInfo != null) && (logId != null))
                {
                    if (newInfo.UserAdminId != oldInfo.UserAdminId)
                    {
                        UserAdmin objUserName = new UserAdminDao().GetById(newInfo.UserAdminId);
                        if (objUserName != null)
                        {
                            commonDao.InsertLogDetail(logId, "UserAdminId", "User Name", oldInfo.UserAdmin.UserName, objUserName.UserName);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.WFRoleID != oldInfo.WFRoleID)
                    {
                        WFRole obj = new RoleDao().GetByID(newInfo.WFRoleID);
                        if (obj != null)
                        {
                            commonDao.InsertLogDetail(logId, "WFRoleID", "Role", oldInfo.WFRole.Name, obj.Name);
                            isUpdated = true;
                        }
                    }
                    if (newInfo.IsActive != oldInfo.IsActive)
                    {
                        commonDao.InsertLogDetail(logId, "IsActive", "Active", oldInfo.IsActive == Constants.IS_ACTIVE ? "Yes" : "No", newInfo.IsActive == Constants.IS_ACTIVE ? "Yes" : "No");
                        isUpdated = true;
                    }
                    if (isUpdated)
                    {
                        // Insert Key Name
                        string key = newInfo.ID + " [" + oldInfo.UserAdmin.UserName + "] with Role [" + oldInfo.WFRole.Name + "]";
                        commonDao.InsertLogDetail(logId, "WorkFlowAdmin", "Key for Update", key, null);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return isUpdated;
        }
Esempio n. 5
0
        /// <summary>
        /// Insert
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Insert(List<UserAdmin_WFRole> list)
        {
            Message msg = null;
            DbTransaction trans = null;
            bool isSuccess = true;
            try
            {
                dbContext.Connection.Open();
                trans = dbContext.Connection.BeginTransaction();
                dbContext.Transaction = trans;

                foreach (UserAdmin_WFRole item in list)
                {
                    msg = Insert(item);
                    if (msg.MsgType == MessageType.Error)
                    {
                        isSuccess = false;
                        break;
                    }
                }
                if (!isSuccess)
                {
                    trans.Rollback();
                }
                else
                {
                    WFRole wfRole = new RoleDao().GetByID(list[0].WFRoleID);
                    msg = new Message(MessageConstants.I0001, MessageType.Info,
                        "User \"" + string.Join("\"" + Constants.SEPARATE_USER_ADMIN_USERNAME + " \"",
                        list.Select(p => p.UserAdmin.UserName)) + "\"",
                        string.Format("added in role \"{0}\" of Workflow \"{1}\"", wfRole.Name, wfRole.WorkFlow.Name));
                    trans.Commit();
                }
            }
            catch
            {
                trans.Rollback();
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }