Bladeren bron

处理学生名单变更

CrazyIter_Bin 4 jaren geleden
bovenliggende
commit
8c091c9756

+ 0 - 40
TEAMModelFunction/ClassChangeServiceBus.cs

@@ -1,40 +0,0 @@
-using Microsoft.Azure.WebJobs;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Text.Json;
-using System.Threading.Tasks;
-using TEAMModelOS.SDK.DI;
-
-namespace TEAMModelFunction
-{
-    //public class ClassChangeServiceBus
-    //{
-    //    private readonly AzureCosmosFactory _azureCosmos;
-    //    private readonly DingDing _dingDing;
-    //    delegate void DoActivityTarget(string ids,string opt,string no,string source);
-    //    public ClassChangeServiceBus(AzureCosmosFactory azureCosmos, DingDing dingDing)
-    //    {
-    //        _azureCosmos = azureCosmos;
-    //        _dingDing = dingDing;
-    //    }
-    //    /// <summary>
-    //    /// 完善学生名单变更影响的活动
-    //    /// </summary>
-    //    /// <data msg>
-    //    /// "ids":["s111","t111"]//学生
-    //    /// "opt":"join/leave",//状态
-    //    /// "no":"CLASS001"//教室编号
-    //    /// "source":1/2  //学生名单数据来源 1是不同学校的学生账号,2是扫码加入的醍摩豆ID
-    //    /// </data>
-    //    /// <param name="msg"></param>
-    //    /// <returns></returns>
-    //    [FunctionName("ImproveActivity")]
-    //    public async Task ImproveActivity([ServiceBusTrigger("active-task", "classchange", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
-    //        try {
-    //            var json = JsonDocument.Parse(msg);
-
-    //        } catch (Exception e) { }
-    //    }
-    //}
-}

+ 51 - 0
TEAMModelFunction/StuListServiceBus.cs

@@ -0,0 +1,51 @@
+using Microsoft.Azure.WebJobs;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelFunction
+{
+    public class StuListServiceBus
+    {
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        delegate void DoActivityTarget(string ids, string opt, string no, string source);
+        public StuListServiceBus(AzureCosmosFactory azureCosmos, DingDing dingDing)
+        {
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+        }
+        /// <summary>
+        /// 完善学生名单变更影响的活动
+        /// </summary>
+        /// <data msg>
+        /// "ids":["s111","t111"]//学生
+        /// "opt":"join/leave",//状态
+        /// "no":"CLASS001"//教室编号
+        /// "source":1/2  //学生名单数据来源 1是不同学校的学生账号,2是扫码加入的醍摩豆ID
+        /// </data>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        //[FunctionName("StuList")]
+        //public async Task StuList([ServiceBusTrigger("active-task", "stulist", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        //{
+        //    try
+        //    {
+        //        // await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);
+        //        var jsonMsg = JsonDocument.Parse(msg);
+        //        if (jsonMsg.RootElement.TryGetProperty("name", out JsonElement name) && name.ValueKind == JsonValueKind.String)
+        //        {
+                    
+        //        }
+        //    }
+        //    catch (Exception ex)
+        //    {
+        //        await _dingDing.SendBotMsg($"ServiceBus,Blob()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+        //    }
+        //}
+       
+    }
+}

+ 34 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/ClassChange.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
+{
+    /// <summary>
+    /// 学生名单变动
+    /// </summary>
+    public class ClassChange
+    {
+        /// <summary>
+        /// 教师名单加入的
+        /// </summary>
+        public List<string> tchjoin { get; set; } = new List<string>();
+        /// <summary>
+        /// 教师名单离开的
+        /// </summary>
+        public List<string> tchleave { get; set; } = new List<string>();
+        /// <summary>
+        /// 学校名单加入的
+        /// </summary>
+        public List<string> schjoin { get; set; } = new List<string>();
+        /// <summary>
+        /// 学校名单离开的
+        /// </summary>
+        public List<string> schleave { get; set; } = new List<string>();
+        public string listid { get; set; }
+        /// <summary>
+        /// 分区
+        /// </summary>
+        public string scope { get; set; }
+    }
+}

+ 7 - 2
TEAMModelOS/Controllers/School/CourseController.cs

@@ -193,8 +193,13 @@ namespace TEAMModelOS.Controllers
                 stuList.code = stuList.pk + "-" + stuList.code;
                 stuList.code = stuList.pk + "-" + stuList.code;
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
                 {
-                    //var query = $"select *  from c where  c.id ='{stuList.id}' ";
-                    stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{originCode}"));
+                    //var oldStuList=  await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<StuList>(stuList.id, new PartitionKey(stuList.code));
+                   // if (oldStuList.GetRawResponse().Status == 200)
+                    //{
+                    //}
+                    //else if (oldStuList.GetRawResponse().Status == 404) { 
+                    //}
+                     stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{originCode}"));
                 }
                 }
                 else
                 else
                 {
                 {