瀏覽代碼

调整代码

CrazyIter_Bin 3 年之前
父節點
當前提交
a97986e04e

+ 2 - 2
TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

@@ -28,8 +28,9 @@ namespace TEAMModelOS.SDK
                 using var da = await JsonDocument.ParseAsync(aactivity.ContentStream);
                 activity = da.ToObject<MQActivity>();
             }
-            catch (CosmosException ex)
+            catch (CosmosException )
             {
+                activity=null;
             }
             if (activity != null)
             {
@@ -275,7 +276,6 @@ namespace TEAMModelOS.SDK
                             stuInfos.Add(item);
                         }
                     }
-                    
                 }
                 students.ForEach(x =>
                 {

+ 2 - 14
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -3,26 +3,14 @@ using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
-using System.IdentityModel.Tokens.Jwt;
-using System.Linq;
-using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
-using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models;
-using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
-using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Helper.Common.StringHelper;
 using TEAMModelOS.Models;
 using Microsoft.Extensions.Options;
-using TEAMModelOS.SDK.Models.Cosmos;
-using Microsoft.AspNetCore.Authorization;
 using TEAMModelOS.Filter;
-using StackExchange.Redis;
-using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
 using TEAMModelOS.Services.Common;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
@@ -241,7 +229,7 @@ namespace TEAMModelOS.Controllers.Learn
                     }
                 };
                 //是否需要进行分页查询,默认不分页
-                bool iscontinuation = false;
+               // bool iscontinuation = false;
                 //如果指定了返回大小
                 if (requert.TryGetProperty("continuationToken", out JsonElement continuation))
                 {
@@ -249,7 +237,7 @@ namespace TEAMModelOS.Controllers.Learn
                     if (!continuation.ValueKind.Equals(JsonValueKind.Null) && !continuation.ValueKind.Equals(JsonValueKind.Undefined))
                     {
                         continuationToken = continuation.GetString();
-                        iscontinuation = true;
+                       // iscontinuation = true;
                     }
                 };
                 List<Vote> votes = new List<Vote>();

+ 3 - 3
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -129,7 +129,7 @@ namespace TEAMModelOS.Controllers
                             try {
 
                                 itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
-                            } catch (Exception  ex) {
+                            } catch (Exception  ) {
                                 itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
 
                             };
@@ -165,7 +165,7 @@ namespace TEAMModelOS.Controllers
 
                             itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
                         }
-                        catch (Exception ex)
+                        catch (Exception )
                         {
                             itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-{itemInfo.code.Replace("Item-", "")}", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(),subjects= new List<SubjectCount>() };
 
@@ -305,7 +305,7 @@ namespace TEAMModelOS.Controllers
 
                         itemCond = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>(itemInfo.periodId, new PartitionKey($"ItemCond-{itemInfo.code.Replace("Item-", "")}"));
                     }
-                    catch (Exception ex)
+                    catch (Exception )
                     {
                         itemCond = new ItemCond() { id = itemInfo.periodId, code = $"ItemCond-hbcn", pk = "ItemCond", ttl = -1, count = 0, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
 

+ 7 - 4
TEAMModelOS/Controllers/School/ClassController.cs

@@ -215,13 +215,13 @@ namespace TEAMModelOS.Controllers
         [ProducesDefaultResponseType]
         //[AuthToken(Roles = "Teacher")]
         [HttpPost("find-new-students")]
-        public async Task<IActionResult> FindNewStudent(JsonElement requert)
+        public async Task<IActionResult> FindNewStudent(JsonElement request)
         {
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                if (!requert.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
-                requert.TryGetProperty("school_code", out JsonElement schoolId);
+                if (!request.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
+                request.TryGetProperty("school_code", out JsonElement schoolId);
                 List<string> classes = ids.ToObject<List<string>>();
                 List<dynamic> list = new List<dynamic>();
                 foreach (string cls in classes) {
@@ -233,6 +233,7 @@ namespace TEAMModelOS.Controllers
                 return Ok(new { list });
             }
             catch (CosmosException ex) {
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},find-new-students()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }
@@ -261,7 +262,7 @@ namespace TEAMModelOS.Controllers
                 List<object> suList = new List<object>();
                 List<(string id, string name, string pic, string code, string classId ,string groupId, string groupName, string no)> listStudent = new List<(string id, string name, string pic, string code, string classId, string groupId, string groupName, string no)>();
                 //var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(ids[i].GetString(), new PartitionKey($"Class-{schoolId}"));
-                string className = "";
+                //string className = "";
                 /*                if (response.Status == 200)
                                 {
                                     using var document = await JsonDocument.ParseAsync(response.ContentStream);
@@ -627,6 +628,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},hiteach-link()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }
@@ -678,6 +680,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},hiteach-unlink-classId()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }

+ 9 - 7
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -130,6 +130,7 @@ namespace TEAMModelOS.Controllers
             }
             catch(Exception ex)
             {
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/set-teacher-info()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest("teacher not exist");
 
             }
@@ -189,7 +190,7 @@ namespace TEAMModelOS.Controllers
                                 {
                                     area = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Area>($"{areaId}", new PartitionKey("Base-Area"));
                                 }
-                                catch (CosmosException ex)
+                                catch (CosmosException )
                                 {
                                     area = null;
                                 }
@@ -302,12 +303,12 @@ namespace TEAMModelOS.Controllers
         //TODO 此API需處理對應前端返回的相關數據
         [ProducesDefaultResponseType]
         [HttpPost("get-school-info")]        
-        public async Task<IActionResult> GetSchoolInfo(JsonElement requert)
+        public async Task<IActionResult> GetSchoolInfo(JsonElement request)
         {
             try
             {
-                if (!requert.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
-                if (!requert.TryGetProperty("school_code", out JsonElement _school_code)) return BadRequest();
+                if (!request.TryGetProperty("id_token", out JsonElement id_token)) return BadRequest();
+                if (!request.TryGetProperty("school_code", out JsonElement _school_code)) return BadRequest();
                 string school_code = $"{_school_code}";
                 var jwt = new JwtSecurityToken(id_token.GetString());
                 if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.Ordinal)) return BadRequest();
@@ -368,7 +369,7 @@ namespace TEAMModelOS.Controllers
                     {
                         await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ItemCond>($"{period.id}", new PartitionKey($"ItemCond-{school_code}"));
                     }
-                    catch (CosmosException ex) {
+                    catch (CosmosException ) {
                         ItemCond itemCond = new ItemCond {
                             id = period.id, 
                             pk = "ItemCond",
@@ -480,12 +481,12 @@ namespace TEAMModelOS.Controllers
                 return Ok(new { auth_token, blob_uri, blob_sas, school_base, school_courses, school_syllabus, school_classes, school_rooms, size, osblob_uri, osblob_sas, status = 200 });
             }
             catch (CosmosException ex) {
-                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-school-info()\n{ex.Message}{ex.StackTrace}{requert.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-school-info()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { status = ex.Status });
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-school-info()\n{ex.Message}{ex.StackTrace}{requert.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-school-info()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { status = 500 });
             }
         }
@@ -601,6 +602,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
+                await _dingDing.SendBotMsg($"IES5,{_option.Location},Teacher/init/get-school-info()\n{ex.Message}{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }