示例#1
0
        private void LoadDevicesInfo(string installPath)
        {
            string[] deviceConfigPaths = Directory.GetDirectories(ConfigPath.GetConfigFilePath(DevicePath));
            foreach (string devicePath in deviceConfigPaths)
            {
                string deviceName = DirectoryName(devicePath);
                if (deviceName.StartsWith("!") || deviceName.StartsWith("."))
                {
                    continue;
                }
                string deviceKey = deviceName.ToLower();

                DevicesInfo di = null;
                if (!dict.ContainsKey(deviceKey))
                {
                    di = new DevicesInfo() { Name = deviceName };
                    di.Versions = new List<string>();
                    dict.Add(deviceKey, di);
                }
                else
                {
                    di = dict[deviceKey];
                }

                string displayConfig = devicePath + "\\display.cfg";
                if (File.Exists(displayConfig))
                {
                    using (ScadaReader sr = new ScadaReader(displayConfig))
                    {
                        // TODO: Xml Reader parse the whole file.
                        // And retrieve the resulr, no need to loop reading line
                        //
                        SectionType secType = SectionType.None;
                        string line = null;
                        string key = null;
                        IValue value = null;
                        ReadLineResult result = sr.ReadLine(out secType, out line, out key, out value);

                        while (result == ReadLineResult.OK)
                        {
                            if (key.ToLower() == "name")
                            {
                                di.DisplayName = value.ToString();
                            }
                            result = sr.ReadLine(out secType, out line, out key, out value);
                        }
                    }
                }

                string[] versionPaths = Directory.GetDirectories(devicePath);
                foreach (string versionPath in versionPaths)
                {
                    string version = DirectoryName(versionPath);
                    di.Versions.Add(version);
                }
            }
        }
示例#2
0
        private void LoadDevicesInfo(string installPath)
        {
            this.dict.Clear();
            string[] deviceConfigPaths = Directory.GetDirectories(ConfigPath.GetConfigFilePath(DevicePath));
            foreach (string devicePath in deviceConfigPaths)
            {
                string deviceName = DirectoryName(devicePath);
                if (deviceName.StartsWith("!") || deviceName.StartsWith("."))
                {
                    continue;
                }
                string deviceKey = deviceName.ToLower();

                DevicesInfo di = null;
                if (!dict.ContainsKey(deviceKey))
                {
                    di = new DevicesInfo()
                    {
                        Name = deviceName
                    };
                    di.Versions = new List <string>();
                    dict.Add(deviceKey, di);
                }
                else
                {
                    di = dict[deviceKey];
                }

                string displayConfig = devicePath + "\\display.cfg";
                if (File.Exists(displayConfig))
                {
                    using (ScadaReader sr = new ScadaReader(displayConfig))
                    {
                        // TODO: Xml Reader parse the whole file.
                        // And retrieve the resulr, no need to loop reading line
                        //
                        SectionType    secType = SectionType.None;
                        string         line    = null;
                        string         key     = null;
                        IValue         value   = null;
                        ReadLineResult result  = sr.ReadLine(out secType, out line, out key, out value);

                        while (result == ReadLineResult.OK)
                        {
                            if (key.ToLower() == "name")
                            {
                                di.DisplayName = value.ToString();
                            }
                            result = sr.ReadLine(out secType, out line, out key, out value);
                        }
                    }
                }

                string[] versionPaths = Directory.GetDirectories(devicePath);
                foreach (string versionPath in versionPaths)
                {
                    string version = DirectoryName(versionPath);
                    di.Versions.Add(version);
                }
            }
        }