public static bool LoadFromFile(string fileName, out genDocument obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
 /// <summary>
 /// Deserializes xml markup from file into an genDocument object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output genDocument object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool LoadFromFile(string fileName, out genDocument obj, out System.Exception exception)
 {
     exception = null;
     obj = default(genDocument);
     try
     {
         obj = LoadFromFile(fileName);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 /// <summary>
 /// Deserializes workflow markup into an genDocument object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output genDocument object</param>
 /// <param name="exception">output Exception value if deserialize failed</param>
 /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns>
 public static bool Deserialize(string xml, out genDocument obj, out System.Exception exception)
 {
     exception = null;
     obj = default(genDocument);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
 public static bool Deserialize(string xml, out genDocument obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
Пример #5
0
        private void ProcessDocument(genDocument genDoc)
        { 
            // create document
            Document document = new Document(genDoc.name, genDoc.description, genDoc.author, DateTime.Now, null);

            foreach (analysisRef aRef in genDoc.analysisRef)
            {
                // get analysis
                CasePalletAnalysis analysis = LoadPalletAnalysis(document, aRef.analysisId);
                // load case if any
                // load bundle if any
                // load pallet
                // load interlayer if any
                // load pallet analysis
            }
            // attempt to create directory
            string outDir = Path.GetDirectoryName(genDoc.path); ;
            try { Directory.CreateDirectory(outDir); }
            catch (System.UnauthorizedAccessException /*ex*/)
            { throw new UnauthorizedAccessException(string.Format("User not allowed to write under {0}", Directory.GetParent(outDir).FullName)); }
            // save document
            document.Write(genDoc.path);
            // open generated document using treeDiM.StackBuilder.Desktop
            string stackbuilderExePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "treeDiM.StackBuilder.Desktop.exe");
            if (genDoc.open && File.Exists(stackbuilderExePath))
            {
                // build start info
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.FileName = stackbuilderExePath;
                startInfo.Arguments = "\"" + genDoc.path + "\"";
                System.Diagnostics.Process.Start(startInfo);
            }
            else
                _log.Info(string.Format("Executable {0} could not be found!", stackbuilderExePath));
        }