Example #1
0
        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));
        }
 public void OpenTest(int StationId)
 {
     if (baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).State == false)
     {
         baserepo.ChangeStationState(StationId, true);
         IniFileControl.GetInstance().OpenRollerTimeSwitch(baserepo.RollerBaseStations.FirstOrDefault(x => x.RollerBaseStationID == StationId).Station);
         RollerSampleInfo rollersampleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerBaseStationID == StationId && x.State == true);
         samplerepo.setsampleStartTime(rollersampleinfo);
         DealControl.GetInstance().setRollerLimit(StationId, rollersampleinfo.UpLimit, rollersampleinfo.DnLimit);
     }
     Response.Redirect("/TestBlock/Index");
 }