GetAllRights() public method

public GetAllRights ( long subjectId, long entityId, long dataId ) : IQueryable
subjectId long
entityId long
dataId long
return IQueryable
コード例 #1
0
        public ActionResult Subjects_Select(long dataId, long entityId)
        {
            EntityManager entityManager = new EntityManager();
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            List<DataPermissionGridRowModel> subjects = new List<DataPermissionGridRowModel>();

            IQueryable<Subject> data = subjectManager.GetAllSubjects();
            data.ToList().ForEach(s => subjects.Add(DataPermissionGridRowModel.Convert(dataId, entityManager.GetEntityById(entityId), s, permissionManager.GetAllRights(s.Id, entityId, dataId).ToList())));

            return View(new GridModel<DataPermissionGridRowModel> { Data = subjects });
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: BEXIS2/Core
        public ActionResult _CustomMyDatasetBinding()
        {
            DataTable model = new DataTable();

            ViewData["PageSize"] = 10;
            ViewData["CurrentPage"] = 1;

            #region header
            List<HeaderItem> headerItems = new List<HeaderItem>();

            HeaderItem headerItem = new HeaderItem()
            {
                Name = "ID",
                DisplayName = "ID",
                DataType = "Int64"
            };
            headerItems.Add(headerItem);

            ViewData["Id"] = headerItem;

            headerItem = new HeaderItem()
            {
                Name = "Title",
                DisplayName = "Title",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "Description",
                DisplayName = "Description",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "View",
                DisplayName = "View",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "Update",
                DisplayName = "Update",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "Delete",
                DisplayName = "Delete",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "Download",
                DisplayName = "Download",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            headerItem = new HeaderItem()
            {
                Name = "Grant",
                DisplayName = "Grant",
                DataType = "String"
            };
            headerItems.Add(headerItem);

            ViewData["DefaultHeaderList"] = headerItems;

            #endregion

            model = CreateDataTable(headerItems);

            DatasetManager datasetManager = new DatasetManager();
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();

            List<long> gridCommands = datasetManager.GetDatasetLatestIds();
            gridCommands.Skip(Convert.ToInt16(ViewData["CurrentPage"])).Take(Convert.ToInt16(ViewData["PageSize"]));

            foreach (long datasetId in gridCommands)
            {
                //get permissions
                List<int> rights = permissionManager.GetAllRights(subjectManager.GetUserByName(GetUsernameOrDefault()).Id, 1, datasetId).ToList();

                if (rights.Count > 0)
                {
                    DataRow dataRow = model.NewRow();
                    Object[] rowArray = new Object[8];

                    if (datasetManager.IsDatasetCheckedIn(datasetId))
                    {
                        DatasetVersion dsv = datasetManager.GetDatasetLatestVersion(datasetId);

                        MetadataStructureManager msm = new MetadataStructureManager();
                        dsv.Dataset.MetadataStructure = msm.Repo.Get(dsv.Dataset.MetadataStructure.Id);

                        string title = XmlDatasetHelper.GetInformation(dsv, NameAttributeValues.title);
                        string description = XmlDatasetHelper.GetInformation(dsv, NameAttributeValues.description);

                        rowArray[0] = Convert.ToInt64(datasetId);
                        rowArray[1] = title;
                        rowArray[2] = description;
                    }
                    else
                    {
                        rowArray[0] = Convert.ToInt64(datasetId);
                        rowArray[1] = "";
                        rowArray[2] = "Dataset is just in processing.";
                    }

                    if (rights.Contains(1))
                    {
                        rowArray[3] = "✔";
                    }
                    else
                    {
                        rowArray[3] = "✘";
                    }
                    if (rights.Contains(2))
                    {
                        rowArray[4] = "✔";
                    }
                    else
                    {
                        rowArray[4] = "✘";
                    }
                    if (rights.Contains(3))
                    {
                        rowArray[5] = "✔";
                    }
                    else
                    {
                        rowArray[5] = "✘";
                    }
                    if (rights.Contains(4))
                    {
                        rowArray[6] = "✔";
                    }
                    else
                    {
                        rowArray[6] = "✘";
                    }
                    if (rights.Contains(5))
                    {
                        rowArray[7] = "✔";
                    }
                    else
                    {
                        rowArray[7] = "✘";
                    }

                    dataRow = model.NewRow();
                    dataRow.ItemArray = rowArray;
                    model.Rows.Add(dataRow);
                }
            }

            return View(new GridModel(model));
        }