Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SmallReport/SmallReport.Assist/JSONHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private static string Encode<T>(T t, Formatting format)

public static T Decode<T>(string json)
{
return (T)JsonConvert.DeserializeObject(json, typeof(T));
var output = (T)JsonConvert.DeserializeObject(json, typeof(T));
return output;
}
#endregion
}
Expand Down
4 changes: 2 additions & 2 deletions SmallReport/SmallReport.Assist/LogHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using log4net;
using System;
using System;
using System.Text;
using Common.Logging;

namespace SmallReport.Assist
{
Expand Down
5 changes: 4 additions & 1 deletion SmallReport/SmallReport.Assist/WeChat/MessageHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ public static string AccessService(string toUser, string fromUser)
#region Template Msg
public static void SendExpMsg()
{
var openId_leh = "oc0Qp0m9wYecC0cBihpsDdsS-4FU";
var openId_dg = "oc0Qp0pm6a4o9fuFsMZ6ApeEWloU";

var text = $@"
{{
""touser"": ""{"oc0Qp0m9wYecC0cBihpsDdsS-4FU"}"",
""touser"": ""{openId_dg}"",
""template_id"": ""{"u6slk3ft-7x4jRR8lgy-ZlvNtGbMzpP3zeOyX4dGN_0"}"",
""topcolor"":""#FF0000"",
""url"":"""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

public class AccessTokenModel
{
public string AccessToken { get; set; }
public string access_token { get; set; }

public int ExpiresIn { get; set; }
public int expires_in { get; set; }

public string RefreshToken { get; set; }

Expand Down
15 changes: 8 additions & 7 deletions SmallReport/SmallReport.Assist/WeChat/WeChatHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ private static string GetExistAccessToken()
var selectSingleNode = xml.SelectSingleNode("xml");
var singleNode = selectSingleNode?.SelectSingleNode("AccessToken");
if (singleNode != null)
singleNode.InnerText = model.AccessToken;
var accessToken = DateTime.Now.AddSeconds(model.ExpiresIn);
singleNode.InnerText = model.access_token;
var accessToken = DateTime.Now.AddSeconds(model.expires_in);
var xmlNode = xml.SelectSingleNode("xml");
var node = xmlNode?.SelectSingleNode("AccessExpires");
if (node != null)
node.InnerText = accessToken.ToString(CultureInfo.InvariantCulture);
xml.Save(filePath);
token = model.AccessToken;
token = model.access_token;
return token;
}

Expand All @@ -136,8 +136,8 @@ private static AccessTokenModel GetAccessToken()
var atoken = new AccessTokenModel();
var content = HttpGet(asseccUrl);
var token = ParseFromJson<AccessTokenModel>(content);
atoken.AccessToken = token.AccessToken;
atoken.ExpiresIn = token.ExpiresIn;
atoken.access_token = token.access_token;
atoken.expires_in = token.expires_in;
return atoken;
}
#endregion
Expand Down Expand Up @@ -219,7 +219,8 @@ private static string HttpGet(string url)

private static T ParseFromJson<T>(string szJson)
{
return JsonHelper.Decode<T>(szJson);
var output = JsonHelper.Decode<T>(szJson);
return output;
}

public static void SendTemplateMsg(string postContent)
Expand Down Expand Up @@ -254,7 +255,7 @@ private static void Post(string url, string param)
var response = request.GetResponse();
{
var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
reader.ReadToEnd();
var responseStr = reader.ReadToEnd();
reader.Close();
}
}
Expand Down
4 changes: 2 additions & 2 deletions SmallReport/SmallReport.Web/Config/AuthToken.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<xml>
<AccessToken>13_HL2ZP3QrKeD625IBz8IurvvTJFHBkG1LcQVhSIYtJn5tUTDjx3-oomZ6B58B-MK_VMK1Fte0wjHVYPoN5UmUfZdRljJzeHK-mQ5NLVDSaTA7uVfMiGHr4HG5hNPkc_r_L5uGc1NyFnWazYf2ERZeADAVIQ</AccessToken>
<AccessExpires>2018/9/2 17:30:04</AccessExpires>
<AccessToken>13_hcdCJxVL3bk_wmD6r4m_R8VaSCTkt-6umvxkYYpsh508BRgdx-L1FZGswze_S3ZCMvI57SnKVnJDUa4P6npo8t_l777xhWk6-UyM2PCLMG1DO0S_Pn1Y1D-2-Ok7tIcyZFefUc_6fuibuFzCEPUbAIAQBG</AccessToken>
<AccessExpires>09/04/2018 13:37:30</AccessExpires>
</xml>