Inheritance: BExIS.Dcm.Wizard.AbstractTaskManager
コード例 #1
0
        public ActionResult Cancel()
        {
            //public ActionResult LoadMetadata(long datasetId, bool locked = false, bool created = false, bool fromEditMode = false, bool resetTaskManager = false, XmlDocument newMetadata = null)

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager != null)
            {
                DatasetManager dm = new DatasetManager();
                long datasetid = -1;
                bool resetTaskManager = true;
                XmlDocument metadata = null;
                bool editmode = false;
                bool created = false;

                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
                {
                    datasetid = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                }

                if (datasetid > -1 && dm.IsDatasetCheckedIn(datasetid))
                {
                    metadata = dm.GetDatasetLatestMetadataVersion(datasetid);
                    editmode = true;
                    created = true;
                }

                return RedirectToAction("LoadMetadata", "Form", new { area = "DCM", entityId = datasetid, created = created, locked = true, fromEditMode = editmode, resetTaskManager = resetTaskManager, newMetadata = metadata });
            }

            return RedirectToAction("StartMetadataEditor", "Form");
        }
コード例 #2
0
        public ActionResult Copy()
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager != null)
            {
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
                {
                    long datasetid = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);

                    return RedirectToAction("Index", "CreateDataset", new { id = datasetid, type = "DatasetId" });

                }
            }
            //Index(long id = -1, string type = "")
            return RedirectToAction("Index", "CreateDataset", new { id = -1, type = "DatasetId" });
        }
コード例 #3
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult ActivateComplexUsage(int id)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            //TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(id);
            //StepModelHelper parentStepModelHelper = GetStepModelhelper(parentStepId);

            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            bool active = stepModelHelper.Activated ? false : true;
            stepModelHelper.Activated = active;
            //stepModelHelper.Parent.Activated = active;
            if (stepModelHelper.Parent != null)
            {
                StepModelHelper pStepModelHelper = GetStepModelhelper(stepModelHelper.Parent.StepId);
                if (pStepModelHelper != null)
                    pStepModelHelper.Activated = active;
            }
            // update stepmodel to dictionary
            //AddStepModelhelper(newStepModelhelper);

            //update stepModel to parentStepModel
            //for (int i = 0; i > parentStepModelHelper.Childrens.Count; i++)
            //{
            //    StepModelHelper tmp = parentStepModelHelper.Childrens.ElementAt(i);
            //    if (tmp.StepId.Equals(stepModelHelper.StepId)) tmp = stepModelHelper;
            //}

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeUsageView", stepModelHelper);
            }

            if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeUsageView", stepModelHelper);
            }

            return null;
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="xmlDocument"></param>
        /// <returns></returns>
        public static CreateTaskmanager Bind(XmlDocument xmlDocument)
        {
            XmlNodeList       xmlStepInfos = xmlDocument.GetElementsByTagName("stepInfo");
            CreateTaskmanager tm           = new CreateTaskmanager();

            tm.StepInfos = new List <StepInfo>();

            foreach (XmlNode xmlStepInfo in xmlStepInfos)
            {
                StepInfo si = new StepInfo(xmlStepInfo.Attributes.GetNamedItem("title").Value)
                {
                    Id            = tm.GenerateStepId(),
                    Parent        = tm.Root,
                    IsInstanze    = true,
                    HasContent    = true,
                    GetActionInfo = new ActionInfo
                    {
                        ActionName     = xmlStepInfo.Attributes.GetNamedItem("action").Value,
                        ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value,
                        AreaName       = xmlStepInfo.Attributes.GetNamedItem("area").Value
                    },

                    PostActionInfo = new ActionInfo
                    {
                        ActionName     = xmlStepInfo.Attributes.GetNamedItem("action").Value,
                        ControllerName = xmlStepInfo.Attributes.GetNamedItem("controller").Value,
                        AreaName       = xmlStepInfo.Attributes.GetNamedItem("area").Value
                    }
                };

                tm.StepInfos.Add(si);
                tm.Root.Children.Add(si);
            }

            tm.currentStepInfo = tm.Root.Children.First();

            return(tm);
        }
