コード例 #1
0
        public ConfigHelper(Librarian librarian)
        {
            _librarian  = librarian;
            _configData = librarian.ConfigData;
            _etlConfig  = _configData.ETLConfig;

            _findPaths();
        }
コード例 #2
0
        public ConfigHelper(Librarian librarian)
        {
            _librarian = librarian;
            _configData = librarian.ConfigData;
            _etlConfig = _configData.ETLConfig;

            _findPaths();
        }
コード例 #3
0
        public Librarian(string configPath = "")
        {
            InitializeNLog();

            //
            // Deserialize the configuration xml to get the location of the symbology library
            //

            XmlSerializer serializer = new XmlSerializer(typeof(JMSMLConfig));

            serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
            serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);

            if (configPath != "")
            {
                _configPath = configPath;
            }
            else
            {
                string s = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                _configPath = Path.Combine(s, "jmsml.config");
            }

            if (File.Exists(_configPath))
            {
                using(FileStream fs = new FileStream(_configPath, FileMode.Open, FileAccess.Read))
                {
                    if (fs.CanRead)
                    {
                        _configData = (JMSMLConfig)serializer.Deserialize(fs);
                    }
                    else
                    {
                        logger.Error("Unreadable config file: " + _configPath);
                    }
                }
            }
            else
            {
                logger.Error("Config file is missing: " + _configPath);
            }

            //
            // If the config data was good then...
            //

            if(_configData != null)
            {
                //
                // Deserialize the library's base xml to get the base contents of the symbology standard
                //

                serializer = new XmlSerializer(typeof(Library));

                string path = _configData.LibraryPath + "/" + _configData.LibraryName;

                if (File.Exists(path))
                {
                    using (FileStream fsLibrary = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {
                        if (fsLibrary.CanRead)
                        {
                            this._library = (Library)serializer.Deserialize(fsLibrary);

                            //
                            // Deserialize each symbolSet xml
                            //

                            foreach (LibraryDimension dimension in this._library.Dimensions)
                            {
                                foreach (LibraryDimensionSymbolSetRef ssRef in dimension.SymbolSets)
                                {
                                    ushort ssCode = CodeToShort(ssRef.SymbolSetCode);
                                    if (!_sortedSymbolSets.ContainsKey(ssCode))
                                    {
                                        path = _configData.LibraryPath + "/" + ssRef.Instance;
                                        if (File.Exists(path))
                                        {
                                            using (FileStream fsSymbolSet = new FileStream(path, FileMode.Open, FileAccess.Read))
                                            {
                                                if (fsSymbolSet.CanRead)
                                                {
                                                    serializer = new XmlSerializer(typeof(SymbolSet));
                                                    SymbolSet ss = (SymbolSet)serializer.Deserialize(fsSymbolSet);

                                                    if (ss != null)
                                                    {
                                                        _sortedSymbolSets.Add(ssCode, ss);
                                                        _symbolSets.Add(ss);
                                                    }
                                                }
                                                else
                                                {
                                                    logger.Error("Unreadable symbol set: " + path);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            logger.Error("Symbol set is missing: " + path);
                                        }
                                    }
                                }
                            }

                            //
                            // Create special invalid and retired symbols for this library
                            //

                            _invalidSymbol = new Symbol(this, SIDC.INVALID);
                            _retiredSymbol = new Symbol(this, SIDC.RETIRED);
                        }
                        else
                        {
                            logger.Error("Unreadable symbol library: " + path);
                        }
                    }
                }
                else
                {
                    logger.Error("Specified library is missing: " + path);
                }
            }
        }
コード例 #4
0
        public Librarian(string configPath = "")
        {
            InitializeNLog();

            //
            // Deserialize the configuration xml to get the location of the symbology library
            //

            XmlSerializer serializer = new XmlSerializer(typeof(JMSMLConfig));

            serializer.UnknownNode      += new XmlNodeEventHandler(serializer_UnknownNode);
            serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);

            if (configPath != "")
            {
                _configPath = configPath;
            }
            else
            {
                string s = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                _configPath = Path.Combine(s, "jmsml.config");
            }

            if (File.Exists(_configPath))
            {
                using (FileStream fs = new FileStream(_configPath, FileMode.Open, FileAccess.Read))
                {
                    if (fs.CanRead)
                    {
                        _configData = (JMSMLConfig)serializer.Deserialize(fs);
                    }
                    else
                    {
                        logger.Error("Unreadable config file: " + _configPath);
                    }
                }
            }
            else
            {
                logger.Error("Config file is missing: " + _configPath);
            }

            //
            // If the config data was good then...
            //

            if (_configData != null)
            {
                //
                // Deserialize the library's base xml to get the base contents of the symbology standard
                //

                serializer = new XmlSerializer(typeof(Library));

                string path = _configData.LibraryPath + "/" + _configData.LibraryName;

                if (File.Exists(path))
                {
                    using (FileStream fsLibrary = new FileStream(path, FileMode.Open, FileAccess.Read))
                    {
                        if (fsLibrary.CanRead)
                        {
                            this._library = (Library)serializer.Deserialize(fsLibrary);

                            //
                            // Deserialize each symbolSet xml
                            //

                            foreach (LibraryDimension dimension in this._library.Dimensions)
                            {
                                foreach (LibraryDimensionSymbolSetRef ssRef in dimension.SymbolSets)
                                {
                                    ushort ssCode = CodeToShort(ssRef.SymbolSetCode);
                                    if (!_sortedSymbolSets.ContainsKey(ssCode))
                                    {
                                        path = _configData.LibraryPath + "/" + ssRef.Instance;
                                        if (File.Exists(path))
                                        {
                                            using (FileStream fsSymbolSet = new FileStream(path, FileMode.Open, FileAccess.Read))
                                            {
                                                if (fsSymbolSet.CanRead)
                                                {
                                                    serializer = new XmlSerializer(typeof(SymbolSet));
                                                    SymbolSet ss = (SymbolSet)serializer.Deserialize(fsSymbolSet);

                                                    if (ss != null)
                                                    {
                                                        _sortedSymbolSets.Add(ssCode, ss);
                                                        _symbolSets.Add(ss);
                                                    }
                                                }
                                                else
                                                {
                                                    logger.Error("Unreadable symbol set: " + path);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            logger.Error("Symbol set is missing: " + path);
                                        }
                                    }
                                }
                            }

                            //
                            // Create special invalid and retired symbols for this library
                            //

                            _invalidSymbol = new Symbol(this, SIDC.INVALID);
                            _retiredSymbol = new Symbol(this, SIDC.RETIRED);
                        }
                        else
                        {
                            logger.Error("Unreadable symbol library: " + path);
                        }
                    }
                }
                else
                {
                    logger.Error("Specified library is missing: " + path);
                }
            }
        }