public void ResetDefaultLimits(DefaultAlarmRangeLimitView record) { IEnumerable <Channel> channels = DataContext.Table <Channel>().QueryRecords(restriction: new RecordRestriction("MeasurementTypeID = {0} AND MeasurementCharacteristicID = {1}", record.MeasurementTypeID, record.MeasurementCharacteristicID)); string channelIDs = ""; foreach (Channel channel in channels) { if (channelIDs == "") { channelIDs += channel.ID.ToString(); } else { channelIDs += ',' + channel.ID.ToString(); } } IEnumerable <AlarmRangeLimit> limits = DataContext.Table <AlarmRangeLimit>().QueryRecords(restriction: new RecordRestriction($"ChannelID IN ({channelIDs})")); foreach (AlarmRangeLimit limit in limits) { limit.IsDefault = true; limit.High = record.High; limit.Low = record.Low; limit.Severity = record.Severity; limit.RangeInclusive = record.RangeInclusive; limit.PerUnit = record.PerUnit; DataContext.Table <AlarmRangeLimit>().UpdateRecord(limit); } }
public DefaultAlarmRangeLimit CreateNewAlarmRangeLimit(DefaultAlarmRangeLimitView record) { DefaultAlarmRangeLimit arl = new DefaultAlarmRangeLimit(); arl.ID = record.ID; arl.AlarmTypeID = record.AlarmTypeID; arl.MeasurementTypeID = record.MeasurementTypeID; arl.MeasurementCharacteristicID = record.MeasurementCharacteristicID; arl.Severity = record.Severity; arl.High = record.High; arl.Low = record.Low; arl.RangeInclusive = record.RangeInclusive; arl.PerUnit = record.PerUnit; return(arl); }
public void UpdateDefaultAlarmRangeLimitView(DefaultAlarmRangeLimitView record) { DataContext.Table <DefaultAlarmRangeLimit>().UpdateRecord(CreateNewAlarmRangeLimit(record)); }
public void AddNewDefaultAlarmRangeLimitView(DefaultAlarmRangeLimitView record) { DataContext.Table <DefaultAlarmRangeLimit>().AddNewRecord(CreateNewAlarmRangeLimit(record)); }