Bläddra i källkod

处理Redis Value为空的问题

zhouj1203@hotmail.com 5 år sedan
förälder
incheckning
42fb5bc230

+ 11 - 5
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -42,19 +42,21 @@ namespace TEAMModelOS.Controllers.Analysis
         public async Task<BaseJosnRPCResponse> FindExam(JosnRPCRequest<Dictionary<string, object>> request)
         public async Task<BaseJosnRPCResponse> FindExam(JosnRPCRequest<Dictionary<string, object>> request)
         {
         {
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
-            Dictionary<string, object> info = new Dictionary<string, object>();
+            Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
             if (RedisHelper.Instance != null)
             if (RedisHelper.Instance != null)
             {
             {
 
 
                  info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
                  info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
                     ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamRedis(request.@params, request.method); });
                     ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamRedis(request.@params, request.method); });
-                builder.Data(info);
+
+                
+                builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
 
 
             }
             }
             else
             else
             {
             {
                 info = await FindExamRedis(request.@params, request.method);
                 info = await FindExamRedis(request.@params, request.method);
-                builder.Data(info);
+                builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
             }
             }
             return builder.build();
             return builder.build();
 
 
@@ -84,7 +86,7 @@ namespace TEAMModelOS.Controllers.Analysis
 
 
             }
             }
         }
         }
-        public async Task<Dictionary<string, object>> FindExamRedis (Dictionary<string, object> dict, string method) {
+        public async Task<Dictionary<string, dynamic>> FindExamRedis (Dictionary<string, object> dict, string method) {
       
       
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
             //Console.WriteLine(DateTimeOffset.Now.Second);
             //Console.WriteLine(DateTimeOffset.Now.Second);
@@ -114,7 +116,7 @@ namespace TEAMModelOS.Controllers.Analysis
             List<List<string>> subjectPoints = new List<List<string>>();
             List<List<string>> subjectPoints = new List<List<string>>();
             Dictionary<string, object> Average = new Dictionary<string, object>();
             Dictionary<string, object> Average = new Dictionary<string, object>();
             Dictionary<string, object> entryTable = new Dictionary<string, object>();
             Dictionary<string, object> entryTable = new Dictionary<string, object>();
-            Dictionary<string, object> achievementAnalysis = new Dictionary<string, object>();
+            Dictionary<string, dynamic> achievementAnalysis = new Dictionary<string, dynamic>();
             List<string> arrSubject = new List<string>();
             List<string> arrSubject = new List<string>();
             List<string> keys = new List<string>();
             List<string> keys = new List<string>();
             List<string> person = new List<string>();
             List<string> person = new List<string>();
@@ -1295,8 +1297,11 @@ namespace TEAMModelOS.Controllers.Analysis
             if (RedisHelper.Instance != null)
             if (RedisHelper.Instance != null)
             {
             {
                 try {
                 try {
+                    ///RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
+                   /// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
                     List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
                     List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
                     ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamInfoRedis(request.@params, request.method); });
                     ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamInfoRedis(request.@params, request.method); });
+                 
                     builder.Data(info);
                     builder.Data(info);
                 } catch (Exception e) {
                 } catch (Exception e) {
                     throw new BizException(e.Message);
                     throw new BizException(e.Message);
@@ -1314,6 +1319,7 @@ namespace TEAMModelOS.Controllers.Analysis
         {
         {
             try {
             try {
                 List<ExamInfo> info = await azureCosmosDBRepository.FindByDict<ExamInfo>(dict);
                 List<ExamInfo> info = await azureCosmosDBRepository.FindByDict<ExamInfo>(dict);
+
                 if (RedisHelper.Instance != null)
                 if (RedisHelper.Instance != null)
                 {
                 {
                     if (!RedisHelper.Exists(CacheCosmosPrefix + method))
                     if (!RedisHelper.Exists(CacheCosmosPrefix + method))

+ 1 - 6
TEAMModelOS/Program.cs

@@ -1,11 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
 
 
 namespace TEAMModelOS
 namespace TEAMModelOS
 {
 {

+ 2 - 2
TEAMModelOS/Properties/launchSettings.json

@@ -11,7 +11,7 @@
   "profiles": {
   "profiles": {
     "IIS Express": {
     "IIS Express": {
       "commandName": "IISExpress",
       "commandName": "IISExpress",
-      "launchBrowser": true,
+      "launchBrowser": false,
       "launchUrl": "selectModule",
       "launchUrl": "selectModule",
       "environmentVariables": {
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
         "ASPNETCORE_ENVIRONMENT": "Development"
@@ -19,7 +19,7 @@
     },
     },
     "TEAMModelOS": {
     "TEAMModelOS": {
       "commandName": "Project",
       "commandName": "Project",
-      "launchBrowser": true,
+      "launchBrowser": false,
       "launchUrl": "selectModule",
       "launchUrl": "selectModule",
       "applicationUrl": "https://localhost:5001;http://localhost:5000",
       "applicationUrl": "https://localhost:5001;http://localhost:5000",
       "environmentVariables": {
       "environmentVariables": {

+ 2 - 2
TEAMModelOS/Startup.cs

@@ -122,8 +122,8 @@ namespace TEAMModelOS
             services.JwtAuth(Configuration.GetSection("JwtSetting"));
             services.JwtAuth(Configuration.GetSection("JwtSetting"));
             //注入CSRedis
             //注入CSRedis
             var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
             var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
-            CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
-            CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
+           // CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
+         //   CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
             RedisHelper.Initialization(csredis);
             RedisHelper.Initialization(csredis);
            // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
            // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
             //services.AddSingleton<PowerPointService, PowerPointService>();
             //services.AddSingleton<PowerPointService, PowerPointService>();