public List <ListViewItem> LoadDatasetVersionViewList(DataStructureType dataStructureType) { EntityPermissionManager entityPermissionManager = new EntityPermissionManager(); DataStructureManager dataStructureManager = new DataStructureManager(); DatasetManager dm = new DatasetManager(); try { List <long> datasetIds = entityPermissionManager.GetKeys(GetUsernameOrDefault(), "Dataset", typeof(Dataset), RightType.Write).ToList(); List <ListViewItem> tempStructured = new List <ListViewItem>(); List <ListViewItem> tempUnStructured = new List <ListViewItem>(); var DatasetVersions = dm.GetDatasetLatestVersions(datasetIds, false); foreach (var dsv in DatasetVersions) { if (dsv.Dataset.DataStructure.Self.GetType().Equals(typeof(StructuredDataStructure))) { tempStructured.Add(new ListViewItem(dsv.Dataset.Id, dsv.Title)); } else { tempUnStructured.Add(new ListViewItem(dsv.Dataset.Id, dsv.Title)); } } if (dataStructureType.Equals(DataStructureType.Structured)) { return(tempStructured.OrderBy(p => p.Title).ToList()); } else { return(tempUnStructured.OrderBy(p => p.Title).ToList()); } } finally { entityPermissionManager.Dispose(); dataStructureManager.Dispose(); dm.Dispose(); } }
public List <ListViewItem> LoadDatasetViewList() { List <ListViewItem> temp = new List <ListViewItem>(); DatasetManager datasetManager = new DatasetManager(); EntityPermissionManager entityPermissionManager = new EntityPermissionManager(); //get all datasetsid where the current userer has access to UserManager userManager = new UserManager(); XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper(); try { List <long> datasetIds = entityPermissionManager.GetKeys(GetUsernameOrDefault(), "Dataset", typeof(Dataset), RightType.Write); foreach (long id in datasetIds) { if (datasetManager.IsDatasetCheckedIn(id)) { string title = xmlDatasetHelper.GetInformation(id, NameAttributeValues.title); string description = xmlDatasetHelper.GetInformation(id, NameAttributeValues.description); temp.Add(new ListViewItem(id, title, description)); } } return(temp.OrderBy(p => p.Title).ToList()); } finally { datasetManager.Dispose(); entityPermissionManager.Dispose(); userManager.Dispose(); } }
/// <summary> /// create the model of My Dataset table /// </summary> /// <remarks></remarks> /// <seealso cref="_CustomMyDatasetBinding"/> /// <param name="entityname">Name of entity</param> /// <param name="rightType">Type of right (write, delete, grant, read)</param> /// <param name="onlyTable">Return only table without header</param> /// <returns>model</returns> public ActionResult ShowMyDatasets(string entityname, string rightType, string onlyTable = "false") { ViewBag.Title = PresentationModel.GetViewTitleForTenant("Dashboard", this.Session.GetTenant()); List <MyDatasetsModel> model = new List <MyDatasetsModel>(); using (DatasetManager datasetManager = new DatasetManager()) using (EntityPermissionManager entityPermissionManager = new EntityPermissionManager()) using (UserManager userManager = new UserManager()) using (EntityManager entityManager = new EntityManager()) { var entity = entityManager.FindByName(entityname); var user = userManager.FindByNameAsync(GetUsernameOrDefault()).Result; var rightTypeId = RightType.Read; if (rightType == "write") { rightTypeId = RightType.Write; } else if (rightType == "delete") { rightTypeId = RightType.Delete; } else if (rightType == "grant") { rightTypeId = RightType.Grant; } var userName = GetUsernameOrDefault(); if (userName == "DEFAULT") { ViewBag.userLoggedIn = false; rightTypeId = RightType.Read; } else { ViewBag.userLoggedIn = true; } List <long> datasetIds = entityPermissionManager.GetKeys(GetUsernameOrDefault(), entityname, typeof(Dataset), rightTypeId); List <DatasetVersion> datasetVersions = datasetManager.GetDatasetLatestVersions(datasetIds, true); foreach (var dsv in datasetVersions) { Object[] rowArray = new Object[8]; string isValid = "no"; string type = "file"; if (dsv.Dataset.DataStructure.Self is StructuredDataStructure) { type = "tabular"; } if (dsv.Dataset.Status == DatasetStatus.CheckedIn) { string title = dsv.Title; string description = dsv.Description; if (dsv.StateInfo != null) { isValid = DatasetStateInfo.Valid.ToString().Equals(dsv.StateInfo.State) ? "yes" : "no"; } rowArray[0] = Convert.ToInt64(dsv.Dataset.Id); rowArray[1] = title; rowArray[2] = description; rowArray[3] = type; } else { rowArray[0] = Convert.ToInt64(dsv.Dataset.Id); rowArray[1] = ""; rowArray[2] = "Dataset is just in processing."; rowArray[3] = type; } rowArray[7] = true; model.Add(new MyDatasetsModel( (long)rowArray[0], (string)rowArray[1], (string)rowArray[2], (bool)rowArray[7], isValid, (string)rowArray[3])); } } if (onlyTable == "true") { return(PartialView("_myDatasetsView", model)); } else { return(PartialView("_myDatasetsViewHeader", model)); } }
public List <ListViewItem> LoadDatasetVersionViewList(DataStructureType dataStructureType) { EntityPermissionManager entityPermissionManager = new EntityPermissionManager(); DataStructureManager dataStructureManager = new DataStructureManager(); DatasetManager dm = new DatasetManager(); try { ICollection <long> datasetIDs = new List <long>(); datasetIDs = entityPermissionManager.GetKeys(GetUsernameOrDefault(), "Dataset", typeof(Dataset), RightType.Write).ToList(); Dictionary <long, XmlDocument> dmtemp = new Dictionary <long, XmlDocument>(); dmtemp = dm.GetDatasetLatestMetadataVersions(); List <ListViewItem> temp = new List <ListViewItem>(); if (dataStructureType.Equals(DataStructureType.Structured)) { List <StructuredDataStructure> list = dataStructureManager.StructuredDataStructureRepo.Get().ToList(); foreach (StructuredDataStructure sds in list) { sds.Materialize(); foreach (Dataset d in sds.Datasets) { if (dm.IsDatasetCheckedIn(d.Id)) { if (datasetIDs.Contains(d.Id)) { temp.Add(new ListViewItem(d.Id, xmlDatasetHelper.GetInformationFromVersion(dm.GetDatasetLatestVersion(d).Id, NameAttributeValues.title))); } } } } } else { List <UnStructuredDataStructure> list = dataStructureManager.UnStructuredDataStructureRepo.Get().ToList(); foreach (UnStructuredDataStructure sds in list) { foreach (Dataset d in sds.Datasets) { if (datasetIDs.Contains(d.Id)) { if (dm.IsDatasetCheckedIn(d.Id)) { DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(d); temp.Add(new ListViewItem(d.Id, xmlDatasetHelper.GetInformationFromVersion(datasetVersion.Id, NameAttributeValues.title))); } } } } } return(temp.OrderBy(p => p.Title).ToList()); } finally { entityPermissionManager.Dispose(); dataStructureManager.Dispose(); dm.Dispose(); } }