Example #1
0
        static void Main(string[] args)
        {
            Settings = Settings.Parse(args);

            if (Settings == null)
            {
                return;
            }

            if (Settings.Operation == Operation.WordAnalysis)
            {
                Console.WriteLine($"Merge Word Document: {Settings.InputPath}");
                WordImporter importer = new WordImporter();
                importer.Analyze(Settings.InputPath, @"X:\Work\OPC\UA-TypeRepository2\Core\IECTemplate.docx", Settings.OutputPath);
            }

            if (Settings.Operation == Operation.WordToNodeSet)
            {
                Console.WriteLine($"Loading Model: {Settings.TargetModel}");
                ModelImporter importer = new ModelImporter();
                importer.ModelRequired += ModelImporter_ModelRequired;
                importer.LoadModel(Settings.NodeSetFiles[Settings.TargetModel]);

                Console.WriteLine($"Merge Word Document: {Settings.InputPath}");
                importer.MergeWordDocument(Settings.TargetModel, Settings.InputPath);

                Console.WriteLine($"Save NodeSet: {Settings.OutputPath}");
                importer.SaveNodeSet(Settings.TargetModel, Settings.OutputPath);

                Console.WriteLine($"All Done!");
                return;
            }

            if (Settings.Operation == Operation.NodeSetToMarkdown)
            {
                Console.WriteLine($"Loading Model: {Settings.TargetModel}");
                ModelImporter importer = new ModelImporter();
                importer.ModelRequired += ModelImporter_ModelRequired;
                importer.LoadModel(Settings.NodeSetFiles[Settings.TargetModel]);

                Console.WriteLine($"Creating Repository: {Settings.TargetModel}");
                var repository = importer.CreateRepository(Settings.TargetModel);

                Console.WriteLine($"Deleting Output Directory: {Settings.OutputPath}");

                if (Directory.Exists(Settings.OutputPath))
                {
                    foreach (var child in Directory.EnumerateDirectories(Settings.OutputPath))
                    {
                        Directory.Delete(child, true);
                    }
                }

                Console.WriteLine($"Exporting Markdown: {Settings.OutputPath}");
                MarkdownExporter exporter = new MarkdownExporter();
                exporter.Export(repository, Settings.OutputPath);

                Console.WriteLine($"All Done!");
                return;
            }

            if (Settings.Operation == Operation.MarkdownToNodeSet)
            {
                Console.WriteLine($"Loading Model: {Settings.TargetModel}");
                ModelImporter importer = new ModelImporter();
                importer.ModelRequired += ModelImporter_ModelRequired;
                importer.LoadModel(Settings.NodeSetFiles[Settings.TargetModel]);

                var repositoryPath = GetRepositoryPath(Settings.TargetModel);
                Console.WriteLine($"Loading Markdown: {repositoryPath}");
                MarkdownImporter markdown = new MarkdownImporter();
                var repository            = markdown.Import(repositoryPath);

                Console.WriteLine($"Merge Markdown");
                importer.MergeRepository(Settings.TargetModel, repository);

                Console.WriteLine($"Save NodeSet: {Settings.OutputPath}");
                importer.SaveNodeSet(Settings.TargetModel, Settings.OutputPath);

                Console.WriteLine($"All Done!");
                return;
            }
        }