コード例 #1
0
        /// <summary>
        /// 加载产品权限
        /// </summary>
        private void BindSofts()
        {
            URBasicInfoService   biService      = new URBasicInfoService();
            URRightsService      rightService   = new URRightsService();
            List <Soft>          softs          = biService.GetSofts();
            List <ProjectSource> projectSources = biService.GetProjectSources();
            List <RightItem>     selectedSofts  = UserID > 0
                ? rightService.GetUserSoftRights(UserID)
                : rightService.GetRoleSoftRights(RoleID);
            List <RightItem> selectedProjectSources = UserID > 0
                ? rightService.GetUserProjectSourceRights(UserID)
                : rightService.GetRoleProjectSourceRights(RoleID);
            List <RightItem> resIds = new List <RightItem>();

            //产品管理员不能设置资源查看权限
            if (loginService.LoginUser.AccountType != UserTypeOptions.ProductAdmin && UserID > 0)
            {
                resIds = rightService.GetUserResRights(UserID);
            }

            softs.ForEach(soft =>
            {
                var item      = new ListItem("[" + soft.OutID.ToString().PadLeft(6, '0') + "]" + soft.Name, soft.ID.ToString());
                RightItem ri  = selectedSofts.FirstOrDefault(f => f.RightID == soft.ID);
                item.Selected = ri != null;
                item.Enabled  = ri == null || !ri.FromRole;
                item.Attributes.Add("stype", soft.SoftType.ToString());
                item.Attributes.Add("intype", "checkbox");
                if (soft.SoftType == SoftTypeOptions.InternalSoft || soft.SoftType == SoftTypeOptions.MultiSofts)
                {
                    cbkListSoft.Items.Add(item);
                }
                else
                {
                    cbkListSoftout.Items.Add(item);
                }
            });
            if (resIds.Count > 0)
            {
                txtResIdList.Text = string.Join(", ", resIds.Select(a => a.RightID.ToString()).ToArray());
            }
            projectSources.ForEach(projectSource =>
            {
                var item      = new ListItem("[" + projectSource.ProjectSourceID + "]" + projectSource.Name, projectSource.ProjectSourceID.ToString());
                RightItem ri  = selectedProjectSources.FirstOrDefault(f => f.RightID == projectSource.ProjectSourceID);
                item.Selected = ri != null;
                item.Enabled  = ri == null || !ri.FromRole;
                item.Attributes.Add("intype", "checkbox");
                cbkProjectSource.Items.Add(item);
            });
        }
コード例 #2
0
 protected void MyData_Refresh(object sender, StoreRefreshDataEventArgs e)
 {
     Store4.DataSource = biService.GetProjectSources().Select(p => new SimpleProjectource()
     {
         ProjectSourceID   = p.ProjectSourceID,
         AddTime           = p.AddTime,
         Name              = p.Name,
         OnlyInternal      = p.OnlyInternal,
         ProjectSourceType = p.ProjectSourceType.ToString(),
         SortIndex         = p.SortIndex,
         Status            = ((int)p.Status) > 0?true:false,
         SoftID            = p.SoftID
     }).ToList();
     Store4.DataBind();
 }