CrazyIter_Bin 5 months ago
parent
commit
bb104a2b02

+ 6 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/ManageController.cs

@@ -0,0 +1,6 @@
+namespace IES.ExamServer.Controllers
+{
+    public class ManageController
+    {
+    }
+}

+ 6 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/StudentController.cs

@@ -0,0 +1,6 @@
+namespace IES.ExamServer.Controllers
+{
+    public class StudentController
+    {
+    }
+}

+ 0 - 39
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/WeatherForecastController.cs

@@ -1,39 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-
-namespace VueCliSample.Controllers
-{
-    [ApiController]
-    [Route("api/[controller]")]
-    public class WeatherForecastController : ControllerBase
-    {
-        private static readonly string[] Summaries = new[]
-        {
-            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
-        };
-
-        private readonly ILogger<WeatherForecastController> _logger;
-
-        public WeatherForecastController(ILogger<WeatherForecastController> logger)
-        {
-            _logger = logger;
-        }
-
-        [HttpGet]
-        public IEnumerable<WeatherForecast> Get()
-        {
-            var rng = new Random();
-            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
-            {
-                Date = DateTime.Now.AddDays(index),
-                TemperatureC = rng.Next(-20, 55),
-                Summary = Summaries[rng.Next(Summaries.Length)]
-            })
-            .ToArray();
-        }
-    }
-}

+ 65 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Models/Activity.cs

@@ -0,0 +1,65 @@
+using System.Text.Json;
+
+namespace IES.ExamServer.Models
+{
+    public class Activity
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+        /// <summary>
+        /// 类型: Exam 普通评测, Art艺术评测
+        /// </summary>
+        public string  type { get; set; }
+        public string code { get; set; }
+        /// <summary>
+        /// 源数据的发布层级 类型 school  teacher
+        /// </summary>
+        public string owner { get; set; }
+
+        //评测模式
+        public string source { get; set; }
+        public long startTime { get; set; }
+        public long endTime { get; set; }
+        public string scope { get; set; }
+        public string school { get; set; }
+        public string creatorId { get; set; }
+        public string scode { get; set; }
+        public Custom examType { get; set; } = new Custom();
+
+        public List<ExamSubject> subjects { get; set; } = new List<ExamSubject>();
+        //返回科目内容
+        public List<string> subs { get; set; } = new List<string>();
+        //返回字段
+        public List<string> classIds { get; set; } = new List<string>();
+        public List<string> classes { get; set; } = new List<string>();
+        public List<string> stuLists { get; set; } = new List<string>();
+        public List<string> tchLists { get; set; } = new List<string>();
+        public List<JsonElement> targets { get; set; } = new List<JsonElement>();
+        public long createTime { get; set; } 
+        public Dictionary<string, JsonElement> ext { get; set; } = new Dictionary<string, JsonElement>();
+        /// 评分状态,0,未评分, 1已评分
+        public int sStatus { get; set; } = 0;
+        //评测 纸本1或者书面问答0
+        public int qamode { get; set; } = 0;
+        //标记作业活动是否比交
+        public bool mustSubmit { get; set; } = false;
+        //标记问卷是否重复提交 0 否 1 是
+        public int isSub { get; set; } = 0;
+        /// <summary>
+        /// 任务完成状态,-1 未参与,0,未完成, 1已完成
+        /// </summary>
+        public int taskStatus { get; set; } = -1;
+        public string recordUrl { get; set; }
+    }
+    public class Custom
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+    }
+    public class ExamSubject
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+        public int classCount { get; set; }
+    }
+}

+ 0 - 15
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/WeatherForecast.cs

@@ -1,15 +0,0 @@
-using System;
-
-namespace VueCliSample
-{
-    public class WeatherForecast
-    {
-        public DateTime Date { get; set; }
-
-        public int TemperatureC { get; set; }
-
-        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
-
-        public string Summary { get; set; }
-    }
-}

