예제 #1
0
        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();
            }
        }