public int UpdateAlarmEventByID(Model.QueryFile.QueryAlarmEvent alarmEvent) { var cmd = new DataCommand("updateAlarmEventByID", new SqlCustomDbCommand()); cmd.SetParameterValue("@TrigMode", alarmEvent.TrigMode); cmd.SetParameterValue("@RunMode", alarmEvent.RunMode); cmd.SetParameterValue("@RunCount", alarmEvent.RunCount); cmd.SetParameterValue("@RunTime", alarmEvent.RunTime); cmd.SetParameterValue("@Options", alarmEvent.Options); cmd.SetParameterValue("@Id", alarmEvent.ID); return(cmd.ExecuteNonQuery()); }
/// <summary> /// 更新告警触发事件表 /// </summary> /// <param name="alarmEvent"></param> /// <returns></returns> public int UpdateAlarmEvent(Model.QueryFile.QueryAlarmEvent alarmEvent) { var aeEntity = this.GetAlarmEventById(alarmEvent.ID); if (aeEntity == null) {//insert var cmd = new DataCommand("insertAlarmEvent", new SqlCustomDbCommand()); cmd.SetParameterValue("@AlarmTypeId", alarmEvent.AlarmTypeId); cmd.SetParameterValue("@PlugIn", alarmEvent.PlugIn); cmd.SetParameterValue("@TrigMode", alarmEvent.TrigMode); cmd.SetParameterValue("@RunMode", alarmEvent.RunMode); cmd.SetParameterValue("@RunCount", alarmEvent.RunCount); cmd.SetParameterValue("@RunTime", alarmEvent.RunTime); cmd.SetParameterValue("@Options", alarmEvent.Options); cmd.SetParameterValue("@PROJECTID", alarmEvent.PROJECTID); cmd.SetParameterValue("@SYSTEMID", alarmEvent.SYSTEMID); return(cmd.ExecuteNonQuery()); } else {//update aeEntity.AlarmTypeId = (aeEntity.AlarmTypeId != alarmEvent.AlarmTypeId) ? alarmEvent.AlarmTypeId : aeEntity.AlarmTypeId; aeEntity.PlugIn = string.IsNullOrEmpty(alarmEvent.PlugIn) ? aeEntity.PlugIn : alarmEvent.PlugIn; aeEntity.TrigMode = (aeEntity.TrigMode != alarmEvent.TrigMode) ? alarmEvent.TrigMode : aeEntity.TrigMode; aeEntity.RunMode = (aeEntity.RunMode != alarmEvent.RunMode) ? alarmEvent.RunMode : aeEntity.RunMode; aeEntity.RunCount = (aeEntity.RunCount != alarmEvent.RunCount) ? alarmEvent.RunCount : aeEntity.RunCount; aeEntity.RunTime = (aeEntity.RunTime != alarmEvent.RunTime) ? alarmEvent.RunTime : aeEntity.RunTime; aeEntity.Options = string.IsNullOrEmpty(alarmEvent.Options) ? aeEntity.Options : alarmEvent.Options; aeEntity.ProjectId = (aeEntity.ProjectId != alarmEvent.PROJECTID) ? alarmEvent.PROJECTID : aeEntity.ProjectId; aeEntity.SystemId = (aeEntity.SystemId != alarmEvent.SYSTEMID) ? alarmEvent.SYSTEMID : aeEntity.SystemId; var cmd = new DataCommand("updateAlarmEvent", new SqlCustomDbCommand()); cmd.SetParameterValue("@AlarmTypeId", aeEntity.AlarmTypeId); cmd.SetParameterValue("@PlugIn", aeEntity.PlugIn); cmd.SetParameterValue("@TrigMode", aeEntity.TrigMode); cmd.SetParameterValue("@RunMode", aeEntity.RunMode); cmd.SetParameterValue("@RunCount", aeEntity.RunCount); cmd.SetParameterValue("@RunTime", aeEntity.RunTime); cmd.SetParameterValue("@Options", aeEntity.Options); cmd.SetParameterValue("@PROJECTID", aeEntity.ProjectId); cmd.SetParameterValue("@SYSTEMID", aeEntity.SystemId); cmd.SetParameterValue("@Id", aeEntity.ID); return(cmd.ExecuteNonQuery()); } }