+ 2 - 1
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -2555,13 +2555,13 @@ namespace TEAMModelOS.Function
             try
             {
                 //await _dingDing.SendBotMsg($"IES5,{Environment.GetEnvironmentVariable("Option:Location")},Imei AF call\n{msg.ToJsonString()}", GroupNames.成都开发測試群組);
-
                 if (json.RootElement.TryGetProperty("channel", out JsonElement channel) &&
                 json.RootElement.TryGetProperty("userid", out JsonElement userid) &&
                 json.RootElement.TryGetProperty("school", out JsonElement school) &&
                 json.RootElement.TryGetProperty("stus", out JsonElement stus))
                 {
                     json.RootElement.TryGetProperty("imeiType", out JsonElement imeiType);
+                    json.RootElement.TryGetProperty("lessonId", out JsonElement lessonId);
                     var db = _azureCosmos.GetCosmosClient();
                     foreach (var stu in stus.EnumerateArray())
                     {
@@ -2576,6 +2576,7 @@ namespace TEAMModelOS.Function
                                 var imei = doc.ToObject<Imei>();
                                 imei.channel = channel.GetString();
                                 imei.userid = userid.GetString();
+                                imei.lessonId = $"{lessonId}";
                                 if (!string.IsNullOrWhiteSpace($"{imeiType}"))
                                 {
                                     imei.imeiType = $"{imeiType}";

+ 169 - 0
TEAMModelOS.SDK/Models/Cosmos/Normal/ActivitySyncInfo.cs

@@ -0,0 +1,169 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.SDK.Models.Cosmos.Normal
+{
+    /// <summary>
+    /// 活动数据同步信息
+    /// </summary>
+    public class ActivitySyncInfo : CosmosEntity
+    {
+        [Required(ErrorMessage = "活动id必须设置")]
+        public string id { get; set; }
+        //id =活动id
+        // code =ActivitySyncInfo
+        /// <summary>
+        ///school 、private 
+        /// </summary>
+        [Required(ErrorMessage = "数据范围必须设置")]
+        public string scope { get; set; }
+        /// <summary>
+        /// 活动名称
+        /// </summary>
+        public string name { get; set; }
+        public string subject { get; set; }
+
+        /// <summary>
+        /// 数据源拥有者,学校id或者个人id
+        /// </summary>
+        [Required(ErrorMessage = "数据所有者必须设置")]
+        public string owner { get; set; }
+        /// <summary>
+        /// 活动类型 Art  Exam
+        /// </summary>
+        [Required(ErrorMessage = "类型必须设置")]
+        public string type { get; set; }
+        /// <summary>
+        /// 活动数据包生成最新时间戳
+        /// </summary>
+        public long dataTime { get; set; }
+        public long dataSize { get; set; }
+        /// <summary>
+        /// 活动文件包生成最新时间戳
+        /// </summary>
+        public long blobTime { get; set; }
+        /// <summary>
+        /// 活动文件包大小
+        /// </summary>
+        public long blobSize { get; set; }
+        /// <summary>
+        /// 活动文件包数量
+        /// </summary>
+
+        public long blobCount { get; set; }
+        /// <summary>
+        /// 活动页面代码文件生成最新时间戳
+        /// </summary>
+        public long webviewTime { get; set; }
+        /// <summary>
+        /// 活动页面代码文件数量
+        /// </summary>
+        public long webviewCount { get; set; }
+        /// <summary>
+        /// 活动页面代码文件大小
+        /// </summary>
+        public long webviewSize { get; set; }
+        public string webviewPath { get; set; }
+        /// <summary>
+        /// 名单数量
+        /// </summary>
+        public int grouplistCount { get; set; }
+        /// <summary>
+        /// 学生数量
+        /// </summary>
+        public int studentCount { get; set; }
+        /// <summary>
+        /// 试卷数量
+        /// </summary>
+        public int paperCount { get; set; }
+        /// <summary>
+        /// 使用MurmurHash3 生成简码  string s =  $"{MurmurHash3.Hash32(Guid.NewGuid().ToString())}";  十位数字
+        /// </summary>
+        public string shortCode { get; set; }
+        /// <summary>
+        /// 试卷文件包文件hash列表
+        /// </summary>
+        public string hashFile { get; set; }
+    }
+    /// <summary>
+    /// 活动客户端同步信息
+    /// </summary>
+    public class ActivityClientSync : ClientDevice
+    {
+        /// <summary>
+        /// 活动数据包客户端更新时间戳
+        /// </summary>
+        public long dataTime { get; set; }
+        /// <summary>
+        /// 活动文件包客户端更新时间戳
+        /// </summary>
+        public long blobTime { get; set; }
+        /// <summary>
+        /// 活动页面代码文件客户端更新时间戳
+        /// </summary>
+        public long webviewTime { get; set; }
+        /// <summary>
+        /// 上线时间戳
+        /// </summary>
+        public long onlineTime { get; set; }
+        /// <summary>
+        /// 上线时的操作人员
+        /// </summary>
+        public long timdid { get; set; }
+        /// <summary>
+        /// 上线时的操作人员名称
+        /// </summary>
+        public string timdname { get; set; }
+        /// <summary>
+        /// 头像
+        /// </summary>
+        public string picture { get; set; }
+        /// <summary>
+        /// 手机号
+        /// </summary>
+        public string mobile { get; set; }
+    }
+
+    public class ExamPaperFileHash
+    {
+        /// <summary>
+        /// 试卷大小
+        /// </summary>
+        public long size { get; set; }
+        /// <summary>
+        /// 试卷数量
+        /// </summary>
+        public long count { get; set; }
+        /// <summary>
+        /// 试卷里文件最后的更新时间戳
+        /// </summary>
+        public long lastTime { get; set; }
+    }
+    public class PaperFile
+    {
+        /// <summary>
+        /// 文件名
+        /// </summary>
+        public string name { get; set; }
+        /// <summary>
+        /// 文件路径
+        /// </summary>
+        public string path { get; set; }
+        /// <summary>
+        /// 文件hash值
+        /// </summary>
+        public string hash { get; set; }
+        /// <summary>
+        /// 文件后缀
+        /// </summary>
+        public string ext { get; set; }
+        /// <summary>
+        /// 文件大小
+        /// </summary>
+        public long size { get; set; }
+    }
+}

+ 4 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/Student.cs

@@ -27,6 +27,10 @@ namespace TEAMModelOS.SDK.Models
         /// 电子学生证类型,chinamobile 手机号类型,tianbo 串号类型
         /// </summary>
         public string imeiType { get; set; }
+        /// <summary>
+        /// 课例id
+        /// </summary>
+        public string lessonId {  get; set; }
     }
     /// <summary>
     /// 学生

+ 32 - 0
TEAMModelOS.SDK/Models/Service/ActivitySyncInfoService.cs

@@ -0,0 +1,32 @@
+using Microsoft.Azure.Cosmos;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelOS.SDK.Models.Service
+{
+    public sealed class ActivitySyncInfoService
+    {
+
+        /// <summary>
+        /// 活动数据打包
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="scope"></param>
+        /// <param name="owner"></param>
+        /// <param name="type"></param>
+        /// <param name="azureCosmos"></param>
+        /// <param name="azureStorage"></param>
+        public static async Task PackageActivity( string id,string scope, string owner, string type, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage)
+        {
+            var response = await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemStreamAsync(id, new PartitionKey("ActivitySyncInfo"));
+            if (response.IsSuccessStatusCode)
+            {
+
+            }
+        }
+    }
+}

+ 82 - 0
TEAMModelOS/Controllers/Both/ActivitySyncInfoController.cs

@@ -0,0 +1,82 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Options;
+using System.Collections.Generic;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK;
+using TEAMModelOS.Models;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.Filter;
+using System.Text.Json.Nodes;
+using TEAMModelOS.SDK.Models.Cosmos.Normal;
+using Microsoft.Azure.Cosmos;
+
+
+namespace TEAMModelOS.Controllers.Both
+{
+
+    [ProducesResponseType(StatusCodes.Status200OK)]
+    [ProducesResponseType(StatusCodes.Status400BadRequest)]
+
+    [Route("activity-sync")]
+    [ApiController]
+    public class ActivitySyncInfoController : ControllerBase
+    {
+        private AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        private readonly CoreAPIHttpService _coreAPIHttpService;
+        private readonly Option _option;
+        private readonly AzureServiceBusFactory _serviceBus;
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly AzureRedisFactory _azureRedis;
+        public IConfiguration _configuration { get; set; }
+        public ActivitySyncInfoController(AzureRedisFactory azureRedis, AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, CoreAPIHttpService coreAPIHttpService, AzureServiceBusFactory serviceBus, AzureStorageFactory azureStorage, IConfiguration configuration)
+        {
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+            _option = option?.Value;
+            _serviceBus = serviceBus;
+            _configuration = configuration;
+            _azureStorage = azureStorage;
+            _azureRedis = azureRedis; _coreAPIHttpService = coreAPIHttpService;
+        }
+        /// <summary>
+        /// 评测信息打包
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("package")]
+#if !DEBUG
+        [Authorize(Roles = "IES")]
+#endif
+        public async Task<IActionResult> Package(JsonNode request) 
+        {
+
+            /*
+            {
+                "id":"活动id",
+                "scope":"school/private",
+                "owner":"学校简码/醍摩豆id",
+                "type":"Art/Exam"
+            }
+             */
+            if (request["activity"]!=null)
+            {
+                var activity = JsonSerializer.Deserialize<ActivitySyncInfo>(request["activity"]);
+                ValidResult validResult = activity.Valid();
+                if (!validResult.isVaild) 
+                {
+                    return BadRequest(validResult);
+                }
+                
+            }
+           
+
+            return Ok();
+        }
+    }
+}

+ 22 - 16
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -1784,10 +1784,12 @@ namespace TEAMModelOS.Controllers.Client
             try
             {
                 string id_token = HttpContext.GetXAuth("IdToken");
+               
                 //判斷ID Token
                 if (string.IsNullOrWhiteSpace(id_token)) return BadRequest();
                 var jwt = new JwtSecurityToken(id_token);
                 if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.OrdinalIgnoreCase)) return BadRequest();
+               
                 var tid = jwt.Payload.Sub;
                 //初始化
                 var r8 = _azureRedis.GetRedisClient(8);
@@ -1850,6 +1852,20 @@ namespace TEAMModelOS.Controllers.Client
                 (List<RMember> students, _) = await GroupListService.GetMemberByListids(_coreAPIHttpService, db, _dingDing, new List<string>() { request.sid }, request.school);
                
                 string imeiType = string.Empty;
+                //開課記錄保存
+                LessonRecord lr = new()
+                {
+                    school = request.sp.Equals("school") ? request?.school : null,
+                    code = request.sp.Equals("school") ? $"LessonRecord-{request.school}" : $"LessonRecord",
+                    id = _snowflakeId.NextId().ToString(),  //取得授課ID
+                    courseId = request.cid,
+                    groupIds = new() { request.sid },
+                    tmdid = tid,
+                    scope = request.sp,
+                    pk = "LessonRecord",
+                    name = request.cname,
+                    startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
+                };
                 if (_option.Location.Contains("China", StringComparison.OrdinalIgnoreCase)) 
                 {
                     //觸發IMEI更新消息
@@ -1882,7 +1898,7 @@ namespace TEAMModelOS.Controllers.Client
                         var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<int>(sql, "Imei");
                         if (result.list.IsNotEmpty() && result.list[0]>0)
                         {
-                            var imeimsg = new ServiceBusMessage(new { request.channel, userid = request.did, request.school, stus, imeiType }.ToJsonString());
+                            var imeimsg = new ServiceBusMessage(new { request.channel,lessonId= lr.id, userid = request.did, request.school, stus, imeiType }.ToJsonString());
                             imeimsg.ApplicationProperties.Add("name", "Imei");
                             sbm.Add(imeimsg);
                         }
@@ -1891,20 +1907,7 @@ namespace TEAMModelOS.Controllers.Client
                         }
                     }
                 }