コード例 #5
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult ActivateComplexUsageInAChoice(int parentid, int id)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            //TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(id);
            //StepModelHelper parentStepModelHelper = GetStepModelhelper(parentStepId);

            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            bool active = stepModelHelper.Activated ? false : true;
            stepModelHelper.Activated = active;
            stepModelHelper.Parent.Activated = active;

            var firstOrDefault = stepModelHelper.Childrens.FirstOrDefault();
            if (firstOrDefault != null)
                firstOrDefault.Activated = active;

            StepModelHelper pStepModelHelper = GetStepModelhelper(stepModelHelper.Parent.StepId);
            pStepModelHelper.Activated = active;

            // update stepmodel to dictionary
            //AddStepModelhelper(newStepModelhelper);

            //update stepModel to parentStepModel
            for (int i = 0; i < pStepModelHelper.Childrens.Count; i++)
            {
                StepModelHelper child = pStepModelHelper.Childrens.ElementAt(i);
                StepModelHelper childStepModelHelper = GetStepModelhelper(child.StepId);
                child.Activated = child.StepId.Equals(id);
                childStepModelHelper.Activated = child.StepId.Equals(id);

                var childOfChild = child.Childrens.FirstOrDefault();
                if (childOfChild != null)
                    childOfChild.Activated = child.StepId.Equals(id);
            }

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeUsageView", pStepModelHelper);
            }

            if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeUsageView", pStepModelHelper);
            }

            return null;
        }
コード例 #6
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult Reset()
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager != null)
            {
                DatasetManager dm = new DatasetManager();
                long datasetid = -1;
                long metadataStructureid = -1;
                bool resetTaskManager = true;
                XmlDocument metadata = null;
                bool edit = true;
                bool created = false;

                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
                {
                    datasetid = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                }

                if (datasetid > -1 && dm.IsDatasetCheckedIn(datasetid))
                {
                    Dataset dataset = dm.GetDataset(datasetid);
                    metadataStructureid = dataset.MetadataStructure.Id;
                    metadata = dm.GetDatasetLatestMetadataVersion(datasetid);
                    TaskManager.UpdateBus(CreateTaskmanager.METADATA_XML, metadata);
                }

                return RedirectToAction("ImportMetadata", "Form", new { area = "DCM", metadataStructureId = metadataStructureid, edit, created });
            }

            return RedirectToAction("StartMetadataEditor", "Form");
        }
コード例 #7
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult RemoveComplexUsage(int parentStepId, int number)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(parentStepId);
            RemoveFromXml(stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + number + "]");

            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                CreateCompoundModel(TaskManager.Current().Id, true);
            }

            if (u is MetadataPackageUsage)
            {
                stepModelHelper.Model = CreatePackageModel(TaskManager.Current().Id, true);
            }

            stepModelHelper.Childrens.RemoveAt(number - 1);

            //add stepModel to parentStepModel
            for (int i = 0; i < stepModelHelper.Childrens.Count; i++)
            {
                stepModelHelper.Childrens.ElementAt(i).Number = i + 1;
            }

            TaskManager.Remove(TaskManager.Current(), number - 1);

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);

            }
            else if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);
            }

            return null;
        }
コード例 #8
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult LoadMetadataFromExternal(long entityId, string title, long metadatastructureId, long datastructureId=-1,long researchplanId=-1, string sessionKeyForMetadata="", bool resetTaskManager = false)
        {
            bool loadFromExternal = true;
            long metadataStructureId = -1;

            //load metadata from session if exist
            XmlDocument metadata = Session[sessionKeyForMetadata] != null
                ? (XmlDocument) Session[sessionKeyForMetadata]
                : new XmlDocument();

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant()); ;
            ViewData["Locked"] = true;
            ViewData["ShowOptional"] = false;

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager == null || resetTaskManager)
            {
                TaskManager = new CreateTaskmanager();

            }

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            if (loadFromExternal)
            {
                string entityClassPath = "";
                //TaskManager = new CreateTaskmanager();
                Session["CreateDatasetTaskmanager"] = TaskManager;
                TaskManager.AddToBus(CreateTaskmanager.ENTITY_ID, entityId);

                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_CLASS_PATH))
                    entityClassPath = TaskManager.Bus[CreateTaskmanager.ENTITY_CLASS_PATH].ToString();

                bool ready = true;

                // todo i case of entity "BExIS.Dlm.Entities.Data.Dataset" we need to have a check if the dataset is checked in later all enitities should support such functions over webapis
                if (entityClassPath.Equals("BExIS.Dlm.Entities.Data.Dataset"))
                {
                    DatasetManager dm = new DatasetManager();
                    //todo need a check if entity is in use
                    if (!dm.IsDatasetCheckedIn(entityId))
                    {
                        ready = false;
                    }
                }

                if (ready)
                {

                    TaskManager.AddToBus(CreateTaskmanager.METADATASTRUCTURE_ID, metadatastructureId);
                    if(researchplanId!=-1)TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, researchplanId);
                    if(datastructureId!=-1) TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_ID, datastructureId);

                    if (metadata != null && metadata.DocumentElement != null)
                        TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, XmlUtility.ToXDocument(metadata));

                    TaskManager.AddToBus(CreateTaskmanager.ENTITY_TITLE,title);

                    ResearchPlanManager rpm = new ResearchPlanManager();
                    TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, rpm.Repo.Get().First().Id);

                    AdvanceTaskManagerBasedOnExistingMetadata(metadatastructureId);
                    //AdvanceTaskManager(dsv.Dataset.MetadataStructure.Id);

                    foreach (var stepInfo in TaskManager.StepInfos)
                    {

                        StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                        if (stepModelHelper.Model == null)
                        {
                            if (stepModelHelper.Usage is MetadataPackageUsage)
                            {
                                stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);
                                if (stepModelHelper.Model.StepInfo.IsInstanze)
                                    LoadSimpleAttributesForModelFromXml(stepModelHelper);
                            }

                            if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                            {
                                stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);
                                if (stepModelHelper.Model.StepInfo.IsInstanze)
                                    LoadSimpleAttributesForModelFromXml(stepModelHelper);
                            }

                            getChildModelsHelper(stepModelHelper);
                        }

                        stepInfoModelHelpers.Add(stepModelHelper);

                    }

                    if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML))
                    {
                        XDocument xMetadata = (XDocument) TaskManager.Bus[CreateTaskmanager.METADATA_XML];

                        if (String.IsNullOrEmpty(title)) title = "No Title available.";

                        if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_TITLE))
                        {
                            if(TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE]!=null)
                                Model.DatasetTitle = TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE].ToString();
                        }
                        else
                            Model.DatasetTitle = "No Title available.";

                    }
                }
                else
                {
                    ModelState.AddModelError(String.Empty, "Dataset is just in processing.");
                }

            }

            Model.DatasetId = entityId;
            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Created = false;

            //check if a metadatastructure has a import mapping
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            if (metadataStructureId != -1)
                Model.Import = IsImportAvavilable(metadataStructureId);

            //FromCreateOrEditMode
            TaskManager.AddToBus(CreateTaskmanager.EDIT_MODE, false);
            Model.FromEditMode = (bool)TaskManager.Bus[CreateTaskmanager.EDIT_MODE];

            // set edit rights
            Model.EditRight = hasUserEditRights(entityId);
            Model.EditAccessRight = hasUserEditAccessRights(entityId);

            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
コード例 #9
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult ImportMetadata(long metadataStructureId, bool edit = true, bool created = false, bool locked = false)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            XmlDocument newMetadata = (XmlDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, XmlUtility.ToXDocument(newMetadata));

            AdvanceTaskManagerBasedOnExistingMetadata(metadataStructureId);

            foreach (var stepInfo in TaskManager.StepInfos)
            {

                StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                if (stepModelHelper.Model == null)
                {
                    if (stepModelHelper.Usage is MetadataPackageUsage)
                    {
                        stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);
                        if (stepModelHelper.Model.StepInfo.IsInstanze)
                            LoadSimpleAttributesForModelFromXml(stepModelHelper);
                    }

                    if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                    {
                        stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);
                        if (stepModelHelper.Model.StepInfo.IsInstanze)
                            LoadSimpleAttributesForModelFromXml(stepModelHelper);
                    }

                    getChildModelsHelper(stepModelHelper);
                }

                stepInfoModelHelpers.Add(stepModelHelper);

            }

            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Import = IsImportAvavilable(metadataStructureId);
            //set addtionaly functions
            Model.Actions = getAddtionalActions();
            Model.FromEditMode = edit;
            Model.Created = created;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
            {
                long entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                Model.EditRight = hasUserEditRights(entityId);
                Model.EditAccessRight = hasUserEditAccessRights(entityId);
                //Model.DatasetId = entityId;

            }
            else
            {
                Model.EditRight = false;
                Model.EditAccessRight = false;
                Model.DatasetId = -1;
            }

            ViewData["Locked"] = locked;

            return PartialView("MetadataEditor", Model);
        }
コード例 #10
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult DownComplexUsage(int parentStepId, int number)
        {
            int newIndex = number;
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(parentStepId);
            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            if (newIndex <= stepModelHelper.Childrens.Count - 1)
            {

                string xPathOfSelectedElement = stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + number + "]";
                string destinationXPathElement = stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + (number + 1) + "]";

                ChangeInXml(xPathOfSelectedElement, destinationXPathElement);

                if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
                {
                    CreateCompoundModel(TaskManager.Current().Id, true);
                }

                if (u is MetadataPackageUsage)
                {
                    stepModelHelper.Model = CreatePackageModel(TaskManager.Current().Id, true);
                }

                StepModelHelper selectedStepModelHelper = stepModelHelper.Childrens.ElementAt(number - 1);
                stepModelHelper.Childrens.Remove(selectedStepModelHelper);

                stepModelHelper.Childrens.Insert(newIndex, selectedStepModelHelper);

                //update childrens of the parent step based on number
                for (int i = 0; i < stepModelHelper.Childrens.Count; i++)
                {
                    StepModelHelper smh = stepModelHelper.Childrens.ElementAt(i);
                    smh.Number = i + 1;
                    smh.Model.Number = i + 1;
                }

                StepInfo selectedStepInfo = stepModelHelper.Model.StepInfo.Children.ElementAt(number - 1);
                stepModelHelper.Model.StepInfo.Children.Remove(selectedStepInfo);
                stepModelHelper.Model.StepInfo.Children.Insert(newIndex, selectedStepInfo);

                for (int i = 0; i < stepModelHelper.Model.StepInfo.Children.Count; i++)
                {
                    StepInfo si = stepModelHelper.Model.StepInfo.Children.ElementAt(i);
                    si.title = (i + 1).ToString();
                }

                stepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), stepModelHelper.XPath);

            }

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);

            }
            else if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);
            }

            return null;
        }
