Kaynağa Gözat

修改项目名,添加交易入库队列

lcl 3 hafta önce
ebeveyn
işleme
e23cd378e4

+ 2 - 2
.vscode/launch.json

@@ -8,7 +8,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/net7.0/RouterManager.dll",
+            "program": "${workspaceFolder}/bin/Debug/net7.0/SpServer.dll",
             "args": [],
             "cwd": "${workspaceFolder}",
             "stopAtEntry": false,
@@ -28,7 +28,7 @@
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
-            "program": "${workspaceFolder}/bin/Debug/net7.0/RouterManager.dll",
+            "program": "${workspaceFolder}/bin/Debug/net7.0/SpServer.dll",
             "args": [],
             "cwd": "${workspaceFolder}",
             "stopAtEntry": false,

+ 1 - 1
.vscode/settings.json

@@ -1,3 +1,3 @@
 {
-    "dotnet.defaultSolution": "RouterManager.sln"
+    "dotnet.defaultSolution": "SpServer.sln"
 }

+ 3 - 3
.vscode/tasks.json

@@ -7,7 +7,7 @@
             "type": "process",
             "args": [
                 "build",
-                "${workspaceFolder}/RouterManager.csproj",
+                "${workspaceFolder}/SpServer.csproj",
                 "/property:GenerateFullPaths=true",
                 "/consoleloggerparameters:NoSummary"
             ],
@@ -19,7 +19,7 @@
             "type": "process",
             "args": [
                 "publish",
-                "${workspaceFolder}/RouterManager.csproj",
+                "${workspaceFolder}/SpServer.csproj",
                 "/property:GenerateFullPaths=true",
                 "/consoleloggerparameters:NoSummary"
             ],
@@ -32,7 +32,7 @@
             "args": [
                 "watch",
                 "run",
-                "${workspaceFolder}/RouterManager.csproj",
+                "${workspaceFolder}/SpServer.csproj",
                 "/property:GenerateFullPaths=true",
                 "/consoleloggerparameters:NoSummary"
             ],

+ 1 - 1
Program.cs

@@ -106,6 +106,6 @@ app.MapControllerRoute(
 
 app.MapControllers();
 
-app.Urls.Add("http://*:6002");
+app.Urls.Add("http://*:5049");
 
 app.Run();

+ 2 - 2
Properties/launchSettings.json

@@ -14,7 +14,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://*:6002",
+      "applicationUrl": "http://*:5049",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }
@@ -24,7 +24,7 @@
       "dotnetRunMessages": true,
       "launchBrowser": true,
       "launchUrl": "swagger",
-      "applicationUrl": "http://*:6002",
+      "applicationUrl": "http://*:5049",
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
       }

+ 0 - 0
RouterManager.csproj → SpServer.csproj


+ 55 - 0
Task/HaoDaHelper.cs

@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Threading;
+using Common;
+using Infrastructure;
+using Model;
+using Services;
+
+public class HaoDaHelper
+{
+    public readonly static HaoDaHelper Instance = new HaoDaHelper();
+    private HaoDaHelper()
+    { }
+
+    public void Start()
+    {
+        Thread th = new Thread(DoWorks);
+        th.IsBackground = true;
+        th.Start();
+    }
+
+    public void DoWorks()
+    {
+        while (true)
+        {
+            string content = RedisServer.Cache.RPop<string>("hd:notice:order");
+            if(!string.IsNullOrEmpty(content))
+            {
+                DoQueue(content);
+            }
+            else
+            {
+                Thread.Sleep(5000);
+            }
+        }
+    }
+
+    public void DoQueue(string content)
+    {
+        try
+        {
+            var item = Newtonsoft.Json.JsonConvert.DeserializeObject<HdTradeRecord>(content);
+            var tradeService = App.GetService<IHdTradeRecordService>();
+            tradeService.Add(item);
+            
+        }
+        catch (Exception ex)
+        {
+            Function.WriteLog(DateTime.Now.ToString() + "\n" + ex, "好哒订单入库异常");
+        }
+    }
+
+}