public override IDevice OnCreate(IDeviceSource deviceSource) { HDDeviceSource source = (HDDeviceSource)deviceSource; HDDevice d = new HDDevice(); d.Address = source.Address; d.Name = source.DeviceName; d.DeviceSource = source; d.DeviceType = this.Dpu.DeviceType; d.Dpu = this.Dpu; d.Guid = source.Guid; d.StationGuid = source.StationGuid; return(d); }
protected override void OnAdd(IDevice device) { HDDevice d = (HDDevice)device; string s = @"insert into tblDevice(DeviceAddress, deviceType, stationID, DeviceName) values(@DeviceAddress, @DeviceType, @StationID, @DeviceName)"; ListDictionary list = new ListDictionary(); list.Add("DeviceAddress", d.Address); list.Add("DeviceType", d.DeviceType.Type.Name); list.Add("StationID", GuidHelper.ConvertToInt32(d.Station.Guid)); list.Add("DeviceName", d.Name); DBI.Instance.ExecuteScalar(s, list); d.Guid = GuidHelper.Create(GetMaxDeviceID(DBI.Instance)); }