示例#1
0
 /// <summary>
 /// 检查权限
 /// </summary>
 /// <param name="resrouce"></param>
 /// <param name="userCode"></param>
 /// <returns></returns>
 private string CheckRight(string resrouce, string userCode)
 {
     try
     {
         BenQGuru.eMES.Security.SecurityFacade sFacade = new BenQGuru.eMES.Security.SecurityFacade(this._domainDataProvider);
         return(sFacade.CheckResourceRight(userCode, resrouce) == true? "OK":"没有权限");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
     finally
     {
         ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)_domainDataProvider).PersistBroker.CloseConnection();
     }
 }
示例#2
0
        private bool CheckResourceRight()
        {
            if (!this.IsCheckRights)
            {
                return(true);
            }

            this.txtResource.Value = this.txtResource.Value.Trim().ToUpper();
            this.CheckResource     = this.txtResource.Value.Trim().ToUpper();
            if (this.CheckResource == "")
            {
                this.CheckResource = Service.ApplicationService.Current().ResourceCode;
            }
            // 检查资源的用户权限
            if (this.CheckResource != Service.ApplicationService.Current().ResourceCode)
            {
                bool bIsAdmin = false;
                if (Service.ApplicationService.Current().LoginInfo.UserGroups != null)
                {
                    foreach (object o in Service.ApplicationService.Current().LoginInfo.UserGroups)
                    {
                        if (((UserGroup)o).UserGroupType == "ADMIN")
                        {
                            bIsAdmin = true;
                            break;
                        }
                    }
                }
                if (!bIsAdmin)
                {
                    Security.SecurityFacade securityFacade = new BenQGuru.eMES.Security.SecurityFacade(this.DataProvider);
                    if (!securityFacade.CheckResourceRight(Service.ApplicationService.Current().LoginInfo.UserCode, this.CheckResource))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }