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)); }
public ActionResult ReadSource(int index) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; //set current stepinfo based on index if (TaskManager != null) { TaskManager.SetCurrent(index); TaskManager.RemoveExecutedStep(TaskManager.Current()); TaskManager.Current().notExecuted = true; } ReadSourceModel model = new ReadSourceModel(TaskManager.Current()); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.IS_GENERATE)) { model.IsGenerated = (bool)TaskManager.Bus[ImportMetadataStructureTaskManager.IS_GENERATE]; } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ROOT_NODE)) { model.RootNode = TaskManager.Bus[ImportMetadataStructureTaskManager.ROOT_NODE].ToString(); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.SCHEMA_NAME)) { model.SchemaName = TaskManager.Bus[ImportMetadataStructureTaskManager.SCHEMA_NAME].ToString(); } return(PartialView(model)); }
public ActionResult Summary(int index) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; //set current stepinfo based on index if (TaskManager != null) { TaskManager.SetCurrent(index); } SummaryModel model = new SummaryModel(TaskManager.Current()); model.StepInfo = TaskManager.Current(); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ROOT_NODE)) { model.RootName = TaskManager.Bus[ImportMetadataStructureTaskManager.ROOT_NODE].ToString(); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.SCHEMA_NAME)) { model.SchemaName = TaskManager.Bus[ImportMetadataStructureTaskManager.SCHEMA_NAME].ToString(); } return(PartialView(model)); }
public ActionResult SelectAFile(int index) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; //set current stepinfo based on index if (TaskManager != null) { TaskManager.SetCurrent(index); } //Get Bus infomations SelectFileViewModel model = new SelectFileViewModel(); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.FILENAME)) { model.SelectedFileName = TaskManager.Bus[ImportMetadataStructureTaskManager.FILENAME].ToString(); } //get datastuctureType model.SupportedFileExtentions = ImportMetadataStructureWizardHelper.GetExtentionList(); //Get StepInfo model.StepInfo = TaskManager.Current(); model.serverFileList = GetServerFileList(); return(PartialView(model)); }
public ActionResult ReadSource(object[] data) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; ReadSourceModel model = new ReadSourceModel(TaskManager.Current()); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.IS_GENERATE)) { TaskManager.Current().SetValid(true); TaskManager.Current().SetStatus(StepStatus.success); } else { ModelState.AddModelError("", "Please click generate button."); } 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() } })); } return(PartialView(model)); }
public ActionResult Save(ParametersModel model) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; long metadatstructureId = Convert.ToInt64(TaskManager.Bus[ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID]); model.MetadataNodes = GetMetadataNodes(); model.StepInfo = TaskManager.Current(); model.StepInfo.notExecuted = false; if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.TITLE_NODE)) { TaskManager.Bus[ImportMetadataStructureTaskManager.TITLE_NODE] = model.TitleNode; } else { TaskManager.Bus.Add(ImportMetadataStructureTaskManager.TITLE_NODE, model.TitleNode); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.DESCRIPTION_NODE)) { TaskManager.Bus[ImportMetadataStructureTaskManager.DESCRIPTION_NODE] = model.DescriptionNode; } else { TaskManager.Bus.Add(ImportMetadataStructureTaskManager.DESCRIPTION_NODE, model.DescriptionNode); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE)) { TaskManager.Bus[ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE] = model.EntityType; } else { TaskManager.Bus.Add(ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE, model.EntityType); } string mappingFilePathImport = TaskManager.Bus[ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_IMPORT].ToString(); string mappingFilePathExport = TaskManager.Bus[ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_EXPORT].ToString(); try { StoreParametersToMetadataStruture(metadatstructureId, model.TitleNode, model.EntityType, model.DescriptionNode, mappingFilePathImport, mappingFilePathExport); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return(PartialView("SetParameters", model)); }
public ActionResult SetParameters(int index) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; long metadatstructureId = 0; ParametersModel model = new ParametersModel(); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID)) { metadatstructureId = Convert.ToInt64(TaskManager.Bus[ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID]); //set current stepinfo based on index if (TaskManager != null) { TaskManager.SetCurrent(index); } model.MetadataNodes = GetMetadataNodes(); model.Entities = GetEntityList(); } else { ModelState.AddModelError("", "MetadataStructure not exist"); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.TITLE_NODE)) { model.TitleNode = GetDisplayName((string)TaskManager.Bus[ImportMetadataStructureTaskManager.TITLE_NODE]); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.DESCRIPTION_NODE)) { model.DescriptionNode = GetDisplayName((string)TaskManager.Bus[ImportMetadataStructureTaskManager.DESCRIPTION_NODE]); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE)) { model.EntityType = TaskManager.Bus[ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE].ToString(); } model.StepInfo = TaskManager.Current(); model.StepInfo.notExecuted = true; return(PartialView(model)); }
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)); }
public ActionResult SetParameters(int?index, string name = null) { TaskManager = (ImportMetadataStructureTaskManager)Session["TaskManager"]; ParametersModel model = new ParametersModel(); model.StepInfo = TaskManager.Current(); if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.TITLE_NODE) && TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.DESCRIPTION_NODE) && TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE)) { long id = Convert.ToInt64((TaskManager.Bus[ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID])); string mappingFilePathImport = TaskManager.Bus[ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_IMPORT].ToString(); string mappingFilePathExport = TaskManager.Bus[ImportMetadataStructureTaskManager.MAPPING_FILE_NAME_EXPORT].ToString(); string titleXpath = TaskManager.Bus[ImportMetadataStructureTaskManager.TITLE_NODE].ToString(); string descriptionXpath = TaskManager.Bus[ImportMetadataStructureTaskManager.DESCRIPTION_NODE].ToString(); string entity = TaskManager.Bus[ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE].ToString(); model.TitleNode = GetMetadataNodes().First(p => p.XPath.Equals(titleXpath)).DisplayName; model.DescriptionNode = GetMetadataNodes().First(p => p.XPath.Equals(descriptionXpath)).DisplayName; model.EntityType = TaskManager.Bus[ImportMetadataStructureTaskManager.ENTITY_TYPE_NODE].ToString(); TaskManager.Current().SetValid(true); try { StoreParametersToMetadataStruture(id, titleXpath, descriptionXpath, entity, mappingFilePathImport, mappingFilePathExport); } catch (Exception ex) { TaskManager.Current().SetValid(false); ModelState.AddModelError("", ex.Message); } } else { //set existing parameter if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.TITLE_NODE)) { model.TitleNode = GetMetadataNodes().First(p => p.XPath.Equals(TaskManager.Bus[ImportMetadataStructureTaskManager.TITLE_NODE].ToString())).DisplayName; } ; if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.DESCRIPTION_NODE)) { model.DescriptionNode = GetMetadataNodes().First(p => p.XPath.Equals(TaskManager.Bus[ImportMetadataStructureTaskManager.DESCRIPTION_NODE].ToString())).DisplayName; } ; TaskManager.Current().SetValid(false); ModelState.AddModelError("", "Please select the missing field"); } if (TaskManager.Current().IsValid()) { TaskManager.Current().SetStatus(StepStatus.success); 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() } })); } if (TaskManager.Bus.ContainsKey(ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID)) { long metadatstructureId = Convert.ToInt64(TaskManager.Bus[ImportMetadataStructureTaskManager.METADATASTRUCTURE_ID]); model.MetadataNodes = GetMetadataNodes(); model.Entities = GetEntityList(); model.StepInfo.notExecuted = true; } return(PartialView(model)); }
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)); }