Example #1
0
        /// <summary>
        /// Loads the switch mappings from the config file
        /// </summary>
        /// <param name="configFile">Full path to the config xml file</param>
        /// <returns>true on success</returns>
        public bool Load(String configFile)
        {
            if (!File.Exists(configFile))
            {
                Log.Debug("File " + configFile + " does not exist");
                return(false);
            }

            var doc = new XmlDocument();

            doc.Load(configFile);

            var switchMapNodes = doc.SelectNodes("/ACAT/SwitchMap");

            if (switchMapNodes == null)
            {
                return(false);
            }

            // load all the elements
            foreach (XmlNode node in switchMapNodes)
            {
                // get the name of the scanner for which switch
                // mappings have been customzied.  Use "default"
                // as the name of the scanner if the customization
                // should apply to all scanners

                var panel = XmlUtils.GetXMLAttrString(node, "screen");

                if (String.IsNullOrEmpty(panel))
                {
                    panel = XmlUtils.GetXMLAttrString(node, "panel");
                }

                if (String.IsNullOrEmpty(panel))
                {
                    panel = DefaultAttr;
                }

                Log.Debug("panel: " + panel);

                // add it to our list
                panel = panel.ToLower();
                var switchMap = new SwitchMap();
                if (!_switchMapTable.ContainsKey(panel) && switchMap.Load(node))
                {
                    Log.Debug("Adding switchmap entry for panel " + panel);
                    _switchMapTable.Add(panel, switchMap);
                }
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Loads the switch mappings from the config file
        /// </summary>
        /// <param name="configFile">Full path to the config xml file</param>
        /// <returns>true on success</returns>
        public bool Load(String configFile)
        {
            if (!File.Exists(configFile))
            {
                Log.Debug("File " + configFile + " does not exist");
                return false;
            }

            var doc = new XmlDocument();

            doc.Load(configFile);

            var switchMapNodes = doc.SelectNodes("/ACAT/SwitchMap");

            if (switchMapNodes == null)
            {
                return false;
            }

            // load all the elements
            foreach (XmlNode node in switchMapNodes)
            {
                // get the name of the scanner for which switch
                // mappings have been customzied.  Use "default"
                // as the name of the scanner if the customization
                // should apply to all scanners

                var panel = XmlUtils.GetXMLAttrString(node, "screen");

                if (String.IsNullOrEmpty(panel))
                {
                    panel = XmlUtils.GetXMLAttrString(node, "panel");
                }

                if (String.IsNullOrEmpty(panel))
                {
                    panel = DefaultAttr;
                }

                Log.Debug("panel: " + panel);

                // add it to our list
                panel = panel.ToLower();
                var switchMap = new SwitchMap();
                if (!_switchMapTable.ContainsKey(panel) && switchMap.Load(node))
                {
                    Log.Debug("Adding switchmap entry for panel " + panel);
                    _switchMapTable.Add(panel, switchMap);
                }
            }

            return true;
        }