diff --git a/B3WeChat.Web/Pages/WeChatReceive.cs b/B3WeChat.Web/Pages/WeChatReceive.cs
index 3a2280b..ea91edf 100644
--- a/B3WeChat.Web/Pages/WeChatReceive.cs
+++ b/B3WeChat.Web/Pages/WeChatReceive.cs
@@ -73,6 +73,12 @@ namespace BWP.Web.Pages
else if (result is QRCodeMessage)
{
QRCodeMessage msg = result as QRCodeMessage;
+ if (msg.IsUnsubscribeEvent())
+ {
+ Unsubscribe(msg.FromUserName);
+ return;
+ }
+
int scene_id;
if (!msg.TryGetSceneID(out scene_id))
{
@@ -101,5 +107,16 @@ namespace BWP.Web.Pages
}
}
+ //用户取消关注时删除用户名与微信号的映射以及发给它的审批消息
+ private void Unsubscribe(string openID)
+ {
+ var delCustomerUser = new DQDeleteDom(typeof(CustomerUser));
+ delCustomerUser.Where.Conditions.Add(DQCondition.EQ("OpenID", openID));
+ delCustomerUser.EExecute();
+
+ var delApproveMessage = new DQDeleteDom(typeof(ApproveMessage));
+ delApproveMessage.Where.Conditions.Add(DQCondition.EQ("OpenID", openID));
+ delApproveMessage.EExecute();
+ }
}
}
diff --git a/B3WeChat/B3WeChat.csproj b/B3WeChat/B3WeChat.csproj
index cb448e3..12cd065 100644
--- a/B3WeChat/B3WeChat.csproj
+++ b/B3WeChat/B3WeChat.csproj
@@ -110,6 +110,7 @@
+
diff --git a/B3WeChat/BO/DebugInfo.cs b/B3WeChat/BO/DebugInfo.cs
new file mode 100644
index 0000000..e74ca18
--- /dev/null
+++ b/B3WeChat/BO/DebugInfo.cs
@@ -0,0 +1,38 @@
+using BWP.B3Frameworks.BO;
+using Forks.EnterpriseServices.BusinessInterfaces;
+using Forks.EnterpriseServices.DomainObjects2;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+
+namespace BWP.B3WeChat.BO
+{
+ public class DebugInfo:Base
+ {
+ public string Category { get; set; }
+
+ [DbColumn(DbType=SqlDbType.NText)]
+ public string Text { get; set; }
+
+ [DbColumn(DbType=SqlDbType.DateTime)]
+ public DateTime Time { get; set; }
+
+
+ public static void Insert(string category, string text)
+ {
+ var info = new DebugInfo()
+ {
+ Category = category,
+ Text = text,
+ Time = DateTime.Now
+ };
+ using (var contex = new TransactionContext())
+ {
+ contex.Session.Insert(info);
+ contex.Commit();
+ }
+ }
+ }
+}
diff --git a/B3WeChat/Entities/QRCodeMessage.cs b/B3WeChat/Entities/QRCodeMessage.cs
index 4368061..0e2d55b 100644
--- a/B3WeChat/Entities/QRCodeMessage.cs
+++ b/B3WeChat/Entities/QRCodeMessage.cs
@@ -54,6 +54,11 @@ namespace BWP.B3WeChat.Entities
return Event == "subscribe";
}
+ public bool IsUnsubscribeEvent()
+ {
+ return Event == "unsubscribe";
+ }
+
public bool IsScanEvent()
{
return Event == "SCAN";
diff --git a/B3WeChat/Utils/InOutMessageUtil.cs b/B3WeChat/Utils/InOutMessageUtil.cs
index 37f7e25..359ed6a 100644
--- a/B3WeChat/Utils/InOutMessageUtil.cs
+++ b/B3WeChat/Utils/InOutMessageUtil.cs
@@ -1,4 +1,5 @@
using BWP.B3WeChat;
+using BWP.B3WeChat.BO;
using BWP.B3WeChat.Entities;
using Forks.Utils;
using System;
@@ -199,6 +200,9 @@ namespace BWP.B3WeChat.Utils
{
StreamReader reader = new StreamReader(request.InputStream);
String xmlData = reader.ReadToEnd();
+
+ DebugInfo.Insert("微信消息文本", xmlData);
+
return ParseWeChatMessage(xmlData);
}