From 46d928936e41a0d7d01682bd8501e4e4d3b607e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Tue, 7 Nov 2023 16:59:30 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AE=9A=E4=BD=8D=E7=82=B9=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E4=BC=98=E5=8C=96=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/CommonUse.cs | 66 ++++++++++++++++++++++++++++++++++--------- Temp/Default.aspx.cs | 6 ++-- Temp/TempDraw.aspx.cs | 6 ++-- Temp/UserTemp.aspx.cs | 6 ++-- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/App_Code/CommonUse.cs b/App_Code/CommonUse.cs index 9320b94..12813ab 100644 --- a/App_Code/CommonUse.cs +++ b/App_Code/CommonUse.cs @@ -166,10 +166,9 @@ public class CommonUse /// /// /// - public Mat GetPostionXYByFindPostionAndXieLv(Mat color_mat, VectorOfVectorOfPoint selected_contours, string postionCut, out string PYPostion, Image currentFrame, out double xielv) + public Mat GetPostionXYByFindPostionAndXieLv(Mat color_mat, VectorOfVectorOfPoint selected_contours, string postionCut, out string PYPostion, Image currentFrame, out double xielv, out string message) { - - + message = string.Empty; CommonUse commonUse = new CommonUse(); string[] postionc = postionCut.Split(new string[] { "^" }, StringSplitOptions.RemoveEmptyEntries); PYPostion = ""; @@ -179,6 +178,7 @@ public class CommonUse int Y2 = 0, Y1 = 0, X2 = 0, X1 = 0; + xielv = -100; for (int i = 0; i < postionc.Length; i++) { string[] postCutList = postionc[i].Split(','); @@ -193,21 +193,27 @@ public class CommonUse string mx = ""; try { - mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY); + mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY, out message); } catch { + message = GetPostionString(i)+"未找到定位点"; xielv = -100; return null; - mx = "null"; - GrXY = new Point(0, 0); } if (mx.Trim() != "A") { + message = GetPostionString(i) + "未找到定位点"; xielv = -100; return null; - break; + } + + if (!string.IsNullOrWhiteSpace(message)) + { + var posStr = GetPostionString(i); + message = posStr + "识别到多个定位点"; + return null; } Point Mx = GrXY; if (i == 0)//左上角 @@ -243,6 +249,19 @@ public class CommonUse } + private string GetPostionString(int i) + { + switch (i) + { + case 0: return "左上角"; + case 1: return "右上角"; + case 2: return "左下角"; + case 3: return "右下角"; + default: + return "未知位置"; + } + } + /// /// 将给定点集顺时针排序 /// @@ -535,8 +554,9 @@ public class CommonUse /// /// public int[] GetTargetGravityFind(VectorOfVectorOfPoint contours, int x_begin, int x_interval, int x_num, - int y_begin, int y_interval, int y_num, out Point gravityXY) + int y_begin, int y_interval, int y_num, out Point gravityXY, out string messag) { + messag = string.Empty; int[] result = new int[x_num];//结果数组 //数组初值默认为-1 for (int i = 0; i < x_num; i++) @@ -561,9 +581,10 @@ public class CommonUse if (result[x_id] != -1) { - string str = string.Format("第{0}列存在多个答案!请擦拭干净后再扫描", x_id); - result[x_id] = Convert.ToInt32(result[x_id].ToString() + value.ToString()); - gravityXY = gravity[i]; + messag = "识别到多个定位点"; + //string str = string.Format("第{0}列存在多个答案!请擦拭干净后再扫描", x_id); + //result[x_id] = Convert.ToInt32(result[x_id].ToString() + value.ToString()); + //gravityXY = gravity[i]; } else @@ -574,8 +595,25 @@ public class CommonUse gravityXY = gravity[i]; gravityXY.X = rect.X; gravityXY.Y = rect.Y; - break; } + + //if (result[x_id] != -1) + //{ + // string str = string.Format("第{0}列存在多个答案!请擦拭干净后再扫描", x_id); + // result[x_id] = Convert.ToInt32(result[x_id].ToString() + value.ToString()); + // gravityXY = gravity[i]; + + //} + //else + //{ + // Rectangle rect = CvInvoke.BoundingRectangle(contour); + // //这里有修改 + // result[x_id] = value; + // gravityXY = gravity[i]; + // gravityXY.X = rect.X; + // gravityXY.Y = rect.Y; + // break; + //} } return result; } @@ -1010,11 +1048,11 @@ public class CommonUse /// 输出文字 /// public string GetValueAndDrawGrid_Find(Bitmap img, VectorOfVectorOfPoint contours, - int x_begin, int x_interval, int x_num, int y_begin, int y_interval, int y_num, string strText, out Point pFindX) + int x_begin, int x_interval, int x_num, int y_begin, int y_interval, int y_num, string strText, out Point pFindX, out string message) { //画网格 Point pFind; - int[] intArray = GetTargetGravityFind(contours, x_begin, x_interval, x_num, y_begin, y_interval, y_num, out pFind); + int[] intArray = GetTargetGravityFind(contours, x_begin, x_interval, x_num, y_begin, y_interval, y_num, out pFind, out message); int maxValue = GetMaxValueOfArray(intArray);//数组最大值 pFindX = pFind; string str = ""; diff --git a/Temp/Default.aspx.cs b/Temp/Default.aspx.cs index 63a077d..c49a03a 100644 --- a/Temp/Default.aspx.cs +++ b/Temp/Default.aspx.cs @@ -364,11 +364,11 @@ public partial class 外部答题卡_Default : System.Web.UI.Page //Mat mat_dilate1 = commonUse.MyDilate(mat_threshold1); //VectorOfVectorOfPoint selected_contours1; //selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate1, 1); - - Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(currentFramext.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv); + string message = string.Empty; + Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(currentFramext.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv,out message); if (xielv == -100) { - Response.Write("模板配置错误,斜率无法计算"); + Response.Write(message); return false; } int oldWidth = color_mxxx.Bitmap.Width; diff --git a/Temp/TempDraw.aspx.cs b/Temp/TempDraw.aspx.cs index 08174df..4316fc9 100644 --- a/Temp/TempDraw.aspx.cs +++ b/Temp/TempDraw.aspx.cs @@ -679,7 +679,8 @@ public class MK_Operater string mx = ""; try { - mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY); + string message = string.Empty; + mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message); } catch { @@ -747,7 +748,8 @@ public class MK_Operater string mx = ""; try { - mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY); + string message = string.Empty; + mx = commonUse.GetValueAndDrawGrid_Find(color_mat.Bitmap, selected_contours, X, W, 1, Y, H, 1, "", out GrXY,out message); } catch { diff --git a/Temp/UserTemp.aspx.cs b/Temp/UserTemp.aspx.cs index 85ec8df..1c65c30 100644 --- a/Temp/UserTemp.aspx.cs +++ b/Temp/UserTemp.aspx.cs @@ -189,11 +189,11 @@ public partial class Temp_UserTemp : System.Web.UI.Page //Mat color_mat1 = commonUse.DrawContours(currentFramext.Mat, selected_contours1); //commonUse.ShowMatWaitKey("shijuan bianjie", color_mat1, 0.6); - - Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(imagex.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv); + string message = string.Empty; + Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(imagex.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv,out message); if (xielv == -100) { - Response.Write("TEMPERRO"); + Response.Write(message); return; } imagex.Dispose(); From dc35751d35a10cd87ba7ef8374fce8ec5c86496d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Thu, 16 Nov 2023 11:36:49 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E7=82=B9=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/CommonUse.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App_Code/CommonUse.cs b/App_Code/CommonUse.cs index 12813ab..1f7e572 100644 --- a/App_Code/CommonUse.cs +++ b/App_Code/CommonUse.cs @@ -444,7 +444,7 @@ public class CommonUse // bool bo = (rect.Width / rect.Height >= ratio && (rect.Width > 3 && rect.Height > 2) && (area > 200 && area <= 4500)); //bool bo = ((rect.Width > 3 && rect.Height > 2) && (area > 80 && area <= 15000)); //bool bo = pxNums > 130 && pxNums < 300; - bool bo = (approx_curve.Size == 4 && CvInvoke.IsContourConvex(approx_curve) && (rect.Width > 15 && rect.Height > 15) && (area > 550 && area < 2000) && (rect.Width < 50 && rect.Height < 50) && pxNums > 550); + bool bo = (approx_curve.Size == 4 && CvInvoke.IsContourConvex(approx_curve) && (rect.Width > 10 && rect.Height > 10) && (area > 350 && area < 2000) && (rect.Width < 50 && rect.Height < 50) && pxNums > 200); if (bo) { selected_contours.Push(contours[i]); From 163c306dbd249d6aa69b6dd957060e247692b1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Thu, 16 Nov 2023 14:37:28 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E7=82=B9=E5=BF=85=E9=A1=BB=E4=B8=BA=E5=9B=9B=E8=BE=B9=E5=BD=A2?= =?UTF-8?q?=E7=9A=84=E7=AD=9B=E9=80=89=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/CommonUse.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/App_Code/CommonUse.cs b/App_Code/CommonUse.cs index 1f7e572..57d260f 100644 --- a/App_Code/CommonUse.cs +++ b/App_Code/CommonUse.cs @@ -197,7 +197,7 @@ public class CommonUse } catch { - message = GetPostionString(i)+"未找到定位点"; + message = GetPostionString(i) + "未找到定位点"; xielv = -100; return null; } @@ -430,6 +430,8 @@ public class CommonUse // continue; //} + //ShowMatWaitKey("dingweidian", DrawContours(mat, new VectorOfVectorOfPoint(contours[i])), 0.6); + Rectangle rect = CvInvoke.BoundingRectangle(contours[i]);//外接矩形 Mat temp = new Mat(mat, rect);//提取ROI矩形区域 int pxNums = CvInvoke.CountNonZero(temp);//计算图像内非零像素个数 @@ -444,7 +446,11 @@ public class CommonUse // bool bo = (rect.Width / rect.Height >= ratio && (rect.Width > 3 && rect.Height > 2) && (area > 200 && area <= 4500)); //bool bo = ((rect.Width > 3 && rect.Height > 2) && (area > 80 && area <= 15000)); //bool bo = pxNums > 130 && pxNums < 300; - bool bo = (approx_curve.Size == 4 && CvInvoke.IsContourConvex(approx_curve) && (rect.Width > 10 && rect.Height > 10) && (area > 350 && area < 2000) && (rect.Width < 50 && rect.Height < 50) && pxNums > 200); + bool bo = (CvInvoke.IsContourConvex(approx_curve) + && (rect.Width > 10 && rect.Height > 10) + && (area > 200 && area < 2000) + && (rect.Width < 50 && rect.Height < 50) + && pxNums > 200); if (bo) { selected_contours.Push(contours[i]); @@ -1403,7 +1409,7 @@ public class CommonUse Mat mat_color = new Mat(); CvInvoke.CvtColor(mat, mat_color, Emgu.CV.CvEnum.ColorConversion.Gray2Bgr); - CvInvoke.DrawContours(mat_color, contours, -1, new MCvScalar(255, 0, 0), 2); + CvInvoke.DrawContours(mat_color, contours, -1, new MCvScalar(0, 0, 255), 2); return mat_color; } @@ -1501,8 +1507,14 @@ public class CommonUse /// public void ShowMatWaitKey(string title, Mat mat, double zoomRatio) { - CvInvoke.Resize(mat, mat, new Size(), zoomRatio, zoomRatio, Inter.Cubic); - CvInvoke.Imshow(title, mat); + if (!System.Diagnostics.Debugger.IsAttached) + { + return; + } + + var result = new Mat(); + CvInvoke.Resize(mat, result, new Size(), zoomRatio, zoomRatio, Inter.Cubic); + CvInvoke.Imshow(title, result); CvInvoke.WaitKey(0); } From 6b8d25efe020a87d37b7a5c526a4ec5cb3715d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Wed, 22 Nov 2023 18:50:46 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Temp/SplitQuestion.aspx.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Temp/SplitQuestion.aspx.cs b/Temp/SplitQuestion.aspx.cs index 2931d44..fdcc2a8 100644 --- a/Temp/SplitQuestion.aspx.cs +++ b/Temp/SplitQuestion.aspx.cs @@ -187,7 +187,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page //调用接口 //result r = (result)JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), lt.ToJsonString()), typeof(result)); - var r =JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt))); + var r = JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt))); if (r.code == "200" && r.data) { Response.Write("1"); @@ -405,7 +405,14 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; string url = "http://192.168.2.9:6500/"; - if (Request.Url.Host.ToLower().Contains("23544.com")) + + if (Request.Url.Host.ToLower().Contains("w.23544.com")) + { + // 测试地址 + url = "http://mka.w.23544.com:8880/"; + bearer = token; + } + else if (Request.Url.Host.ToLower().Contains("23544.com")) { // 正式地址 url = "https://mk-api.23544.com/ad/"; @@ -432,16 +439,22 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page { throw new Exception("验证接口调用失败!" + Response.StatusCode + " ||| " + reponse.Html); } - + //return (result)JsonConvert.DeserializeObject(reponse.Html, typeof(result)); - return JsonConvert.DeserializeObject(reponse.Html); + return JsonConvert.DeserializeObject(reponse.Html); } private string RequestPost(string id, string body) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; // 测试地址 string url = "http://192.168.2.9:6500/"; - if (Request.Url.Host.ToLower().Contains("23544.com")) + if (Request.Url.Host.ToLower().Contains("w.23544.com")) + { + // 测试地址 + url = "http://mka.w.23544.com:8880/"; + bearer = token; + } + else if (Request.Url.Host.ToLower().Contains("23544.com")) { // 正式地址 url = "https://mk-api.23544.com/ad/"; From f08a432dc35cb6abe01f7bf814b37a4158d92a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Thu, 23 Nov 2023 15:46:31 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20=20IsPostionValue=20?= =?UTF-8?q?=E5=8F=96=E5=87=BA=E6=9D=A5=E6=98=AF=20true=20=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/CommonUse.cs | 10 ++++++---- Temp/Default.aspx.cs | 5 +++-- js/index.js | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/App_Code/CommonUse.cs b/App_Code/CommonUse.cs index 57d260f..05e05e1 100644 --- a/App_Code/CommonUse.cs +++ b/App_Code/CommonUse.cs @@ -418,7 +418,7 @@ public class CommonUse { VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();//所有的轮廓 VectorOfVectorOfPoint selected_contours = new VectorOfVectorOfPoint();//用于存储筛选过后的轮廓 - CvInvoke.FindContours(mat, contours, null, Emgu.CV.CvEnum.RetrType.External, + CvInvoke.FindContours(mat, contours, null, Emgu.CV.CvEnum.RetrType.List, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);//提取所有轮廓,操作过程中会对输入图像进行修改 //筛选轮廓。筛选条件:长宽比大于给定值 @@ -1576,10 +1576,12 @@ public class CommonUse return bitmap; } Mat red = channels[2]; + + return red.Bitmap; //commonUse.ShowMatWaitKey("red", red, 0.5); - Mat redBinary = new Mat(); - CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary); + //Mat redBinary = new Mat(); + //CvInvoke.Threshold(red, redBinary, 150, 255, ThresholdType.Binary); //commonUse.ShowMatWaitKey("red+binary", redBinary, 0.5); //Mat redDilate = new Mat(); @@ -1590,7 +1592,7 @@ public class CommonUse //CvInvoke.MorphologyEx(redBinary, redDilate, MorphOp.Open, kernel, new Point(-1, -1), 1, BorderType.Default, new MCvScalar(0, 0, 0)); //commonUse.ShowMatWaitKey("redDilate", redDilate, 0.5); - return redBinary.Bitmap; + //return redBinary.Bitmap; } } diff --git a/Temp/Default.aspx.cs b/Temp/Default.aspx.cs index c49a03a..d83e7f7 100644 --- a/Temp/Default.aspx.cs +++ b/Temp/Default.aspx.cs @@ -335,6 +335,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page Image currentFramext = new Image(PictureBoxBitMap); Image myImage = new Image(commonUse.FilterRed(PictureBoxBitMap)); + // 进行中值滤波 CvInvoke.MedianBlur(myImage, myImage, 5); // 进行高斯滤波 @@ -346,14 +347,14 @@ public partial class 外部答题卡_Default : System.Web.UI.Page Bitmap bm_dest = myImage.Bitmap; Image EmguImagex1 = new Image(bm_dest); Mat mat_threshold1 = new Mat(); - CvInvoke.Threshold(EmguImagex1, mat_threshold1, 180, 255, Emgu.CV.CvEnum.ThresholdType.BinaryInv); + CvInvoke.Threshold(EmguImagex1, mat_threshold1, 210, 255, Emgu.CV.CvEnum.ThresholdType.BinaryInv); Mat mat_dilate = commonUse.MyDilate(mat_threshold1); VectorOfVectorOfPoint selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate, 1); //var color_mat1 = commonUse.DrawContours(mat_dilate, selected_contours1); //commonUse.ShowMatWaitKey("44444", color_mat1, 0.8); - //Response.Write(ImgToBase64String(color_mat1.Bitmap)); + ////Response.Write(ImgToBase64String(color_mat1.Bitmap)); //return false; diff --git a/js/index.js b/js/index.js index ce491c4..12f6c3f 100644 --- a/js/index.js +++ b/js/index.js @@ -24,7 +24,7 @@ function CloseHideArea(obj) { ///设置锚点 function SetMao(obj, index) { - if (IsPostionValue == "False") { + if (IsPostionValue.toLowerCase() == "false" || IsPostionValue.toLowerCase() == "0") { alert("无法设置定位点,请修改主模板数据."); return; } @@ -815,7 +815,7 @@ function SetMaoPostion(postiondata) { //alert(IsPostionValue); if (postiondata == "") { - if (IsPostionValue == "1") { + if (IsPostionValue == "1" || IsPostionValue.toLowerCase() == "true") { SetMao(document.getElementById("point_0"), 0); SetMao(document.getElementById("point_1"), 1); SetMao(document.getElementById("point_2"), 2); @@ -823,7 +823,7 @@ function SetMaoPostion(postiondata) { } return; } - if (IsPostionValue == "0") { + if (IsPostionValue == "0" || IsPostionValue.toLowerCase() == "false") { $("#draggable_0").remove(); $("#draggable_1").remove(); $("#draggable_2").remove(); From 770ecd9c76edb6e99e4bf1d4b1159a7b81b199c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Tue, 28 Nov 2023 17:32:49 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=87=E9=A2=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Temp/SplitQuestion.aspx.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Temp/SplitQuestion.aspx.cs b/Temp/SplitQuestion.aspx.cs index fdcc2a8..5d43a2d 100644 --- a/Temp/SplitQuestion.aspx.cs +++ b/Temp/SplitQuestion.aspx.cs @@ -76,7 +76,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page long subjective = Convert.ToInt64(Globals.Request("subjective")); var checkResult = CheckStatusByApi(subjective); - if (!checkResult.data) + if (!checkResult.data.Value) { Response.Write("验证失败!" + checkResult.message); return; @@ -188,7 +188,11 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page //调用接口 //result r = (result)JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), lt.ToJsonString()), typeof(result)); var r = JsonConvert.DeserializeObject(RequestPost(subjective.ToString(), JsonConvert.SerializeObject(lt))); - if (r.code == "200" && r.data) + if (r == null || r.code != "200") + { + throw new Exception("调用接口失败了!"); + } + if (r.code == "200" && r.data.Value) { Response.Write("1"); } @@ -409,7 +413,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page if (Request.Url.Host.ToLower().Contains("w.23544.com")) { // 测试地址 - url = "http://mka.w.23544.com:8880/"; + url = "https://mka.w.23544.com:8843/"; bearer = token; } else if (Request.Url.Host.ToLower().Contains("23544.com")) @@ -441,7 +445,12 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page } //return (result)JsonConvert.DeserializeObject(reponse.Html, typeof(result)); - return JsonConvert.DeserializeObject(reponse.Html); + var ress = JsonConvert.DeserializeObject(reponse.Html); + if (ress == null || ress.code != "200") + { + throw new Exception("验证接口调用失败!" + Response.StatusCode + " ||| " + reponse.Html); + } + return ress; } private string RequestPost(string id, string body) { @@ -451,7 +460,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page if (Request.Url.Host.ToLower().Contains("w.23544.com")) { // 测试地址 - url = "http://mka.w.23544.com:8880/"; + url = "https://mka.w.23544.com:8843/"; bearer = token; } else if (Request.Url.Host.ToLower().Contains("23544.com")) @@ -510,7 +519,7 @@ public partial class Temp_SplitQuestion : System.Web.UI.Page public string message { get; set; } public string code { get; set; } - public bool data { get; set; } + public bool? data { get; set; } }