Ver código fonte

修复空指针bug

lcl 3 meses atrás
pai
commit
ce57495276
2 arquivos alterados com 5 adições e 2 exclusões
  1. 4 2
      Controllers/HomeController.cs
  2. 1 0
      Util/Queue/PosPushHelper.cs

+ 4 - 2
Controllers/HomeController.cs

@@ -149,8 +149,10 @@ namespace MySystem.Controllers
 
         public string push()
         {
-            AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"ANDROID\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
-            AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"IOS\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
+            // AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"ANDROID\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
+            // AliyunPushHelper.Instance.DoSomeThing("{\"Account\":\"14726006947\",\"Device\":\"IOS\",\"Title\":\"测试推送\",\"Body\":\"客小爽推送功能即将上线\"}");
+            string content = "{\"data_type\":\"bind\",\"data_content\":{\"pos_sn\":\"1014BS0023511\",\"mer_no\":\"15608798003\",\"id_card\":null,\"mer_name\":\"15608798003\",\"mer_mobile\":\"15608798003\",\"request_id\":\"2024102310381200098289115\",\"bind_time\":\"2024-10-23 10:38:12\",\"brand\":\"23\"}}";
+            PosPushHelper.Instance.DoSomeThing(content);
             return "ok";
         }
     }

+ 1 - 0
Util/Queue/PosPushHelper.cs

@@ -54,6 +54,7 @@ namespace MySystem
         {
             string url = "";
             function.WriteLog(DateTime.Now.ToString() + "\n" + content, "统一推送日志");
+            content = content.Replace("null", "\"\"");
             JsonData jsonObj = JsonMapper.ToObject(content);
             string dataType = jsonObj["data_type"].ToString();
             string dataContent = jsonObj["data_content"].ToJson();