Exemplo n.º 1
0
        private void populateLookup(XDocument xml)
        {
            IEnumerable <XElement> elements = null;

            if (xml.Element("UNITFONTMAPPINGS").HasElements)
            {
                elements = xml.Elements();

                IEnumerator <XElement> itr = null;// = xml.DescendantNodes().GetEnumerator();
                //XElement unitConstants = XElement.Load(ofd1.FileName, LoadOptions.None);
                itr = elements.GetEnumerator();


                XElement child = null;
                itr.MoveNext();
                child = itr.Current;//SYMBOLCONSTANTS
                if (child.HasElements)
                {
                    elements = child.Elements();
                    itr      = elements.GetEnumerator();//SYMBOLS
                    while (itr.MoveNext())
                    {
                        child = itr.Current;
                        UnitFontLookupInfo temp = UnitFontLookupInfo.XNodeToUnitFontLookupInfo(child);
                        if ((temp != null) && _UnitMappings.ContainsKey(temp.getBasicSymbolID()) == false)//temp will be null if node is an XCOMMENT
                        {
                            _UnitMappings[temp.getBasicSymbolID()] = temp;
                        }
                    } //end while
                }
            }         //end if
        }             //end populate lookup
Exemplo n.º 2
0
        public UnitFontLookupInfo getLookupInfo(String SymbolID)
        {
            try
            {
                String code = SymbolUtilities.getBasicSymbolID(SymbolID);
                //        if(SymbolUtilities.isSIGINT(SymbolID))
                //            code = code.substring(0, 10) + "--***";
                //        else
                code = code.Substring(0, 10) + "*****";
                UnitFontLookupInfo data = null;
                if (_UnitMappings.ContainsKey(code))
                {
                    data = _UnitMappings[code];
                }

                return(data);
            }
            catch (Exception exc)
            {
                ErrorLogger.LogException("UnitFontLookupC", "getLookupInfo()", exc, ErrorLevel.WARNING);
                return(null);
            }
        }
        public static UnitFontLookupInfo XNodeToUnitFontLookupInfo(XNode node)
        {
            UnitFontLookupInfo ufli       = null;
            XElement           element    = null;
            XElement           subElement = null;
            //XAttribute attribute = null;
            XNode nextNode = null;

            try
            {
                if (node is XElement)
                {
                    element = (XElement)node;

                    if (element.HasElements)
                    {
                        ufli       = new UnitFontLookupInfo();
                        subElement = null;
                        if (element.FirstNode is XElement)
                        {
                            subElement = (XElement)element.FirstNode;
                        }
                        while (subElement != null)
                        {
                            if (subElement.Name == "DESCRIPTION")
                            {
                                ufli._Description = subElement.FirstNode.ToString();//get element value
                                //ufli._strDescription = ufli._strDescription.Replace("&amp;", "&");
                            }
                            else if (subElement.Name.LocalName == "SYMBOLID")
                            {
                                ufli._SymbolID = subElement.FirstNode.ToString();
                            }
                            else if (subElement.Name.LocalName == "MAPPING1U")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._mapping1U = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING1F")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._mapping1F = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING1N")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._mapping1N = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING1H")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._mapping1H = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING1COLOR")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._color1 = SymbolUtilities.getColorFromHexString(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING2")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._mapping2 = int.Parse(subElement.FirstNode.ToString());
                                }
                            }
                            else if (subElement.Name.LocalName == "MAPPING2COLOR")
                            {
                                if (subElement.FirstNode != null && subElement.FirstNode.ToString() != "")
                                {
                                    ufli._color2 = SymbolUtilities.getColorFromHexString(subElement.FirstNode.ToString());
                                }
                            }

                            nextNode   = subElement.NextNode;
                            subElement = null;
                            while (subElement == null && nextNode != null)
                            {
                                if (nextNode is XElement)
                                {
                                    subElement = (XElement)nextNode;
                                }
                                else
                                {
                                    nextNode = nextNode.NextNode;
                                }
                            }
                        }
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Xml.XmlException xe)
            {
                Console.WriteLine(xe.Message);
                Console.WriteLine(xe.StackTrace);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                Console.WriteLine(exc.StackTrace);
            }
            if (ufli.getBasicSymbolID() != null && ufli.getBasicSymbolID() != "")
            {
                return(ufli);
            }
            else
            {
                return(null);
            }
        }