瀏覽代碼

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

章政 7 年之前
父節點
當前提交
f9dc197175
共有 1 個文件被更改,包括 37 次插入6 次删除
  1. 37 6
      UAS_Web/tool/RequestHandler.cs

+ 37 - 6
UAS_Web/tool/RequestHandler.cs

@@ -133,9 +133,9 @@ namespace UAS_Web.tool
 
                         using (Graphics g = Graphics.FromImage(bit))
                         {
-                            g.CompositingQuality = CompositingQuality.HighQuality;
-                            g.SmoothingMode = SmoothingMode.HighQuality;
-                            g.InterpolationMode = InterpolationMode.HighQualityBicubic;   
+                            //g.CompositingQuality = CompositingQuality.HighQuality;
+                            //g.SmoothingMode = SmoothingMode.HighQuality;
+                            //g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                             ////定义一枝画笔
                             //Pen pen = new Pen(Color.Black);
                             ////用这个画笔在左上角画一个矩形
@@ -145,7 +145,33 @@ namespace UAS_Web.tool
                                 Dictionary<string, object> Sidc = parameter.Find(p => p["LP_NAME"].ToString().Replace(" ", "").Replace("\"", "").ToUpper() == itemc.Key.ToUpper());
                                 if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "text")
                                 {
-                                    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()));
+                                    string itemstr = "";
+                                    if (itemc.Value != null)
+                                    {
+                                        itemstr = itemc.Value.ToString();
+                                        while (itemstr.StartsWith("\f") || itemstr.StartsWith("\v") || itemstr.StartsWith("\t") || itemstr.StartsWith("\r") || itemstr.StartsWith("\n"))
+                                        {
+                                            itemstr = itemstr.Remove(0, 2);
+                                        }
+                                        if (itemstr.StartsWith("\""))
+                                        {
+                                            itemstr = itemstr.Remove(0, 1);
+                                        }
+                                        while (itemstr.EndsWith("\f") || itemstr.EndsWith("\v") || itemstr.EndsWith("\t") || itemstr.EndsWith("\r") || itemstr.EndsWith("\n"))
+                                        {
+                                            itemstr = itemstr.Remove(itemstr.Length - 2);
+                                        }
+                                        if (itemstr.EndsWith("\""))
+                                        {
+                                            itemstr = itemstr.Remove(itemstr.Length - 1);
+                                        }
+                                        if (itemstr.Contains("\\\""))
+                                        {
+                                            itemstr = itemstr.Replace("\\\"", "\"");
+                                            Console.WriteLine(itemstr);
+                                        }
+                                    }
+                                    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()));
                                 }
                                 else if (Sidc["LP_VALUETYPE"].ToString().Replace(" ", "").Replace("\"", "") == "barcode")
                                 {
@@ -304,7 +330,7 @@ namespace UAS_Web.tool
             }
             else
             {
-                MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\}\s*\]|null|"".+?""|-{0,1}\d*)");//使用正则表达式匹配出JSON数据中的键与值 
+                MatchCollection Match = Regex.Matches(JsonData, @"""(.+?)"": {0,1}(\[[\s\S]+?\}\s*\]|null|"".+?""(,+?)|"".+?""(\s*?)(\}+?)|-{0,1}\d*)");//使用正则表达式匹配出JSON数据中的键与值 
 
                 foreach (Match item in Match)
                 {
@@ -323,7 +349,12 @@ namespace UAS_Web.tool
                             Data = List;
                         }
                         else if (item.Groups[2].ToString().ToLower() == "null") Data = null;//如果数据为null(字符串类型),直接转换成null
-                        else Data = item.Groups[2].ToString(); //数据为数字、字符串中的一类,直接写入 
+                        else if (item.Groups[2].ToString().EndsWith(","))
+                            Data = item.Groups[2].ToString().Remove(item.Groups[2].ToString().Length - 1); //数据为数字、字符串中的一类,则去掉,直接写入 
+                        else if (item.Groups[2].ToString().EndsWith("}"))
+                            Data = item.Groups[2].ToString().Remove(item.Groups[2].ToString().Length - 1); //数据为数字、字符串中的一类,则去掉,直接写入 
+                        else
+                            Data = item.Groups[2].ToString();
                         Dic.Add(item.Groups[1].ToString(), Data);
                     }
                     catch { }