示例#1
0
        /// <summary>
        /// 查询获取指定的用户是否已配置权限
        /// </summary>
        /// <param name="szUserID">用户ID</param>
        /// <param name="rightType">用户权限类型</param>
        /// <param name="nCount">返回的记录数</param>
        /// <returns>SystemData.ReturnValue</returns>
        private short ExistRightInfo(string szUserID, UserRightType rightType, ref int nCount)
        {
            if (GlobalMethods.Misc.IsEmptyString(szUserID))
                return SystemData.ReturnValue.PARAM_ERROR;

            if (base.MedQCAccess == null)
                return SystemData.ReturnValue.PARAM_ERROR;

            string szCondition = string.Format("{0}='{1}'AND {2}='{3}'"
                , SystemData.UserRightTable.USER_ID, szUserID
                , SystemData.UserRightTable.RIGHT_TYPE, UserRightBase.GetRightTypeName(rightType));
            string szSQL = string.Format(SystemData.SQL.SELECT_WHERE, "COUNT(*)", SystemData.DataTable.USER_RIGHT, szCondition);

            nCount = 0;
            try
            {
                object objValue = base.MedQCAccess.ExecuteScalar(szSQL, CommandType.Text);
                if (objValue == null || objValue == System.DBNull.Value)
                    nCount = 0;
                if (!int.TryParse(objValue.ToString(), out nCount))
                    nCount = 0;
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("RightAccess.ExistRightInfo", new string[] { "SQL" }, new object[] { szSQL }, "SQL执行失败!", ex);
                return SystemData.ReturnValue.EXCEPTION;
            }
            return SystemData.ReturnValue.OK;
        }
示例#2
0
        /// <summary>
        /// 更新已有编辑器用户权限
        /// </summary>
        /// <param name="userRight">用户权限</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short UpdateUserRight(UserRightBase userRight)
        {
            if (userRight == null || GlobalMethods.Misc.IsEmptyString(userRight.UserID))
                return SystemData.ReturnValue.PARAM_ERROR;

            if (base.MedQCAccess == null)
                return SystemData.ReturnValue.PARAM_ERROR;

            string szField = string.Format("{0}='{1}'", SystemData.UserRightTable.RIGHT_CODE, userRight.GetRightCode());
            string szCondition = string.Format("{0}='{1}' AND {2}='{3}'"
                , SystemData.UserRightTable.USER_ID, userRight.UserID
                , SystemData.UserRightTable.RIGHT_TYPE, UserRightBase.GetRightTypeName(userRight.RightType));
            string szTable = SystemData.DataTable.USER_RIGHT;
            string szSQL = string.Format(SystemData.SQL.UPDATE, szTable, szField, szCondition);

            int count = 0;
            try
            {
                count = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("RightAccess.UpdateUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return SystemData.ReturnValue.EXCEPTION;
            }
            return (count <= 0) ? SystemData.ReturnValue.RES_NO_FOUND : SystemData.ReturnValue.OK;
        }
示例#3
0
        private void toolbtnSave_Click(object sender, EventArgs e)
        {
            if (this.m_lstCheckHdpRoleUser == null)
            {
                this.m_lstCheckHdpRoleUser = new List <HdpRoleUser>();
            }
            m_lstCheckHdpRoleUser.Clear();
            for (int index = 0; index < this.dataGridView1.Rows.Count; index++)
            {
                HdpRole hdpRole = this.dataGridView1.Rows[index].Tag as HdpRole;
                if ((bool)this.dataGridView1.Rows[index].Cells[this.colCheckBox.Index].Value == true)
                {
                    HdpRoleUser hdpRoleUser = new HdpRoleUser();
                    hdpRoleUser.UserID   = this.m_UserInfo.USER_ID;
                    hdpRoleUser.RoleCode = hdpRole.RoleCode;
                    m_lstCheckHdpRoleUser.Add(hdpRoleUser);
                }
            }
            short shRet = HdpRoleUserAccess.Instance.SaveRoleUserList(this.m_UserInfo.USER_ID, CheckHdpRoleUserList);
            //兼容用户登录,插入一条用户账号密码信息到USER_RIGHT_T表中
            UserRightBase userRight = UserRightBase.Create(UserRightType.MedQC);

            userRight.UserID    = this.m_UserInfo.USER_ID;
            userRight.RightType = UserRightType.MedQC;
            shRet = RightAccess.Instance.GetUserRight(this.m_UserInfo.USER_ID, UserRightType.MedQC, ref userRight);

            shRet = RightAccess.Instance.SaveUserRight(userRight);
            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.ShowError("授权失败");
                return;
            }
            MessageBoxEx.ShowMessage("授权成功");
            this.DialogResult = DialogResult.OK;
        }
示例#4
0
        /// <summary>
        /// 保存指定行的数据到远程数据表,需要注意的是:行的删除状态会与其他状态共存
        /// </summary>
        /// <param name="row">指定行</param>
        /// <returns>SystemData.ReturnValue</returns>
        private short SaveRowData(DataTableViewRow row)
        {
            if (row == null || row.Index < 0)
            {
                return(SystemData.ReturnValue.FAILED);
            }

            if (this.dataGridView1.IsNormalRow(row) || this.dataGridView1.IsUnknownRow(row))
            {
                if (!this.dataGridView1.IsDeletedRow(row))
                {
                    return(SystemData.ReturnValue.CANCEL);
                }
            }

            UserRightBase userRight = null;

            if (!this.MakeRowData(row, ref userRight))
            {
                return(SystemData.ReturnValue.FAILED);
            }

            short shRet = SystemData.ReturnValue.OK;

            return(SystemData.ReturnValue.OK);
        }
示例#5
0
        /// <summary>
        /// 获取指定行当前的权限数据
        /// </summary>
        /// <param name="row">指定行</param>
        /// <param name="userRight">用户的权限信息</param>
        /// <returns>bool</returns>
        private bool MakeRowData(DataTableViewRow row, ref UserRightBase userRight)
        {
            if (row == null || row.Index < 0)
            {
                return(false);
            }

            object cellValue = row.Cells[this.colUserID.Index].Value;

            if (cellValue == null || cellValue.ToString().Trim() == string.Empty)
            {
                return(false);
            }


            return(true);
        }
示例#6
0
        /// <summary>
        /// 获取所有编辑器用户权限
        /// </summary>
        /// <param name="rightType">用户权限类型</param>
        /// <param name="lstUserRight">用户权限信息列表</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short GetUserRight(UserRightType rightType, ref List<UserRightBase> lstUserRight)
        {
            if (base.MedQCAccess == null)
                return SystemData.ReturnValue.PARAM_ERROR;

            string szField = string.Format("{0},{1},{2}"
                , SystemData.UserRightTable.USER_ID, SystemData.UserRightTable.RIGHT_CODE
                , SystemData.UserRightTable.RIGHT_DESC);
            string szTable = SystemData.DataTable.USER_RIGHT;
            DbParameter[] param = new DbParameter[1]{new DbParameter(SystemData.UserRightTable.RIGHT_TYPE
                                                                 , UserRightBase.GetRightTypeName(rightType))};
            string szCondition = string.Format("{0}='{1}' or {0}='MRQC'", SystemData.UserRightTable.RIGHT_TYPE
                ,SystemData.UserRightTable.RIGHT_TYPE);
            string szSQL = string.Format(SystemData.SQL.SELECT_WHERE, szField, szTable, szCondition);

            IDataReader dataReader = null;
            try
            {
                dataReader = base.MedQCAccess.ExecuteReader(szSQL, CommandType.Text, ref param);
                if (dataReader == null || dataReader.IsClosed || !dataReader.Read())
                    return SystemData.ReturnValue.RES_NO_FOUND;

                if (lstUserRight == null)
                    lstUserRight = new List<UserRightBase>();
                lstUserRight.Clear();

                do
                {
                    UserRightBase userRight = UserRightBase.Create(rightType);
                    userRight.UserID = dataReader.GetString(0).Trim();
                    if (!dataReader.IsDBNull(2))
                        userRight.RightDesc = dataReader.GetString(2);
                    if (!dataReader.IsDBNull(1))
                        userRight.SetRightCode(dataReader.GetString(1));
                    lstUserRight.Add(userRight);
                } while (dataReader.Read());
                return SystemData.ReturnValue.OK;
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("RightAccess.GetUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return SystemData.ReturnValue.EXCEPTION;
            }
            finally { base.MedQCAccess.CloseConnnection(false); }
        }
示例#7
0
        /// <summary>
        /// 保存用户权限
        /// </summary>
        /// <param name="userRight">用户权限</param>
        /// <returns>SystemData.ReturnValue</returns>
        public short SaveUserRight(UserRightBase userRight)
        {
            if (userRight == null || GlobalMethods.Misc.IsEmptyString(userRight.UserID))
                return SystemData.ReturnValue.PARAM_ERROR;

            int count = 0;
            short shRet = this.ExistRightInfo(userRight.UserID, userRight.RightType, ref count);
            if (shRet != SystemData.ReturnValue.OK)
                return shRet;
            if (count > 0)
                return this.UpdateUserRight(userRight);

            if (base.MedQCAccess == null)
                return SystemData.ReturnValue.PARAM_ERROR;

            string szField = string.Format("{0},{1},{2},{3}"
                , SystemData.UserRightTable.USER_ID, SystemData.UserRightTable.RIGHT_CODE
                , SystemData.UserRightTable.RIGHT_DESC, SystemData.UserRightTable.RIGHT_TYPE);
            string szValue = string.Format("'{0}','{1}','{2}','{3}'"
                , userRight.UserID, userRight.GetRightCode().Replace('0','1')
                , userRight.RightDesc, UserRightBase.GetRightTypeName(userRight.RightType));
            string szTable = SystemData.DataTable.USER_RIGHT;
            string szSQL = string.Format(SystemData.SQL.INSERT, szTable, szField, szValue);

            count = 0;
            try
            {
                count = base.MedQCAccess.ExecuteNonQuery(szSQL, CommandType.Text);
            }
            catch (Exception ex)
            {
                LogManager.Instance.WriteLog("RightAccess.SaveUserRight", new string[] { "szSQL" }, new object[] { szSQL }, ex);
                return SystemData.ReturnValue.EXCEPTION;
            }
            return (count > 0) ? SystemData.ReturnValue.OK : SystemData.ReturnValue.ACCESS_ERROR;
        }
示例#8
0
 /// <summary>
 /// 加载指定用户的权限信息到当前DataGridView控件末尾
 /// </summary>
 /// <param name="row">权限对象属性集合(可空)</param>
 /// <param name="userRight">用户的权限信息</param>
 private void SetRowData(DataTableViewRow row, UserRightBase userRight)
 {
 }
示例#9
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string szUserID = this.txtUserID.Text.Trim().ToUpper();

            if (GlobalMethods.Misc.IsEmptyString(szUserID))
            {
                MessageBoxEx.Show("请输入您的用户ID!");
                this.txtUserID.Focus();
                this.txtUserID.SelectAll();
                return;
            }
            this.Cursor = Cursors.WaitCursor;

            //获取用户信息
            UserInfo userInfo = null;

            if (szUserID.ToUpper() == "ADMINISTRATOR")
            {
                szUserID           = "administrator";//管理员账户要小写
                userInfo           = new UserInfo();
                userInfo.USER_ID   = szUserID;
                userInfo.USER_NAME = "管理员";
                goto ADMINISTRATOR_LOGIN;
            }
            short shRet = UserAccess.Instance.GetUserInfo(szUserID, ref userInfo);

            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.Show("登录失败,系统无法获取用户信息!");
                this.Cursor = Cursors.Default;
                return;
            }
            if (userInfo == null)
            {
                MessageBoxEx.Show("您输入的账号非法!");
                this.txtUserID.Focus();
                this.txtUserID.SelectAll();
                this.Cursor = Cursors.Default;
                return;
            }

            //查询用户权限信息
            UserRightType rightType     = UserRightType.MedQC;
            UserRightBase userRightBase = null;

            shRet = RightAccess.Instance.GetUserRight(szUserID, rightType, ref userRightBase);
            if (shRet != SystemData.ReturnValue.OK &&
                shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("登录失败,系统无法获取用户权限!");
                this.Cursor = Cursors.Default;
                return;
            }

            //验证用户输入的密码
