/// <summary> /// 保存设备信息 /// </summary> /// <returns></returns> public bool SaveDeviceInfomation(Device device, PointInfo points, LogConfig log, List <AlarmConfig> alarm, List <DigitalSignature> ds) { using (System.Data.SQLite.SQLiteConnection conn = SQLiteHelper.SQLiteHelper.CreateConn()) { PointTempBLL _point = new PointTempBLL(); LogConfigBLL _log = new LogConfigBLL(); AlarmConfigBLL _alarm = new AlarmConfigBLL(); ReportEditorBLL _report = new ReportEditorBLL(); DigitalSignatureBLL _digital = new DigitalSignatureBLL(); if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } System.Data.Common.DbTransaction tran = conn.BeginTransaction(); try { //保存设备信息 if (InsertDevice(device, tran) && //保存温度点信息 _point.InsertPoint(points, tran) && //保存log信息 _log.InsertLogConfig(log, tran) && //保存alarm信息 _alarm.InsertAlarmConfig(alarm, tran) && _digital.InsertDigitalSignature(ds, tran) ) { tran.Commit(); } else { tran.Rollback(); } } catch (Exception ex) { tran.Rollback(); conn.Close(); _tracing.Error(ex, "save data to db failed!"); return(false); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(true); }
public bool DeleteDeviceInformation(List <Device> device, List <PointInfo> points, List <LogConfig> log, List <AlarmConfig> alarm, List <DigitalSignature> digital) { //if(_digital.IsExist() using (System.Data.SQLite.SQLiteConnection conn = SQLiteHelper.SQLiteHelper.CreateConn()) { PointTempBLL _point = new PointTempBLL(); LogConfigBLL _log = new LogConfigBLL(); AlarmConfigBLL _alarm = new AlarmConfigBLL(); DigitalSignatureBLL _digital = new DigitalSignatureBLL(); ReportEditorBLL _reportBll = new ReportEditorBLL(); if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); } System.Data.Common.DbTransaction tran = conn.BeginTransaction(); try { //删除设备信息 DeleteDevice(device, tran); ////删除温度点信息 _point.DeletePointInfo(points, tran); ////删除log信息 _log.DeleteLogConfig(log, tran); ////删除alarm信息 _alarm.DeleteAlarmConfig(alarm, tran); device.ForEach(p => _reportBll.DeleteReportEditorBySnTn(p.SerialNum, p.TripNum, tran)); _digital.DeleteDigitalSignature(digital, tran); tran.Commit(); } catch (Exception ex) { _tracing.Error(ex, "delete the device info failed"); tran.Rollback(); conn.Close(); return(false); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } return(true); }