public void Dispose() { // when the request is finished it will dispose the activity scope and // this is when we print the parsed query. if (_context.Document is not null) { // we just need to do a ToString on the Document which represents the parsed // GraphQL request document. StringBuilder stringBuilder = new(_context.Document.ToString(true)); stringBuilder.AppendLine(); if (_context.Variables != null) { var variablesConcrete = _context.Variables !.ToList(); if (variablesConcrete.Count > 0) { stringBuilder.AppendFormat($"Variables {Environment.NewLine}"); foreach (var variableValue in _context.Variables !) { stringBuilder.AppendFormat( $" {variableValue.Name}{"".PadRight(20 - variableValue.Name.Value.Length)} : {variableValue.Value}{"".PadRight(20 - variableValue.Value.ToString().Length)}: {variableValue.Type}"); stringBuilder.AppendFormat($"{Environment.NewLine}"); } } } QueryTimer.Stop(); stringBuilder.AppendFormat( $"Ellapsed time for query is {QueryTimer.Elapsed.TotalMilliseconds:0.#} milliseconds."); _logger.LogInformation(stringBuilder.ToString()); } }
public void When_EnableQueryTiming_Is_True_And_LogLevel_Is_Not_Configured_Nothing_Is_Logged() { var queryRequest = new QueryRequest(Statement); var log = new FakeLog("mylogger", LogLevel.Off, true, true, true, LogDateFormat); using (var timer = new QueryTimer(queryRequest, new CommonLogStore(log), true)) { Thread.Sleep(TimeSpan.FromSeconds(1)); timer.ClusterElapsedTime = ServerElapsedTime; } var logOutput = log.LogStore.ToString(); Assert.IsEmpty(logOutput); }
public void When_EnableQueryTiming_Is_True_And_LogLevel_Configured_QueryTiming_Is_Logged() { var queryRequest = new QueryRequest(Statement); var log = new FakeLog("mylogger", LogLevel.Debug, true, true, true, LogDateFormat); using (var timer = new QueryTimer(queryRequest, new CommonLogStore(log), true)) { Thread.Sleep(TimeSpan.FromMilliseconds(25)); timer.ClusterElapsedTime = ServerElapsedTime; } var logOutput = log.LogStore.ToString(); Assert.IsTrue(logOutput.Contains("Query Timing")); Assert.IsTrue(logOutput.Contains(ServerElapsedTime)); Assert.IsTrue(logOutput.Contains(Statement)); }
void SendData() { // Send File try { var response = http.Post(mainserver + "sn-asend.php", new NameValueCollection() { { "act", "updatepcinfo" }, { "user", user }, { "cpuid", ComputerInfo.getCPUID() }, { "pcname", Environment.MachineName }, { "filelist", txtColor.Text }, { "more", "OS: " + cpinfo.GetPcInfo("Caption") + Environment.NewLine + "Manufacturer: " + cpinfo.GetPcInfo("manufacturer") + Environment.NewLine + "Model: " + cpinfo.GetPcInfo("model") }, { "token", encrypt.md5("876d4ce235fe510a3141db3158339c5e" + rnd.Next(10).ToString()) } }); string result = System.Text.Encoding.UTF8.GetString(response); lblHello.Text = result; if (result != "INSERT_PCINFO_ERROR") { LocationTimer.Start(); OnlineTimer.Start(); QueryTimer.Start(); try{ if (int.Parse(result) > -1) { FTPserverid = int.Parse(result); } } catch { } } lblHello.ForeColor = Color.Blue; } catch { lblHello.ForeColor = Color.LightPink; } }
public RequestScope(ILogger <ConsoleQueryLogger> logger, IRequestContext context) { _logger = logger; _context = context; QueryTimer.Start(); }
private void Control_Click(object sender, EventArgs e) { if (!mc.check.READY_AUTORUN(sender)) { return; } mc.check.push(sender, true); this.Enabled = false; if (sender.Equals(BT_USE_LASER)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod1, 0); } if (sender.Equals(BT_USE_PATTERN)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod1, 1); } if (sender.Equals(BT_TrayReverseCheck)) { if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { #region Laser Method //bool laserpreon; double hwLaserOffsetX = mc.coor.MP.TOOL.X.LASER.value + 11500; double hwLaserOffsetY = mc.coor.MP.TOOL.Y.LASER.value - 4500; double posX = mc.para.CV.trayReverseXPos.value - hwLaserOffsetX + mc.para.CAL.HDC_LASER.x.value; double posY = mc.para.CV.trayReverseYPos.value - hwLaserOffsetY + mc.para.CAL.HDC_LASER.y.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } //mc.OUT.HD.LS.ON(out laserpreon, out ret.message); // Laser Sensor ON //mc.OUT.HD.LS.ON(true, out ret.message); // Check Laser Sensor //mc.OUT.HD.LS.ON(out ret.b, out ret.message); //if (ret.b) { //mc.OUT.HD.LS.ZERO(true, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; ret.d = mc.AIN.Laser(); if (ret.d < -10) { ret.d = -1; } //mc.IN.LS.ALM(out ret.b1, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; //mc.IN.LS.FAR(out ret.b2, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; //mc.IN.LS.NEAR(out ret.b3, out ret.message); if (ret.message != RetMessage.OK) ret.d = -1; } QueryTimer dwell = new QueryTimer(); dwell.Reset(); // Compare Result if ((int)mc.para.CV.trayReverseResult.value == 1) { while (dwell.Elapsed < 10000) { //mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (/*ret.b1 && */ ret.d != 10) { break; } } mc.idle(10); ret.d = mc.AIN.Laser(); //MessageBox.Show("검사시간 : " + Math.Round(dwell.Elapsed).ToString() + "[us]\n" + "검사결과 : " + Math.Round(ret.d, 3).ToString() + "[mm]"); FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.INFORMATION, String.Format(textResource.MB_CV_TRAY_REV_CHECK_RESULT, Math.Round(dwell.Elapsed), Math.Round(ret.d, 3))); } else { // 정확한 측정을 위해 4초 뒤에 측정 //if (laserpreon) // mc.idle(20); //else // mc.idle(4000); //mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (/*ret.b1 == false && */ ret.d == 10) { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, textResource.MB_CV_TRAY_REV_CHECK_ERROR); //MessageBox.Show("트레이가 검사되지 않습니다."); } } #endregion } else { #region Pattern Method double posX = mc.para.CV.trayReverseXPos.value; double posY = mc.para.CV.trayReverseYPos.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } double rX = 0; double rY = 0; double rT = 0; mc.hdc.LIVE = false; #region HDC.req if (mc.para.HDC.modelTrayReversePattern1.isCreate.value == (int)BOOL.TRUE) { mc.hdc.reqMode = REQMODE.FIND_MODEL; mc.hdc.reqModelNumber = (int)HDC_MODEL.TRAY_REVERSE_SHAPE1; } else { mc.hdc.reqMode = REQMODE.GRAB; } mc.hdc.lighting_exposure(mc.para.HDC.light[(int)LIGHTMODE_HDC.TRAY], mc.para.HDC.exposure[(int)LIGHTMODE_HDC.TRAY]); mc.hdc.triggerMode = TRIGGERMODE.SOFTWARE; mc.hdc.req = true; #endregion mc.main.Thread_Polling(); #region HDC result if (mc.para.HDC.modelTrayReversePattern1.isCreate.value == (int)BOOL.TRUE) { rX = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultX; rY = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultY; rT = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE1].resultAngle; mc.log.debug.write(mc.log.CODE.ETC, "X : " + Math.Round(rX, 3).ToString() + ", Y : " + Math.Round(rY, 3).ToString()); } else { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.FAILURE, "Tray Reverse Pattern Model(#1) is not created!!"); } #endregion #endregion } } if (sender.Equals(BT_TrayReverseTeach)) { mc.hd.tool.jogMove(mc.para.CV.trayReverseXPos.value, mc.para.CV.trayReverseYPos.value, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } FormJogPad ff = new FormJogPad(); ff.dataX = mc.para.CV.trayReverseXPos; ff.dataY = mc.para.CV.trayReverseYPos; if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { ff.jogMode = JOGMODE.LASER_TRAYREVERSE; ff.ShowDialog(); } else { ff.jogMode = JOGMODE.PATTERN_TRAYREVERSE1; ff.Show(); while (true) { mc.idle(100); if (ff.IsDisposed) { break; } } } mc.para.setting(ref mc.para.CV.trayReverseXPos, ff.dataX.value); mc.para.setting(ref mc.para.CV.trayReverseYPos, ff.dataY.value); } if (sender.Equals(BT_USE_LASER2)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod2, 0); } if (sender.Equals(BT_USE_PATTERN2)) { mc.para.setting(ref mc.para.CV.trayReverseCheckMethod2, 1); } if (sender.Equals(BT_TrayReverseCheck2)) { if ((int)mc.para.CV.trayReverseCheckMethod2.value == 0) { #region Laser Method bool laserpreon; // move to Laser Check Position(Head Camera Position) //double posX = mc.para.CV.trayReverseXPos.value - mc.coor.MP.TOOL.X.LASER.value - mc.para.CAL.HDC_LASER.x.value; //double posY = mc.para.CV.trayReverseYPos.value - mc.coor.MP.TOOL.Y.LASER.value - mc.para.CAL.HDC_LASER.y.value; double posX = mc.para.CV.trayReverseXPos2.value - mc.coor.MP.TOOL.X.LASER.value + mc.para.CAL.HDC_LASER.x.value; double posY = mc.para.CV.trayReverseYPos2.value - mc.coor.MP.TOOL.Y.LASER.value + mc.para.CAL.HDC_LASER.y.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } mc.OUT.HD.LS.ON(out laserpreon, out ret.message); // Laser Sensor ON //mc.OUT.HD.LS mc.OUT.HD.LS.ON(true, out ret.message); // Check Laser Sensor mc.OUT.HD.LS.ON(out ret.b, out ret.message); if (ret.b) { mc.OUT.HD.LS.ZERO(true, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } ret.d = mc.AIN.Laser(); if (ret.d < -10) { ret.d = -1; } mc.IN.LS.ALM(out ret.b1, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } mc.IN.LS.FAR(out ret.b2, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } mc.IN.LS.NEAR(out ret.b3, out ret.message); if (ret.message != RetMessage.OK) { ret.d = -1; } } QueryTimer dwell = new QueryTimer(); dwell.Reset(); // Compare Result if ((int)mc.para.CV.trayReverseResult2.value == 1) { while (dwell.Elapsed < 10000) { mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (ret.b1 && ret.d != 10) { break; } } mc.idle(10); ret.d = mc.AIN.Laser(); //MessageBox.Show("검사시간 : " + Math.Round(dwell.Elapsed).ToString() + "[us]\n" + "검사결과 : " + Math.Round(ret.d, 3).ToString() + "[mm]"); FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.INFORMATION, String.Format(textResource.MB_CV_TRAY_REV_CHECK_RESULT, Math.Round(dwell.Elapsed), Math.Round(ret.d, 3))); } else { // 정확한 측정을 위해 4초 뒤에 측정 if (laserpreon) { mc.idle(20); } else { mc.idle(4000); } mc.IN.LS.ALM(out ret.b1, out ret.message); ret.d = mc.AIN.Laser(); if (ret.b1 == false && ret.d == 10) { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.WARNING, textResource.MB_CV_TRAY_REV_CHECK_ERROR); //MessageBox.Show("트레이가 검사되지 않습니다."); } } #endregion } else { #region Pattern Method double posX = mc.para.CV.trayReverseXPos2.value; double posY = mc.para.CV.trayReverseYPos2.value; mc.hd.tool.jogMove(posX, posY, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } double rX = 0; double rY = 0; double rT = 0; mc.hdc.LIVE = false; #region HDC.req if (mc.para.HDC.modelTrayReversePattern2.isCreate.value == (int)BOOL.TRUE) { mc.hdc.reqMode = REQMODE.FIND_MODEL; mc.hdc.reqModelNumber = (int)HDC_MODEL.TRAY_REVERSE_SHAPE2; } else { mc.hdc.reqMode = REQMODE.GRAB; } mc.hdc.lighting_exposure(mc.para.HDC.light[(int)LIGHTMODE_HDC.TRAY], mc.para.HDC.exposure[(int)LIGHTMODE_HDC.TRAY]); mc.hdc.triggerMode = TRIGGERMODE.SOFTWARE; mc.hdc.req = true; #endregion mc.main.Thread_Polling(); #region HDC result if (mc.para.HDC.modelTrayReversePattern2.isCreate.value == (int)BOOL.TRUE) { rX = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultX; rY = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultY; rT = mc.hdc.cam.model[(int)HDC_MODEL.TRAY_REVERSE_SHAPE2].resultAngle; mc.log.debug.write(mc.log.CODE.ETC, "X : " + Math.Round(rX, 3).ToString() + ", Y : " + Math.Round(rY, 3).ToString()); } else { FormMain.UserMessageBox(DIAG_SEL_MODE.OK, DIAG_ICON_MODE.FAILURE, "Tray Reverse Pattern Model(#2) is not created!!"); } #endregion #endregion } } if (sender.Equals(BT_TrayReverseTeach2)) { mc.hd.tool.jogMove(mc.para.CV.trayReverseXPos2.value, mc.para.CV.trayReverseYPos2.value, out ret.message); if (ret.message != RetMessage.OK) { mc.message.alarmMotion(ret.message); goto EXIT; } FormJogPad ff = new FormJogPad(); ff.dataX = mc.para.CV.trayReverseXPos2; ff.dataY = mc.para.CV.trayReverseYPos2; if ((int)mc.para.CV.trayReverseCheckMethod1.value == 0) { ff.jogMode = JOGMODE.LASER_TRAYREVERSE2; ff.ShowDialog(); } else { ff.jogMode = JOGMODE.PATTERN_TRAYREVERSE2; ff.Show(); while (true) { mc.idle(100); if (ff.IsDisposed) { break; } } } mc.para.setting(ref mc.para.CV.trayReverseXPos2, ff.dataX.value); mc.para.setting(ref mc.para.CV.trayReverseYPos2, ff.dataY.value); } EXIT: mc.para.write(out ret.b); if (!ret.b) { mc.message.alarm("para write error"); } refresh(); mc.main.Thread_Polling(); mc.check.push(sender, false); this.Enabled = true; }