Example #1
0
        /****************************************************************/

        #region ControlDevice

        public static void O2Db(ControlDevice obj, EFData.ControlDevice dbObj)
        {
            //XElement data;
            //EFData.ControlSpace dbCS = new EFData.ControlSpace();
            //ControlSpace cs = obj.ControlSpace;

            //if (dbObj.Id == 0)
            //    dbObj.Id = obj.Id;
            dbObj.Model         = obj.Model;
            dbObj.Name          = obj.Name;
            dbObj.HaveDimmer    = obj.HaveDimmer;
            dbObj.Remark        = obj.Remark;
            dbObj.MultiChannel  = obj.MultiChannel;
            dbObj.CanAddChannel = obj.CanAddChannel;
            dbObj.DotNetType    = obj.DotNetType;
            dbObj.Profile       = obj.Profile;
            //dbObj.ControlSpace = new EFData.ControlSpace();
            //Mapper.O2Db(obj.ControlSpace, dbObj.ControlSpace);
            //EFData.ControlChannel dbCh;
            //foreach(ControlChannel ch in obj.ControlChannels)
            //{
            //    dbCh = new EFData.ControlChannel();
            //    O2Db(ch, dbCh);
            //    dbObj.ControlChannels.Add(dbCh);
            //}
            //if (obj is ArtNetControlDevice)
            //{
            //    data = new XElement
            //    ("Params",
            //        new XElement("IPAddress",
            //                     new XAttribute("Value", (obj as ArtNetControlDevice).IPAddress.ToString()),
            //                     new XAttribute("ChCount", (obj as ArtNetControlDevice).IPChCount.ToString())),
            //        new XElement("VirtualIP",
            //                     new XAttribute("Value", (obj as ArtNetControlDevice).VirtualIP.ToString()),
            //                     new XAttribute("ChCount", (obj as ArtNetControlDevice).VIPChCount.ToString()))
            //    );
            //    dbObj.Profile = data.ToString();
            //}
        }
Example #2
0
        public static void Db2O(EFData.ControlDevice dbObj, out ControlDevice obj)
        {
            //IPAddress adr;
            //XElement data;

            obj               = (ControlDevice)Activator.CreateInstance(Type.GetType(dbObj.DotNetType));
            obj.Id            = dbObj.Id;
            obj.Name          = dbObj.Name;
            obj.Model         = dbObj.Model;
            obj.HaveDimmer    = dbObj.HaveDimmer;
            obj.Profile       = dbObj.Profile;
            obj.Remark        = dbObj.Remark;
            obj.MultiChannel  = dbObj.MultiChannel;
            obj.CanAddChannel = dbObj.CanAddChannel;
            obj.DotNetType    = dbObj.DotNetType;

            //if (obj is ArtNetControlDevice)
            //{
            //    data = XElement.Parse(dbObj.Profile);
            //    var x = data.Element("IPAddress").Attribute("Value").Value;
            //    var y = data.Element("VirtualIP").Attribute("Value").Value;
            //    IPAddress.TryParse(x, out adr);
            //    (obj as ArtNetControlDevice).IPAddress = adr;
            //    IPAddress.TryParse(y, out adr);
            //    (obj as ArtNetControlDevice).VirtualIP = adr;
            //    (obj as ArtNetControlDevice).IPChCount = int.Parse(data.Element("IPAddress").Attribute("ChCount").Value);
            //    (obj as ArtNetControlDevice).VIPChCount = int.Parse(data.Element("VirtualIP").Attribute("ChCount").Value);
            //}
            //if (obj is GenericControlDevice)
            //{
            //    data = XElement.Parse(dbObj.Profile);
            //    obj.CanDimming = Boolean.Parse(data.Attribute("HaveDimmer").Value);
            //}
//            (Data.ControlChannel)Activator.CreateInstance(Type.GetType(dbLE_Proxy.LightElement.ControlChannel.DotNetChannelType));
            //obj.ControlSpace = new EFData.ControlSpace();
            //Db2O(dbObj.ControlSpace, obj.ControlSpace);
        }