public JsonResult OpenTest(string station) { Task dbtask = new Task(() => { RollerSampleInfo rollersampleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerBaseStation.Station == station && !x.State.Equals("结束")); int StationId = rollersampleinfo.RollerBaseStationID; baserepo.ChangeStationState(StationId, true); baserepo.SaveForceInfo(rollersampleinfo.RollerBaseStation.ForcerCfg.ForcerName, rollersampleinfo.UpLimit, rollersampleinfo.DnLimit, rollersampleinfo.SetValue, true); samplerepo.setsampleStartTime(rollersampleinfo); samplerepo.setsampleState(rollersampleinfo.RollerSampleInfoID, "开始"); rollersampleinfo = samplerepo.RollerSampleInfos.Include(x => x.RollerBaseStation).Include(x => x.RollerBaseStation.ForcerCfg).Include(x => x.RollerBaseStation.TimerCfg).FirstOrDefault(x => x.RollerBaseStation.Station == station && !x.State.Equals("结束")); tsi.AddTestSample(rollersampleinfo); rollertimer.ReadTimeData(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).TimerCfg.TimerName); rollerforcer.setJudgeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).ForcerCfg.ForcerName, true); rollerforcer.OpenRollerForcerSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).ForcerCfg.ForcerName); rollertimer.OpenRollerTimeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).TimerCfg.TimerName); Entities context = new Entities(); context.PROCEDURE_ROLLERSAMPLEINFO(0); context.SaveChanges(); }); dbtask.Start(); dbtask.Wait(); string str = "成功开启试验!"; return(Json(str, JsonRequestBehavior.AllowGet)); }
private void HandleFaultData() { try { rollertimer.CloseRollerTimeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.Station == faultdata.station).TimerCfg.TimerName); rollerforcer.CloseRollerForcerSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.Station == faultdata.station).ForcerCfg.ForcerName); int sampleId = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerBaseStation.Station == faultdata.station && x.State.Equals("开始")).RollerSampleInfoID; string totaltime = rollertimer.ReadTimeData(baserepo.RollerBaseStations.FirstOrDefault(x => x.Station == faultdata.station).TimerCfg.TimerName); recordrepo.SaveRollerRecordInfo(new RollerRecordInfo() { CurrentTime = DateTime.Now, SampleStatus = false, RollerSampleInfoID = sampleId, TotalTime = totaltime, RecordInfo = "上限值:" + faultdata.UpLimit + "|下限值:" + faultdata.DnLimit + "|实际值:" + faultdata.Value }); samplerepo.setsampleState(sampleId, "故障"); Entities context = new Entities(); context.PROCEDURE_ROLLERRECORDINFO(0); context.PROCEDURE_ROLLERSAMPLEINFO(0); context.SaveChanges(); } catch (Exception ex) { LogHelper.WriteLog(this.GetType(), ex); } }
public ActionResult EditSampleTestingRecord(RollerRecordInfo rollerrecordinfo) { if (ModelState.IsValid) { RollerSampleInfo rollersampleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerSampleInfoID == rollerrecordinfo.RollerSampleInfoID); int sampleId = rollerrecordinfo.RollerSampleInfoID; string totaltime = rollertimer.ReadTimeData(baserepo.RollerBaseStations.FirstOrDefault(x => x.Station == rollersampleinfo.RollerBaseStation.Station).TimerCfg.TimerName); if (rollerrecordinfo.SampleStatus == false) { samplerepo.setsampleState(sampleId, "故障"); rollertimer.CloseRollerTimeSwitch(rollersampleinfo.RollerBaseStation.TimerCfg.TimerName); rollerforcer.CloseRollerForcerSwitch(rollersampleinfo.RollerBaseStation.ForcerCfg.ForcerName); } rollerrecordinfo.CurrentTime = DateTime.Now; rollerrecordinfo.TotalTime = totaltime; recordrepo.SaveRollerRecordInfo(rollerrecordinfo); Entities context = new Entities(); context.PROCEDURE_ROLLERRECORDINFO(0); context.SaveChanges(); return(RedirectToActionPermanent("Index", new { RollerSampleInfoID = rollerrecordinfo.RollerSampleInfoID })); } else { RollerSampleInfo rollersamleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(a => a.RollerSampleInfoID == rollerrecordinfo.RollerSampleInfoID); return(View("EditSampleTestingRecord", new RollerRecordInfo() { RollerSampleInfoID = rollerrecordinfo.RollerSampleInfoID, RollerSampleInfo = rollersamleinfo })); } }