Beispiel #1
0
        public ActionResult ShowListOfMetadataNodesForDescriptionReciever(string Id)
        {
            SearchMetadataNode SelectedNode = GetMetadataNodes().Where(s => s.DisplayName.Equals(Id)).FirstOrDefault();

            ParametersModel model = new ParametersModel();

            model.StepInfo = TaskManager.Current();

            model.DescriptionNode = SelectedNode.DisplayName;

            model.Entities = GetEntityList();

            TaskManager.AddToBus(ImportMetadataStructureTaskManager.DESCRIPTION_NODE, SelectedNode.XPath);

            if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.TITLE_NODE))
            {
                model.TitleNode = GetDisplayName((string)TaskManager.Bus[ImportMetadataStructureTaskManager.TITLE_NODE]);
            }

            if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE))
            {
                model.EntityType = TaskManager.Bus[ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE].ToString();
            }

            return(PartialView("SetParameters", model));
        }
Beispiel #2
0
        /// <summary>
        /// Selected File store din the BUS
        /// </summary>
        /// <param name="SelectFileUploader"></param>
        /// <returns></returns>
        public ActionResult SelectFileProcess(HttpPostedFileBase SelectFileUploader)
        {
            ImportMetadataStructureTaskManager TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            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(ImportMetadataStructureTaskManager.FILEPATH, path);

                TaskManager.AddToBus(ImportMetadataStructureTaskManager.FILENAME, SelectFileUploader.FileName);
                TaskManager.AddToBus(ImportMetadataStructureTaskManager.EXTENTION, SelectFileUploader.FileName.Split('.').Last());
                Session["TaskManager"] = TaskManager;
            }

            //return RedirectToAction("UploadWizard");
            return(Content(""));
        }
Beispiel #3
0
        private List <SearchMetadataNode> GetMetadataNodes()
        {
            TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            if (TaskManager != null && !TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ALL_METADATA_NODES))
            {
                TaskManager.AddToBus(ImportMetadataStructureTaskManager.ALL_METADATA_NODES, GetAllXPathsOfSimpleAttributes());
            }

            return((List <SearchMetadataNode>)TaskManager.Bus[ImportMetadataStructureTaskManager.ALL_METADATA_NODES]);
        }
Beispiel #4
0
        /// <summary>
        /// Selected File from server and store into BUS
        /// </summary>
        /// <param name="SelectFileUploader"></param>
        /// <returns></returns>
        public ActionResult SelectFileFromServerProcess(string fileName)
        {
            ImportMetadataStructureTaskManager TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            if (fileName != null)
            {
                //string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "ServerFiles",fileName);

                //data/datasets/1/1/
                string dataPath = AppConfiguration.DataPath; //Path.Combine(AppConfiguration.WorkspaceRootPath, "Data");
                string path     = Path.Combine(dataPath, "Temp", GetUsernameOrDefault(), fileName);

                TaskManager.AddToBus(ImportMetadataStructureTaskManager.FILEPATH, path);

                TaskManager.AddToBus(ImportMetadataStructureTaskManager.FILENAME, fileName);
                TaskManager.AddToBus(ImportMetadataStructureTaskManager.EXTENTION, "." + fileName.Split('.').Last());
                Session["TaskManager"] = TaskManager;
            }

            //return RedirectToAction("UploadWizard");
            return(Content(""));
        }
        public ActionResult GenerateMS()
        {
            //open schema
            XmlSchemaManager xmlSchemaManager = new XmlSchemaManager();

            string root                = "";
            string schemaName          = "";
            long   metadataStructureid = 0;

            TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ROOT_NODE))
            {
                root = TaskManager.Bus[ImportMetadataStructureTaskManager.ROOT_NODE].ToString();
            }

            if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.SCHEMA_NAME))
            {
                schemaName = TaskManager.Bus[ImportMetadataStructureTaskManager.SCHEMA_NAME].ToString();
            }

            string path = TaskManager.Bus[ImportMetadataStructureTaskManager.FILEPATH].ToString();
            //path = @"https://code.ecoinformatics.org/code/eml/tags/RELEASE_EML_2_1_1/eml.xsd";

            ReadSourceModel model = new ReadSourceModel(TaskManager.Current());

            model.SchemaName = schemaName;
            model.RootNode   = root;

            if (!RegExHelper.IsFilenameValid(schemaName))
            {
                model.ErrorList.Add(new Error(ErrorType.Other,
                                              "Name : \" " + schemaName + " \" is invalid. These special characters are not allowed : \\/:*?\"<>|"));
            }
            else
            {
                try
                {
                    //file.WriteLine("check schema exist");
                    if (SchemaNameExist(schemaName))
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other,
                                                      "A Metadata structure with this name already exist. Please choose a other name."));
                    }
                    else
                    if (String.IsNullOrEmpty(schemaName))
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other, "A Metadata structure must have a name."));
                    }
                    else
                    {
                        xmlSchemaManager.Load(path, GetUserNameOrDefault());
                    }

                    if (!String.IsNullOrEmpty(model.RootNode) && !xmlSchemaManager.Elements.Any(e => e.Name.Equals(model.RootNode)))
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other, "Root node not exist"));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    model.ErrorList.Add(new Error(ErrorType.Other, "Can not create metadatastructure."));
                    throw ex;
                }

                if (model.ErrorList.Count == 0)
                {
                    try
                    {
                        metadataStructureid = xmlSchemaManager.GenerateMetadataStructure(root, schemaName);
                    }
                    catch (Exception ex)
                    {
                        xmlSchemaManager.Delete(schemaName);
                        ModelState.AddModelError("", ex.Message);
                        model.ErrorList.Add(new Error(ErrorType.Other, "Can not create metadatastructure."));
                    }
                }

                TaskManager.AddToBus(ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_IMPORT,
                                     xmlSchemaManager.mappingFileNameImport);
                TaskManager.AddToBus(ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_EXPORT,
                                     xmlSchemaManager.mappingFileNameExport);


                model.StepInfo.notExecuted = false;

                if (model.ErrorList.Count == 0)
                {
                    model.IsGenerated = true;

                    if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.IS_GENERATE))
                    {
                        TaskManager.Bus[ImportMetadataStructureTaskManager.IS_GENERATE] = true;
                    }
                    else
                    {
                        TaskManager.Bus.Add(ImportMetadataStructureTaskManager.IS_GENERATE, true);
                    }

                    if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID))
                    {
                        TaskManager.Bus[ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID] = metadataStructureid;
                    }
                    else
                    {
                        TaskManager.Bus.Add(ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID, metadataStructureid);
                    }
                }
            }

            return(PartialView("ReadSource", model));
        }
Beispiel #6
0
        public ActionResult SelectAFile(object[] data)
        {
            SelectFileViewModel model = new SelectFileViewModel();

            TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"];

            if (data != null)
            {
                TaskManager.AddToBus(data);
            }

            model.StepInfo = TaskManager.Current();

            TaskManager.Current().SetValid(false);

            if (TaskManager != null)
            {
                // is path of FileStream exist
                if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.FILEPATH))
                {
                    if (IsSupportedExtention(TaskManager))
                    {
                        try
                        {
                            //check if file exist and add to taskmanager
                            string filePath = TaskManager.Bus[ImportMetadataStructureTaskManager.FILEPATH].ToString();
                            if (FileHelper.FileExist(filePath))
                            {
                                TaskManager.Current().SetValid(true);
                                TaskManager.Current().SetStatus(StepStatus.success);
                            }
                            else
                            {
                                model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                            }
                        }
                        catch
                        {
                            model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                        }


                        try
                        {
                            LoadXSDSchema(GetUsernameOrDefault());
                        }
                        catch (Exception ex)
                        {
                            ModelState.AddModelError("", ex.Message);
                            model.ErrorList.Add(new Error(ErrorType.Other, "Can not find any dependent files to the selected schema. Please upload missing files to server and try it again."));
                            TaskManager.Current().SetValid(false);
                        }



                        if (TaskManager.Current().IsValid())
                        {
                            TaskManager.AddExecutedStep(TaskManager.Current());
                            TaskManager.GoToNext();
                            Session["TaskManager"] = TaskManager;
                            ActionInfo actionInfo = TaskManager.Current().GetActionInfo;
                            return(RedirectToAction(actionInfo.ActionName, actionInfo.ControllerName, new RouteValueDictionary {
                                { "area", actionInfo.AreaName }, { "index", TaskManager.GetCurrentStepInfoIndex() }
                            }));
                        }
                    }
                    else
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other, "File is not supported."));
                    }
                }
                else
                {
                    model.ErrorList.Add(new Error(ErrorType.Other, "No FileStream selected or submitted."));
                }
            }

            model.serverFileList          = GetServerFileList();
            model.SupportedFileExtentions = ImportMetadataStructureWizardHelper.GetExtentionList();

            return(PartialView(model));
        }