public void SaveSignalModel() { //Check Database for _TSF.name //If not found add it //walk through attributes //check for attribute names //if not found add them var dao = new SignalDAO(); dbSignal dataSignal = dao.getSignal( _name, _signalNameSpace ); dbSignal baseSignal = dao.getSignal( _baseSignalName, _baseSignalNameSpace ); if (dataSignal == null) { dataSignal = new dbSignal(); dataSignal.parentSignalId = baseSignal != null ? baseSignal.signalId : 0; dataSignal.xmlns = _signalNameSpace; dataSignal.signalName = _name; dataSignal.uuid = Guid.Parse( _tsf.uuid ); dataSignal.save(); } foreach (SignalAttribute attr in _attributes) { bool hasAttribute = dao.hasAttribute( dataSignal.signalId, attr.Name ); dbSignalAttribute dbAttribute; if (!hasAttribute) dbAttribute = new dbSignalAttribute(); else dbAttribute = dao.GetAttribute( dataSignal.signalId, attr.Name ); dbAttribute.DataState = hasAttribute ? BASEBean.eDataState.DS_EDIT : BASEBean.eDataState.DS_ADD; dbAttribute.attributeName = attr.Name; dbAttribute.signalId = dataSignal.signalId; dbAttribute.defaultValue = attr.DefaultValue; dbAttribute.fixedValue = attr.FixedValue; dbAttribute.type = attr.SchemaType; dbAttribute.save(); } }