Beispiel #1
0
        //[MeasurePerformance]
        public ActionResult ShowPrimaryData(long datasetID)
        {
            Session["Filter"]              = null;
            Session["Columns"]             = null;
            Session["DownloadFullDataset"] = false;
            ViewData["DownloadOptions"]    = null;

            DatasetManager       dm  = new DatasetManager();
            DataStructureManager dsm = new DataStructureManager();
            //permission download
            EntityPermissionManager entityPermissionManager = new EntityPermissionManager();

            try
            {
                if (dm.IsDatasetCheckedIn(datasetID))
                {
                    //long versionId = dm.GetDatasetLatestVersionId(datasetID); // check for zero value
                    //DatasetVersion dsv = dm.DatasetVersionRepo.Get(versionId);
                    DatasetVersion          dsv = dm.GetDatasetLatestVersion(datasetID);
                    StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);
                    DataStructure           ds  = dsm.AllTypesDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);

                    // TODO: refactor Download Right not existing, so i set it to read
                    bool downloadAccess = entityPermissionManager.HasEffectiveRight(HttpContext.User.Identity.Name,
                                                                                    "Dataset", typeof(Dataset), datasetID, RightType.Read);

                    //TITLE
                    string title = xmlDatasetHelper.GetInformationFromVersion(dsv.Id, NameAttributeValues.title);

                    if (ds.Self.GetType() == typeof(StructuredDataStructure))
                    {
                        //ToDO Javad: 18.07.2017 -> replaced to the new API for fast retrieval of the latest version
                        //
                        //List<AbstractTuple> dataTuples = dm.GetDatasetVersionEffectiveTuples(dsv, 0, 100);
                        //DataTable table = SearchUIHelper.ConvertPrimaryDataToDatatable(dsv, dataTuples);
                        DataTable table = dm.GetLatestDatasetVersionTuples(dsv.Dataset.Id, 0, 100);

                        Session["gridTotal"] = dm.GetDatasetVersionEffectiveTupleCount(dsv);

                        return(PartialView(ShowPrimaryDataModel.Convert(datasetID, title, sds, table, downloadAccess)));

                        //return PartialView(new ShowPrimaryDataModel());
                    }

                    if (ds.Self.GetType() == typeof(UnStructuredDataStructure))
                    {
                        return
                            (PartialView(ShowPrimaryDataModel.Convert(datasetID, title, ds,
                                                                      SearchUIHelper.GetContantDescriptorFromKey(dsv, "unstructuredData"), downloadAccess)));
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Dataset is just in processing.");
                }

                return(PartialView(null));
            }
            finally
            {
                dm.Dispose();
                dsm.Dispose();
                entityPermissionManager.Dispose();
            }
        }
        public ActionResult ShowPrimaryData(long datasetID, int versionId)
        {
            Session["Filter"]              = null;
            Session["Columns"]             = null;
            Session["DownloadFullDataset"] = false;
            ViewData["DownloadOptions"]    = null;
            IOUtility            iOUtility = new IOUtility();
            DatasetManager       dm        = new DatasetManager();
            DataStructureManager dsm       = new DataStructureManager();
            //permission download
            EntityPermissionManager entityPermissionManager = new EntityPermissionManager();

            try
            {
                if (dm.IsDatasetCheckedIn(datasetID))
                {
                    // get latest or other datasetversion
                    DatasetVersion dsv           = dm.GetDatasetVersion(versionId);
                    bool           latestVersion = versionId == dm.GetDatasetLatestVersionId(datasetID);


                    DataStructure ds = dsm.AllTypesDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);

                    // TODO: refactor Download Right not existing, so i set it to read
                    bool downloadAccess = entityPermissionManager.HasEffectiveRight(HttpContext.User.Identity.Name, typeof(Dataset), datasetID, RightType.Read);

                    bool editRights = entityPermissionManager.HasEffectiveRight(HttpContext.User.Identity.Name, typeof(Dataset), datasetID, RightType.Write);

                    //TITLE
                    string title = dsv.Title;

                    if (ds.Self.GetType() == typeof(UnStructuredDataStructure))
                    {
                        if (this.IsAccessible("MMM", "ShowMultimediaData", "multimediaData") && ConfigurationManager.AppSettings["useMultimediaModule"].ToLower().Equals("true"))
                        {
                            return(RedirectToAction("multimediaData", "ShowMultimediaData", new RouteValueDictionary {
                                { "area", "MMM" }, { "datasetID", datasetID }, { "versionId", versionId }, { "entityType", "Publication" }
                            }));
                        }
                        else
                        {
                            return
                                (PartialView(ShowPrimaryDataModel.Convert(datasetID,
                                                                          versionId,
                                                                          title,
                                                                          ds,
                                                                          SearchUIHelper.GetContantDescriptorFromKey(dsv, "unstructuredData"),
                                                                          downloadAccess,
                                                                          iOUtility.GetSupportedAsciiFiles(),
                                                                          latestVersion,
                                                                          editRights)));
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Dataset is just in processing.");
                }

                return(PartialView(null));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dm.Dispose();
                dsm.Dispose();
                entityPermissionManager.Dispose();
            }
        }