Пример #1
0
        static void Run(string[] args)
        {
            _librarian.IsLogging = true;

            CommandLineArgs.I.parseArgs(args, "/e=false;/+=false;/-source=false;/-legacy=false;/xas=SIMPLE;/size=32;/asOriginal=false;/+amplifiers=false");

            string exportPath = CommandLineArgs.I.argAsString("/xe");
            string exportLegacyEntityCPath  = CommandLineArgs.I.argAsString("/xleC");
            string exportLegacyFrameBc2Path = CommandLineArgs.I.argAsString("/xlfBc2");
            string exportDomainPath         = CommandLineArgs.I.argAsString("/b");
            string symbolSet      = CommandLineArgs.I.argAsString("/s");
            string query          = CommandLineArgs.I.argAsString("/q");
            string dimensionQuery = CommandLineArgs.I.argAsString("/qd");
            string identityQuery  = CommandLineArgs.I.argAsString("/qi");
            string contextQuery   = CommandLineArgs.I.argAsString("/qc");
            string help           = CommandLineArgs.I.argAsString("/?");
            string xPoints        = CommandLineArgs.I.argAsString("/p");
            string xLines         = CommandLineArgs.I.argAsString("/l");
            string xAreas         = CommandLineArgs.I.argAsString("/a");
            string importPath     = CommandLineArgs.I.argAsString("/i");
            string legacyCode     = CommandLineArgs.I.argAsString("/lc");
            string modPath        = CommandLineArgs.I.argAsString("/m");
            string framePath      = CommandLineArgs.I.argAsString("/xf");
            string amplifierPath  = CommandLineArgs.I.argAsString("/xa");
            string contextPath    = CommandLineArgs.I.argAsString("/xc");
            string hqTFFDPath     = CommandLineArgs.I.argAsString("/xh");
            string ocaPath        = CommandLineArgs.I.argAsString("/xo");
            string exportAs       = CommandLineArgs.I.argAsString("/xas").ToUpper();
            string exportAVDPath  = CommandLineArgs.I.argAsString("/xavd");
            string exportSchemas  = CommandLineArgs.I.argAsString("/xschemas");

            string exportLegacy = CommandLineArgs.I.argAsString("/xl");
            string exportLookup = CommandLineArgs.I.argAsString("/xll");

            string legacyDest = CommandLineArgs.I.argAsString("/ild");
            string legacySrc  = CommandLineArgs.I.argAsString("/ils");

            long size = CommandLineArgs.I.argAsLong("/size");

            bool dataValidation    = (CommandLineArgs.I.argAsString("/e") != "false");
            bool appendFiles       = (CommandLineArgs.I.argAsString("/+") != "false");
            bool omitSource        = (CommandLineArgs.I.argAsString("/-source") != "false");
            bool omitLegacyTag     = (CommandLineArgs.I.argAsString("/-legacy") != "false");
            bool asOriginal        = (CommandLineArgs.I.argAsString("/asOriginal") != "false");
            bool includeAmplifiers = (CommandLineArgs.I.argAsString("/+amplifiers") != "false");

            if (help == "/?")
            {
                Console.WriteLine("jmsml.exe - Usage - Command line options are:");
                Console.WriteLine("");
                Console.WriteLine("/?\t\t\t: Help/Show command line options.");
                Console.WriteLine("");
                Console.WriteLine("/b\t\t\t: Export all coded base domain tables to a folder.");
                Console.WriteLine("/e\t\t\t: Add data validation when exporting domain tables.");
                Console.WriteLine("");
                Console.WriteLine("/i\t\t\t: Import raw data into stubbed out symbol set XML.");
                Console.WriteLine("/m\t\t\t: Path to a modifier file created when importing data.");
                Console.WriteLine("");
                Console.WriteLine("/ild\t\t\t: Import raw legacy data into an existing symbol set.");
                Console.WriteLine("/ils\t\t\t: The source file holding legacy data to be imported.");
                Console.WriteLine("");
                Console.WriteLine("/q=\"<expression>\"\t: Use regular expression to query on labels.");
                Console.WriteLine("/qc=\"<expression>\"\t: Use regular expression to query on context.");
                Console.WriteLine("/qd=\"<expression>\"\t: Use regular expression to query on dimension.");
                Console.WriteLine("/qi=\"<expression>\"\t: Use regular expression to query on standard identity.");
                Console.WriteLine("/s=\"<expression>\"\t: Use regular expression to query on symbol set labels.");
                Console.WriteLine("");
                Console.WriteLine("/xa=\"<pathname>\"\t: Export amplifiers.");
                Console.WriteLine("/xc=\"<pathname>\"\t: Export contexts.");
                Console.WriteLine("/xe=\"<pathname>\"\t: Export entities and modifiers.");
                Console.WriteLine("/xf=\"<pathname>\"\t: Export frames.");
                Console.WriteLine("/xh=\"<pathname>\"\t: Export HQ/TF/FD.");
                Console.WriteLine("/xl=\"<pathname>\"\t: Export legacy data (for testing).");
                Console.WriteLine("/xleC=\"<pathname>\"\t: Export legacy entities for 2525C.");
                Console.WriteLine("/xlfBc2=\"<pathname>\"\t: Export legacy frames for 2525B Change 2.");
                Console.WriteLine("/xll=\"<pathname>\"\t: Export legacy lookup table for 2525C.");
                Console.WriteLine("/xo=\"<pathname>\"\t: Export operational condition amplifiers.*");
                Console.WriteLine("/xas=\"<as_option>\"\t: Export as SIMPLE, DOMAIN, or IMAGE.");
                Console.WriteLine("");
                Console.WriteLine("/xavd=\"<pathname>\"t: Export amplifier value domains.");
                Console.WriteLine("");
                Console.WriteLine("/xschemas=\"<pathname>\"t: Export all schemas.");
                Console.WriteLine("");
                Console.WriteLine("/+\t\t\t: Append multiple e(x)port files together.");
                Console.WriteLine("/-source\t\t: Leave source file out of exported tags.");
                Console.WriteLine("/size=\"<pixels>\"\t: Specify the size for exported image information.");
                Console.WriteLine("/asOriginal\t\t: Map legacy SIDCs to original symbol components.");
                Console.WriteLine("/+amplifiers");
                Console.WriteLine("");
                Console.WriteLine("/a\t\t\t: Export symbols with AREA geometry.");
                Console.WriteLine("/l\t\t\t: Export symbols with LINE geometry.");
                Console.WriteLine("/p\t\t\t: Export symbols with POINT geometry.");
                Console.WriteLine("");
                Console.WriteLine("* - <pathname> argument has two comma seperated values.");
                Console.WriteLine("");
                Console.WriteLine("<Enter> to continue.");
                Console.ReadLine();
            }

            _exportAsLookup.Add("SIMPLE", ETLExportEnum.ETLExportSimple);
            _exportAsLookup.Add("DOMAIN", ETLExportEnum.ETLExportDomain);
            _exportAsLookup.Add("IMAGE", ETLExportEnum.ETLExportImage);

            ETLExportEnum _exportThisAs = _exportAsLookup[exportAs];

            if (exportLegacy != "")
            {
                _etl.ExportLegacy(exportLegacy);
            }

            if (exportLookup != "")
            {
                _etl.ExportLegacyLookup(exportLookup, "2525C", asOriginal, includeAmplifiers, appendFiles);
            }

            if (exportPath != "")
            {
                _etl.Export(exportPath, symbolSet, query, xPoints == "/p" || xLines == "" && xAreas == "",
                            xLines == "/l" || xPoints == "" && xAreas == "",
                            xAreas == "/a" || xPoints == "" && xLines == "",
                            _exportThisAs,
                            appendFiles,
                            omitSource,
                            omitLegacyTag,
                            size);
            }

            if (exportLegacyEntityCPath != "")
            {
                _etl.ExportLegacyEntities(exportLegacyEntityCPath, "2525C", size);
            }

            if (exportLegacyFrameBc2Path != "")
            {
                _etl.ExportLegacyFrames(exportLegacyFrameBc2Path, "2525Bc2", size, appendFiles);
            }

            if (exportDomainPath != "")
            {
                _etl.ExportDomains(exportDomainPath, dataValidation, appendFiles);
            }

            if (importPath != "")
            {
                _etl.Import(importPath, modPath, symbolSet, legacyCode);
            }

            if (framePath != "")
            {
                _etl.ExportFrames(framePath, contextQuery, identityQuery, dimensionQuery, _exportThisAs, appendFiles, omitSource, omitLegacyTag, size);
            }

            if (amplifierPath != "")
            {
                _etl.ExportAmplifiers(amplifierPath, _exportThisAs, appendFiles, omitSource, omitLegacyTag, size, query);
            }

            if (contextPath != "")
            {
                _etl.ExportContext(contextPath, dataValidation, appendFiles);
            }

            if (hqTFFDPath != "")
            {
                _etl.ExportHQTFFD(hqTFFDPath, _exportThisAs, appendFiles, omitSource, omitLegacyTag, size);
            }

            if (ocaPath != "")
            {
                string[] paths = ocaPath.Split(',');

                if (paths.Count() == 2)
                {
                    _etl.ExportOCA(paths[0], paths[1], _exportThisAs, appendFiles, omitSource, omitLegacyTag, size);
                }
                else
                {
                    _etl.ExportOCA(ocaPath, "", _exportThisAs, appendFiles, omitSource, omitLegacyTag, size);
                }
            }

            if (legacySrc != "" && legacyDest != "")
            {
                _etl.ImportLegacyData(legacySrc, legacyDest);
            }

            if (exportAVDPath != "")
            {
                _etl.ExportAmplifierValueDomains(exportAVDPath, appendFiles);
            }

            if (exportSchemas != "")
            {
                _etl.ExportSchemas(exportSchemas);
            }
        }
