public bool Insert(TighteningResultModel model) { if (model == null) { return(false); } return(Invoke((c) => c?.Insert(model) > 0)); }
/// <summary> /// 拧紧数据上传 /// </summary> private async void UpLoadTightenData() { while (true) { try { List <TightenModel> lstData = await RFIDDBHelper.LocalSQLHandler.TighteningService.GetNoUploadDataAsync(10); if (lstData.Count > 0) { foreach (var data in lstData) { TighteningResultModel model = TightenMapper.MapTightenData(data); if (RFIDDBHelper.MSSQLHandler.TightenService.Insert(model)) { data.IsUpload = 1; await RFIDDBHelper.LocalSQLHandler.TighteningService.UpdateAsync(data); } } } List <LTopEngineResultModel> lstStationData = await RFIDDBHelper.LocalSQLHandler.LTopEngineResult.GetNoUploadDataAsync(10); if (lstStationData.Count > 0) { foreach (var item in lstStationData) { if (currentEngine != null && item.EngineCode == currentEngine.EngineCode) { continue; } TopEngineResultModel model = new TopEngineResultModel() { EngineCode = item.EngineCode, Result = item.Result, StationId = item.StationId, CreateTime = item.CreateTime, UpdateTime = item.UpdateTime }; if (RFIDDBHelper.MSSQLHandler.TopEngineResult.Insert(model) > 0) { item.IsUpload = 1; await RFIDDBHelper.LocalSQLHandler.LTopEngineResult.UpdateAsync(item); } } } } catch (Exception exx) { Log.Error("上传拧紧数据时出现异常", exx); } finally { await Task.Delay(1000 * 30); } } }
/// <summary> /// 数据展示 /// </summary> /// <param name="model"></param> private void DisplayData(TighteningResultModel model) { //拧紧数据控件绑定还没有完成 TightenDatas.AddTightenData(model); view.TighteningData = model; if (TightenDatas.IsTightenOK()) { view.TightenResult = "OK"; } }
/// <summary> /// 读取拧紧数据 /// </summary> /// <param name="msg"></param> private void ReadLastTightenData(OpMessage msg) { try { TighteningResultModel result = new TighteningResultModel(); result.EngineCode = msg.Get <string>("VinNumber").Trim(); result.Torque = !decimal.TryParse(msg.Get <string>("Torque"), out decimal torque) ? -1 : torque / 100.0m; result.Angle = !decimal.TryParse(msg.Get <string>("Angle"), out decimal angle) ? -1 : angle; result.Result = !int.TryParse(msg.Get <string>("TighteningStatus"), out int status3) ? -1 : status3; result.ResultTime = result.CreateTime = DateTime.Now; DisplayData(result); SaveTightenData(result); } catch (Exception ex) { _logger.Error("ReadLastTightenData", ex); } }
private void ShowTighteningRepairs(object sender, EventArgs e) { DataGridView grid = sender as DataGridView; TighteningResultModel current = (TighteningResultModel)grid.CurrentRow.DataBoundItem; if (current != null) { TighteningRepairModel repair = new TighteningRepairModel(); repair.TighteningResultId = current.Id; var logsRepair = _serviceTigtheningRepair.GetByPrimary(repair); using (TigtheningRepairsForm frm = new TigtheningRepairsForm()) { frm.DataBinding.DataSource = logsRepair.ToList(); frm.ShowDialog(); } } }
/// <summary> /// 保存拧紧数据 /// </summary> /// <param name="model"></param> private void SaveTightenData(TighteningResultModel model) { try { model.StationID = tdConfig.Station.StationID; model.StationName = tdConfig.Station.StationName; model.ResultTime = DateTime.Now; model.CreateTime = model.ResultTime; model.EngineCode = currentEngineCode; //暂时屏蔽 RFIDDBHelper.MSSQLHandler.TightenService.Insert(model); } catch (Exception ex) { view.LogText = "拧紧数据存储到服务器上失败"; _logger.Error("拧紧数据存储到服务器上失败", ex); } try { int i = RFIDDBHelper.LocalSQLHandler.TighteningService.Insert(new Lite.Model.TightenModel() { StationName = tdConfig.Station.StationName, EngineCode = currentEngineCode, BoltNo = model.BoltNO, Torque = model.Torque, Angle = model.Angle, Result = model.Result }); if (i < 1) { view.LogText = "拧紧数据存储到本地数据库失败"; } } catch (Exception ex) { _logger.Error("拧紧数据存储到本地数据库异常", ex); view.LogText = "拧紧数据存储到本地数据库异常"; } }
private TighteningRepairModel autoMappingRepair(TighteningResultModel t) { TighteningRepairModel tr = new TighteningRepairModel(); tr.No = t.No; tr.Result = t.Result; tr.Min = t.Min; tr.Max = t.Max; tr.Target = t.Target; tr.TestResult = t.TestResult; //JointsControlAngle Result tr.JointResult = t.JointResult; tr.JointMin = t.JointMin; tr.JointMax = t.JointMax; tr.JointTarget = t.JointTarget; tr.JointTestResult = t.JointTestResult; tr.CreatedBy = 1; tr.LastUpdatedBy = 1; return(tr); }
public void Test(TighteningResultModel model) { DisplayData(model); }
public void AddTightenData(TighteningResultModel td) { TightenDatas.Add(td); }