RequestHandler.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. using CefSharp;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Drawing;
  5. using System.Drawing.Drawing2D;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8. using System.Windows.Forms;
  9. using System.Drawing.Printing;
  10. using FastReport;
  11. using System.Data;
  12. using System.Threading;
  13. using System.Net;
  14. using System.Text;
  15. using System.Web;
  16. using System.Diagnostics;
  17. namespace UAS_Web.tool
  18. {
  19. class RequestHandler : IRequestHandler
  20. {
  21. public event Action<byte[]> NotifyMsg;
  22. //打印图片集合
  23. List<Bitmap> bitmaps = new List<Bitmap>();
  24. Report BarcodeReport = new Report();
  25. Report BoxReport = new Report();
  26. //图片打印中间变量
  27. int imagecount = 0;
  28. int index = 0;
  29. string PrinterName = "";
  30. string PrintType = "";
  31. PrinterList print;
  32. string LABELNAME = "";
  33. string labelview = "";
  34. /// <summary>
  35. /// 拦截指定请求
  36. /// </summary>
  37. /// <param name="browserControl"></param>
  38. /// <param name="browser"></param>
  39. /// <param name="frame"></param>
  40. /// <param name="request"></param>
  41. /// <param name="response"></param>
  42. /// <returns></returns>
  43. IResponseFilter IRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response)
  44. {
  45. MessageFilter filter;
  46. switch (request.Url.Substring(request.Url.LastIndexOf("/") + 1))
  47. {
  48. case "zplPrinter":
  49. filter = FilterManager.CreateFilter(request.Identifier.ToString()) as MessageFilter;
  50. return filter;
  51. case "zplPrint.action":
  52. filter = FilterManager.CreateFilter(request.Identifier.ToString()) as MessageFilter;
  53. return filter;
  54. case "getPrintType.action":
  55. filter = FilterManager.CreateFilter(request.Identifier.ToString()) as MessageFilter;
  56. return filter;
  57. case "vendorZplPrint.action":
  58. filter = FilterManager.CreateFilter(request.Identifier.ToString()) as MessageFilter;
  59. return filter;
  60. default:
  61. break;
  62. }
  63. return null;
  64. }
  65. /// <summary>
  66. /// 完成响应后获取Js返回的数据
  67. /// </summary>
  68. /// <param name="browserControl"></param>
  69. /// <param name="browser"></param>
  70. /// <param name="frame"></param>
  71. /// <param name="request"></param>
  72. /// <param name="response"></param>
  73. /// <param name="status"></param>
  74. /// <param name="receivedContentLength"></param>
  75. void IRequestHandler.OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
  76. {
  77. MessageFilter filter;
  78. string str;
  79. Dictionary<string, object> data;
  80. switch (request.Url.Substring(request.Url.LastIndexOf("/") + 1))
  81. {
  82. case "zplPrinter":
  83. var m = request.Method;
  84. if (request.Method == "POST")
  85. {
  86. using (var postData = request.PostData)
  87. {
  88. if (postData != null)
  89. {
  90. var elements = postData.Elements;
  91. var charSet = request.GetCharSet();
  92. foreach (var element in elements)
  93. {
  94. if (element.Type == PostDataElementType.Bytes)
  95. {
  96. string body = HttpUtility.UrlDecode(element.GetBody(charSet),Encoding.UTF8);
  97. LABELNAME = body.Substring(body.LastIndexOf('=')+1);
  98. }
  99. }
  100. }
  101. }
  102. }
  103. //弹出打印机选择列表
  104. print = new PrinterList(browser) { StartPosition = FormStartPosition.CenterScreen,TopMost=true };
  105. print.Controls["Confirm"].Click += RequestHandler_Click;
  106. print.PrintDoc.PrintPage += PrintPage;
  107. print.ShowDialog();
  108. break;
  109. case "zplPrint.action":
  110. filter = FilterManager.GetFileter(request.Identifier.ToString()) as MessageFilter;
  111. str = System.Text.Encoding.UTF8.GetString(filter.dataAll.ToArray());
  112. data = ToDictionary(str);
  113. //获取所有的打印格式数据
  114. if (data.ContainsKey("data"))
  115. {
  116. string PrintCode = data["data"].ToString().Replace(" ", "").Replace("\"", "");
  117. List<string> PrintList = new List<string>();
  118. int PrintTime = Regex.Matches(PrintCode, "XA").Count;
  119. for (int i = 0; i < PrintTime; i++)
  120. {
  121. PrintList.Add(PrintCode.Substring(0, PrintCode.IndexOf("XZ") + 2));
  122. PrintCode = PrintCode.Substring(PrintCode.IndexOf("XZ") + 2);
  123. }
  124. for (int i = 0; i < PrintList.Count; i++)
  125. {
  126. PrintHelper.SendStringToPrinter(PrinterName, PrintList[i]);
  127. }
  128. data.Clear();
  129. }
  130. else if (data.ContainsKey("exceptionInfo"))
  131. {
  132. //string PrintCode = data["exceptionInfo"].ToString();
  133. //MessageBox.Show(PrintCode);
  134. }
  135. break;
  136. case "getPrintType.action":
  137. filter = FilterManager.GetFileter(request.Identifier.ToString()) as MessageFilter;
  138. str = System.Text.Encoding.UTF8.GetString(filter.dataAll.ToArray());
  139. data = ToDictionary(str);
  140. PrintType = data["data"].ToString().Replace("\"", "");
  141. break;
  142. case "vendorZplPrint.action":
  143. try
  144. {
  145. filter = FilterManager.GetFileter(request.Identifier.ToString()) as MessageFilter;
  146. str = System.Text.Encoding.UTF8.GetString(filter.dataAll.ToArray());
  147. data = ToDictionary(str);
  148. vendorZplPrint(data);
  149. }
  150. catch (Exception ex)
  151. {
  152. MessageBox.Show(ex.Message + "请重新进行打印");
  153. return;
  154. }
  155. break;
  156. default:
  157. break;
  158. }
  159. }
  160. public void vendorZplPrint(Object data)
  161. {
  162. DataTable dt = new DataTable();
  163. RadioButton PRFR = (RadioButton)print.Controls["PRFR"];
  164. RadioButton PRPIC = (RadioButton)print.Controls["PRPIC"];
  165. string type;
  166. bitmaps.Clear();
  167. List<Dictionary<string, object>> parameter = new List<Dictionary<string, object>>();
  168. List<Dictionary<string, object>> barcode = new List<Dictionary<string, object>>();
  169. try
  170. {
  171. parameter = (List<Dictionary<string, object>>)((Dictionary<string, object>)data)["parameter"];
  172. barcode = (List<Dictionary<string, object>>)((Dictionary<string, object>)data)["barcode"];
  173. }
  174. catch {
  175. MessageBox.Show("打印数据解析异常,请联系管理员进行处理");
  176. return;
  177. }
  178. try
  179. {
  180. type = ((String)((Dictionary<string, object>)data)["type"]).Replace("\"", "");
  181. }
  182. catch
  183. {
  184. type = "no";
  185. }
  186. try
  187. {
  188. labelview = ((String)((Dictionary<string, object>)data)["label_type"]).Replace("\"", "");
  189. }
  190. catch
  191. {
  192. labelview = "";
  193. }
  194. if (PRFR.Checked)
  195. {
  196. Thread.Sleep(1000);
  197. int i = 0;
  198. while (DownLoadFile.downloading && i < 2)
  199. {
  200. Thread.Sleep(1000);
  201. i++;
  202. }
  203. if (DownLoadFile.downloading)
  204. Console.WriteLine("标签更新有误");
  205. try
  206. {
  207. if (type == "box")
  208. {
  209. BoxReport.Load(System.AppDomain.CurrentDomain.BaseDirectory + LABELNAME + ".frx");
  210. }
  211. else {
  212. BarcodeReport.Load(System.AppDomain.CurrentDomain.BaseDirectory + LABELNAME + ".frx");
  213. }
  214. }
  215. catch
  216. {
  217. MessageBox.Show("未找到可使用的标签文件,请重试");
  218. return;
  219. }
  220. }
  221. int la_width = int.Parse(parameter.First()["LA_WIDTH"].ToString());
  222. int la_height = int.Parse(parameter.First()["LA_HEIGHT"].ToString());
  223. foreach (var item in barcode)
  224. {
  225. Bitmap bit = new Bitmap(la_width * 10, la_height * 4);
  226. using (Graphics g = Graphics.FromImage(bit))
  227. {
  228. //g.CompositingQuality = CompositingQuality.HighQuality;
  229. //g.SmoothingMode = SmoothingMode.HighQuality;
  230. //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  231. ////定义一枝画笔
  232. //Pen pen = new Pen(Color.Black);
  233. ////用这个画笔在左上角画一个矩形
  234. //g.DrawRectangle(pen, new Rectangle(10, 10, 50, 20));
  235. foreach (var itemc in item)
  236. {
  237. Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
  238. if (Sidc != null)
  239. {
  240. if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
  241. {
  242. string itemstr = "";
  243. if (itemc.Value != null)
  244. {
  245. itemstr = itemc.Value.ToString();
  246. while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
  247. {
  248. itemstr = itemstr.Remove(0, 2);
  249. }
  250. if (itemstr.StartsWith("\""))
  251. {
  252. itemstr = itemstr.Remove(0, 1);
  253. }
  254. while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
  255. {
  256. itemstr = itemstr.Remove(itemstr.Length - 2);
  257. }
  258. if (itemstr.EndsWith("\""))
  259. {
  260. itemstr = itemstr.Remove(itemstr.Length - 1);
  261. }
  262. if (itemstr.Contains("\\\""))
  263. {
  264. itemstr = itemstr.Replace("\\\"", "\"");
  265. }
  266. }
  267. if (PRFR.Checked)
  268. {
  269. DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
  270. if (!dt.Columns.Contains(itemc.Key))
  271. dt.Columns.Add(DC);
  272. }
  273. if (PRPIC.Checked)
  274. {
  275. PrintHelper.Printstring(itemc.Value != null ? itemstr : " ", int.Parse(Sidc["LP_SIZE"].ToString()), g, int.Parse(Sidc["LP_LEFTRATE"].ToString()), int.Parse(Sidc["LP_TOPRATE"].ToString()));
  276. }
  277. }
  278. else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
  279. {
  280. if (PRFR.Checked)
  281. {
  282. DataColumn DC = new DataColumn(itemc.Key, Type.GetType("System.String"));
  283. if (!dt.Columns.Contains(itemc.Key))
  284. dt.Columns.Add(DC);
  285. }
  286. if (PRPIC.Checked)
  287. {
  288. PrintHelper.DrawBarcode(itemc.Value != null ? itemc.Value.ToString().Replace("\"", "") : " ", ref bit, double.Parse(Sidc["LP_LEFTRATE"].ToString()), double.Parse(Sidc["LP_TOPRATE"].ToString()), double.Parse(Sidc["LP_WIDTH"].ToString()), double.Parse(Sidc["LP_HEIGHT"].ToString()) - 2);
  289. PrintHelper.Printstring(itemc.Value != null ? itemc.Value.ToString().Replace("\"", "") : " ", int.Parse(Sidc["LP_SIZE"].ToString()), g, int.Parse(Sidc["LP_LEFTRATE"].ToString()), int.Parse(Sidc["LP_TOPRATE"].ToString()) + double.Parse(Sidc["LP_HEIGHT"].ToString()) - 2);
  290. }
  291. }
  292. }
  293. }
  294. }
  295. bitmaps.Add(bit);
  296. }
  297. if (PRFR.Checked)
  298. {
  299. foreach (var item in barcode)
  300. {
  301. DataRow dr = dt.NewRow();
  302. //g.CompositingQuality = CompositingQuality.HighQuality;
  303. //g.SmoothingMode = SmoothingMode.HighQuality;
  304. //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
  305. ////定义一枝画笔
  306. //Pen pen = new Pen(Color.Black);
  307. ////用这个画笔在左上角画一个矩形
  308. //g.DrawRectangle(pen, new Rectangle(10, 10, 50, 20));
  309. foreach (var itemc in item)
  310. {
  311. Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
  312. if (Sidc != null)
  313. {
  314. if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
  315. {
  316. string itemstr = "";
  317. if (itemc.Value != null)
  318. {
  319. itemstr = itemc.Value.ToString();
  320. while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
  321. {
  322. itemstr = itemstr.Remove(0, 2);
  323. }
  324. if (itemstr.StartsWith("\""))
  325. {
  326. itemstr = itemstr.Remove(0, 1);
  327. }
  328. while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
  329. {
  330. itemstr = itemstr.Remove(itemstr.Length - 2);
  331. }
  332. if (itemstr.EndsWith("\""))
  333. {
  334. itemstr = itemstr.Remove(itemstr.Length - 1);
  335. }
  336. if (itemstr.Contains("\\\""))
  337. {
  338. itemstr = itemstr.Replace("\\\"", "\"");
  339. Console.WriteLine(itemstr);
  340. }
  341. }
  342. dr[itemc.Key] = itemstr;
  343. }
  344. else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
  345. {
  346. dr[itemc.Key] = itemc.Value.ToString().Replace("\"", "");
  347. }
  348. }
  349. }
  350. dt.Rows.Add(dr);
  351. }
  352. }
  353. if (PRPIC.Checked)
  354. {
  355. if (bitmaps.Count > 0)
  356. {
  357. imagecount = bitmaps.Count;
  358. print.PrintDoc.Print();
  359. }
  360. }
  361. if (PRFR.Checked)
  362. {
  363. try
  364. {
  365. if (labelview == "")
  366. {
  367. if (type == "box")
  368. {
  369. BoxReport.RegisterData(dt, "VENDORBARCODE_BOX_VIEW");
  370. BoxReport.GetDataSource("VENDORBARCODE_BOX_VIEW").Enabled = true;
  371. BoxReport.PrintSettings.ShowDialog = false;
  372. BoxReport.PrintSettings.Printer = PrinterName;
  373. BoxReport.Print();
  374. }
  375. else
  376. {
  377. BarcodeReport.RegisterData(dt, "VENDORBARCODE_VIEW");
  378. BarcodeReport.GetDataSource("VENDORBARCODE_VIEW").Enabled = true;
  379. BarcodeReport.PrintSettings.ShowDialog = false;
  380. BarcodeReport.PrintSettings.Printer = PrinterName;
  381. BarcodeReport.Print();
  382. }
  383. }
  384. else {
  385. BarcodeReport.RegisterData(dt, labelview);
  386. BarcodeReport.GetDataSource(labelview).Enabled = true;
  387. BarcodeReport.PrintSettings.ShowDialog = false;
  388. BarcodeReport.PrintSettings.Printer = PrinterName;
  389. BarcodeReport.Print();
  390. }
  391. }
  392. catch(Exception ex)
  393. {
  394. MessageBox.Show(ex.Message+"打印出现错误,请检查标签文件选择是否正确");
  395. }
  396. dt.Clear();
  397. }
  398. }
  399. private void PrintPage(object sender, PrintPageEventArgs e)
  400. {
  401. Image i = bitmaps[index];
  402. Graphics g = e.Graphics;
  403. g.DrawImage(i, 4, 10, i.Width, i.Height);
  404. if (index < imagecount - 1)
  405. {
  406. e.HasMorePages = true;
  407. index++;
  408. }
  409. else
  410. {
  411. index = 0;
  412. e.HasMorePages = false;
  413. }
  414. }
  415. private void RequestHandler_Click(object sender, EventArgs e)
  416. {
  417. //设置打印机名称
  418. print.PrintDoc.PrinterSettings.PrinterName = print.Controls["Printer"].Text;
  419. PrinterName = print.Controls["Printer"].Text;
  420. RadioButton PRXA = (RadioButton)print.Controls["PRXA"];
  421. RadioButton PRPIC = (RadioButton)print.Controls["PRPIC"];
  422. //获取矩阵图的分辨率
  423. Graphics gr = print.PrintDoc.PrinterSettings.CreateMeasurementGraphics();
  424. print.browser.FocusedFrame.ExecuteJavaScriptAsync("(function(value,value1){dpi=value,printType=value1})('" + gr.DpiX + "','" + PrintType + "')");
  425. if (PRXA.Checked)
  426. {
  427. print.browser.FocusedFrame.ExecuteJavaScriptAsync("document.getElementById('confirmZplPrint').click();");
  428. }
  429. else
  430. {
  431. print.browser.FocusedFrame.ExecuteJavaScriptAsync("document.getElementById('confirmPicturePrint').click();");
  432. }
  433. print.Close();
  434. }
  435. void filter_NotifyData(byte[] data)
  436. {
  437. if (NotifyMsg != null)
  438. {
  439. NotifyMsg(data);
  440. }
  441. }
  442. public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
  443. {
  444. return false;
  445. }
  446. public bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isRedirect)
  447. {
  448. return false;
  449. }
  450. public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
  451. {
  452. return CefReturnValue.Continue;
  453. }
  454. public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
  455. {
  456. return false;
  457. }
  458. public bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture)
  459. {
  460. return false;
  461. }
  462. public void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath)
  463. {
  464. }
  465. public bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url)
  466. {
  467. return false;
  468. }
  469. public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
  470. {
  471. return false;
  472. }
  473. public void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status)
  474. {
  475. }
  476. public void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser)
  477. {
  478. }
  479. public void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
  480. {
  481. }
  482. public void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, ref string newUrl)
  483. {
  484. }
  485. bool IRequestHandler.OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response)
  486. {
  487. return false;
  488. }
  489. public void GetData()
  490. {
  491. }
  492. public static Dictionary<string, object> ToDictionary(string JsonData)
  493. {
  494. object Data = null;
  495. Dictionary<string, object> Dic = new Dictionary<string, object>();
  496. if (JsonData.StartsWith("["))
  497. {
  498. //如果目标直接就为数组类型,则将会直接输出一个Key为List的List<Dictionary<string, object>>集合
  499. //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["List"];
  500. List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
  501. MatchCollection ListMatch = Regex.Matches(JsonData, @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组
  502. foreach (Match ListItem in ListMatch)
  503. {
  504. List.Add(ToDictionary(ListItem.ToString()));//递归调用
  505. }
  506. Data = List;
  507. Dic.Add("List", Data);
  508. }
  509. else
  510. {
  511. MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\}\s*\]|null|"".+?""(,+?)|"".+?""(\s*?)(\}+?)|-{0,1}\d*)");//使用正则表达式匹配出JSON数据中的键与值
  512. foreach (Match item in Match)
  513. {
  514. try
  515. {
  516. if (item.Groups[2].ToString().StartsWith("["))
  517. {
  518. //如果目标是数组,将会输出一个Key为当前Json的List<Dictionary<string, object>>集合
  519. //使用示例List<Dictionary<string, object>> ListDic = (List<Dictionary<string, object>>)Dic["Json中的Key"];
  520. List<Dictionary<string, object>> List = new List<Dictionary<string, object>>();
  521. MatchCollection ListMatch = Regex.Matches(item.Groups[2].ToString(), @"{[\s\S]+?}");//使用正则表达式匹配出JSON数组
  522. foreach (Match ListItem in ListMatch)
  523. {
  524. List.Add(ToDictionary(ListItem.ToString()));//递归调用
  525. }
  526. Data = List;
  527. }
  528. else if (item.Groups[2].ToString().ToLower() == "null") Data = null;//如果数据为null(字符串类型),直接转换成null
  529. else if (item.Groups[2].ToString().EndsWith(","))
  530. Data = item.Groups[2].ToString().Remove(item.Groups[2].ToString().Length - 1); //数据为数字、字符串中的一类,则去掉,直接写入
  531. else if (item.Groups[2].ToString().EndsWith("}"))
  532. Data = item.Groups[2].ToString().Remove(item.Groups[2].ToString().Length - 1); //数据为数字、字符串中的一类,则去掉,直接写入
  533. else
  534. Data = item.Groups[2].ToString();
  535. Dic.Add(item.Groups[1].ToString(), Data);
  536. }
  537. catch { }
  538. }
  539. }
  540. return Dic;
  541. }
  542. }
  543. }