示例#1
0
        private SetupModel GetDefaultModel()
        {
            SetupModel model = new SetupModel();

            model = LoadLists(model);

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                model.SelectedMetadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                model.SelectedMetadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            model.BlockDatasetId = false;
            model.BlockDatastructureId = false;
            model.BlockMetadataStructureId = false;

            return model;
        }
示例#2
0
        /// <summary>
        /// load all existing lists for this step
        /// if there are stored in the session
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private SetupModel LoadLists(SetupModel model)
        {
            if ((List<ListViewItem>)Session["MetadataStructureViewList"] != null) model.MetadataStructureViewList = (List<ListViewItem>)Session["MetadataStructureViewList"];
            if ((List<ListViewItemWithType>)Session["DataStructureViewList"] != null) model.DataStructureViewList = (List<ListViewItemWithType>)Session["DataStructureViewList"];
            if ((List<ListViewItem>)Session["DatasetViewList"] != null) model.DatasetViewList = (List<ListViewItem>)Session["DatasetViewList"];

            return model;
        }
示例#3
0
        public ActionResult StoreSelectedDatasetSetup(SetupModel model)
        {
            CreateTaskmanager TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            DatasetManager dm = new DatasetManager();

            if (model == null)
            {
                model = GetDefaultModel();
                return PartialView("Index", model);
            }

            model = LoadLists(model);

            if (ModelState.IsValid )
            {
                TaskManager.AddToBus(CreateTaskmanager.METADATASTRUCTURE_ID, model.SelectedMetadataStructureId);
                TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_ID, model.SelectedDataStructureId);

                // set datastructuretype
                TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_TYPE, GetDataStructureType(model.SelectedDataStructureId));

                //dataset is selected
                if (model.SelectedDatasetId != 0 && model.SelectedDatasetId != -1)
                {
                    if (dm.IsDatasetCheckedIn(model.SelectedDatasetId))
                    {
                        DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(model.SelectedDatasetId);
                        TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID,
                            datasetVersion.Dataset.ResearchPlan.Id);
                        TaskManager.AddToBus(CreateTaskmanager.ENTITY_TITLE,
                            XmlDatasetHelper.GetInformation(datasetVersion, NameAttributeValues.title));

                        // set datastructuretype
                        TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_TYPE,
                            GetDataStructureType(model.SelectedDataStructureId));

                        // set MetadataXml From selected existing Dataset
                        XDocument metadata = XmlUtility.ToXDocument(datasetVersion.Metadata);
                        SetXml(metadata);
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Dataset is just in processing");
                    }
                }
                else
                {
                    ResearchPlanManager rpm = new ResearchPlanManager();
                    TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, rpm.Repo.Get().First().Id);
                }

                return RedirectToAction("StartMetadataEditor", "Form");

            }

            return View("Index", model);
        }