コード例 #11
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void CreateXml()
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            // load metadatastructure with all packages and attributes

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
            {
                XmlMetadataWriter xmlMetadatWriter = new XmlMetadataWriter(XmlNodeMode.xPath);

                XDocument metadataXml = xmlMetadatWriter.CreateMetadataXml(Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]));

                //local path
                //string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "metadataTemp.Xml");

                TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, metadataXml);

                //setup loaded
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.SETUP_LOADED))
                    TaskManager.Bus[CreateTaskmanager.SETUP_LOADED] = true;
                else
                    TaskManager.Bus.Add(CreateTaskmanager.SETUP_LOADED, true);

                //save
                //metadataXml.Save(path);
            }
        }
コード例 #12
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void ChangeInXml(string selectedXPath, string destinationXPath)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];
            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);

            metadataXml = xmlMetadataWriter.Change(metadataXml, selectedXPath, destinationXPath);

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
            // locat path
            string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "metadataTemp.Xml");
            metadataXml.Save(path);
        }
コード例 #13
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult AddComplexUsage(int parentStepId, int number)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            //TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
            int position = number + 1;

            StepModelHelper parentStepModelHelper = GetStepModelhelper(parentStepId);
            BaseUsage u = LoadUsage(parentStepModelHelper.Usage);

            //Create new step
            StepInfo newStep = new StepInfo(UsageHelper.GetNameOfType(u))
            {
                Id = TaskManager.GenerateStepId(),
                parentTitle = parentStepModelHelper.Model.StepInfo.title,
                Parent = parentStepModelHelper.Model.StepInfo,
                IsInstanze = true,
            };

            string xPath = parentStepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(u) + "[" + position + "]";

            // add to parent stepId
            parentStepModelHelper.Model.StepInfo.Children.Add(newStep);
            TaskManager.StepInfos.Add(newStep);

            // create Model
            AbstractMetadataStepModel model = null;

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                model = MetadataCompoundAttributeModel.ConvertToModel(parentStepModelHelper.Usage, number);
                model.Number = position;

                ((MetadataCompoundAttributeModel)model).ConvertMetadataAttributeModels(LoadUsage(parentStepModelHelper.Usage), metadataStructureId, newStep.Id);

                //Update metadata xml
                //add step to metadataxml
                AddCompoundAttributeToXml(model.Source, model.Number, parentStepModelHelper.XPath);
            }

            if (u is MetadataPackageUsage)
            {
                model = MetadataPackageModel.Convert(parentStepModelHelper.Usage, number);
                model.Number = position;
                ((MetadataPackageModel)model).ConvertMetadataAttributeModels(LoadUsage(parentStepModelHelper.Usage), metadataStructureId, newStep.Id);

                //Update metadata xml
                //add step to metadataxml
                AddPackageToXml(model.Source, model.Number, parentStepModelHelper.XPath);
            }

            // create StepModel for new step
            StepModelHelper newStepModelhelper = new StepModelHelper
            {
                StepId = newStep.Id,
                Usage = parentStepModelHelper.Usage,
                Number = position,
                Model = model,
                XPath = xPath,
                Level = parentStepModelHelper.Level+1,
                Activated = true
            };

            newStep.Children = GetChildrenSteps(u, newStep, xPath, newStepModelhelper);
            newStepModelhelper.Model.StepInfo = newStep;
            newStepModelhelper = getChildModelsHelper(newStepModelhelper);

            // add stepmodel to dictionary
            AddStepModelhelper(newStepModelhelper);

            //add stepModel to parentStepModel
            parentStepModelHelper.Childrens.Insert(newStepModelhelper.Number - 1, newStepModelhelper);

            //update childrens of the parent step based on number
            for (int i = 0; i < parentStepModelHelper.Childrens.Count; i++)
            {
                StepModelHelper smh = parentStepModelHelper.Childrens.ElementAt(i);
                smh.Number = i + 1;
            }

            // add step to parent and update title of steps
            //parentStepModelHelper.Model.StepInfo.Children.Insert(newStepModelhelper.Number - 1, newStep);
            for (int i = 0; i < parentStepModelHelper.Model.StepInfo.Children.Count; i++)
            {
                StepInfo si = parentStepModelHelper.Model.StepInfo.Children.ElementAt(i);
                si.title = (i + 1).ToString();
            }

            //// load InstanzB for parentmodel
            parentStepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), parentStepModelHelper.XPath);

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeView", parentStepModelHelper);
            }

            if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeView", parentStepModelHelper);
            }

            return null;
        }
