using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.Drawing; namespace WebManager { public class ImageProcess : IImageProcessByWeb { #region /// /// 数据定义 /// private String webServer_IP = ""; private String webServer_Port = ""; private String webServer_Path = ""; private String Url = ""; private const String Post = "Post"; private const String Content_Type= "Content-Type:application/json"; private String[] _url = new string[9]; #endregion /// /// 构造函数 /// /// WebServer的IP地址 /// WebServer的端口号 public ImageProcess(String ws_ip,String ws_port,String ws_url) { this.webServer_IP = ws_ip; this.webServer_Port = ws_port; this._url = ws_url.Split(','); //更新Web网址 Update_Url(); } /// /// 更新Web网址 /// private void Update_Url() { this.webServer_Path = "/" + this.webServer_Path; this.Url = "http://" + this.webServer_IP + ":" + this.webServer_Port + this.webServer_Path; } /// /// WebServer的IP地址 /// public String WebServer_IP { //get { return this.webServer_IP; } set { this.webServer_IP = value; } } /// /// WebServer的端口号 /// public String WebServer_Port { //get { return this.webServer_IP; } set { this.webServer_Port = value; } } /// /// 向WebServer请求数据及返回结果 /// /// 请求数据的JSON /// 返回结果的JSON private String RequestString(String postString) { try { String res = HttpRequestHelper.DoRequest(this.Url, Post, Content_Type, postString); return res; } catch { return ""; } } /// /// 计算原始图像偏移角度及方向 /// /// 图片路径 /// 孔类型 /// 厂家类型 /// 返回角度 /// 返回方向 /// 图像接口返回状态 /// json字符串 public void Img_OffsetAngle_Direction(String imagePath, int imageType, String firm, out float degree, out int direction, out int state) { try { this.webServer_Path = this._url[0]; } catch { this.webServer_Path = "FIB_degree_recognize"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret= (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { degree = Convert.ToSingle(jname["degree"].ToString()); direction = Convert.ToInt32(jname["direction"].ToString()); } else { degree = 0; direction = 0; } } else { state = 0; direction = 0; degree = 0; } } /// /// 计算切割点位置 /// /// 图片路径 /// 样品类型 /// 厂家类型 /// 切割点相对于原点坐标左上角x值 /// 切割点相对于原点坐标左上角y值 /// 切割点相对于原点坐标右上角x值 /// 切割点相对于原点坐标右上角y值 /// 返回状态 /// json字符串 public void Img_Cut_Position(String imagePath, int imageType, String firm, out float offsetx1, out float offsety1, out float offsetx2, out float offsety2, out int state) { try { this.webServer_Path = this._url[1]; } catch { this.webServer_Path = "test2"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); JArray jlocation = JArray.Parse(jname["location"].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { offsetx1 = Convert.ToSingle(jlocation[0][0].ToString()); offsety1 = Convert.ToSingle(jlocation[0][1].ToString()); offsetx2 = Convert.ToSingle(jlocation[1][0].ToString()); offsety2 = Convert.ToSingle(jlocation[1][1].ToString()); } else { offsetx1 = 0; offsety1 = 0; offsetx2 = 0; offsety2 = 0; } } else { state = 0; offsetx1 = 0; offsety1 = 0; offsetx2 = 0; offsety2 = 0; } } /// /// 是否切割成功验证 /// /// 切割前图像路径 /// 切割后图像路径 /// 图像接口返回状态 /// json字符串 public void Img_Cut_Success(String imageBefore, String imageAfter, out int state) { try { this.webServer_Path = this._url[2]; } catch { this.webServer_Path = "FIB_verify"; } Update_Url(); JObject json = new JObject(); json.Add("img_before_path", imageBefore); json.Add("img_after_path", imageAfter); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "") { state = Convert.ToInt32(jret["state"].ToString()); } else { state = 0; } } /// /// 计算切割后图像梯形区域上边中心点坐标 /// /// 图片路径 /// 梯形中心点X轴坐标 /// 梯形中心点Y轴坐标 /// 图像接口返回状态 /// json字符串 public void Img_Trapezoid_Top_Center_Position(String imagePath, int imageType, String firm, out float offsetx, out float offsety, out int state)//2020-12-15 修改添加 imageType, firm 两个参数 { try { this.webServer_Path = this._url[3]; } catch { this.webServer_Path = "test4"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); JArray jlocation = JArray.Parse(jname["top_center"].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if(state==1) { offsetx = Convert.ToSingle(jlocation[0].ToString()); offsety = Convert.ToSingle(jlocation[1].ToString()); } else { offsetx = 0; offsety = 0; } } else { state = 0; offsetx = 0; offsety = 0; } } /// /// 自动对焦 /// /// 一组图片路径 /// json字符串 public String Img_Auto_Focus(List imagePath) { try { this.webServer_Path = this._url[4]; } catch { this.webServer_Path = "test5"; } Update_Url(); JObject json = new JObject(); for(int i=0;i /// 自动消像散 /// /// 一组图片路径 /// json字符串 public String Img_Auto_Stigmatic(List imagePath) { try { this.webServer_Path = this._url[5]; } catch { this.webServer_Path = "test6"; } Update_Url(); JObject json = new JObject(); for (int i = 0; i < imagePath.Count; i++) { json.Add("img_path" + i.ToString(), imagePath[i]); } String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property("img_path") != null && jret.Property("img_path").ToString() != "") { return jret["img_path"].ToString(); } else { return ""; } } /// /// 计算切割面区域偏移角度及方向 /// /// 图片路径 /// 图像偏移角度 /// 旋转方向 /// 图像接口返回状态 /// json字符串 public void Img_Center_Position_OffsetAngle_Direction(String imagePath, int imageType, String firm, out float degree, out int direction, out int state) { try { this.webServer_Path = this._url[6]; } catch { this.webServer_Path = "test7"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { degree = Convert.ToSingle(jname["degree"].ToString()); direction = Convert.ToInt32(jname["direction"].ToString()); } else { degree = 0; direction = 0; } } else { state = 0; direction = 0; degree = 0; //offsetx = 0; //offsety = 0; } } /// /// 计算两个测量区域坐标 /// /// 图片路径 /// 样品类型 /// 厂商 /// 观测点1位置 /// 观测点1放大倍数 /// 观测点2位置 /// 观测点2放大倍数 /// 返回结果状态 /// json字符串 public void Img_Two_Region_Position(String imagePath, int imageType, String firm, out Point center1, out float mag1, out Point center2, out float mag2, out Point center3, out int state) { try { this.webServer_Path = this._url[7]; } catch { this.webServer_Path = "test8"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { JArray jcenter1 = JArray.Parse(jname["center1"].ToString()); String ptx = jcenter1[0].ToString(); String pty = jcenter1[1].ToString(); center1 = new Point(Convert.ToInt32(ptx),Convert.ToInt32(pty)); String jmag1 = jname["magnification1"].ToString(); mag1 = Convert.ToSingle(jmag1.ToString()); JArray jcenter2 = JArray.Parse(jname["center2"].ToString()); ptx = jcenter2[0].ToString(); pty = jcenter2[1].ToString(); center2 = new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty)); String jmag2 = jname["magnification2"].ToString(); mag2 = Convert.ToSingle(jmag2.ToString()); JArray jcenter3 = JArray.Parse(jname["center3"].ToString()); ptx = jcenter3[0].ToString(); pty = jcenter3[1].ToString(); center3 = new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty)); } else { center1 = new Point(0, 0); center2 = new Point(0, 0); center3 = new Point(0, 0); mag1 = 0; mag2 = 0; state = 0; } } else { center1 = new Point(0, 0); center2 = new Point(0, 0); center3 = new Point(0, 0); mag1 = 0; mag2 = 0; state = 0; } } /// /// 测量尺寸 /// /// 图片1路径 /// 图片2路径 /// 图片1的像素大小 /// 图片2的像素大小 /// 测量结果的生成目录 /// 样品类型 /// 厂类 /// 测量结果返回 /// json字符串 public void Img_Measure_Size(String imagePath1, String imagePath2, float size1, float size2, String resultPath, int imageType, String firm, out int state) { try { this.webServer_Path = this._url[8]; } catch { this.webServer_Path = "test9"; } Update_Url(); JObject json = new JObject(); json.Add("img_path1", imagePath1); json.Add("img_path2", imagePath2); json.Add("size1", size1); json.Add("size2", size2); json.Add("result_path", resultPath); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "") { state = Convert.ToInt32(jret["state"].ToString()); } else { state = 0; } } /// /// DDIC计算原始图像偏移角度及方向 /// /// 图片路径 /// 返回角度 /// 返回方向 /// 图像接口返回状态 /// json字符串 public void Img_DDIC_OffsetAngle_Direction(String imagePath, out float degree, out int direction, out int state) { try { this.webServer_Path = this._url[9]; } catch { this.webServer_Path = "DDIC_degree_recognize"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { degree = Convert.ToSingle(jname["degree"].ToString()); direction = Convert.ToInt32(jname["direction"].ToString()); } else { degree = 0; direction = 0; } } else { state = 0; direction = 0; degree = 0; } } /// /// DDIC计算切割点位置 /// /// 图片路径 /// 切割点相对于原点坐标左上角x值 /// 切割点相对于原点坐标左上角y值 /// 返回状态 /// json字符串 public void Img_DDIC_Cut_Position(String imagePath, int imageType, String firm, out float offsetx, out float offsety, out int state) { try { this.webServer_Path = this._url[10]; } catch { this.webServer_Path = "DDIC_cal_cut_location"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { JArray jlocation = JArray.Parse(jname["location"].ToString()); offsetx = Convert.ToSingle(jlocation[0][0].ToString()); offsety = Convert.ToSingle(jlocation[0][1].ToString()); } else { offsetx = 0; offsety = 0; } } else { state = 0; offsetx = 0; offsety = 0; } } /// /// DDIC梯形位置识别 /// /// 图片路径 /// 梯形中心点X轴坐标 /// 梯形中心点Y轴坐标 /// 图像接口返回状态 /// json字符串 public void Img_DDIC_Trapezoid_Top_Center_Position(String imagePath, out float offsetx, out float offsety, out int state) { try { this.webServer_Path = this._url[11]; } catch { this.webServer_Path = "test4"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); JArray jlocation = JArray.Parse(jname["top_center"].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { offsetx = Convert.ToSingle(jlocation[0].ToString()); offsety = Convert.ToSingle(jlocation[1].ToString()); } else { offsetx = 0; offsety = 0; } } else { state = 0; offsetx = 0; offsety = 0; } } /// /// DDIC测量点计算 /// /// 图片路径 /// 返回结果状态 /// json字符串 public void Img_DDIC_Measure_Location(String imagePath, out List measure_points, out int state) { try { this.webServer_Path = this._url[12]; } catch { this.webServer_Path = "DDIC_measure_location"; } Update_Url(); measure_points = new List(); JObject json = new JObject(); json.Add("img_path", imagePath); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { JArray jcenter1 = JArray.Parse(jname["location1"].ToString()); String ptx = jcenter1[0].ToString(); String pty = jcenter1[1].ToString(); measure_points.Add(new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty))); jcenter1 = JArray.Parse(jname["location2"].ToString()); ptx = jcenter1[0].ToString(); pty = jcenter1[1].ToString(); measure_points.Add(new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty))); jcenter1 = JArray.Parse(jname["location3"].ToString()); ptx = jcenter1[0].ToString(); pty = jcenter1[1].ToString(); measure_points.Add(new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty))); jcenter1 = JArray.Parse(jname["location4"].ToString()); ptx = jcenter1[0].ToString(); pty = jcenter1[1].ToString(); measure_points.Add(new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty))); jcenter1 = JArray.Parse(jname["location5"].ToString()); ptx = jcenter1[0].ToString(); pty = jcenter1[1].ToString(); measure_points.Add(new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty))); } else { state = 0; } } else { state = 0; } } /// /// DDIC测量尺寸 /// /// 图片1路径 /// 图片2路径 /// 图片3路径 /// 图片4路径 /// 图片5路径 /// 测量结果的生成目录 /// 测量结果返回 /// json字符串 public void Img_DDIC_Measure_Size(String imagePath1, String imagePath2, String imagePath3, String imagePath4, String imagePath5, String resultPath, out int state) { try { this.webServer_Path = this._url[13]; } catch { this.webServer_Path = "DDIC_measure_parameter"; } Update_Url(); JObject json = new JObject(); json.Add("img_path1", imagePath1); json.Add("img_path2", imagePath2); json.Add("img_path3", imagePath3); json.Add("img_path4", imagePath4); json.Add("img_path5", imagePath5); json.Add("result_path", resultPath); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "") { state = Convert.ToInt32(jret["state"].ToString()); } else { state = 0; } } /// /// EDS返回点信息 /// /// 图片路径 /// 第几张图片 /// 图片类型 /// 厂商 /// 返回点数据 /// 返回状态 public void EDS_Param_Points(String imagePath, int num, int imageType, String firm, out List listPoints, out int state) { try { this.webServer_Path = this._url[9]; } catch { this.webServer_Path = "test9"; } listPoints = new List(); state = 0; Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("num", num); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if(jret!=null && jret.Property(imagePath)!=null && jret.Property(imagePath).ToString()!="") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if(state==1) { JArray xpoints = JArray.Parse(jname["Xlists"].ToString()); JArray ypoints = JArray.Parse(jname["Ylists"].ToString()); if(xpoints.Count==ypoints.Count) { List lt_x = new List(); for(int i=0;i /// EDS返回线信息 /// /// 图片路径 /// 第几张图片 /// 图片类型 /// 厂商 /// 返回点数据 /// 返回状态 public void EDS_Param_Lines(String imagePath, int num, int imageType, String firm, out List list_pt, out List height, out int state) { try { this.webServer_Path = this._url[10]; } catch { this.webServer_Path = "test10"; } list_pt = new List(); height = new List(); state = 0; Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("num", num); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { JArray lines = JArray.Parse(jname["lines1"].ToString()); int x = Convert.ToInt32(lines[0][0].ToString()); int y1 = Convert.ToInt32(lines[0][1].ToString()); int y2 = Convert.ToInt32(lines[1][1].ToString()); Point pt = new Point(); pt.X = x; pt.Y = y1; list_pt.Add(pt); height.Add(Math.Abs(y2 - y1)); lines = JArray.Parse(jname["lines2"].ToString()); x = Convert.ToInt32(lines[0][0].ToString()); y1 = Convert.ToInt32(lines[0][1].ToString()); y2 = Convert.ToInt32(lines[1][1].ToString()); pt = new Point(); pt.X = x; pt.Y = y1; list_pt.Add(pt); height.Add(Math.Abs(y2 - y1)); lines = JArray.Parse(jname["lines3"].ToString()); x = Convert.ToInt32(lines[0][0].ToString()); y1 = Convert.ToInt32(lines[0][1].ToString()); y2 = Convert.ToInt32(lines[1][1].ToString()); pt = new Point(); pt.X = x; pt.Y = y1; list_pt.Add(pt); height.Add(Math.Abs(y2 - y1)); } } } /// /// EDS返回点信息 /// /// 图片路径 /// 第几张图片 /// 图片类型 /// 厂商 /// 返回点数据 /// 返回状态 public void EDS_Param_Areas(String imagePath, int num, int imageType, String firm, out Point pt_left_top, out int width, out int height, out int state) { try { this.webServer_Path = this._url[11]; } catch { this.webServer_Path = "test11"; } pt_left_top = new Point(); width = 0; height = 0; state = 0; Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("num", num); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { width = Convert.ToInt32(jname["length"].ToString()); JArray lines = JArray.Parse(jname["areas"].ToString()); pt_left_top.X = Convert.ToInt32(lines[0][0].ToString()); int y1 = Convert.ToInt32(lines[0][1].ToString()); pt_left_top.Y = y1; int y2 = Convert.ToInt32(lines[1][1].ToString()); height = Math.Abs(y2 - y1); } } } /// /// 计算测量区域坐标 /// /// 图片路径 /// 样品类型 /// 厂商 /// 观测点位置列表 /// 观测点放大倍数列表 /// 对焦点位置 /// 返回结果状态 /// json字符串 public void Img_Measure_Region_Position(String imagePath, int imageType, String firm, out List center, out List mag, out Point center0, out int state) { try { this.webServer_Path = this._url[7]; } catch { this.webServer_Path = "test8"; } Update_Url(); JObject json = new JObject(); json.Add("img_path", imagePath); json.Add("img_type", imageType); json.Add("firm", firm); center = new List(); mag = new List(); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property(imagePath) != null && jret.Property(imagePath).ToString() != "") { JObject jname = JObject.Parse(jret[imagePath].ToString()); state = Convert.ToInt32(jname["state"].ToString()); if (state == 1) { JArray jcenter = JArray.Parse(jname["center"].ToString()); String ptx = ""; String pty = ""; for (int i = 0; i < jcenter.Count; i++) { ptx = jcenter[i][0].ToString(); pty = jcenter[i][1].ToString(); Point pt = new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty)); center.Add(pt); } JArray jmag = JArray.Parse(jname["magnification"].ToString()); for (int i = 0; i < jmag.Count; i++) { mag.Add(Convert.ToSingle(jmag[i].ToString())); } JArray jcenter0 = JArray.Parse(jname["center0"].ToString()); ptx = jcenter0[0].ToString(); pty = jcenter0[1].ToString(); center0 = new Point(Convert.ToInt32(ptx), Convert.ToInt32(pty)); } else { center0 = new Point(0, 0); state = 0; } } else { center0 = new Point(0, 0); state = 0; } } /// /// 测量尺寸 /// /// 图片1路径 /// 图片2路径 /// 图片1的像素大小 /// 图片2的像素大小 /// 测量结果的生成目录 /// 样品类型 /// 厂类 /// 测量结果返回 /// json字符串 public void Img_Measure_Height(List imagePath, List size, String resultPath, int imageType, String firm, out int state) { try { this.webServer_Path = this._url[8]; } catch { this.webServer_Path = "test9"; } Update_Url(); JObject json = new JObject(); JArray jpath = new JArray(); JArray jsize = new JArray(); for (int i = 0; i < imagePath.Count; i++) { jpath.Add(imagePath[i]); jsize.Add(size[i]); } json.Add("img_path", jpath); json.Add("result_path", resultPath); json.Add("size", jsize); json.Add("img_type", imageType); json.Add("firm", firm); String res = RequestString(JsonConvert.SerializeObject(json)); JObject jret = (JObject)JsonConvert.DeserializeObject(res); if (jret != null && jret.Property("state") != null && jret.Property("state").ToString() != "") { state = Convert.ToInt32(jret["state"].ToString()); } else { state = 0; } } } }