Ejemplo n.º 1
0
        internal StepHeaderSectionSyntax GetHeaderSyntax()
        {
            var macros = new List <StepHeaderMacroSyntax>()
            {
                new StepHeaderMacroSyntax(
                    FileDescriptionText,
                    new StepSyntaxList(
                        new StepSyntaxList(StepWriter.SplitStringIntoParts(Description).Select(s => new StepStringSyntax(s))),
                        new StepStringSyntax(ImplementationLevel))),
                new StepHeaderMacroSyntax(
                    FileNameText,
                    new StepSyntaxList(
                        new StepStringSyntax(Name),
                        new StepStringSyntax(Timestamp.ToString("O")),
                        new StepSyntaxList(StepWriter.SplitStringIntoParts(Author).Select(s => new StepStringSyntax(s))),
                        new StepSyntaxList(StepWriter.SplitStringIntoParts(Organization).Select(s => new StepStringSyntax(s))),
                        new StepStringSyntax(PreprocessorVersion),
                        new StepStringSyntax(OriginatingSystem),
                        new StepStringSyntax(Authorization))),
                new StepHeaderMacroSyntax(
                    FileSchemaText,
                    new StepSyntaxList(
                        new StepSyntaxList(
                            Schemas
                            .Select(s => s.ToSchemaName())
                            .Concat(UnsupportedSchemas)
                            .Select(s => new StepStringSyntax(s)))))
            };

            return(new StepHeaderSectionSyntax(-1, -1, macros));
        }
Ejemplo n.º 2
0
        private static void ParseStepFile(string fileInput, ref int countSuccess)
        {
            string fileName = string.Empty;

            try
            {
                string fullPath = Path.GetFullPath(fileInput);
                string onlyPath = Directory.GetParent(fullPath).FullName;
                fileName = Path.GetFileNameWithoutExtension(fileInput);
                Console.WriteLine("\nLoading STP file... " + fileName);
                LogWriter.Instance.ParsingFileName = fileInput;
                LogWriter.Instance.WriteInfoLog("Loading STP file... " + fileName);
                StepFile stepFile;
                using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
                {
                    stepFile = StepFile.Load(fs);
                }

                XmlDocument doc     = new XmlDocument();
                XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

                Console.WriteLine("Writing XML file...");
                XmlWriterSettings settings = new XmlWriterSettings
                {
                    ConformanceLevel   = ConformanceLevel.Auto,
                    Indent             = true,
                    IndentChars        = "    ",
                    OmitXmlDeclaration = false,
                    CloseOutput        = false,
                    Encoding           = Encoding.UTF8
                };
                XmlWriter  xmlWriter  = XmlWriter.Create(onlyPath + "/" + fileName + ".xml", settings);
                StepWriter stepWriter = new StepWriter(stepFile, false, xmlWriter);

                xmlWriter.WriteStartDocument(true);
                xmlWriter.WriteStartElement("STP");
                stepWriter.Save();
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();

                xmlWriter.Flush();
                xmlWriter.Close();

                Console.WriteLine("Success!");
                LogWriter.Instance.WriteInfoLog("Success!");
                countSuccess++;
            }
            catch (Exception ex)
            {
                _failedFiles.Add(fileName);
                LogWriter.Instance.WriteErrorLog(ex);
                Console.WriteLine("Failed to parse file " + fileName + " " + ex.Message);
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                if (File.Exists(args[0]))
                {
                    string fullPath = Path.GetFullPath(args[0]);
                    string onlyPath = Directory.GetParent(fullPath).FullName;
                    string fileName = Path.GetFileNameWithoutExtension(args[0]);
                    Console.WriteLine("Loading STP file...");
                    StepFile stepFile;
                    using (FileStream fs = new FileStream(fullPath, FileMode.Open))
                    {
                        stepFile = StepFile.Load(fs);
                    }

                    XmlDocument doc     = new XmlDocument();
                    XmlNode     docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

                    Console.WriteLine("Writing XML file...");
                    XmlWriterSettings settings = new XmlWriterSettings
                    {
                        ConformanceLevel   = ConformanceLevel.Fragment,
                        Indent             = true,
                        IndentChars        = "    ",
                        OmitXmlDeclaration = false,
                        CloseOutput        = false,
                        Encoding           = Encoding.Unicode
                    };
                    XmlWriter  xmlWriter  = XmlWriter.Create(onlyPath + "/" + fileName + ".xml", settings);
                    StepWriter stepWriter = new StepWriter(stepFile, false, xmlWriter);
                    stepWriter.Save();

                    xmlWriter.Flush();
                    xmlWriter.Close();

                    Console.WriteLine("Success!");
                }
                else
                {
                    Console.WriteLine("File Not Exists");
                }
            }
            else
            {
                Console.WriteLine("No STP File found");
            }
        }