コード例 #14
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void AdvanceTaskManagerBasedOnExistingMetadata(long MetadataStructureId)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();

            List<MetadataPackageUsage> metadataPackageList = metadataStructureManager.GetEffectivePackages(MetadataStructureId).ToList();

            List<StepModelHelper> stepModelHelperList = new List<StepModelHelper>();
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_STEP_MODEL_HELPER))
            {
                TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList;
            }
            else
            {
                TaskManager.Bus.Add(CreateTaskmanager.METADATA_STEP_MODEL_HELPER, stepModelHelperList);
            }

            TaskManager.StepInfos = new List<StepInfo>();

            foreach (MetadataPackageUsage mpu in metadataPackageList)
            {
                //only add none optional usages
                StepInfo si = new StepInfo(mpu.Label)
                {
                    Id = TaskManager.GenerateStepId(),
                    parentTitle = mpu.MetadataPackage.Name,
                    Parent = TaskManager.Root,
                    IsInstanze = false,
                };

                TaskManager.StepInfos.Add(si);
                StepModelHelper stepModelHelper = new StepModelHelper(si.Id, 1, mpu, "Metadata//" + mpu.Label.Replace(" ", string.Empty) + "[1]", null);

                stepModelHelperList.Add(stepModelHelper);

                si = LoadStepsBasedOnUsage(mpu, si, "Metadata//" + mpu.Label.Replace(" ", string.Empty) + "[1]", stepModelHelper);
                TaskManager.Root.Children.Add(si);

                TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList;

            }

            TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER] = stepModelHelperList;
            Session["CreateDatasetTaskmanager"] = TaskManager;
        }
コード例 #15
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private StepModelHelper AddStepModelhelper(StepModelHelper stepModelHelper)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_STEP_MODEL_HELPER))
            {
                ((List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]).Add(stepModelHelper);

                return stepModelHelper;
            }

            return stepModelHelper;
        }
コード例 #16
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void UpdateCompoundAttributeToXml(BaseUsage usage, int number, string xpath)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);

            metadataXml = xmlMetadataWriter.AddPackage(metadataXml, usage, number, UsageHelper.GetNameOfType(usage), UsageHelper.GetIdOfType(usage), UsageHelper.GetChildren(usage), BExIS.Xml.Helpers.XmlNodeType.MetadataAttribute, BExIS.Xml.Helpers.XmlNodeType.MetadataAttributeUsage, xpath);

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
        }
コード例 #17
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private StepModelHelper GetStepModelhelper(int stepId)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_STEP_MODEL_HELPER))
            {
                return ((List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER]).Where(s => s.StepId.Equals(stepId)).FirstOrDefault();
            }

            return null;
        }
コード例 #18
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult DownMetadataAttributeUsage(object value, int id, int parentid, int number, int parentModelNumber, int parentStepId)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            List<StepModelHelper> list = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER];

            StepModelHelper stepModelHelperParent = list.Where(s => s.StepId.Equals(parentStepId)).FirstOrDefault();

            Down(stepModelHelperParent, id, number);

            UpdateChildrens(stepModelHelperParent, id);

            AbstractMetadataStepModel model = stepModelHelperParent.Model;

            if (model != null)
            {
                if (model is MetadataPackageModel)
                {
                    return PartialView("_metadataPackageUsageView", stepModelHelperParent);
                }

                if (model is MetadataCompoundAttributeModel)
                {
                    return PartialView("_metadataCompoundAttributeUsageView", stepModelHelperParent);
                }
            }

            return null;
        }
