public JsonResult CloseTest(string station) { Task dbtask = new Task(() => { RollerSampleInfo rollersampleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerBaseStation.Station == station && !x.State.Equals("结束")); int StationId = rollersampleinfo.RollerBaseStation.RollerBaseStationID; int sampleId = rollersampleinfo.RollerSampleInfoID; baserepo.ChangeStationState(StationId, false); samplerepo.setsampleState(sampleId, "结束"); samplerepo.setsampleEndTime(sampleId); string totaltime = rollertimer.ReadTimeData(rollersampleinfo.RollerBaseStation.TimerCfg.TimerName); if (totaltime != null) { samplerepo.setsampleTotalTime(sampleId, TimeSpan.Parse(totaltime)); } rollerforcer.setJudgeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).ForcerCfg.ForcerName, false); rollerforcer.CloseRollerForcerSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).ForcerCfg.ForcerName); baserepo.SaveForceInfo(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).ForcerCfg.ForcerName, 0, 0, 0, false); rollertimer.CloseRollerTimeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).TimerCfg.TimerName); rollertimer.CleanRollerTime(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).TimerCfg.TimerName); tsi.RemoveSampleList(sampleId); Entities context = new Entities(); context.PROCEDURE_ROLLERSAMPLEINFO(0); context.SaveChanges(); }); dbtask.Start(); dbtask.Wait(); string str = "成功结束试验!"; return(Json(str, JsonRequestBehavior.AllowGet)); }
public void CloseTest(int StationId) { if (baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).State == true) { baserepo.ChangeStationState(StationId, false); int sampleId = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.State == true && x.RollerBaseStationID == StationId).RollerSampleInfoID; samplerepo.setsampleState(sampleId, false); samplerepo.setsampleEndTime(sampleId); IniFileControl.GetInstance().CloseRollerTimeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).Station); IniFileControl.GetInstance().CleanRollerTime(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).Station); } Response.Redirect("/TestBlock/Index"); }