forked from JeffreySu/WechatVideoCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
29,263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.26730.10 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SenparcClass", "SenparcClass\SenparcClass.csproj", "{0275598C-F2F2-496F-8FD0-3AA32C66695A}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SenparcClass.Tests", "SenparcClass.Tests\SenparcClass.Tests.csproj", "{7BE4B376-B1AE-4431-8CCB-D9F830CB9311}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SenparcClass.Service", "SenparcClass.Service\SenparcClass.Service.csproj", "{9B19D3E6-6BA0-4A19-8C17-ABE1B3736EE6}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0275598C-F2F2-496F-8FD0-3AA32C66695A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0275598C-F2F2-496F-8FD0-3AA32C66695A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0275598C-F2F2-496F-8FD0-3AA32C66695A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0275598C-F2F2-496F-8FD0-3AA32C66695A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7BE4B376-B1AE-4431-8CCB-D9F830CB9311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7BE4B376-B1AE-4431-8CCB-D9F830CB9311}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7BE4B376-B1AE-4431-8CCB-D9F830CB9311}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7BE4B376-B1AE-4431-8CCB-D9F830CB9311}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{9B19D3E6-6BA0-4A19-8C17-ABE1B3736EE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9B19D3E6-6BA0-4A19-8C17-ABE1B3736EE6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9B19D3E6-6BA0-4A19-8C17-ABE1B3736EE6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9B19D3E6-6BA0-4A19-8C17-ABE1B3736EE6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F595DE0C-CC63-4DEA-B923-155CED2D05CB} | ||
EndGlobalSection | ||
EndGlobal |
23 changes: 23 additions & 0 deletions
23
课程Demo代码/20-24 微信支付/SenparcClass/SenparcClass.Service/Class10/WeatherResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SenparcClass.Service.Class10 | ||
{ | ||
public class WeatherResult | ||
{ | ||
public string date { get; set; } | ||
public string message { get; set; } | ||
public int status { get; set; } | ||
public string city { get; set; } | ||
public int count { get; set; } | ||
public DateTime AddTime { get; set; } | ||
|
||
public WeatherResult() | ||
{ | ||
AddTime = DateTime.Now; | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
课程Demo代码/20-24 微信支付/SenparcClass/SenparcClass.Service/Class14/TemplateMessageCourseNotice.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Senparc.Weixin.Entities.TemplateMessage; | ||
using Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SenparcClass.Service.Class14 | ||
{ | ||
public class TemplateMessageCourseNotice : TemplateMessageBase | ||
{ | ||
public TemplateDataItem first { get; set; } | ||
public TemplateDataItem keyword1 { get; set; } | ||
public TemplateDataItem keyword2 { get; set; } | ||
public TemplateDataItem keyword3 { get; set; } | ||
public TemplateDataItem keyword4 { get; set; } | ||
public TemplateDataItem keyword5 { get; set; } | ||
public TemplateDataItem remark { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="_first"></param> | ||
/// <param name="time">时间</param> | ||
/// <param name="host"></param> | ||
/// <param name="service"></param> | ||
/// <param name="status"></param> | ||
/// <param name="message"></param> | ||
/// <param name="_remark"></param> | ||
/// <param name="url"></param> | ||
/// <param name="templateId"></param> | ||
public TemplateMessageCourseNotice( | ||
string _first, | ||
string time, | ||
string host, | ||
string service, | ||
string status, | ||
string message, | ||
string _remark, | ||
string url, string templateId = "nSS3Jx7q-eOhCM-bpv1jdSm3_slq2c1pxF_PKUNXj5g") | ||
: base(templateId, url, "视频培训测试") | ||
{ | ||
first = new TemplateDataItem(_first); | ||
keyword1 = new TemplateDataItem(time); | ||
keyword2 = new TemplateDataItem(host); | ||
keyword3 = new TemplateDataItem(service); | ||
keyword4 = new TemplateDataItem(status); | ||
keyword5 = new TemplateDataItem(message); | ||
remark = new TemplateDataItem(_remark); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
课程Demo代码/20-24 微信支付/SenparcClass/SenparcClass.Service/Config.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SenparcClass.Service | ||
{ | ||
public class TemplateMessageItem | ||
{ | ||
public string Name { get; set; } | ||
public string AppId { get; set; } | ||
public string TemplateNumber { get; set; } | ||
public string TemplateId { get; set; } | ||
public string SubscribeMsgTemplateId { get; set; } | ||
|
||
public TemplateMessageItem(string name, string appId, string templateNumber, string templateId, string subscribeMsgTemplateId) | ||
{ | ||
Name = name; | ||
AppId = appId; | ||
TemplateNumber = templateNumber; | ||
TemplateId = templateId; | ||
SubscribeMsgTemplateId = subscribeMsgTemplateId; | ||
} | ||
} | ||
|
||
public static class Config | ||
{ | ||
public static string AppId = System.Configuration.ConfigurationManager.AppSettings["WeixinAppId"]; | ||
public static string AppSecret = System.Configuration.ConfigurationManager.AppSettings["WeixinAppSecret"]; | ||
|
||
public static int LogRecordCount = 0; | ||
|
||
public static int LogExceptionRecordCount = 0; | ||
|
||
public static Dictionary<string, List<TemplateMessageItem>> TemplateMessageCollection; | ||
|
||
static Config() | ||
{ | ||
TemplateMessageCollection = new Dictionary<string, List<TemplateMessageItem>>(); | ||
|
||
TemplateMessageCollection[AppId] = new List<TemplateMessageItem>() { | ||
new TemplateMessageItem("视频培训测试", AppId, "Nil", | ||
"nSS3Jx7q-eOhCM-bpv1jdSm3_slq2c1pxF_PKUNXj5g", "Nil"), | ||
//new TemplateMessageBag("课程提醒", AppId, "63l8YSI2uYqlZwb8dkMSy2Lp8caHcaWc2Id0b_XYvtM", | ||
// "KU0hL0UVWzJA_8jmolH_o1UcNuNIcvQ36EiPcdd6F8Y", "OPENTM411013653"), | ||
}; | ||
|
||
//var tmBag = TemplateMessageCollection[AppId].FirstOrDefault(z => z.Name == "课程提醒"); | ||
} | ||
|
||
/// <summary> | ||
/// 获取TemplateMessageBag | ||
/// </summary> | ||
/// <param name="appId"></param> | ||
/// <param name="name"></param> | ||
/// <returns></returns> | ||
public static TemplateMessageItem GetTemplateMessageBag(string appId,string name) | ||
{ | ||
if (!TemplateMessageCollection.ContainsKey(appId)) | ||
{ | ||
return null; | ||
} | ||
|
||
var bagList = TemplateMessageCollection[appId]; | ||
var bag = bagList.FirstOrDefault(z => z.Name == name); | ||
return bag; | ||
} | ||
} | ||
|
||
|
||
//public static string TemplateNumber = "OPENTM411013653";//模板消息编号 | ||
|
||
//public static string TemplateId = "KU0hL0UVWzJA_8jmolH_o1UcNuNIcvQ36EiPcdd6F8Y";//模板ID | ||
|
||
//public static string SubscribeMsgTemplateId = "63l8YSI2uYqlZwb8dkMSy2Lp8caHcaWc2Id0b_XYvtM";//一次性订阅消息模板ID | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
课程Demo代码/20-24 微信支付/SenparcClass/SenparcClass.Service/CustomMessageContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Senparc.Weixin.Context; | ||
using Senparc.Weixin.MP.Entities; | ||
|
||
namespace SenparcClass.Service | ||
{ | ||
public class CustomMessageContext : MessageContext<IRequestMessageBase, IResponseMessageBase> | ||
{ | ||
public CustomMessageContext() | ||
{ | ||
base.MessageContextRemoved += CustomMessageContext_MessageContextRemoved; | ||
} | ||
|
||
/// <summary> | ||
/// 当上下文过期,被移除时触发的时间 | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
void CustomMessageContext_MessageContextRemoved(object sender, Senparc.Weixin.Context.WeixinContextRemovedEventArgs<IRequestMessageBase, IResponseMessageBase> e) | ||
{ | ||
/* 注意,这个事件不是实时触发的(当然你也可以专门写一个线程监控) | ||
* 为了提高效率,根据WeixinContext中的算法,这里的过期消息会在过期后下一条请求执行之前被清除 | ||
*/ | ||
|
||
var messageContext = e.MessageContext as CustomMessageContext; | ||
if (messageContext == null) | ||
{ | ||
return;//如果是正常的调用,messageContext不会为null | ||
} | ||
|
||
//TODO:这里根据需要执行消息过期时候的逻辑,下面的代码仅供参考 | ||
|
||
//Log.InfoFormat("{0}的消息上下文已过期",e.OpenId); | ||
//api.SendMessage(e.OpenId, "由于长时间未搭理客服,您的客服状态已退出!"); | ||
} | ||
} | ||
} |
Oops, something went wrong.