예제 #1
0
        static public void SaveXml()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<XmlLightMngt></XmlLightMngt>");

            foreach (var item in _Lights)
            {
                LightFixture fix = item.Value;

                XmlElement ele = doc.CreateElement("Light");
                ele.SetAttribute("GUID", fix.GUID);
                ele.SetAttribute("AreaId", fix.AreaId.ToString());
                ele.SetAttribute("LuminaireId", fix.LuminaireId.ToString());
                if (fix.LuminaireId == LightFixture.UNKNOW_LIGHT_ID)
                {
                    ele.SetAttribute("OnLevelForArea", fix.LuminaireId.ToString());
                    ele.SetAttribute("OffLevelForArea", fix.LuminaireId.ToString());
                }
                doc.DocumentElement.AppendChild(ele);
            }
            doc.Save(XmlFileName);
        }
예제 #2
0
        public static LightFixture GetLight(string GUID)
        {
            if (_Lights == null)
            {
                _Lights = new Dictionary <string, LightFixture>();

                LoadXml();
            }

            LightFixture light = new LightFixture(GUID);

            if (_Lights.TryGetValue(GUID, out light))
            {
                return(light);
            }
            else
            {
                light = new LightFixture(GUID);
                _Lights.Add(GUID, light);
            }

            return(light);
        }