public string Line(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetLegacySymbol symbol, LegacyEntityType entity, LegacyFunctionCodeType code)
        {
            string result = "";
            string graphic = "";

            _notes = "";

            string graphicPath = _configHelper.GetPath("JMSML_2525C", FindEnum.Find2525C);

            if (entity.Graphic != "" && entity.Icon != IconType.FULL_FRAME)
                graphic = entity.Graphic;
            else
                graphic = GrabGraphic(entity.CloverGraphic, entity.RectangleGraphic, entity.SquareGraphic, entity.DiamondGraphic, sig.GraphicSuffix);

            string id = graphic.Substring(0, graphic.Length - 4); ;

            IconType iType = entity.Icon;
            string geometryType = GeometryIs(entity.GeometryType);

            string itemRootedPath = _configHelper.BuildRootedPath(graphicPath, graphic);
            string itemOriginalPath = _configHelper.BuildOriginalPath(graphicPath, graphic);

            if (!File.Exists(itemOriginalPath))
                _notes = _notes + "image file does not exist;";

            result = result + itemRootedPath;
            result = result + "," + Convert.ToString(_configHelper.PointSize);
            result = result + "," + id;
            result = result + "," + BuildEntityItemCategory(ss, iType, geometryType);
            result = result + "," + BuildEntityItemTags(sig, ss, symbol, entity, code);
            result = result + "," + id;
            result = result + "," + geometryType;
            result = result + "," + _notes;

            return result;
        }
        private string _BuildLegacySIDC(LegacyFunctionCodeType functionCode)
        {
            string result = "";

            if (_symbolSet != null && _affiliation != null && _dimension != null &&
               _status != null && _amplifierGroup != null && _amplifier != null && _context.ContextCode != 2)
            {

                if (_legacySymbol != null)
                {
                    // Schema
                    if (functionCode.SchemaOverride != "")
                        result = functionCode.SchemaOverride;
                    else
                        result = _symbolSet.LegacyCodingSchemeCode[0].Value;

                    // Standard Identity
                    if (functionCode.StandardIdentityOverride != "")
                        result = result + functionCode.StandardIdentityOverride;
                    else
                        result = result + _affiliation.LegacyStandardIdentityCode[0].Value;

                    // Dimension
                    if (functionCode.DimensionOverride != "")
                        result = result + functionCode.DimensionOverride;
                    else
                        result = result + _dimension.LegacyDimensionCode[0].Value;

                    // Status
                    if (functionCode.StatusOverride != "")
                        result = result + functionCode.StatusOverride;
                    else
                        result = result + _status.LegacyStatusCode[0].Value;

                    // Function
                    result = result + functionCode.Value;
                }
                else
                {
                    result = _symbolSet.LegacyCodingSchemeCode[0].Value +
                                  _affiliation.LegacyStandardIdentityCode[0].Value +
                                  _dimension.LegacyDimensionCode[0].Value +
                                  _status.LegacyStatusCode[0].Value +
                                  _blankLegacyFunction;
                }

                // HQTFFD
                if (functionCode.HQTFFDOverride != "")
                    result = result + functionCode.HQTFFDOverride;
                else
                    result = result + _amplifierGroup.LegacyModifierCode[0].Value;

                // Amplifier
                if (functionCode.AmplifierOverride != "")
                    result = result + functionCode.AmplifierOverride;
                else
                    result = result + _amplifier.LegacyModifierCode[0].Value;

                //Tail
                if (functionCode.TailOverride != "")
                    result = result + functionCode.TailOverride;
                else
                    result = result + _blankLegacyTail;
            }

            return result;
        }
        public string Line(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyFunctionCodeType functionCode)
        {
            string result = "";

            string name = _buildName(ss, legacySymbol);
            string entityCode = "";
            string extraIcon = "";

            // Special care is needed with special entity subtypes

            bool isEntitySubTypeSpecial = false;

            if (_entitySubType != null)
            {
                if (_configHelper.IsSpecialEntitySubtype(ss, _entitySubType))
                {
                    entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, null);
                    extraIcon = _entityExport.CodeIt(null, ss, null, null, _entitySubType);
                    isEntitySubTypeSpecial = true;
                }
                else
                    entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, _entitySubType);
            }
            else
                entityCode = _entityExport.CodeIt(null, ss, _entity, _entityType, _entitySubType);

            string mod1Code = "";
            string mod2Code = "";

            if (_modifier1 != null && _modifier1.Label != "Unspecified" && _modifier1.Label != "Not Applicable")
                mod1Code = _modifierExport.CodeIt(ss, "1", _modifier1);

            if (_modifier2 != null && _modifier2.Label != "Unspecified" && _modifier2.Label != "Not Applicable")
                mod2Code = _modifierExport.CodeIt(ss, "2", _modifier2);

            bool fullFrame = false;
            string geometry = _entityExport.GeometryIt(_entity, _entityType, _entitySubType);

            if (_entitySubType != null && !isEntitySubTypeSpecial)
            {
                fullFrame = _entitySubType.Icon == IconType.FULL_FRAME;
            }
            else if (_entityType != null)
            {
                fullFrame = _entityType.Icon == IconType.FULL_FRAME;
            }
            else if (_entity != null)
            {
                fullFrame = _entity.Icon == IconType.FULL_FRAME;
            }

            string fullFrameOutput = fullFrame ? "TRUE" : "";

            result = name;
            result = result + "," + _buildSIDCKey(ss, legacySymbol, functionCode); // + "LegacyKey";
            result = result + "," + entityCode; // + "MainIcon";
            result = result + "," + mod1Code;  // + "Modifier1";
            result = result + "," + mod2Code; // + "Modifier2";
            result = result + "," + extraIcon; // + "ExtraIcon";
            result = result + "," + fullFrameOutput; // + "FullFrame";
            result = result + "," + geometry; // + "GeometryType";
            result = result + ","; // + "Standard";
            result = result + ","; // + "Status";
            result = result + ","; // + "Notes";

            return result;
        }
