Prechádzať zdrojové kódy

增加个人消息队列功能

lichunlei 3 rokov pred
rodič
commit
22948a5d28
2 zmenil súbory, kde vykonal 71 pridanie a 17 odobranie
  1. 53 0
      AppStart/Helper/MessageCenterService.cs
  2. 18 17
      Startup.cs

+ 53 - 0
AppStart/Helper/MessageCenterService.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using MySystem.PxcModels;
+
+namespace MySystem
+{
+    public class MessageCenterService
+    {
+        public readonly static MessageCenterService Instance = new MessageCenterService();
+        private MessageCenterService()
+        { }
+
+        public void Start()
+        {
+            try
+            {
+                dosomething();
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "消息中心队列异常");
+            }
+        }
+
+        public void dosomething()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("MsgPersonalQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    try
+                    {
+                        WebCMSEntities db = new WebCMSEntities();
+                        MsgPersonal msg = Newtonsoft.Json.JsonConvert.DeserializeObject<MsgPersonal>(data);
+                        db.MsgPersonal.Add(msg);
+                        db.SaveChanges();
+                        db.Dispose();
+                    }
+                    catch (Exception ex)
+                    {
+                        
+                        function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "消息中心队列异常");
+                    }
+                }
+            }
+        }
+    }
+}

+ 18 - 17
Startup.cs

@@ -90,9 +90,9 @@ namespace MySystem
             // services.AddHostedService<PopService>();
             // services.AddHostedService<SycnSpTimer>(); //同步SP数据
 
-            services.AddHostedService<TimerStatTimer>(); //实时统计创客、激活商户数
-            services.AddHostedService<PosTradeStatTimer>(); // 统计头天的交易额、商户型创客、激活奖励、开机奖励
-            services.AddHostedService<AlipayPayBack2Timer>(); //支付宝回调处理
+            // services.AddHostedService<TimerStatTimer>(); //实时统计创客、激活商户数
+            // services.AddHostedService<PosTradeStatTimer>(); // 统计头天的交易额、商户型创客、激活奖励、开机奖励
+            // services.AddHostedService<AlipayPayBack2Timer>(); //支付宝回调处理
 
             //services.AddHttpContextAccessor();
 
@@ -190,23 +190,24 @@ namespace MySystem
             // TradeStatTimer2.Instance.Start(); //交易统计
 
             //必须打开的
-            ActiveRewardTimer.Instance.Start(); //实时处理激活记录
-            TradeStatTimer.Instance.Start(); //交易统计
-            ChangePosTimer.Instance.Start(); //售后换新执行机具数据转移
-            MakeReferenceQrCodeService.Instance.StartListen(); //生成创客邀请二维码
-            SycnSpBindService.Instance.Start(); //同步SP绑定数据
-            SycnSpMerchantService.Instance.Start(); //同步SP商户数据
-            SycnSpActiveService.Instance.Start(); //同步SP激活数据
-            SycnSpTradeService.Instance.Start(); //同步SP交易数据
-            RedPackageHelper.Instance.Start(); //每天生成300个红包
-            RedPackageHelper.Instance.StartStatTop10(); //红包活动统计排行
-            RedPackageHelper.Instance.StartSendPrize(); //红包活动发奖
+            // ActiveRewardTimer.Instance.Start(); //实时处理激活记录
+            // TradeStatTimer.Instance.Start(); //交易统计
+            // ChangePosTimer.Instance.Start(); //售后换新执行机具数据转移
+            // MakeReferenceQrCodeService.Instance.StartListen(); //生成创客邀请二维码
+            // SycnSpBindService.Instance.Start(); //同步SP绑定数据
+            // SycnSpMerchantService.Instance.Start(); //同步SP商户数据
+            // SycnSpActiveService.Instance.Start(); //同步SP激活数据
+            // SycnSpTradeService.Instance.Start(); //同步SP交易数据
+            // RedPackageHelper.Instance.Start(); //每天生成300个红包
+            // RedPackageHelper.Instance.StartStatTop10(); //红包活动统计排行
+            // RedPackageHelper.Instance.StartSendPrize(); //红包活动发奖
             //必须打开的
 
+            MessageCenterService.Instance.Start(); // 消息队列
             // StatService.Instance.StartEverDay("2022-06-18");
-            StatService.Instance.StartPosActNum(); //实时统计激活数
-            StatService.Instance.StartNewUserNum(); //实时统计新增创客数
-            StatService.Instance.StatProfit(); //实时统计创客收益
+            // StatService.Instance.StartPosActNum(); //实时统计激活数
+            // StatService.Instance.StartNewUserNum(); //实时统计新增创客数
+            // StatService.Instance.StatProfit(); //实时统计创客收益
             // StatService.Instance.StartEverDayV2("");
             // RedPackageHelper.Instance.Start();
             // StatService.Instance.StatUserLevel();