ADMINISTRATOR_LOGIN:
            shRet = RightAccess.Instance.VerifyUser(szUserID, this.txtUserPwd.Text);
            if (shRet == SystemData.ReturnValue.FAILED)
            {
                MessageBoxEx.Show("您输入的登录口令错误!");
                this.txtUserPwd.Focus();
                this.txtUserPwd.SelectAll();
                this.Cursor = Cursors.Default;
                return;
            }
            if (shRet != SystemData.ReturnValue.OK &&
                shRet != SystemData.ReturnValue.RES_NO_FOUND)
            {
                MessageBoxEx.Show("登录失败,系统无法验证用户信息!");
                this.Cursor = Cursors.Default;
                return;
            }
            this.Cursor = Cursors.Default;
            SystemParam.Instance.UserInfo = userInfo;
            SystemConfig.Instance.Write(SystemData.ConfigKey.DEFAULT_LOGIN_USERID, szUserID);
            HdpProduct hdpProduct = (this.cboProduct.SelectedItem as HdpProduct);

            if (hdpProduct == null)
            {
                MessageBoxEx.Show("网络出现异常!");
                return;
            }
            string szProduct = hdpProduct.NAME_SHORT;

            SystemConfig.Instance.Write(SystemData.ConfigKey.DEFAULT_LOGIN_PRODUCT, szProduct);
            DataCache.Instance.HdpProduct = this.cboProduct.SelectedItem as HdpProduct;

            //查找用户角色
            List <HdpRoleUser> lstHdpRoleUser = null;

            shRet = HdpRoleUserAccess.Instance.GetHdpRoleUserList(szUserID, ref lstHdpRoleUser);
            if (shRet != SystemData.ReturnValue.OK)
            {
                MessageBoxEx.Show("登录失败,系统无法获取用户权限!");
                this.Cursor = Cursors.Default;
                return;
            }
            //缓存用户角色权限信息
            List <HdpRoleGrant> lstHdpAllRoleGrant = new List <HdpRoleGrant>();

            foreach (HdpRoleUser item in lstHdpRoleUser)
            {
                List <HdpRoleGrant> lstHdpRoleGrant = new List <HdpRoleGrant>();
                shRet = HdpRoleGrantAccess.Instance.GetHdpRoleGrantList(item.RoleCode, string.Empty, ref lstHdpRoleGrant);
                if (shRet == SystemData.ReturnValue.OK)
                {
                    lstHdpAllRoleGrant.AddRange(lstHdpRoleGrant);
                }
            }
            DataCache.Instance.QcAdminDepts       = null;
            DataCache.Instance.DicHdpParameter    = null;
            DataCache.Instance.RoleName           = string.Join(",", lstHdpRoleUser.Select(m => m.RoleName).ToArray());
            RightHandler.Instance.LstHdpRoleGrant = lstHdpAllRoleGrant;

            this.DialogResult = DialogResult.OK;
        }