Пример #4
0
        private void _importLegacyData(string source, string destination)
        {
            if (File.Exists(destination))
            {
                SymbolSet ss = _deserializeSymbolSet(destination);
                LibraryDimension dimension = _librarian.Dimension(ss.DimensionID);

                if (ss != null)
                {
                    string code = Convert.ToString(ss.SymbolSetCode.DigitOne) + Convert.ToString(ss.SymbolSetCode.DigitTwo);

                    if (code != "")
                    {
                        // Open the source file for read.

                        if (File.Exists(source))
                        {
                            // Lets build a list of legacy symbols to hold the results

                            List<SymbolSetLegacySymbol> legacySymbols = new List<SymbolSetLegacySymbol>();

                            // Now process the input

                            string line = "";

                            using (StreamReader r = new StreamReader(source))
                            {
                                while (!r.EndOfStream)
                                {
                                    line = r.ReadLine();

                                    string[] tokens = line.Split(',');
                                    string ssCode = tokens[2];
                                    string legacyCode = tokens[0];
                                    string fullLegacyCode = tokens[1];

                                    string mod1Code = tokens[4];
                                    string mod2Code = tokens[5];

                                    string status = tokens[6];
                                    string remarks = tokens[7];

                                    // Skip over all rows in the source file that don't match the symbol set code
                                    // or where the 2525C SIDC field is blank.

                                    if (ssCode == code && legacyCode != "")
                                    {
                                        // Extract the six character function code from the current 2525C SIDC.

                                        string functionCode = legacyCode.Substring(legacyCode.Length - 6);
                                        //string schemaCode = legacyCode.Substring(0, 1);
                                        //string dimensionCode = legacyCode.Substring(2, 1);

                                        string entityCode = tokens[3];

                                        if (entityCode.Length == 6)
                                        {
                                            string eCode = entityCode.Substring(0, 2);
                                            string etCode = entityCode.Substring(2, 2);
                                            string estCode = entityCode.Substring(4, 2);

                                            // Now that we have everything, let's find the pieces in the open symbol set

                                            SymbolSetLegacySymbol ls = new SymbolSetLegacySymbol();

                                            // Find the entity, entity type, and entity subtype for the specified SIDC.

                                            SymbolSetEntity entity = _librarian.Entity(ss, Convert.ToUInt16(eCode.Substring(0, 1)), Convert.ToUInt16(eCode.Substring(1, 1)));

                                            if (entity != null)
                                            {
                                                ls.EntityID = entity.ID;
                                                ls.ID = entity.ID;

                                                if (etCode != "00")
                                                {
                                                    SymbolSetEntityEntityType eType = _librarian.EntityType(entity, Convert.ToUInt16(etCode.Substring(0, 1)), Convert.ToUInt16(etCode.Substring(1, 1)));

                                                    if (eType != null)
                                                    {
                                                        ls.EntityTypeID = eType.ID;
                                                        ls.ID = ls.ID + "_" + eType.ID;

                                                        if (estCode != "00")
                                                        {
                                                            EntitySubTypeType eSubType = _librarian.EntitySubType(eType, Convert.ToUInt16(estCode.Substring(0, 1)), Convert.ToUInt16(estCode.Substring(1, 1)));

                                                            if (eSubType != null)
                                                            {
                                                                ls.EntitySubTypeID = eSubType.ID;
                                                                ls.ID = ls.ID + "_" + eSubType.ID;
                                                            }
                                                        }
                                                    }
                                                }
                                            }

                                            // No entities were found, so mark it as retired.

                                            if (ls.ID == null)
                                            {
                                                ls.ID = "RETIRED";
                                                ls.Remarks = "Retired";
                                            }

                                            // Find the modifier 1 and modifier 2 for the specified SIDC.

                                            if (mod1Code != "" && mod1Code != "00" && mod1Code != "0")
                                            {
                                                if (mod1Code.Length == 2)
                                                {
                                                    ModifiersTypeModifier mod = _librarian.ModifierOne(ss, Convert.ToUInt16(mod1Code.Substring(0, 1)), Convert.ToUInt16(mod1Code.Substring(1, 1)));

                                                    if (mod != null)
                                                    {
                                                        ls.ModifierOneID = mod.ID;
                                                        ls.ID = ls.ID + "_" + mod.ID;
                                                    }
                                                }
                                            }

                                            if (mod2Code != "" && mod2Code != "00" && mod2Code != "0")
                                            {
                                                if (mod2Code.Length == 2)
                                                {
                                                    ModifiersTypeModifier mod = _librarian.ModifierTwo(ss, Convert.ToUInt16(mod2Code.Substring(0, 1)), Convert.ToUInt16(mod2Code.Substring(1, 1)));

                                                    if (mod != null)
                                                    {
                                                        ls.ModifierTwoID = mod.ID;
                                                        ls.ID = ls.ID + "_" + mod.ID;
                                                    }
                                                }
                                            }

                                            ls.ID = ls.ID + "_SYM";
                                            ls.Label = fullLegacyCode;

                                            // Add the legacy function code

                                            LegacyFunctionCodeType lfCode = new LegacyFunctionCodeType();
                                            lfCode.Name = "2525C";

                                            if (fullLegacyCode.Substring(0, 1) != ss.LegacyCodingSchemeCode[0].Value)
                                                lfCode.SchemaOverride = fullLegacyCode.Substring(0, 1);

                                            if (fullLegacyCode.Substring(2, 1) != dimension.LegacyDimensionCode[0].Value)
                                                lfCode.DimensionOverride = fullLegacyCode.Substring(2, 1);

                                            lfCode.Value = functionCode;

                                            if (status != "")
                                                lfCode.Description = status;

                                            if (remarks != "")
                                                lfCode.Remarks = remarks;

                                            ls.LegacyFunctionCode = new LegacyFunctionCodeType[] { lfCode };

                                            // Add it to the current legacy symbol set

                                            legacySymbols.Add(ls);
                                        }
                                    }
                                }

                                r.Close();
                            }

                            // Done processing the input.  If there is anything in our list then add it to the
                            // symbol set and re-serialize it.  Remove the existing values if they exist.

                            if (legacySymbols.Count > 0)
                            {
                                ss.LegacySymbols = legacySymbols.ToArray();

                                // Serialize the symbol set

                                _serializeSymbolSet(ss, destination);
                            }
                        }
                    }
                }
            }
        }
        private string _buildSIDCKey(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyFunctionCodeType functionCode)
        {
            // Builds a unique key from a select number of characters from an SIDC.
            // The pattern for this is:
            //
            // S-D-FFFFFF
            //
            // Where:
            //
            // S = Schema code
            // D = Dimension code
            // FFFFFF = Function code

            string result = "";

            if (functionCode != null)
            {
                if (functionCode.SchemaOverride == "")
                {
                    LegacyLetterCodeType letterCode = _configHelper.LegacyLetter(ss.LegacyCodingSchemeCode, _standard);
                    if(letterCode != null)
                        result = letterCode.Value;
                }
                else
                    result = functionCode.SchemaOverride;

                result = result + "-";

                Librarian lib = _configHelper.Librarian;
                LibraryDimension dimension = lib.Dimension(ss.DimensionID);

                if (functionCode.DimensionOverride == "")
                {
                    LegacyLetterCodeType letterCode = _configHelper.LegacyLetter(dimension.LegacyDimensionCode, _standard);
                    if (letterCode != null)
                        result = result + letterCode.Value;
                }
                else
                    result = result + functionCode.DimensionOverride;

                result = result + "-";
                result = result + functionCode.Value;
            }

            return result;
        }
        public string Line(SymbolSet ss, SymbolSetLegacySymbol legacySymbol, LegacyEntityType legacyEntity, LegacyFunctionCodeType functionCode)
        {
            string result = "";

            string sidcKey = _buildSIDCKey(ss, legacySymbol, functionCode);

            bool fullFrame = (legacyEntity.Icon == IconType.FULL_FRAME);
            string fullFrameOutput = fullFrame ? "TRUE" : "";

            result = legacyEntity.Label;
            result = result + "," + sidcKey;
            result = result + "," + sidcKey;
            result = result + ",";
            result = result + ",";
            result = result + ",";
            result = result + "," + fullFrameOutput;
            result = result + "," + "Point"; // TODO : Handle this through a modernized form of GeometryIt
            result = result + ",";
            result = result + ",";
            result = result + ",";

            return result;
        }
        public LegacyFunctionCodeType[] LegacyFunctions(LegacyFunctionCodeType[] functionArray, string standard)
        {
            // Retrieves and returns an array of all function codes in the given array matching the given standard

            List<LegacyFunctionCodeType> functionCodes = new List<LegacyFunctionCodeType>();

            foreach (LegacyFunctionCodeType functionCodeInArray in functionArray)
            {
                if (functionCodeInArray.Name == standard)
                {
                    functionCodes.Add(functionCodeInArray);
                }
            }

            return functionCodes.ToArray<LegacyFunctionCodeType>();
        }
        public LegacyFunctionCodeType LegacyFunction(LegacyFunctionCodeType[] functionArray, string standard)
        {
            // Retrieves and returns the first function code in the given array matching the given standard

            LegacyFunctionCodeType functionCode = null;

            foreach(LegacyFunctionCodeType functionCodeInArray in functionArray)
            {
                if (functionCodeInArray.Name == standard)
                {
                    functionCode = functionCodeInArray;
                    break;
                }
            }

            return functionCode;
        }
        protected string BuildEntityItemTags(LibraryStandardIdentityGroup sig, SymbolSet ss, SymbolSetLegacySymbol symbol, LegacyEntityType entity, LegacyFunctionCodeType code)
        {
            // Builds a list of seperated tag strings from information derived from the specified objects.
            // TODO: Normalize with similar code found in the preceding function.

            string result = "";
            string graphic = "";

            string name = entity.Label.Replace(',', '-');

            // Add the type of geometry

            string geometry = _geometryList[(int)entity.GeometryType];

            if (entity.Icon == IconType.FULL_FRAME)
            {
                if (sig != null)
                {
                    graphic = GrabGraphic(entity.CloverGraphic, entity.RectangleGraphic, entity.SquareGraphic, entity.DiamondGraphic, sig.GraphicSuffix);
                }

                _notes = _notes + "icon touches frame;";
            }
            else
                graphic = entity.Graphic;

            // Create the unique ID

            string id = graphic.Substring(0, graphic.Length - 4);

            // Grab any custom XML tags that might exist

            string[] xmlTags = entity.Tags;

            // Now build the string

            result = ss.Label.Replace(',', '-');
            result = result + ";" + name;

            // If there is a standard identity group, add it

            if (sig != null)
            {
                result = result + ";" + sig.Label;
            }

            // Add any custom XML or export tags that might exist

            result = _configHelper.AddCustomTags(result, id, xmlTags);

            // Add the 15 character SIDC for the symbol

            result = result + ";" + symbol.Label;

            // Add the entity's type

            result = result + ";" + Convert.ToString(entity.Icon);

            // Add the three most important pieces of information

            result = result + ";" + geometry;
            result = result + ";" + name;
            result = result + ";" + id;

            if (result.Length > 255)
            {
                // Can't have a tag string greater than 255 in length.
                // Human interaction will be required to resolve these on a case by case basis.

                _notes = _notes + "styleItemTags > 255;";
            }

            return result;
        }