Beispiel #1
0
 public static bool Save(Stream stream, IModelSystemStructure root, string description,
                         List <ILinkedParameter> linkedParameters, ref string error)
 {
     try
     {
         using (
             XmlWriter writer = XmlWriter.Create(stream,
                                                 new XmlWriterSettings()
         {
             Indent = true, Encoding = Encoding.Unicode
         }))
         {
             writer.WriteStartDocument();
             writer.WriteStartElement("Root");
             writer.Flush();
             root.Save(writer);
             if (description != null)
             {
                 writer.WriteStartElement("Description");
                 writer.WriteString(description);
                 writer.WriteEndElement();
             }
             if (linkedParameters != null)
             {
                 foreach (var lp in linkedParameters)
                 {
                     writer.WriteStartElement("LinkedParameter");
                     writer.WriteAttributeString("Name", lp.Name);
                     if (lp.Value != null)
                     {
                         writer.WriteAttributeString("Value", lp.Value.ToString());
                     }
                     foreach (var reference in lp.Parameters)
                     {
                         writer.WriteStartElement("Reference");
                         writer.WriteAttributeString("Name", LookupName(reference, root));
                         writer.WriteEndElement();
                     }
                     writer.WriteEndElement();
                 }
             }
             writer.WriteEndDocument();
         }
         return(true);
     }
     catch (Exception e)
     {
         error = e.Message;
         return(false);
     }
 }
Beispiel #2
0
        private void RunModelSystem(out List <ErrorWithPath> errors, IModelSystemStructure mstStructure)
        {
            errors = new List <ErrorWithPath>(0);
            AlertValidationStarting();
            // check to see if the directory exists, if it doesn't create it
            DirectoryInfo info = new DirectoryInfo(RunDirectory);

            if (!info.Exists)
            {
                info.Create();
            }
            Directory.SetCurrentDirectory(RunDirectory);
            mstStructure.Save(Path.GetFullPath("RunParameters.xml"));

            if (!RunTimeValidation(new List <int>(), errors, mstStructure))
            {
                InvokeRuntimeValidationError(errors);
            }
            else
            {
                SetStatusToRunning();
                _MST.Start();
            }
        }