Пример #2
0
        public void Export(string path, string symbolSetExpression = "", string expression = "", bool exportPoints = true, bool exportLines = true, bool exportAreas = true, ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false, bool omitLegacy = false, long size = 32)
        {
            // The public entry point for exporting selective contents of the JMSML library
            // into CSV format.

            // Accepts a path for the output (sans file name extension).  The caller
            // may also provide optional regular expressions to filter on the Label
            // attributes of SymbolSets in the library and a second optional regular
            // expression for filtering on the Label attributes of other objects being
            // exported.

            IEntityExport entityExporter = null;
            IModifierExport modifierExporter = null;

            string entityPath = path;
            string modifier1Path = path;
            string modifier2Path = path;
            string specialPath = path;

            _configHelper.PointSize = (int)size;

            switch (exportType)
            {
                // Based on the type of export, create instances of the
                // appropriate helper class(es).

                case ETLExportEnum.ETLExportSimple:
                    entityExporter = new SimpleEntityExport(_configHelper);
                    modifierExporter = new SimpleModifierExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportDomain:
                    entityExporter = new DomainEntityExport(_configHelper);
                    modifierExporter = new DomainModifierExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportImage:
                    entityExporter = new ImageEntityExport(_configHelper, omitSource, omitLegacy);
                    modifierExporter = new ImageModifierExport(_configHelper, omitSource, true); // Suppress legacy tag
                    break;
            }

            if (entityExporter != null && modifierExporter != null)
            {
                if (!append)
                {
                    // If we're not appending the modifiers to the entities
                    // then add a string to the file name to make them unique.

                    specialPath = entityPath + "_Special_Entity_Subtype";
                    entityPath = entityPath + "_Entities";
                    modifier1Path = modifier1Path + "_Modifier_Ones";
                    modifier2Path = modifier2Path + "_Modifier_Twos";
                }

                entityPath = entityPath + ".csv";
                specialPath = specialPath + ".csv";
                modifier1Path = modifier1Path + ".csv";
                modifier2Path = modifier2Path + ".csv";

                _exportEntities(exportType, entityExporter, entityPath, specialPath, symbolSetExpression, expression, exportPoints, exportLines, exportAreas, append);
                _exportModifiers(modifierExporter, modifier1Path, modifier2Path, symbolSetExpression, expression, append);
            }
        }
