Ejemplo n.º 1
0
        /// <summary>
        /// 根據用戶等級帶出該USER所能管理的角色   EMP_LEVEL=9 代表超級管理員  1代表可以管理本部門所有角色 0 代表普通用戶
        /// </summary>
        public void SelectRoleByEmp_level(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec sfcdb = null;
            List <c_role_byempl> RoleInfoLevel;
            T_C_ROLE             RoleInfo;
            T_c_user_role        GetRoleID;

            string EMP_LEVEL = this.LoginUser.EMP_LEVEL;
            string FACTORY   = this.LoginUser.FACTORY;
            string BU_NAME   = this.LoginUser.BU;
            string DPT_NAME  = this.LoginUser.DPT_NAME;
            string EDIT_EMP  = Data["EDIT_EMP"].ToString();

            try
            {
                sfcdb     = this.DBPools["SFCDB"].Borrow();
                RoleInfo  = new T_C_ROLE(sfcdb, DBTYPE);
                GetRoleID = new T_c_user_role(sfcdb, DBTYPE);
                List <get_c_roleid> ROLE_ID = GetRoleID.GetRoleID(EDIT_EMP, sfcdb);
                RoleInfoLevel         = RoleInfo.ManageRoleByUser(ROLE_ID, DPT_NAME, BU_NAME, FACTORY, EMP_LEVEL, sfcdb);
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "用戶所的角色獲取成功";
                StationReturn.Data    = RoleInfoLevel;
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
Ejemplo n.º 2
0
        public static void InputEmpPrivchecker(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count == 0)
            {
                throw new Exception("參數數量不正確!");
            }
            MESStationSession EMP_NOLoadPoint = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (EMP_NOLoadPoint == null)
            {
                EMP_NOLoadPoint = new MESStationSession()
                {
                    MESDataType = "INPUTEMP", InputValue = Input.Value.ToString(), SessionKey = "1", ResetInput = Input
                };
                Station.StationSession.Add(EMP_NOLoadPoint);
            }
            bool   bPrivilege = false;
            string empNo      = Input.Value.ToString();
            //T_c_user cUser = new T_c_user(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            //Row_c_user rUser = cUser.getC_Userbyempno(empNo, Station.SFCDB, DB_TYPE_ENUM.Oracle);

            T_c_user_role       cUserRole  = new T_c_user_role(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            List <get_c_roleid> roleList   = cUserRole.GetRoleID(empNo, Station.SFCDB);
            List <string>       listRoleID = new List <string>();

            foreach (var item in roleList)
            {
                listRoleID.Add(item.ROLE_ID);
            }
            T_C_ROLE_PRIVILEGE tRolePrivilege = new T_C_ROLE_PRIVILEGE(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            List <c_role_privilegeinfobyemp> privilegeList = new List <c_role_privilegeinfobyemp>();

            foreach (string item in listRoleID)
            {
                List <c_role_privilegeinfobyemp> tempList = tRolePrivilege.QueryRolePrivilege(item, Station.SFCDB);
                privilegeList.AddRange(tempList);
            }
            EMP_NOLoadPoint.Value = privilegeList;
            foreach (var item in privilegeList)
            {
                if (item.PRIVILEGE_NAME == Station.DisplayName)
                {
                    bPrivilege = true;
                }
            }
            if (bPrivilege)
            {
                Station.AddMessage("MES00000001", new string[] { }, MESReturnView.Station.StationMessageState.Pass);
            }
            else
            {
                throw new Exception("no privilege");
            }
        }