Example #1
0
        public static SimulationDataSet LoadSimulationDataSetFromXml(this DomainCreator domainCreator, string path, string workplaceName, string scenarioName, string crewName)
        {
            path = path.TrimEnd('/', '\\') + Path.DirectorySeparatorChar;
            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("Data path not found! [" + path + ']');
            }
            var workplace = domainCreator.CreateWorkplace(workplaceName);

            workplace.LoadFromXml(path + FileIO.WorkplaceFileName);
            var taskList = domainCreator.CreateTaskDictionary();

            taskList.LoadFromXml(path + FileIO.TasksFileName);
            var crew = domainCreator.CreateCrew(crewName, taskList);

            crew.LoadFromXml(path + crewName + CrewFileNameExtension);
            var scenario = domainCreator.CreateScenario(scenarioName,
                                                        phaseRefName =>
            {
                var myPath = path + phaseRefName + FileIO.PhaseFileNameExtension;
                if (File.Exists(myPath))
                {
                    var phase = domainCreator.CreatePhase(phaseRefName, taskList);
                    phase.LoadFromXml(myPath, taskList);
                    return(phase);
                }
                else
                {
                    return(null);
                }
            });

            scenario.LoadFromXml(path + scenarioName + FileIO.ScenarioFileNameExtension);
            return(domainCreator.CreateSimulationDataSet(workplace, taskList, scenario, crew));
        }
Example #2
0
 public static SimulationDataSet LoadSimulationDataSetFromSingleXmlFile(this DomainCreator domainCreator, string fileName)
 {
     if (String.IsNullOrEmpty(fileName) || !File.Exists(fileName))
     {
         throw new FileNotFoundException("Simulation dataSet file not found!", fileName);
     }
     using (var reader = XmlReader.Create(fileName, XmlIO.SimManningXmlReaderSettings))
     {
         return(domainCreator.LoadSimulationDataSetFromSingleXml(XDocument.Load(reader, LoadOptions.None).Root));
     }
 }