コード例 #19
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private AbstractMetadataStepModel LoadSimpleAttributesForModelFromXml(StepModelHelper stepModelHelper)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            XDocument metadata = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            XElement complexElement = XmlUtility.GetXElementByXPath(stepModelHelper.XPath, metadata);
            List<MetadataAttributeModel> additionalyMetadataAttributeModel = new List<MetadataAttributeModel>();

            foreach (MetadataAttributeModel simpleMetadataAttributeModel in stepModelHelper.Model.MetadataAttributeModels)
            {
                int numberOfSMM = 1;
                if (complexElement != null)
                {
                    //Debug.WriteLine("XXXXXXXXXXXXXXXXXXXX");
                    //Debug.WriteLine(simpleMetadataAttributeModel.Source.Label);
                    IEnumerable<XElement> childs = XmlUtility.GetChildren(complexElement).Where(e => e.Attribute("id").Value.Equals(simpleMetadataAttributeModel.Id.ToString()));

                    if (childs.Any())
                        numberOfSMM = childs.First().Elements().Count();
                }

                for (int i = 1; i <= numberOfSMM; i++)
                {
                    string xpath = stepModelHelper.GetXPathFromSimpleAttribute(simpleMetadataAttributeModel.Id, i);
                    XElement simpleElement = XmlUtility.GetXElementByXPath(xpath, metadata);

                    if (i == 1)
                    {

                        if (simpleElement != null && !String.IsNullOrEmpty(simpleElement.Value))
                        {
                            simpleMetadataAttributeModel.Value = simpleElement.Value;
                            // if at least on item has a value, the parent should be activated
                            setStepModelActive(stepModelHelper);
                        }

                    }
                    else
                    {
                        MetadataAttributeModel newMetadataAttributeModel = simpleMetadataAttributeModel.Kopie(i, numberOfSMM);
                        newMetadataAttributeModel.Value = simpleElement.Value;
                        if (i == numberOfSMM) newMetadataAttributeModel.last = true;
                        additionalyMetadataAttributeModel.Add(newMetadataAttributeModel);
                    }

                }
            }

            foreach (var item in additionalyMetadataAttributeModel)
            {
                List<MetadataAttributeModel> tempList = stepModelHelper.Model.MetadataAttributeModels;

                int indexOfLastSameAttribute = tempList.IndexOf(tempList.Where(a => a.Id.Equals(item.Id)).Last());
                tempList.Insert(indexOfLastSameAttribute + 1, item);
            }

            return stepModelHelper.Model;
        }
コード例 #20
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult LoadExternalXml()
        {
            string validationMessage = "";

            if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            if (TaskManager != null &&
                TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID) &&
                TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_IMPORT_XML_FILEPATH))
            {

                //xml metadata for import
                string metadataForImportPath = (string)TaskManager.Bus[CreateTaskmanager.METADATA_IMPORT_XML_FILEPATH];

                if (FileHelper.FileExist(metadataForImportPath))
                {
                    XmlDocument metadataForImport = new XmlDocument();
                    metadataForImport.Load(metadataForImportPath);

                    // metadataStructure ID
                    long metadataStructureId = (Int64)TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID];
                    MetadataStructureManager metadataStructureManager = new MetadataStructureManager();
                    string metadataStructrueName = metadataStructureManager.Repo.Get(metadataStructureId).Name;

                    // loadMapping file
                    string path_mappingFile = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DIM"), XmlMetadataImportHelper.GetMappingFileName(metadataStructureId, TransmissionType.mappingFileImport, metadataStructrueName));

                    // XML mapper + mapping file
                    XmlMapperManager xmlMapperManager = new XmlMapperManager(TransactionDirection.ExternToIntern);
                    xmlMapperManager.Load(path_mappingFile, "IDIV");

                    // generate intern metadata without internal attributes
                    XmlDocument metadataResult = xmlMapperManager.Generate(metadataForImport, 1, true);

                    // generate intern template metadata xml with needed attribtes
                    XmlMetadataWriter xmlMetadatWriter = new XmlMetadataWriter(BExIS.Xml.Helpers.XmlNodeMode.xPath);
                    XDocument metadataXml = xmlMetadatWriter.CreateMetadataXml(metadataStructureId,
                        XmlUtility.ToXDocument(metadataResult));

                    XmlDocument metadataXmlTemplate = XmlMetadataWriter.ToXmlDocument(metadataXml);

                    // set attributes FROM metadataXmlTemplate TO metadataResult
                    XmlDocument completeMetadata = XmlMetadataImportHelper.FillInXmlValues(metadataResult,
                        metadataXmlTemplate);

                    TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, completeMetadata);

                    //LoadMetadata(long datasetId, bool locked= false, bool created= false, bool fromEditMode = false, bool resetTaskManager = false, XmlDocument newMetadata=null)
                    return RedirectToAction("ImportMetadata", "Form",
                        new {metadataStructureId = metadataStructureId});

                }
            }

            return Content("Error Message :"+validationMessage);
        }
コード例 #21
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void RemoveAttributeToXml(BaseUsage parentUsage, int packageNumber, BaseUsage attribute, int number, string metadataAttributeName, string parentXPath)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];
            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);

            metadataXml = xmlMetadataWriter.RemoveAttribute(metadataXml, attribute, number, metadataAttributeName, parentXPath);

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
            // locat path
            //string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "metadataTemp.Xml");
            //metadataXml.Save
        }
