Explorar o código

发短信打日志

lcl hai 1 semana
pai
achega
59f023abd5
Modificáronse 2 ficheiros con 34 adicións e 0 borrados
  1. 4 0
      Util/HaoDa/SendSMS.cs
  2. 30 0
      Util/LogHelper.cs

+ 4 - 0
Util/HaoDa/SendSMS.cs

@@ -30,7 +30,9 @@ namespace MySystem
 
         public string Do(string mobile, string code)
         {
+            string logString = "";
             String querys = "mobile=" + mobile + "&param=**code**%3A" + code + "%2C**minute**%3A5&smsSignId=8b278cf2bb2a4b3c818cc7a436307a12&templateId=908e94ccf08b4476ba6c876d13f084ad";
+            logString += "\n" + querys;
             String bodys = "";
             String url = host + path;
             HttpWebRequest httpRequest = null;
@@ -72,6 +74,8 @@ namespace MySystem
             Stream st = httpResponse.GetResponseStream();
             StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
             string result = reader.ReadToEnd();
+            logString += "\n" + result;
+            LogHelper.Instance.WriteLog(logString, "阿里云短信验证码日志", true);
             return result;
         }
 

+ 30 - 0
Util/LogHelper.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading;
+using Library;
+using LitJson;
+using MySystem;
+
+public class LogHelper
+{
+    public readonly static LogHelper Instance = new LogHelper();
+    private LogHelper()
+    { }
+
+    public void WriteLog(string Content, string FileName, bool sls = false)
+    {
+        if(sls)
+        {
+            Dictionary<string, string> dic = new Dictionary<string, string>();
+            dic.Add("Topic", FileName);
+            dic.Add("Content", Content);
+            KxsRedisDbconn.Instance.AddList("SlsLogQueue", Newtonsoft.Json.JsonConvert.SerializeObject(dic));
+        }
+        else
+        {
+            function.WriteLog(Content, FileName);
+        }
+    }
+}