예제 #1
0
        public void fillDatasetList()
        {
            using (DatasetManager dm = new DatasetManager())
            {
                DatasetListElement datasetListElement = new DatasetListElement();
                datasets = new List <DatasetListElement>();

                XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();


                foreach (var item in dm.GetDatasetLatestVersions(dataStructure.Id, true))
                {
                    datasetListElement = new DatasetListElement(item.Key, item.Value.Title);
                    datasets.Add(datasetListElement);
                }
            }
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        public void fillDatasetList()
        {
            DatasetListElement datasetListElement = new DatasetListElement();
            DatasetManager     dm = null;

            datasets = new List <DatasetListElement>();

            try
            {
                dm = new DatasetManager();
                XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();


                foreach (var item in dm.GetDatasetLatestVersions(dataStructure.Id, true))
                {
                    datasetListElement = new DatasetListElement(item.Key, xmlDatasetHelper.GetInformation(item.Value.Id, NameAttributeValues.title));
                    datasets.Add(datasetListElement);
                }
            }
            finally
            {
                dm.Dispose();
            }
        }
예제 #4
0
        public List <EntityStoreItem> GetEntities(int skip, int take)
        {
            bool withPaging = (take > 0);


            using (var uow = this.GetUnitOfWork())
                using (DatasetManager dm = new DatasetManager())
                    using (MetadataStructureManager metadataStructureManager = new MetadataStructureManager())
                    {
                        XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
                        var entities = new List <EntityStoreItem>();

                        try
                        {
                            List <long> metadataStructureIds = metadataStructureManager.Repo.Query().Select(m => m.Id).ToList();

                            List <long> metadataSturctureIdsForDatasets = new List <long>();
                            metadataSturctureIdsForDatasets = metadataStructureIds.Where(m => xmlDatasetHelper.HasEntity(m, _entityName)).ToList();

                            foreach (var msid in metadataSturctureIdsForDatasets)
                            {
                                var datasetIds = new List <long>();
                                // get all datasets based on metadata data structure id
                                if (withPaging)
                                {
                                    datasetIds = dm.DatasetRepo
                                                 .Query(d => d.MetadataStructure.Id.Equals(msid))
                                                 .Skip(skip)
                                                 .Take(take)
                                                 .Select(d => d.Id).ToList();
                                }
                                else
                                {
                                    datasetIds = dm.DatasetRepo.Query(d => d.MetadataStructure.Id.Equals(msid)).Select(d => d.Id).ToList();
                                }


                                if (!datasetIds.Any())
                                {
                                    continue;
                                }

                                // create tuples based on dataset id list, and get latest version of each dataset

                                List <DatasetVersion> datasetVersions = dm.GetDatasetLatestVersions(datasetIds, false);
                                foreach (var dsv in datasetVersions)
                                {
                                    var e = new EntityStoreItem()
                                    {
                                        Id      = dsv.Dataset.Id,
                                        Title   = dsv.Title,
                                        Version = dm.GetDatasetVersionCount(dsv.Dataset.Id)
                                    };

                                    entities.Add(e);
                                }
                            }

                            return(entities.ToList());
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
        }
예제 #5
0
        /// <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));
            }
        }
예제 #6
0
        /// <summary>
        /// create a model to fill the table of My Dataset
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref="ShowMyDatasets"/>
        /// <param>NA</param>
        /// <returns>model</returns>
        public ActionResult _CustomMyDatasetBinding()
        {
            DataTable model = new DataTable();

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

            #region header

            List <HeaderItem> headerItems = CreateHeaderItems();
            ViewData["DefaultHeaderList"] = headerItems;

            #endregion header

            model = CreateDataTable(headerItems);

            DatasetManager          datasetManager          = new DatasetManager();
            EntityPermissionManager entityPermissionManager = new EntityPermissionManager();
            UserManager             userManager             = new UserManager();
            EntityManager           entityManager           = new EntityManager();

            try
            {
                var entity = entityManager.FindByName("Dataset");
                var user   = userManager.FindByNameAsync(GetUsernameOrDefault()).Result;

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

                List <DatasetVersion> datasetVersions = datasetManager.GetDatasetLatestVersions(gridCommands, false);
                foreach (var dsv in datasetVersions)
                {
                    var datasetId = dsv.Dataset.Id;

                    //get permissions
                    int rights = entityPermissionManager.GetEffectiveRights(user?.Id, entity.Id, datasetId);

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

                        if (datasetManager.IsDatasetCheckedIn(datasetId))
                        {
                            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(datasetId);
                            rowArray[1] = title;
                            rowArray[2] = description;
                        }
                        else
                        {
                            rowArray[0] = Convert.ToInt64(datasetId);
                            rowArray[1] = "";
                            rowArray[2] = "Dataset is just in processing.";
                        }

                        rowArray[3] = (rights & (int)RightType.Read) > 0 ? "✔" : "✘";
                        rowArray[4] = (rights & (int)RightType.Write) > 0 ? "✔" : "✘";
                        rowArray[5] = (rights & (int)RightType.Delete) > 0 ? "✔" : "✘";
                        //rowArray[6] = (rights & (int)RightType.Download) > 0 ? "✔" : "✘";
                        rowArray[6] = (rights & (int)RightType.Grant) > 0 ? "✔" : "✘";
                        rowArray[7] = isValid;

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

                return(View(new GridModel(model)));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                datasetManager.Dispose();
                entityPermissionManager.Dispose();
                entityManager.Dispose();
                userManager.Dispose();
            }
        }