コード例 #22
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult LoadMetadata(long entityId, bool locked = false, bool created = false, bool fromEditMode = false, bool resetTaskManager = false, XmlDocument newMetadata = null)
        {
            bool loadFromExternal = resetTaskManager;
            long metadataStructureId = -1;

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            ViewData["Locked"] = locked;
            ViewData["ShowOptional"] = false;

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager == null)
            {
                TaskManager = new CreateTaskmanager();
                loadFromExternal = true;
            }

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            stepInfoModelHelpers = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER];

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_TITLE))
            {
                if (TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE] != null)
                    Model.DatasetTitle = TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE].ToString();
            }
            else
                Model.DatasetTitle = "No Title available.";

            Model.DatasetId = entityId;
            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Created = created;

            //check if a metadatastructure has a import mapping
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            if(metadataStructureId!=-1)
                Model.Import = IsImportAvavilable(metadataStructureId);

            //FromCreateOrEditMode
            TaskManager.AddToBus(CreateTaskmanager.EDIT_MODE, fromEditMode);
            Model.FromEditMode = (bool)TaskManager.Bus[CreateTaskmanager.EDIT_MODE];

            Model.EditRight = hasUserEditRights(entityId);
            Model.EditAccessRight = hasUserEditAccessRights(entityId);

            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
コード例 #23
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void RemoveCompoundAttributeToXml(BaseUsage usage, int number)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);
            metadataXml = xmlMetadataWriter.RemovePackage(metadataXml, usage, number, UsageHelper.GetNameOfType(usage));

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
        }
コード例 #24
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult ReloadMetadataEditor(bool locked = false, bool show = false)
        {
            ViewData["Locked"] = locked;
            ViewData["ShowOptional"] = show;

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();

            foreach (var stepInfo in TaskManager.StepInfos)
            {

                StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                if (stepModelHelper.Model == null)
                {
                    if (stepModelHelper.Usage is MetadataPackageUsage)
                        stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);

                    if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                        stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);

                    getChildModelsHelper(stepModelHelper);
                }

                stepInfoModelHelpers.Add(stepModelHelper);

            }

            MetadataEditorModel Model = new MetadataEditorModel();
            Model.StepModelHelpers = stepInfoModelHelpers;

            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthorizationRights = false;
            bool hasAuthenticationRigths = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;
            long entityId = -1;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
            {
                entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                Model.EditRight = hasUserEditRights(entityId);
                Model.EditAccessRight = hasUserEditAccessRights(entityId);

            }
            else
            {
                Model.EditRight = false;
                Model.EditAccessRight = false;
            }

            Model.FromEditMode = true;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
            {
                long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                Model.Import = IsImportAvavilable(metadataStructureId);
            }

            #endregion
            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
コード例 #25
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void RemoveFromXml(string xpath)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);
            metadataXml = xmlMetadataWriter.Remove(metadataXml, xpath);

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
        }
コード例 #26
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult RemoveMetadataAttributeUsage(object value, int id, int parentid, int number, int parentModelNumber, int parentStepId)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            List<StepModelHelper> list = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER];

            StepModelHelper stepModelHelperParent = list.Where(s => s.StepId.Equals(parentStepId)).FirstOrDefault();

            //find the right element in the list
            MetadataAttributeModel removeAttributeModel = stepModelHelperParent.Model.MetadataAttributeModels.Where(m => m.Source.Id.Equals(id) && m.Number.Equals(number)).First();
            //remove attribute
            stepModelHelperParent.Model.MetadataAttributeModels.Remove(removeAttributeModel);
            //update childrenList
            UpdateChildrens(stepModelHelperParent, id);

            AbstractMetadataStepModel model = stepModelHelperParent.Model;

            BaseUsage parentUsage = stepModelHelperParent.Usage;
            BaseUsage attrUsage = UsageHelper.GetChildren(parentUsage).Where(u => u.Id.Equals(id)).FirstOrDefault();

            //remove from xml
            RemoveAttributeToXml(stepModelHelperParent.Usage, stepModelHelperParent.Number, attrUsage, number, UsageHelper.GetNameOfType(attrUsage), stepModelHelperParent.XPath);

            if (model != null)
            {

                if (model is MetadataPackageModel)
                {
                    return PartialView("_metadataPackageUsageView", stepModelHelperParent);
                }

                if (model is MetadataCompoundAttributeModel)
                {
                    return PartialView("_metadataCompoundAttributeUsageView", stepModelHelperParent);
                }
            }

            return null;
        }
コード例 #27
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void SetXml(XDocument metadataXml)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            // load metadatastructure with all packages and attributes

            if (metadataXml != null)
            {
                // locat path
                //string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "metadataTemp.Xml");

                TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, metadataXml);

                //setup loaded
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.SETUP_LOADED))
                    TaskManager.Bus[CreateTaskmanager.SETUP_LOADED] = true;
                else
                    TaskManager.Bus.Add(CreateTaskmanager.SETUP_LOADED, true);
            }
        }
