public async Task <IActionResult> GetPressureTest(int?skip, int?top, string columns, string WELL_BORE_CODE, DateTime?DATEPRD, string TEST_TYPE) { int s = (skip == null) ? 0 : skip.GetValueOrDefault(); int t = (top == null) ? 1000 : top.GetValueOrDefault(); if (s < 0) { return(BadRequest("Skip can't be a negative number")); } if (t < 1) { return(BadRequest("Top can't be less then 1")); } if (columns != null) { columns = columns.Replace(" ", ""); } /* This section is used to check the existence of columns suplied in the request, * and in the event of no columns being supplied finds a list of each column of the given model. */ PressureTest obj = new PressureTest(); var cols = obj.GetType().GetProperties().Select(e => e.Name.ToUpper()).ToArray(); if (columns == null) { columns = string.Join(",", cols); } else { string[] colSplit = columns.Split(','); foreach (string col in colSplit) { if (!cols.Contains(col.Trim().ToUpper())) { return(BadRequest(col + " is not a valid column")); } } } /* This section takes care of the db request. * Here Linq.Dynamic.Core is used to dynamically select specific columns. */ var result = _db.PressureTest .Where(e => (e.WELL_BORE_CODE == WELL_BORE_CODE || WELL_BORE_CODE == null) && (e.DATEPRD >= DATEPRD || DATEPRD == null) && (e.TEST_TYPE == TEST_TYPE || TEST_TYPE == null) ) .Skip(s) .Take(t) .Select("new(" + columns + ")"); return(Ok(await result.ToDynamicListAsync())); }
public void CheckTip() { var inject_list = injector.Entercloses.Where(item => item.InjEnable).ToList(); int[] pressure = IMask.Gen(0); int[] movez = IMask.Gen(100); var act = PressureTest.create(3000, inject_list.ToArray(), movez, 50, 50); act.runAction(injectorDevice); ////var act = InjectCheckTip.create(30000, 100, 0); ////act.runAction(injectorDevice); //Random rd = new Random(); //T_BJ_GelSeat seat = new T_BJ_GelSeat(); //seat.X = 2120; //seat.Y = 3820; //seat.Z = 5700; //seat.ZCatch = 100; //seat.ZPut = 100; //seat.ZLimit = 6000; //seat.Gap = 0; //int sleeptime = rd.Next()%10*10000; //var act_inject = Sequence.create(InjectMoveTo.create(300000, injectorDevice.GetSeleteced(), 3000, IMask.Gen(1000, 1000, 1000, -1), IMask.Gen(-1))); //var act_hand = Sequence.create( // SkCallBackFun.create((ActionBase act_tem)=> { // if (injectorDevice.Injector.XMotor.CurrentDistance < 2000) // { // return true; // } // return false; // }), // MoveTo.create(300000, -1, -1, 0), MoveTo.create(300000, (int)seat.X, (int)(seat.Y + seat.Gap), -1), HandTakeCard.create(700000, (int)seat.Z, (int)seat.ZLimit, (int)seat.ZCatch, 0),HandPutCard.create(500000, (int)seat.Z, 0), SKSleep.create(sleeptime), MoveTo.create(300000, -1, -1, 0), MoveTo.create(300000, (int)seat.X, (int)(seat.Y + seat.Gap), -1), HandTakeCard.create(700000, (int)seat.Z, (int)seat.ZLimit, (int)seat.ZCatch, 0), HandPutCard.create(500000, (int)seat.Z, 0)); //act_inject.AddAction(SkCallBackFun.create((ActionBase act_tem) => //{ // act_hand.runAction(handDevice); // return true; //})); //act_inject.runAction(injectorDevice); }