-                //開課記錄保存
-                LessonRecord lr = new()
-                {
-                    school = request.sp.Equals("school") ? request?.school : null,
-                    code = request.sp.Equals("school") ? $"LessonRecord-{request.school}" : $"LessonRecord",
-                    id = _snowflakeId.NextId().ToString(),  //取得授課ID
-                    courseId = request.cid,
-                    groupIds = new() { request.sid },
-                    tmdid = tid,
-                    scope = request.sp,
-                    pk = "LessonRecord",
-                    name = request.cname,
-                    startTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
-                };
+               
                 await db.GetContainer(Constant.TEAMModelOS, request.sp.Equals("school") ? "School" : "Teacher").CreateItemAsync(lr, new PartitionKey(lr.code));
                 //觸發開課統計                
                 var messageChange = new ServiceBusMessage(lr.ToJsonString());
@@ -1941,7 +1944,10 @@ namespace TEAMModelOS.Controllers.Client
 
                     }
                 }
-
+                if (request.school.Equals("ghxyfs"))
+                {
+                    await _dingDing.SendBotMsg($"{request.ToJsonString()},{lr.id}", GroupNames.成都开发測試群組);
+                }
                 return Ok(new { status = 200, lr.id, students, size, usize, imeiType });
             }
             catch (Exception ex)