Пример #3
0
        private void _exportEntities(ETLExportEnum exportType, IEntityExport exporter, string path, string specialPath, string symbolSetExpression = "", string expression = "", bool exportPoints = true, bool exportLines = true, bool exportAreas = true, bool append = false)
        {
            // Exports entity, entity types, and entity sub types to CSV, by optionally testing a
            // regular expression against the Label attributes of the containing symbol sets
            // and of the entitites in those symbol sets.  It also allows filtering on geometry,
            // so only point, line, or area symbols can be exported.

            // This method accepts an exporter, a light weight object that knows what column
            // headings to return and how to compose a CSV line of output from the data its
            // provided.

            using (var w = new StreamWriter(path))
            {
                var line = string.Format("{0}", exporter.Headers);

                w.WriteLine(line);
                w.Flush();

                // Initialize a counter to track lines written out
                int rowCount = 0;

                foreach (SymbolSet s in _symbolSets)
                {
                    if (symbolSetExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(s.Label, symbolSetExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        continue;

                    foreach (SymbolSetEntity e in s.Entities)
                    {
                        if (!(exporter is ImageEntityExport) || e.EntityCode.DigitOne != 0 || e.EntityCode.DigitTwo != 0)
                        {
                            if (expression == "" || System.Text.RegularExpressions.Regex.IsMatch(e.Label, expression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                            {
                                if (exportPoints && e.GeometryType == GeometryType.POINT ||
                                    exportLines && e.GeometryType == GeometryType.LINE ||
                                    exportAreas && e.GeometryType == GeometryType.AREA ||
                                    (e.EntityCode.DigitOne == 0 && e.EntityCode.DigitTwo == 0))
                                {
                                    // If the icon is Full Frame then four lines need to be exported, to reflect the four icon shapes.
                                    // Else just write out one line for non-Full-Frame.

                                    if (e.Icon == IconType.FULL_FRAME && exportType == ETLExportEnum.ETLExportImage)
                                    {
                                        foreach (LibraryStandardIdentityGroup sig in _library.StandardIdentityGroups)
                                        {
                                            line = string.Format("{0}", exporter.Line(sig, s, e, null, null));

                                            w.WriteLine(line);
                                            w.Flush();

                                            rowCount++;
                                        }
                                    }
                                    else
                                    {
                                        line = string.Format("{0}", exporter.Line(null, s, e, null, null));

                                        w.WriteLine(line);
                                        w.Flush();

                                        rowCount++;
                                    }
                                }
                            }

                            if (e.EntityTypes != null)
                            {
                                foreach (SymbolSetEntityEntityType eType in e.EntityTypes)
                                {
                                    if (expression == "" || System.Text.RegularExpressions.Regex.IsMatch(eType.Label, expression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                    {
                                        if (exportPoints && eType.GeometryType == GeometryType.POINT ||
                                            exportLines && eType.GeometryType == GeometryType.LINE ||
                                            exportAreas && eType.GeometryType == GeometryType.AREA)
                                        {
                                            // If the icon is Full Frame then four lines need to be exported, to reflect the four icon shapes.
                                            // Else just write out one line for non-Full-Frame.

                                            if (eType.Icon == IconType.FULL_FRAME && exportType == ETLExportEnum.ETLExportImage)
                                            {
                                                foreach (LibraryStandardIdentityGroup sig in _library.StandardIdentityGroups)
                                                {
                                                    line = string.Format("{0}", exporter.Line(sig, s, e, eType, null));

                                                    w.WriteLine(line);
                                                    w.Flush();

                                                    rowCount++;
                                                }
                                            }
                                            else
                                            {
                                                line = string.Format("{0}", exporter.Line(null, s, e, eType, null));

                                                w.WriteLine(line);
                                                w.Flush();

                                                rowCount++;
                                            }
                                        }
                                    }

                                    if (eType.EntitySubTypes != null)
                                    {
                                        foreach (EntitySubTypeType eSubType in eType.EntitySubTypes)
                                        {
                                            if (expression == "" || System.Text.RegularExpressions.Regex.IsMatch(eSubType.Label, expression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                            {
                                                if (exportPoints && eSubType.GeometryType == GeometryType.POINT ||
                                                    exportLines && eSubType.GeometryType == GeometryType.LINE ||
                                                    exportAreas && eSubType.GeometryType == GeometryType.AREA)
                                                {
                                                    // If the icon is Full Frame then four lines need to be exported, to reflect the four icon shapes.
                                                    // Else just write out one line for non-Full-Frame.

                                                    if (eSubType.Icon == IconType.FULL_FRAME && exportType == ETLExportEnum.ETLExportImage)
                                                    {
                                                        foreach (LibraryStandardIdentityGroup sig in _library.StandardIdentityGroups)
                                                        {
                                                            line = string.Format("{0}", exporter.Line(sig, s, e, eType, eSubType));

                                                            w.WriteLine(line);
                                                            w.Flush();

                                                            rowCount++;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        line = string.Format("{0}", exporter.Line(null, s, e, eType, eSubType));

                                                        w.WriteLine(line);
                                                        w.Flush();

                                                        rowCount++;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Now process through any special entity sub types that might exist in a symbol set

                    if (s.SpecialEntitySubTypes != null && !(exporter is DomainEntityExport))
                    {
                        _exportSpecialEntities(exportType, exporter, s, w, s.SpecialEntitySubTypes);
                    }
                    else if (s.SpecialEntitySubTypes != null)
                    {
                        if (!append)
                        {
                            StreamWriter ws = new StreamWriter(specialPath);

                            line = string.Format("{0}", exporter.Headers);

                            ws.WriteLine(line);
                            ws.Flush();

                            _exportSpecialEntities(exportType, exporter, s, ws, s.SpecialEntitySubTypes);

                            ws.Close();
                        }
                        else
                            _exportSpecialEntities(exportType, exporter, s, w, s.SpecialEntitySubTypes);
                    }
                }

                w.Close();

                if (rowCount == 0)
                {
                    // Empty file so delete it
                    logger.Warn("Empty " + path + ". Deleting file...");
                    File.Delete(path);
                }
            }
        }
Пример #4
0
        public void ExportHQTFFD(string path, ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false, bool omitLegacy = false, long size = 32)
        {
            // The public entry point for exporting HQTFFD from the JMSML library
            // into CSV format.  These include combinations of headquarter, task force, and feint/dummy amplifiers

            // Accepts a path for the output (sans file name extension).  The output may also
            // be appended to an existing file.

            IHQTFFDExport hqTFFDExporter = null;
            string line = "";

            _configHelper.PointSize = (int)size;

            switch (exportType)
            {
                case ETLExportEnum.ETLExportDomain:
                    hqTFFDExporter = new DomainHQTFFDExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportImage:
                    hqTFFDExporter = new ImageHQTFFDExport(_configHelper, omitSource, omitLegacy);
                    break;
            }

            if (hqTFFDExporter != null)
            {
                using (var w = new StreamWriter(path + ".csv", append))
                {
                    if (!append)
                    {
                        line = string.Format("{0}", hqTFFDExporter.Headers);

                        w.WriteLine(line);
                        w.Flush();
                    }

                    foreach (LibraryHQTFDummy hqTFFD in _library.HQTFDummies)
                    {
                        if (hqTFFD.Graphics != null && exportType == ETLExportEnum.ETLExportImage)
                        {
                            foreach (LibraryHQTFDummyGraphic graphic in hqTFFD.Graphics)
                            {
                                line = hqTFFDExporter.Line(hqTFFD, graphic);

                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();
                                }
                            }
                        }
                        else if (exportType == ETLExportEnum.ETLExportDomain)
                        {
                            if (!hqTFFD.IsExtension)
                            {
                                line = hqTFFDExporter.Line(hqTFFD, null);

                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        public void ExportOCA(string path, string statusPath, ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false, bool omitLegacy = false, long size = 32)
        {
            // The public entry point for exporting operational condition amplifiers from the JMSML library
            // into CSV format.

            // Accepts a path for the output (sans file name extension).  The output may also
            // be appended to an existing file.  Splits out the Status codes alone to a second file.

            IOCAExport ocaExporter = null;
            string line = "";

            _configHelper.PointSize = (int)size;

            switch (exportType)
            {
                case ETLExportEnum.ETLExportDomain:
                    ocaExporter = new DomainOCAExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportImage:
                    ocaExporter = new ImageOCAExport(_configHelper, omitSource, omitLegacy);
                    break;
            }

            if (ocaExporter != null)
            {
                using (var w = new StreamWriter(path + ".csv", append))
                {
                    // Create a second stream writer for status alone

                    StreamWriter ws = new StreamWriter(statusPath + ".csv");

                    if (!append)
                    {
                        line = string.Format("{0}", ocaExporter.Headers);

                        w.WriteLine(line);
                        w.Flush();

                        if (exportType == ETLExportEnum.ETLExportDomain)
                        {
                            ws.WriteLine(line);
                            ws.Flush();
                        }
                    }

                    foreach (LibraryStatus status in _library.Statuses)
                    {
                        if (status.Graphic != null && exportType == ETLExportEnum.ETLExportImage)
                        {
                            // Alternative graphic drawn for a given status

                            line = ocaExporter.Line(status);

                            if (line != "")
                            {
                                w.WriteLine(line);
                                w.Flush();
                            }
                        }

                        if (status.Graphics != null && exportType == ETLExportEnum.ETLExportImage)
                        {
                            foreach (LibraryStatusGraphic graphic in status.Graphics)
                            {
                                line = ocaExporter.Line(status, graphic);

                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();
                                }
                            }
                        }
                        else if (exportType == ETLExportEnum.ETLExportDomain)
                        {
                            if (!status.IsExtension)
                            {
                                line = ocaExporter.Line(status);

                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();

                                    if (status.StatusCode <= 1)
                                    {
                                        ws.WriteLine(line);
                                        ws.Flush();
                                    }
                                }
                            }
                        }
                    }

                    ws.Close();
                }
            }
        }
Пример #6
0
        public void ExportFrames(string path, string contextExpression = "", string standardIdentityExpression = "", string dimensionExpression = "", ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false, bool omitLegacy = false, long size = 32)
        {
            // The public entry point for exporting frames from the JMSML library
            // into CSV format.

            // Accepts a path for the output (sans file name extension).  The caller
            // may also provide optional regular expressions to filter on the Label
            // attributes of the objects being exported.

            IFrameExport frameExporter = null;
            string line = "";

            _configHelper.PointSize = (int)size;

            switch (exportType)
            {
                case ETLExportEnum.ETLExportDomain:
                    frameExporter = new DomainFrameExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportImage:
                    frameExporter = new ImageFrameExport(_configHelper, omitSource, omitLegacy);
                    break;
            }

            if (frameExporter != null)
            {
                using (var w = new StreamWriter(path + ".csv", append))
                {
                    if (!append)
                    {
                        line = string.Format("{0}", frameExporter.Headers);

                        w.WriteLine(line);
                        w.Flush();
                    }

                    if (exportType == ETLExportEnum.ETLExportImage)
                    {
                        foreach (LibraryContext context in _library.Contexts)
                        {
                            if (contextExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(context.Label, contextExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                continue;

                            foreach (LibraryStandardIdentity identity in _library.StandardIdentities)
                            {
                                if (standardIdentityExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(identity.Label, standardIdentityExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                    continue;

                                foreach (LibraryDimension dimension in _library.Dimensions)
                                {
                                    if (dimensionExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(dimension.Label, dimensionExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                        continue;

                                    // Export a frame for Status = Current

                                    line = frameExporter.Line(_librarian, context, identity, dimension, _library.Statuses[0], false, false);

                                    if (line != "")
                                    {
                                        w.WriteLine(line);
                                        w.Flush();
                                    }

                                    // Export the frame for Status = Planned (not every frame will have a Planned version)
                                    // Shortened the label for this export so the stylx file will use the shorter name.

                                    LibraryStatus status = _library.Statuses[1];
                                    status.LabelAlias = "Planned";
                                    line = frameExporter.Line(_librarian, context, identity, dimension, status, false, false);
                                    status.LabelAlias = "";

                                    if (line != "")
                                    {
                                        w.WriteLine(line);
                                        w.Flush();
                                    }

                                    // Export the frame for the Civilian option (not every frame has one)

                                    line = frameExporter.Line(_librarian, context, identity, dimension, _library.Statuses[0], true, false);

                                    if (line != "")
                                    {
                                        w.WriteLine(line);
                                        w.Flush();
                                    }

                                    // Export the frame for the Planned Civilian option (not every frame has one)

                                    line = frameExporter.Line(_librarian, context, identity, dimension, _library.Statuses[1], false, true);

                                    if (line != "")
                                    {
                                        w.WriteLine(line);
                                        w.Flush();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (LibraryStandardIdentity identity in _library.StandardIdentities)
                        {
                            if (standardIdentityExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(identity.Label, standardIdentityExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                continue;

                            line = frameExporter.Line(null, null, identity, null, null, false, false);

                            if (!identity.IsExtension)
                            {
                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();
                                }
                            }
                        }
                    }

                    w.Close();
                }
            }
        }
Пример #7
0
        public void ExportAmplifiers(string path, ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false, bool omitLegacy = false, long size = 32, string amplifierExpression = "")
        {
            // The public entry point for exporting amplifiers from the JMSML library
            // into CSV format.  These include echelons, mobilities, and auxiliary equipment

            // Accepts a path for the output (sans file name extension).  The output may also
            // be appended to an existing file.

            IAmplifierExport amplifierExporter = null;
            string line = "";

            _configHelper.PointSize = (int)size;

            switch (exportType)
            {
                case ETLExportEnum.ETLExportDomain:
                    amplifierExporter = new DomainAmplifierExport(_configHelper);
                    break;

                case ETLExportEnum.ETLExportImage:
                    amplifierExporter = new ImageAmplifierExport(_configHelper, omitSource, omitLegacy);
                    break;
            }

            if (amplifierExporter != null)
            {
                using (var w = new StreamWriter(path + ".csv", append))
                {
                    if (!append)
                    {
                        line = string.Format("{0}", amplifierExporter.Headers);

                        w.WriteLine(line);
                        w.Flush();
                    }

                    foreach (LibraryAmplifierGroup lag in _library.AmplifierGroups)
                    {
                        if (amplifierExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(lag.Label, amplifierExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                            continue;

                        if (lag.Amplifiers != null)
                        {
                            foreach (LibraryAmplifierGroupAmplifier amp in lag.Amplifiers)
                            {
                                if (amp.Graphics != null && exportType == ETLExportEnum.ETLExportImage)
                                {
                                    foreach (LibraryAmplifierGroupAmplifierGraphic graphic in amp.Graphics)
                                    {
                                        line = amplifierExporter.Line(lag, amp, graphic);

                                        if (line != "")
                                        {
                                            w.WriteLine(line);
                                            w.Flush();
                                        }
                                    }
                                }
                                else if (exportType == ETLExportEnum.ETLExportDomain)
                                {
                                    if (!amp.IsExtension)
                                    {
                                        line = amplifierExporter.Line(lag, amp, null);

                                        if (line != "")
                                        {
                                            w.WriteLine(line);
                                            w.Flush();
                                        }
                                    }
                                }
                            }
                        }
                    }

                    w.Close();
                }
            }
        }
Пример #8
0
        private void _exportSpecialEntities(ETLExportEnum exportType, IEntityExport exporter, SymbolSet s, StreamWriter w, EntitySubTypeType[] array)
        {
            // Exports special entities to a CSV file

            string line = "";

            if (array != null)
            {
                foreach (EntitySubTypeType eSubType in array)
                {
                    if (eSubType.Icon == IconType.SPECIAL && exportType == ETLExportEnum.ETLExportImage)
                    {
                        foreach (LibraryStandardIdentityGroup sig in _library.StandardIdentityGroups)
                        {
                            line = string.Format("{0}", exporter.Line(sig, s, eSubType));

                            w.WriteLine(line);
                            w.Flush();
                        }
                    }
                    else
                    {
                        if (exportType == ETLExportEnum.ETLExportDomain)
                            line = string.Format("{0}", exporter.Line(eSubType));
                        else
                            line = string.Format("{0}", exporter.Line(null, s, eSubType));

                        w.WriteLine(line);
                        w.Flush();
                    }
                }
            }
        }
Пример #9
0
        public void ExportFrames(string path, string contextExpression = "", string standardIdentityExpression = "", string dimensionExpression = "", ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool omitSource = false)
        {
            // The public entry point for exporting frames from the JMSML library
            // into CSV format.

            // Accepts a path for the output (sans file name extension).  The caller
            // may also provide optional regular expressions to filter on the Label
            // attributes of the objects being exported.

            IFrameExport frameExporter = null;

            switch (exportType)
            {
            case ETLExportEnum.ETLExportImage:
                frameExporter = new ImageFrameExport(_configHelper, omitSource);
                break;
            }

            if (frameExporter != null)
            {
                using (var w = new StreamWriter(path + ".csv"))
                {
                    var line = string.Format("{0}", frameExporter.Headers);

                    w.WriteLine(line);
                    w.Flush();

                    foreach (LibraryContext context in _library.Contexts)
                    {
                        if (contextExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(context.Label, contextExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                        {
                            continue;
                        }

                        foreach (LibraryStandardIdentity identity in _library.StandardIdentities)
                        {
                            if (standardIdentityExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(identity.Label, standardIdentityExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                            {
                                continue;
                            }

                            foreach (LibraryDimension dimension in _library.Dimensions)
                            {
                                if (dimensionExpression != "" && !System.Text.RegularExpressions.Regex.IsMatch(dimension.Label, dimensionExpression, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                                {
                                    continue;
                                }

                                line = frameExporter.Line(_librarian, context, identity, dimension);

                                if (line != "")
                                {
                                    w.WriteLine(line);
                                    w.Flush();
                                }
                            }
                        }
                    }

                    w.Close();
                }
            }
        }
Пример #10
0
        public void Export(string path, string symbolSetExpression = "", string expression = "", bool exportPoints = true, bool exportLines = true, bool exportAreas = true, ETLExportEnum exportType = ETLExportEnum.ETLExportSimple, bool append = false, bool omitSource = false)
        {
            // The public entry point for exporting selective contents of the JMSML library
            // into CSV format.

            // Accepts a path for the output (sans file name extension).  The caller
            // may also provide optional regular expressions to filter on the Label
            // attributes of SymbolSets in the library and a second optional regular
            // expression for filtering on the Label attributes of other objects being
            // exported.

            IEntityExport   entityExporter   = null;
            IModifierExport modifierExporter = null;

            string entityPath   = path;
            string modifierPath = path;

            switch (exportType)
            {
            // Based on the type of export, create instances of the
            // appropriate helper class(es).

            case ETLExportEnum.ETLExportSimple:
                entityExporter   = new SimpleEntityExport();
                modifierExporter = new SimpleModifierExport();
                break;

            case ETLExportEnum.ETLExportDomain:
                entityExporter   = new DomainEntityExport(_configHelper);
                modifierExporter = new DomainModifierExport(_configHelper);
                break;

            case ETLExportEnum.ETLExportImage:
                entityExporter   = new ImageEntityExport(_configHelper, omitSource);
                modifierExporter = new ImageModifierExport(_configHelper, omitSource);
                break;
            }

            if (entityExporter != null && modifierExporter != null)
            {
                if (!append)
                {
                    // If we're not appending the modifiers to the entities
                    // then add a string to the file name to make them unique.

                    entityPath   = entityPath + "_Entities";
                    modifierPath = modifierPath + "_Modifiers";
                }

                entityPath   = entityPath + ".csv";
                modifierPath = modifierPath + ".csv";

                _exportEntities(entityExporter, entityPath, symbolSetExpression, expression, exportPoints, exportLines, exportAreas);
                _exportModifiers(modifierExporter, modifierPath, symbolSetExpression, expression, append);
            }
        }