public JsonResult LoadData(String cReviewType) { AuthApprDao authApprDao = new AuthApprDao(); List <AuthReviewModel> rows = new List <AuthReviewModel>(); using (new TransactionScope( TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted })) { using (dbTreasuryEntities db = new dbTreasuryEntities()) { try { //查出待覆核的資料 rows = authApprDao.qryAuthReview("R", "1", db); } catch (Exception e) { logger.Error("其它錯誤:" + e.ToString()); return(Json(new { success = false, err = "其它錯誤,請洽系統管理員!!" })); } } } using (DB_INTRAEntities dbIntra = new DB_INTRAEntities()) { Dictionary <string, string> userNameMap = new Dictionary <string, string>(); OaEmpDao oaEmpDao = new OaEmpDao(); string createUid = ""; foreach (AuthReviewModel d in rows) { createUid = StringUtil.toString(d.createUid); if (!"".Equals(createUid)) { if (!userNameMap.ContainsKey(createUid)) { userNameMap = oaEmpDao.qryUsrName(userNameMap, createUid, dbIntra); } d.createUid = createUid + " " + userNameMap[createUid]; } } } var jsonData = new { success = true, rows }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 異動覆核資料檔 /// </summary> /// <param name="cReviewSeq"></param> /// <param name="cReviewFlag"></param> /// <param name="conn"></param> /// <param name="transaction"></param> private void procAuthAppr(string aplyNo, string appStatus, SqlConnection conn, SqlTransaction transaction) { AUTH_APPR authAppr = new AUTH_APPR(); authAppr.APLY_NO = aplyNo; authAppr.APPR_STATUS = appStatus; authAppr.APPR_UID = Session["UserID"].ToString(); authAppr.APPR_DT = DateTime.Now; authAppr.LAST_UPDATE_UID = Session["UserID"].ToString(); authAppr.LAST_UPDATE_DT = DateTime.Now; AuthApprDao authApprDao = new AuthApprDao(); authApprDao.updateStatus(authAppr, conn, transaction); }
public JsonResult execReviewU(string aplyNo, string userId, string apprStatus) { string strConn = DbUtil.GetDBTreasuryConnStr(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); SqlTransaction transaction = conn.BeginTransaction("Transaction"); try { AuthApprDao AuthApprDao = new AuthApprDao(); AUTH_APPR authAppr = AuthApprDao.qryByKey(aplyNo); if (StringUtil.toString(authAppr.CREATE_UID).Equals(Session["UserID"].ToString())) { return(Json(new { success = false, errors = "覆核人員與申請人員相同,不可執行覆核作業!!" }, JsonRequestBehavior.AllowGet)); } //異動使用者資料檔 string cExecType = ""; CodeUserHisDao codeUserHisDao = new CodeUserHisDao(); CodeUserDao codeUserDao = new CodeUserDao(); CODE_USER cODEUSERO = new CODE_USER(); CODE_USER_HIS codeUserHis = codeUserHisDao.qryByAplyNo(aplyNo); string execAction = ""; if (codeUserHis != null) { execAction = StringUtil.toString(codeUserHis.EXEC_ACTION); } if ("A".Equals(execAction)) //新增使用者 { } else { //異動角色 cODEUSERO = codeUserDao.qryUserByKey(userId); } if ("A".Equals(execAction)) { if ("2".Equals(apprStatus)) { cODEUSERO.USER_ID = StringUtil.toString(codeUserHis.USER_ID); cODEUSERO.IS_DISABLED = codeUserHis.IS_DISABLED; cODEUSERO.IS_MAIL = codeUserHis.IS_MAIL; cODEUSERO.MEMO = codeUserHis.MEMO; cODEUSERO.DATA_STATUS = "1"; cODEUSERO.CREATE_UID = authAppr.CREATE_UID; cODEUSERO.CREATE_DT = authAppr.CREATE_DT; cODEUSERO.LAST_UPDATE_UID = StringUtil.toString(authAppr.CREATE_UID); cODEUSERO.LAST_UPDATE_DT = authAppr.CREATE_DT; cODEUSERO.APPR_UID = Session["UserID"].ToString(); cODEUSERO.APPR_DT = DateTime.Now; int cnt = codeUserDao.Create(cODEUSERO, conn, transaction); //新增LOG Log log = new Log(); log.CFUNCTION = "使用者管理-新增"; log.CACTION = "A"; log.CCONTENT = codeUserDao.userLogContent(cODEUSERO); LogDao.Insert(log, Session["UserID"].ToString()); //新增稽核軌跡 procTrackLog("A", codeUserDao, cODEUSERO, conn, transaction); } } else { //新增LOG Log log = new Log(); log.CFUNCTION = "使用者管理-修改"; log.CACTION = "U"; log.CCONTENT = codeUserDao.userLogContent(cODEUSERO); LogDao.Insert(log, Session["UserID"].ToString()); cODEUSERO.DATA_STATUS = "1"; cODEUSERO.LAST_UPDATE_UID = StringUtil.toString(authAppr.CREATE_UID); cODEUSERO.LAST_UPDATE_DT = authAppr.CREATE_DT; cODEUSERO.APPR_UID = Session["UserID"].ToString(); cODEUSERO.APPR_DT = DateTime.Now; cODEUSERO.FREEZE_DT = null; cODEUSERO.FREEZE_UID = ""; if ("U".Equals(execAction) && "2".Equals(apprStatus)) { cODEUSERO.IS_DISABLED = codeUserHis.IS_DISABLED; cODEUSERO.IS_MAIL = StringUtil.toString(codeUserHis.IS_MAIL); cODEUSERO.MEMO = StringUtil.toString(codeUserHis.MEMO); } int cnt = codeUserDao.Update(cODEUSERO, conn, transaction); //20190418 201904160117-00 Bianco 修改稽核軌跡 procTrackLog("E", codeUserDao, cODEUSERO, conn, transaction); } //覆核狀態=核可時 if ("2".Equals(apprStatus)) { procUserRoleHis(cODEUSERO, aplyNo, conn, transaction); //異動使用者角色 } //異動覆核資料檔 procAuthAppr(aplyNo, apprStatus, conn, transaction); transaction.Commit(); return(Json(new { success = true })); } catch (Exception e) { transaction.Rollback(); logger.Error("[execReviewR]其它錯誤:" + e.ToString()); return(Json(new { success = false, errors = "其它錯誤,請洽系統管理員!!" }, JsonRequestBehavior.AllowGet)); } } }
///// <summary> ///// 開啟使用者修改明細畫面 ///// </summary> ///// <param name="aplyNo"></param> ///// <returns></returns> //public ActionResult detailUser(string cReviewSeq) //{ // try // { // using (DbAccountEntities db = new DbAccountEntities()) // { // CodeUserHisDao codeUserHisDao = new CodeUserHisDao(); // AuthReviewUserModel userData = codeUserHisDao.qryByNowHis(cReviewSeq, db); // string[] cDateTime = userData.cCrtDateTime.Split(' '); // userData.cCrtDateTime = DateUtil.formatDateTimeDbToSc(cDateTime[0] + " " + cDateTime[1], "DT"); // ViewBag.bHaveData = "Y"; // ViewBag.cReviewSeq = cReviewSeq; // return View(userData); // } // } // catch (Exception e) // { // ViewBag.bHaveData = "N"; // return View(); // } //} /// <summary> /// 開啟使用者修改明細畫面 /// </summary> /// <param name="aplyNo"></param> /// <returns></returns> public ActionResult detailUser(string aplyNo, string userId) { try { string execAction = ""; AuthApprDao AuthApprDao = new AuthApprDao(); AUTH_APPR authAppr = new AUTH_APPR(); if (!"".Equals(StringUtil.toString(aplyNo))) { authAppr = AuthApprDao.qryByKey(aplyNo); ViewBag.bView = "N"; } else { authAppr = AuthApprDao.qryByFreeRole(userId); if (authAppr != null) { aplyNo = StringUtil.toString(authAppr.APLY_NO); } ViewBag.bView = "Y"; } AuthReviewUserModel userData = new AuthReviewUserModel(); userData.aplyNo = aplyNo; userData.userId = authAppr.APPR_MAPPING_KEY; userData.createUid = authAppr.CREATE_UID; OaEmpDao oaEmpDao = new OaEmpDao(); using (DB_INTRAEntities dbIntra = new DB_INTRAEntities()) { try { userData.createUid = userData.createUid == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(userData.createUid, dbIntra).EMP_NAME); userData.userName = userData.userId == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(userData.userId, dbIntra).EMP_NAME); } catch (Exception e) { } } userData.createDt = authAppr.CREATE_DT.ToString(); SysCodeDao sysCodeDao = new SysCodeDao(); Dictionary <string, string> dicExecAction = sysCodeDao.qryByTypeDic("EXEC_ACTION"); Dictionary <string, string> dicYNFlag = sysCodeDao.qryByTypeDic("YN_FLAG"); CodeUserHisDao codeUserHisDao = new CodeUserHisDao(); CODE_USER_HIS codeUserHis = codeUserHisDao.qryByAplyNo(aplyNo); if (codeUserHis != null) { execAction = StringUtil.toString(codeUserHis.EXEC_ACTION); } if ("".Equals(execAction)) { CodeUserDao codeUserDao = new CodeUserDao(); CODE_USER codeUser = new CODE_USER(); codeUser = codeUserDao.qryUserByKey(authAppr.APPR_MAPPING_KEY); userData.isMailB = StringUtil.toString(codeUser.IS_MAIL); userData.isDisabledB = StringUtil.toString(codeUser.IS_DISABLED); userData.memoB = StringUtil.toString(codeUser.MEMO); } else { if ("A".Equals(execAction)) { userData.isMail = StringUtil.toString(codeUserHis.IS_MAIL); userData.isDisabled = StringUtil.toString(codeUserHis.IS_DISABLED); userData.memo = StringUtil.toString(codeUserHis.MEMO); } else { userData.isMail = StringUtil.toString(codeUserHis.IS_MAIL); userData.isDisabled = StringUtil.toString(codeUserHis.IS_MAIL); userData.memo = StringUtil.toString(codeUserHis.MEMO); userData.isMailB = StringUtil.toString(codeUserHis.IS_MAIL_B); userData.isDisabledB = StringUtil.toString(codeUserHis.IS_DISABLED_B); userData.memoB = StringUtil.toString(codeUserHis.MEMO_B); } } userData.execAction = execAction; userData.execActionDesc = dicExecAction.ContainsKey(userData.execAction) ? dicExecAction[userData.execAction] : userData.execAction; userData.isDisabledDesc = dicYNFlag.ContainsKey(userData.isDisabled) ? dicYNFlag[userData.isDisabled] : userData.isDisabled; userData.isDisabledDescB = dicYNFlag.ContainsKey(userData.isDisabledB) ? dicYNFlag[userData.isDisabledB] : userData.isDisabledB; userData.isMailDesc = dicYNFlag.ContainsKey(userData.isMail) ? dicYNFlag[userData.isMail] : userData.isMail; userData.isMailDescB = dicYNFlag.ContainsKey(userData.isMailB) ? dicYNFlag[userData.isMailB] : userData.isMailB; ViewBag.bHaveData = "Y"; ViewBag.aplyNo = aplyNo; return(View(userData)); } catch (Exception e) { ViewBag.bHaveData = "N"; return(View()); } }
public ActionResult updateRole(RoleMgrModel roleMgrModel, String authFunc , List <CodeRoleEquipModel> equipData, List <CodeRoleItemModel> itemData, List <CodeRoleItemModel> formAplyData) { string roleId = StringUtil.toString(roleMgrModel.cRoleID); bool bChgRole = false; bool bChgFunc = false; bool bChgEquip = false; bool bChgItem = false; bool bChgFormAply = false; bool bNewRole = false; CodeRoleDao codeRoleDao = new CodeRoleDao(); CODE_ROLE codeRoleO = new CODE_ROLE(); bool bDupRoleName = codeRoleDao.dupRoleName(StringUtil.toString(roleMgrModel.cRoleID), StringUtil.toString(roleMgrModel.roleAuthType), StringUtil.toString(roleMgrModel.cRoleName)); if (bDupRoleName) { return(Json(new { success = false, errors = "相同角色群組下,不能建置相同的角色名稱!!" }, JsonRequestBehavior.AllowGet)); } //比對是否有異動"角色資訊" if ("".Equals(roleId)) { bNewRole = true; bChgRole = true; SysSeqDao sysSeqDao = new SysSeqDao(); var cId = sysSeqDao.qrySeqNo("F1", "").ToString(); roleId = "F1" + cId.ToString().PadLeft(8, '0'); } else { codeRoleO = codeRoleDao.qryRoleByKey(roleId); if (!( StringUtil.toString(roleMgrModel.cRoleName).Equals(StringUtil.toString(codeRoleO.ROLE_NAME)) && StringUtil.toString(roleMgrModel.isDisabled).Equals(StringUtil.toString(codeRoleO.IS_DISABLED)) && StringUtil.toString(roleMgrModel.vMemo).Equals(StringUtil.toString(codeRoleO.MEMO)) )) { bChgRole = true; } } //比對是否有異動"授權功能" List <FuncRoleModel> funcList = new List <FuncRoleModel>(); string[] funcData = authFunc.Split('|'); if ("F".Equals(roleMgrModel.roleAuthType)) { CodeRoleFunctionDao CodeRoleFunctionDao = new CodeRoleFunctionDao(); List <FuncRoleModel> roleFuncListO = CodeRoleFunctionDao.qryForRoleMgr(roleId); foreach (string item in funcData) { if (!"".Equals(StringUtil.toString(item))) { FuncRoleModel funcRoleModel = new FuncRoleModel(); funcRoleModel.cRoleId = roleId; funcRoleModel.cFunctionID = item; if (roleFuncListO.Exists(x => x.cFunctionID == item)) { funcRoleModel.execAction = ""; } else { bChgFunc = true; funcRoleModel.execAction = "A"; } funcList.Add(funcRoleModel); } } foreach (FuncRoleModel oItem in roleFuncListO) { if (!funcList.Exists(x => x.cFunctionID == oItem.cFunctionID)) { bChgFunc = true; FuncRoleModel funcRoleModel = new FuncRoleModel(); funcRoleModel.cRoleId = roleId; funcRoleModel.cFunctionID = oItem.cFunctionID; funcRoleModel.execAction = "D"; funcList.Add(funcRoleModel); } } } //比對是否有異動"金庫設備權限" List <CodeRoleEquipModel> equipList = new List <CodeRoleEquipModel>(); CodeRoleTreaItemDao codeRoleTreaItemDao = new CodeRoleTreaItemDao(); if ("E".Equals(roleMgrModel.roleAuthType)) { List <CodeRoleEquipModel> roleEquipListO = codeRoleTreaItemDao.qryForRoleMgr(roleId); if (equipData != null) { foreach (CodeRoleEquipModel item in equipData) { CodeRoleEquipModel codeRoleEquipModel = new CodeRoleEquipModel(); codeRoleEquipModel.roleId = roleId; codeRoleEquipModel.treaEquipId = StringUtil.toString(item.treaEquipId); //codeRoleEquipModel.controlMode = StringUtil.toString(item.controlMode); codeRoleEquipModel.custodyMode = StringUtil.toString(item.custodyMode); codeRoleEquipModel.custodyOrder = StringUtil.toString(item.custodyOrder); codeRoleEquipModel.custodyModeB = ""; codeRoleEquipModel.custodyOrderB = ""; codeRoleEquipModel.execAction = ""; if (roleEquipListO.Exists(x => x.treaEquipId == item.treaEquipId)) { CodeRoleEquipModel itemO = roleEquipListO.Find(x => x.treaEquipId == item.treaEquipId); if (!( //item.controlMode.Equals(itemO.controlMode) && item.custodyMode.Equals(itemO.custodyMode) && item.custodyOrder.Equals(itemO.custodyOrder))) { codeRoleEquipModel.execAction = "U"; codeRoleEquipModel.custodyModeB = itemO.custodyMode; codeRoleEquipModel.custodyOrderB = itemO.custodyOrder; bChgEquip = true; } } else { codeRoleEquipModel.execAction = "A"; bChgEquip = true; } equipList.Add(codeRoleEquipModel); } } foreach (CodeRoleEquipModel oItem in roleEquipListO) { if (equipList != null) { if (!equipList.Exists(x => x.treaEquipId == oItem.treaEquipId)) { bChgEquip = true; CodeRoleEquipModel codeRoleEquipModel = new CodeRoleEquipModel(); codeRoleEquipModel.roleId = roleId; codeRoleEquipModel.treaEquipId = StringUtil.toString(oItem.treaEquipId); codeRoleEquipModel.controlMode = StringUtil.toString(oItem.controlMode); codeRoleEquipModel.custodyMode = StringUtil.toString(oItem.custodyMode); codeRoleEquipModel.custodyOrder = StringUtil.toString(oItem.custodyOrder); codeRoleEquipModel.execAction = "D"; equipList.Add(codeRoleEquipModel); } } else { bChgEquip = true; CodeRoleEquipModel codeRoleEquipModel = new CodeRoleEquipModel(); codeRoleEquipModel.roleId = roleId; codeRoleEquipModel.treaEquipId = StringUtil.toString(oItem.treaEquipId); codeRoleEquipModel.controlMode = StringUtil.toString(oItem.controlMode); codeRoleEquipModel.custodyMode = StringUtil.toString(oItem.custodyMode); codeRoleEquipModel.custodyOrder = StringUtil.toString(oItem.custodyOrder); codeRoleEquipModel.execAction = "D"; equipList.Add(codeRoleEquipModel); } } } //比對是否有異動"存取項目權限" CodeRoleItemDao codeRoleItemDao = new CodeRoleItemDao(); List <CodeRoleItemModel> itemList = new List <CodeRoleItemModel>(); if ("I".Equals(roleMgrModel.roleAuthType)) { List <CodeRoleItemModel> itemDataO = codeRoleItemDao.qryForRoleMgr(roleId, "1"); if (itemData != null) { foreach (CodeRoleItemModel item in itemData) { CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(item.itemId); codeRoleItemModel.authType = "1"; if (itemDataO.Exists(x => x.itemId == item.itemId)) { codeRoleItemModel.execAction = ""; } else { bChgItem = true; codeRoleItemModel.execAction = "A"; } itemList.Add(codeRoleItemModel); } } foreach (CodeRoleItemModel oItem in itemDataO) { if (itemList != null) { if (!itemList.Exists(x => x.itemId == oItem.itemId)) { bChgItem = true; CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(oItem.itemId); codeRoleItemModel.authType = "1"; codeRoleItemModel.execAction = "D"; itemList.Add(codeRoleItemModel); } } else { bChgItem = true; CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(oItem.itemId); codeRoleItemModel.authType = "1"; codeRoleItemModel.execAction = "D"; itemList.Add(codeRoleItemModel); } } } //比對是否有異動"表單申請權限" List <CodeRoleItemModel> formAplyList = new List <CodeRoleItemModel>(); if ("A".Equals(roleMgrModel.roleAuthType)) { List <CodeRoleItemModel> formAplyDataO = codeRoleItemDao.qryForRoleMgr(roleId, "2"); if (formAplyData != null) { foreach (CodeRoleItemModel item in formAplyData) { CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(item.itemId); codeRoleItemModel.authType = "2"; if (formAplyDataO.Exists(x => x.itemId == item.itemId)) { codeRoleItemModel.execAction = ""; } else { bChgFormAply = true; codeRoleItemModel.execAction = "A"; } formAplyList.Add(codeRoleItemModel); } } foreach (CodeRoleItemModel oItem in formAplyDataO) { if (formAplyList != null) { if (!formAplyList.Exists(x => x.itemId == oItem.itemId)) { bChgFormAply = true; CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(oItem.itemId); codeRoleItemModel.authType = "2"; codeRoleItemModel.execAction = "D"; formAplyList.Add(codeRoleItemModel); } } else { bChgFormAply = true; CodeRoleItemModel codeRoleItemModel = new CodeRoleItemModel(); codeRoleItemModel.roleId = roleId; codeRoleItemModel.itemId = StringUtil.toString(oItem.itemId); codeRoleItemModel.authType = "2"; codeRoleItemModel.execAction = "D"; formAplyList.Add(codeRoleItemModel); } } } if (bChgRole == false && bChgFunc == false && bChgEquip == false && bChgItem == false && bChgFormAply == false) { return(Json(new { success = false, errors = "未異動畫面資料,將不進行修改覆核作業!!" }, JsonRequestBehavior.AllowGet)); } /*------------------ DB處理 begin------------------*/ string strConn = DbUtil.GetDBTreasuryConnStr(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); SqlTransaction transaction = conn.BeginTransaction("Transaction"); try { roleMgrModel.cRoleID = roleId; AuthApprDao authApprDao = new AuthApprDao(); AUTH_APPR authAppr = new AUTH_APPR(); authAppr.AUTH_APLY_TYPE = "R"; authAppr.APPR_STATUS = "1"; authAppr.APPR_MAPPING_KEY = roleId; authAppr.CREATE_UID = Session["UserID"].ToString(); //新增"覆核資料檔" string aplyNo = authApprDao.insert(authAppr, conn, transaction); //異動"角色資料檔"覆核狀態 if (bNewRole == false) { updateRole(roleMgrModel, codeRoleO, conn, transaction); } //處理角色資料檔的異動 if (bChgRole) { //新增"角色資料異動檔" CodeRoleHisDao codeRoleHisDao = new CodeRoleHisDao(); CODE_ROLE_HIS codeRoleHis = new CODE_ROLE_HIS(); codeRoleHis.APLY_NO = aplyNo; codeRoleHis.ROLE_ID = StringUtil.toString(roleMgrModel.cRoleID); codeRoleHis.ROLE_NAME = StringUtil.toString(roleMgrModel.cRoleName); codeRoleHis.ROLE_AUTH_TYPE = StringUtil.toString(roleMgrModel.roleAuthType); codeRoleHis.IS_DISABLED = StringUtil.toString(roleMgrModel.isDisabled); codeRoleHis.MEMO = StringUtil.toString(roleMgrModel.vMemo); if (codeRoleO != null) { codeRoleHis.ROLE_NAME_B = StringUtil.toString(codeRoleO.ROLE_NAME); codeRoleHis.IS_DISABLED_B = StringUtil.toString(codeRoleO.IS_DISABLED); codeRoleHis.MEMO_B = StringUtil.toString(codeRoleO.MEMO); } else { codeRoleHis.ROLE_NAME_B = ""; codeRoleHis.IS_DISABLED_B = ""; codeRoleHis.MEMO_B = ""; } if (bNewRole) { codeRoleHis.EXEC_ACTION = "A"; } else { codeRoleHis.EXEC_ACTION = "U"; } codeRoleHisDao.insert(codeRoleHis, conn, transaction); } //處理功能角色資料檔的異動 if (bChgFunc) { CodeRoleFuncHisDao codeRoleFuncHisDao = new CodeRoleFuncHisDao(); foreach (FuncRoleModel func in funcList) { codeRoleFuncHisDao.insert(aplyNo, "Treasury", func, conn, transaction); //if (!"".Equals(func.execAction)) { // codeRoleFuncHisDao.insert(aplyNo, "Treasury", func, conn, transaction); //} } } //處理角色金庫設備資料檔的異動 if (bChgEquip) { CodeRoleTreaItemHisDao codeRoleTreaItemHisDao = new CodeRoleTreaItemHisDao(); foreach (CodeRoleEquipModel equip in equipList) { codeRoleTreaItemHisDao.insert(aplyNo, equip, conn, transaction); //if (!"".Equals(equip.execAction)) //{ // codeRoleTreaItemHisDao.insert(aplyNo, equip, conn, transaction); //} } } //處理角色存取項目資料檔的異動(存取項目) if (bChgItem) { CodeRoleItemHisDao codeRoleItemHisDao = new CodeRoleItemHisDao(); foreach (CodeRoleItemModel item in itemList) { codeRoleItemHisDao.insert(aplyNo, item, conn, transaction); //if (!"".Equals(item.execAction)) //{ // codeRoleItemHisDao.insert(aplyNo, item, conn, transaction); //} } } //處理角色存取項目資料檔的異動(表單申請) if (bChgFormAply) { CodeRoleItemHisDao codeRoleItemHisDao = new CodeRoleItemHisDao(); foreach (CodeRoleItemModel item in formAplyList) { codeRoleItemHisDao.insert(aplyNo, item, conn, transaction); //if (!"".Equals(item.execAction)) //{ // codeRoleItemHisDao.insert(aplyNo, item, conn, transaction); //} } } transaction.Commit(); /*------------------ DB處理 end------------------*/ return(Json(new { success = true, aplyNo = aplyNo })); } catch (Exception e) { transaction.Rollback(); logger.Error("[updateRole]其它錯誤:" + e.ToString()); return(Json(new { success = false, errors = "其它錯誤,請洽系統管理員!!" }, JsonRequestBehavior.AllowGet)); } } }
/// <summary> /// 開啟角色修改明細畫面 /// </summary> /// <param name="aplyNo"></param> /// <returns></returns> public ActionResult detailRole(string aplyNo, string roleId) { try { string execAction = ""; AuthApprDao AuthApprDao = new AuthApprDao(); AUTH_APPR authAppr = new AUTH_APPR(); if (!"".Equals(StringUtil.toString(aplyNo))) { authAppr = AuthApprDao.qryByKey(aplyNo); ViewBag.bView = "N"; } else { authAppr = AuthApprDao.qryByFreeRole(roleId); if (authAppr != null) { aplyNo = StringUtil.toString(authAppr.APLY_NO); } ViewBag.bView = "Y"; } AuthReviewRoleModel roleData = new AuthReviewRoleModel(); roleData.aplyNo = aplyNo; roleData.createUid = authAppr.CREATE_UID; OaEmpDao oaEmpDao = new OaEmpDao(); using (DB_INTRAEntities dbIntra = new DB_INTRAEntities()) { try { roleData.createUid = roleData.createUid == null ? "" : StringUtil.toString(oaEmpDao.qryByUsrId(roleData.createUid, dbIntra).EMP_NAME); } catch (Exception e) { } } roleData.createDt = authAppr.CREATE_DT.ToString(); roleData.roleName = ""; roleData.isDisabled = ""; roleData.memo = ""; roleData.roleNameB = ""; roleData.isDisabledB = ""; roleData.memoB = ""; CodeRoleHisDao CodeRoleHisDao = new CodeRoleHisDao(); CODE_ROLE_HIS codeRoleHis = CodeRoleHisDao.qryByAplyNo(aplyNo); if (codeRoleHis != null) { execAction = StringUtil.toString(codeRoleHis.EXEC_ACTION); } if ("".Equals(execAction)) { CodeRoleDao CodeRoleDao = new CodeRoleDao(); CODE_ROLE codeRole = new CODE_ROLE(); codeRole = CodeRoleDao.qryRoleByKey(authAppr.APPR_MAPPING_KEY); roleData.roleId = StringUtil.toString(codeRole.ROLE_ID); roleData.roleAuthType = StringUtil.toString(codeRole.ROLE_AUTH_TYPE); roleData.roleNameB = StringUtil.toString(codeRole.ROLE_NAME); roleData.isDisabledB = StringUtil.toString(codeRole.IS_DISABLED); roleData.memoB = StringUtil.toString(codeRole.MEMO); } else { roleData.roleId = StringUtil.toString(codeRoleHis.ROLE_ID); roleData.roleAuthType = StringUtil.toString(codeRoleHis.ROLE_AUTH_TYPE); if ("A".Equals(execAction)) { roleData.roleName = StringUtil.toString(codeRoleHis.ROLE_NAME); roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED); roleData.memo = StringUtil.toString(codeRoleHis.MEMO); } else { roleData.roleName = StringUtil.toString(codeRoleHis.ROLE_NAME); roleData.isDisabled = StringUtil.toString(codeRoleHis.IS_DISABLED); roleData.memo = StringUtil.toString(codeRoleHis.MEMO); roleData.roleNameB = StringUtil.toString(codeRoleHis.ROLE_NAME_B); roleData.isDisabledB = StringUtil.toString(codeRoleHis.IS_DISABLED_B); roleData.memoB = StringUtil.toString(codeRoleHis.MEMO_B); } } SysCodeDao sysCodeDao = new SysCodeDao(); SYS_CODE sysCode = new SYS_CODE(); sysCode = sysCodeDao.qryByKey("ROLE_AUTH_TYPE", StringUtil.toString(roleData.roleAuthType)); if (sysCode != null) { roleData.roleAuthTypeDesc = StringUtil.toString(sysCode.CODE_VALUE); } sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabledB)); if (sysCode != null) { roleData.isDisabledB = StringUtil.toString(sysCode.CODE_VALUE); } sysCode = sysCodeDao.qryByKey("IS_DISABLED", StringUtil.toString(roleData.isDisabled)); if (sysCode != null) { roleData.isDisabled = StringUtil.toString(sysCode.CODE_VALUE); } ViewBag.bHaveData = "Y"; ViewBag.aplyNo = aplyNo; return(View(roleData)); } catch (Exception e) { ViewBag.bHaveData = "N"; return(View()); } }
/// <summary> /// 異動使用者資訊 /// </summary> /// <param name="userMgrModel"></param> /// <returns></returns> public JsonResult updateUser(UserMgrModel userMgrModel, List <CodeUserRoleModel> roleData, string execAction) { bool bUserChg = false; bool bRoleChg = false; CodeUserDao codeUserDao = new CodeUserDao(); CODE_USER userO = codeUserDao.qryUserByKey(userMgrModel.cUserID); if ("A".Equals(execAction)) { if (userO != null) { if (!"".Equals(StringUtil.toString(userO.USER_ID))) { return(Json(new { success = false, err = "使用者已存在系統,不可新增!!" }, JsonRequestBehavior.AllowGet)); } } bUserChg = true; } else { if (userO == null) { return(Json(new { success = false, err = "該使用者不存在系統!!" }, JsonRequestBehavior.AllowGet)); } else { if (StringUtil.toString(userMgrModel.isDisabled).Equals(StringUtil.toString(userO.IS_DISABLED)) && StringUtil.toString(userMgrModel.isMail).Equals(StringUtil.toString(userO.IS_MAIL)) && StringUtil.toString(userMgrModel.vMemo).Equals(StringUtil.toString(userO.MEMO)) ) { bUserChg = false; } else { bUserChg = true; } } } //比對是否有異動"角色授權" CodeUserRoleDao codeUserRoleDao = new CodeUserRoleDao(); List <CodeUserRoleModel> roleDataO = codeUserRoleDao.qryByUserID(userMgrModel.cUserID); List <CodeUserRoleModel> roleList = new List <CodeUserRoleModel>(); if (roleData != null) { foreach (CodeUserRoleModel role in roleData) { CodeUserRoleModel codeUserRoleModel = new CodeUserRoleModel(); codeUserRoleModel.userId = StringUtil.toString(userMgrModel.cUserID); codeUserRoleModel.roleId = StringUtil.toString(role.roleId); if (roleDataO.Exists(x => x.roleId == role.roleId)) { codeUserRoleModel.execAction = ""; } else { bRoleChg = true; codeUserRoleModel.execAction = "A"; } roleList.Add(codeUserRoleModel); } } foreach (CodeUserRoleModel oRole in roleDataO) { if (roleList != null) { if (!roleList.Exists(x => x.roleId == oRole.roleId)) { bRoleChg = true; CodeUserRoleModel codeUserRoleModel = new CodeUserRoleModel(); codeUserRoleModel.userId = StringUtil.toString(userMgrModel.cUserID); codeUserRoleModel.roleId = StringUtil.toString(oRole.roleId); codeUserRoleModel.execAction = "D"; roleList.Add(codeUserRoleModel); } } else { bRoleChg = true; CodeUserRoleModel codeUserRoleModel = new CodeUserRoleModel(); codeUserRoleModel.userId = StringUtil.toString(oRole.userId); codeUserRoleModel.roleId = StringUtil.toString(oRole.roleId); codeUserRoleModel.execAction = "D"; roleList.Add(codeUserRoleModel); } } if (bUserChg == false && bRoleChg == false) { return(Json(new { success = false, errors = "未異動畫面資料,將不進行修改覆核作業!!" }, JsonRequestBehavior.AllowGet)); } /*------------------ DB處理 begin------------------*/ string strConn = DbUtil.GetDBTreasuryConnStr(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); SqlTransaction transaction = conn.BeginTransaction("Transaction"); try { AuthApprDao authApprDao = new AuthApprDao(); AUTH_APPR authAppr = new AUTH_APPR(); authAppr.AUTH_APLY_TYPE = "U"; authAppr.APPR_STATUS = "1"; authAppr.APPR_MAPPING_KEY = userMgrModel.cUserID; authAppr.CREATE_UID = Session["UserID"].ToString(); //新增"覆核資料檔" string aplyNo = authApprDao.insert(authAppr, conn, transaction); // 異動"使用者資料檔"資料狀態 if (!"A".Equals(execAction)) { Log log = new Log(); log.CFUNCTION = "使用者管理-修改"; log.CACTION = "U"; log.CCONTENT = codeUserDao.userLogContent(userO); LogDao.Insert(log, Session["UserID"].ToString()); userO.DATA_STATUS = "2"; userO.LAST_UPDATE_UID = Session["UserID"].ToString(); userO.LAST_UPDATE_DT = DateTime.Now; userO.FREEZE_UID = Session["UserID"].ToString(); userO.FREEZE_DT = DateTime.Now; int cnt = codeUserDao.Update(userO, conn, transaction); } //處理使用者資料檔的異動 if (bUserChg) { CodeUserHisDao codeUserHisDao = new CodeUserHisDao(); CODE_USER_HIS userHis = new CODE_USER_HIS(); userHis.APLY_NO = aplyNo; userHis.USER_ID = userMgrModel.cUserID; userHis.IS_DISABLED = userMgrModel.isDisabled; userHis.IS_MAIL = userMgrModel.isMail; userHis.MEMO = userMgrModel.vMemo; if (!"A".Equals(execAction)) { userHis.IS_DISABLED_B = userO.IS_DISABLED; userHis.IS_MAIL_B = userO.IS_MAIL; userHis.MEMO_B = userO.MEMO; userHis.EXEC_ACTION = "U"; } else { userHis.EXEC_ACTION = "A"; } codeUserHisDao.insert(userHis, conn, transaction); } //處理角色金庫設備資料檔的異動 if (bRoleChg) { CodeUserRoleHisDao codeUserRoleHisDao = new CodeUserRoleHisDao(); foreach (CodeUserRoleModel role in roleList) { codeUserRoleHisDao.insert(aplyNo, role, conn, transaction); //if (!"".Equals(role.execAction)) //{ // codeUserRoleHisDao.insert(aplyNo, role, conn, transaction); //} } } transaction.Commit(); /*------------------ DB處理 end------------------*/ return(Json(new { success = true, aplyNo = aplyNo })); } catch (Exception e) { transaction.Rollback(); logger.Error("[updateUser]其它錯誤:" + e.ToString()); return(Json(new { success = false, err = "其它錯誤,請洽系統管理員!!" }, JsonRequestBehavior.AllowGet)); } } }