+ 81 - 96
TEAMModelOS/Controllers/Third/IRS/ThirdIRSController.cs

@@ -93,11 +93,17 @@ namespace TEAMModelOS.Controllers
         {
             try {
                 var lessonTask = request.ToObject<LessonTask>();
+
                 string sql = $"select value c from c where c.school='{lessonTask.school}' and c.channel='{lessonTask.channel}'";
+                if (!string.IsNullOrWhiteSpace(lessonTask.lessonId)) 
+                {
+                    sql=$"{sql}  and c.lessonId='{lessonTask.lessonId}'";
+                }
                 var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Imei>(sql, "Imei");
                 if (result.list.IsNotEmpty())
                 {
                     long now = DateTimeOffset.UtcNow.GetGMTTime(8).ToUnixTimeMilliseconds();
+                    await _azureRedis.GetRedisClient(8).StringSetAsync($"LessonTask:{lessonTask.id}", lessonTask.ToJsonString(), expiry: new TimeSpan(8, 0, 0));
                     switch (lessonTask.imeiType)
                     {
                         case "ThirdIRS_139zhxy":
@@ -166,7 +172,7 @@ namespace TEAMModelOS.Controllers
                             }
                             break;
                     }
-                    await _azureRedis.GetRedisClient(8).StringSetAsync( $"LessonTask:{lessonTask.id}" , lessonTask.ToJsonString(), expiry: new TimeSpan(8, 0, 0));
+                  
                 }
             } catch (Exception ex) 
             {
@@ -197,119 +203,97 @@ namespace TEAMModelOS.Controllers
                 {
                     timestamp= _timestamp.ToString();
                 }
-             //   if (!string.IsNullOrEmpty(sign)  && !string.IsNullOrWhiteSpace(timestamp))
-            //    {
-                 //   string local_sign = Md5Hash.Encrypt($"{AppID139zhxy}{AppKey139zhxy}{timestamp}");
-                //    if (local_sign.Equals(sign))
+
+                var result = json.ToObject<ZHXY139IRSResult>();
+                // await _dingDing.SendBotMsg($"接收到 139zhxy反馈器推送信息!{json.ToJsonString()}\n", GroupNames.成都开发測試群組);
+                var data = await _azureRedis.GetRedisClient(8).StringGetAsync($"LessonTask:{result.workId}");
+                string datastr = $"{data}";
+                if (!string.IsNullOrWhiteSpace(datastr))
+                {
+                    LessonTask lessonTask = data.ToString().ToObject<LessonTask>();
+                    string kid = result.imei;
+                    if (string.IsNullOrWhiteSpace(result.imei))
                     {
-                        var result = json.ToObject<ZHXY139IRSResult>();
-                       // await _dingDing.SendBotMsg($"接收到 139zhxy反馈器推送信息!{json.ToJsonString()}\n", GroupNames.成都开发測試群組);
-                        var data = await _azureRedis.GetRedisClient(8).StringGetAsync($"LessonTask:{result.workId}");
-                        if (!data.IsNullOrEmpty)
+                        kid=result.phone;
+                    }
+                    Imei stu = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemAsync<Imei>(kid, new PartitionKey("Imei"));
+                    if (!string.IsNullOrWhiteSpace(stu?.channel) && !string.IsNullOrWhiteSpace(stu?.userid)  && lessonTask.channel.Equals(stu?.channel))
+                    {
+                        // 處理單例復用,提高請求效率,避免ServiceTransportType.Persistent websocket斷線在Azure偶發的消息遺失
+                        // TODO 尚須注意釋放的問題,後續須處理
+
+                        // 下面註解寫法會造成Azure上消息偶發遺失,Localhost不會發生
+                        //var serviceManager = _azureSignalR.GetServiceManager();                       
+                        //using var hub = await serviceManager.CreateHubContextAsync($"C{stu.channel}", CancellationToken.None);
+                        //目前只支持单个题目回传
+                        var answer = result.answers?.FirstOrDefault();
+                        List<string> ans = new List<string>();
+                        if (answer!=null)
                         {
-                            LessonTask lessonTask = data.ToString().ToObject<LessonTask>();
-                            string kid = result.imei;
-                            if (string.IsNullOrWhiteSpace(result.imei)) 
+                            string con = answer.answer;
+                            var item = lessonTask.examTask.items.Find(x => x.order.Equals(answer.id));
+                            if (item!=null)
                             {
-                                kid=result.phone;
-                            }
-                            Imei stu = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReadItemAsync<Imei>(kid, new PartitionKey("Imei"));
-                            if (!string.IsNullOrWhiteSpace(stu?.channel) && !string.IsNullOrWhiteSpace(stu?.userid)  && lessonTask.channel.Equals(stu?.channel))
-                            {
-                                // 處理單例復用,提高請求效率,避免ServiceTransportType.Persistent websocket斷線在Azure偶發的消息遺失
-                                // TODO 尚須注意釋放的問題,後續須處理
-                              
-                                // 下面註解寫法會造成Azure上消息偶發遺失,Localhost不會發生
-                                //var serviceManager = _azureSignalR.GetServiceManager();                       
-                                //using var hub = await serviceManager.CreateHubContextAsync($"C{stu.channel}", CancellationToken.None);
-
-
-
-                                //目前只支持单个题目回传
-                                var answer = result.answers?.FirstOrDefault();
-                                List<string> ans = new List<string>();
-                                if (answer!=null)
+                                if (item.type.Equals("single") || item.type.Equals("multiple") || item.type.Equals("sortmultiple")|| item.type.Equals("judge"))
                                 {
-                                    string con = answer.answer;
-                                    var item = lessonTask.examTask.items.Find(x => x.order.Equals(answer.id));
-                                    if (item!=null)
-                                    {
-                                        if (item.type.Equals("single") || item.type.Equals("multiple") || item.type.Equals("sortmultiple")|| item.type.Equals("judge"))
-                                        {
-                                            var anscon = con.Select(x => $"{x}").ToList();
-                                            if (anscon.Count<10)
-                                            {
-                                                ans= anscon;
-                                            }
-                                        }
-                                        else
-                                        {
-                                            ans= new List<string>() { answer.answer };
-                                        }
-                                    }
-                                    else
+                                    var anscon = con.Select(x => $"{x}").ToList();
+                                    if (anscon.Count<10)
                                     {
-                                        var anscon = con.Select(x => $"{x}").ToList();
-                                        if (anscon.Count<10)
-                                        {
-                                            ans= anscon;
-                                        }
+                                        ans= anscon;
                                     }
                                 }
-                            var hub = _azureSignalR.GetServiceManager().GetHubContext($"C{stu.channel}");
-                            var common = JsonSerializer.Serialize(new
+                                else
+                                {
+                                    ans= new List<string>() { answer.answer };
+                                }
+                            }
+                            else
                             {
-                                action = "DirectIRS.Answer",
-                                clientType = "DI",
-                                sender = stu.stuid,
-                                timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                                waitReturn = false,
-                                payload = new { irsno = "", answer = ans.ToArray() }
-                            });
-                            await hub.Clients.User(stu.userid).SendCoreAsync("onMessage", new[]{new {
+                                var anscon = con.Select(x => $"{x}").ToList();
+                                if (anscon.Count<10)
+                                {
+                                    ans= anscon;
+                                }
+                            }
+                        }
+                        var hub = _azureSignalR.GetServiceManager().GetHubContext($"C{stu.channel}");
+                        var common = JsonSerializer.Serialize(new
+                        {
+                            action = "DirectIRS.Answer",
+                            clientType = "DI",
+                            sender = stu.stuid,
+                            timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                            waitReturn = false,
+                            payload = new { irsno = "", answer = ans.ToArray() }
+                        });
+                        await hub.Clients.User(stu.userid).SendCoreAsync("onMessage", new[]{new {
                                 connectionId = (string)null,
                                 to = (string)null,
                                 groupname = (string)null,
                                 sender = stu.stuid,
                                 text = common
                             }});
-                            message= "推送成功!";
-                             //   await _dingDing.SendBotMsg($"接收到 139zhxy反馈器推送信息并转发成功!{json.ToJsonString()}\n{ans.ToJsonString()}", GroupNames.成都开发測試群組);
-                                return Ok(new { code = 0, message, timestamp = now });
-
-                            }
-                            else
-                            {
-                                await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS通道异常:频道不存在!{json.ToJsonString()}", GroupNames.成都开发測試群組);
-                            }
-                        }
-                        else
-                        {
-                            code=3;
-                            message="任务不存在!";
-                            await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS异常:任务不存在!{json.ToJsonString()}", GroupNames.成都开发測試群組);
-                        }
+                        message= "推送成功!";
+                       // await _dingDing.SendBotMsg($"{_option.Location},接收到 139zhxy反馈器推送信息并转发成功!{json.ToJsonString()}\n{ans.ToJsonString()}", GroupNames.成都开发測試群組);
+                        return Ok(new { code = 0, message, timestamp = now });
+                    }
+                    else
+                    {
+                        await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS通道异常:频道不存在!{json.ToJsonString()}", GroupNames.成都开发測試群組);
                     }
-                    //else
-                //    {
-                    //    code=2;
-                     //   message="签名验证失败!";
-                     //   await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS异常:签名验证失败!{json.ToJsonString()}", GroupNames.成都开发測試群組);
-                   // }
-             //   }
-            //    else
-              //  {
-                 //   code =1;
-                  //  message="签名或时间戳为空!";
-                 //   await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS异常:签名或时间戳为空!{json.ToJsonString()}", GroupNames.成都开发測試群組);
-              //  }
+                }
+                else
+                {
+                    code=3;
+                    message="任务不存在!";
+                    await _dingDing.SendBotMsg($"{_option.Location},139zhxy反馈器推送IRS异常:任务不存在!{json.ToJsonString()}", GroupNames.成都开发測試群組);
+                }
             }
             catch (Exception ex) {
                 await _dingDing.SendBotMsg($"139zhxy反馈器推送IRS异常:代码异常!{json.ToJsonString()}\n{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
             }
             return Ok(new { code ,message, timestamp =now});
         }
-
         /// <summary>
         /// 修改学校信息
         /// </summary>
@@ -379,9 +363,6 @@ namespace TEAMModelOS.Controllers
                 await _dingDing.SendBotMsg($"IES5,{_option.Location},tianbo/api/course/cardUploadData()\n{ex.Message}\n{ex.StackTrace}{request.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { code = 200, msg = "成功", data = (string)null });
             }
-
-
-
         }
     }
 
@@ -390,6 +371,10 @@ namespace TEAMModelOS.Controllers
     /// </summary>
     public class LessonTask
     {
+        /// <summary>
+        /// 课例id
+        /// </summary>
+        public string lessonId { get; set; }
         /// <summary>
         /// 任务id
         /// </summary>

+ 1 - 1
TEAMModelOS/Program.cs

@@ -12,7 +12,7 @@ namespace TEAMModelOS
     {
         public static void Main(string[] args)
         {
-           
+             
             CreateHostBuilder(args).Build().Run();
         }