コード例 #28
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        /// <summary>
        /// Selected File store din the BUS
        /// </summary>
        /// <param name="SelectFileUploader"></param>
        /// <returns></returns>
        public ActionResult SelectFileProcess(HttpPostedFileBase SelectFileUploader)
        {
            if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            if (SelectFileUploader != null)
            {
                //data/datasets/1/1/
                string dataPath = AppConfiguration.DataPath; //Path.Combine(AppConfiguration.WorkspaceRootPath, "Data");
                string storepath = Path.Combine(dataPath, "Temp", GetUsernameOrDefault());

                // if folder not exist
                if (!Directory.Exists(storepath))
                {
                    Directory.CreateDirectory(storepath);
                }

                string path = Path.Combine(storepath, SelectFileUploader.FileName);

                SelectFileUploader.SaveAs(path);

                TaskManager.AddToBus(CreateTaskmanager.METADATA_IMPORT_XML_FILEPATH, path);

            }

            return Content("");
        }
コード例 #29
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        private void UpdateAttribute(BaseUsage parentUsage, int packageNumber, BaseUsage attribute, int number, object value, string parentXpath)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            XDocument metadataXml = (XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];
            XmlMetadataWriter xmlMetadataWriter = new XmlMetadataWriter(XmlNodeMode.xPath);

            metadataXml = xmlMetadataWriter.Update(metadataXml, attribute, number, value, UsageHelper.GetNameOfType(attribute), parentXpath);

            TaskManager.Bus[CreateTaskmanager.METADATA_XML] = metadataXml;
            // locat path
            string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "metadataTemp.Xml");
            metadataXml.Save(path);
        }
コード例 #30
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult StartMetadataEditor()
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            ViewData["ShowOptional"] = false;

            MetadataEditorModel Model = new MetadataEditorModel();

            if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            if (TaskManager != null)
            {
                //load empty metadata xml if needed
                if (!TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML))
                {
                    CreateXml();
                }

                bool loaded = false;
                //check if formsteps are loaded
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.FORM_STEPS_LOADED))
                {
                    loaded = (bool)TaskManager.Bus[CreateTaskmanager.FORM_STEPS_LOADED];
                }

                // load form steps
                if (loaded == false && TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                {
                    long metadataStrutureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                    // generate all steps
                    // one step for each complex type  in the metadata structure
                    AdvanceTaskManager(metadataStrutureId);
                }

                List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();

                // foreach step and the childsteps... generate a stepModelhelper
                foreach (var stepInfo in TaskManager.StepInfos)
                {
                    StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                    if (stepModelHelper.Model == null)
                    {
                        if (stepModelHelper.Usage is MetadataPackageUsage)
                            stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);

                        if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                            stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);

                        getChildModelsHelper(stepModelHelper);
                    }

                    stepInfoModelHelpers.Add(stepModelHelper);

                }

                Model.StepModelHelpers = stepInfoModelHelpers;

                //set import
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                {
                    long id = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                    Model.Import = IsImportAvavilable(id);
                }

                //set addtionaly functions
                Model.Actions = getAddtionalActions();
            }

            return View("MetadataEditor", Model);
        }
コード例 #31
0
ファイル: FormController.cs プロジェクト: BEXIS2/Core
        public ActionResult AddMetadataAttributeUsage(int id, int parentid, int number, int parentModelNumber, int parentStepId)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            List<StepModelHelper> list = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER];

            StepModelHelper stepModelHelperParent = list.Where(s => s.StepId.Equals(parentStepId)).FirstOrDefault();

            BaseUsage parentUsage = LoadUsage(stepModelHelperParent.Usage);
            int pNumber = stepModelHelperParent.Number;

            BaseUsage metadataAttributeUsage = UsageHelper.GetChildren(parentUsage).Where(u => u.Id.Equals(id)).FirstOrDefault();

            //BaseUsage metadataAttributeUsage = UsageHelper.GetSimpleUsageById(parentUsage, id);

            MetadataAttributeModel modelAttribute = MetadataAttributeModel.Convert(metadataAttributeUsage, parentUsage, metadataStructureId, parentModelNumber, stepModelHelperParent.StepId);
            modelAttribute.Number = ++number;

            AbstractMetadataStepModel model = stepModelHelperParent.Model;

            Insert(modelAttribute, stepModelHelperParent, number);
            UpdateChildrens(stepModelHelperParent, modelAttribute.Source.Id);

            //addtoxml
            AddAttributeToXml(parentUsage, parentModelNumber, metadataAttributeUsage, number, stepModelHelperParent.XPath);

            model.ConvertInstance((XDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML], stepModelHelperParent.XPath + "//" + metadataAttributeUsage.Label.Replace(" ", string.Empty));

            if (model != null)
            {

                if (model is MetadataPackageModel)
                {
                    return PartialView("_metadataPackageUsageView", stepModelHelperParent);
                }

                if (model is MetadataCompoundAttributeModel)
                {
                    return PartialView("_metadataCompoundAttributeUsageView", stepModelHelperParent);
                }
            }

            return null;
        }