CrazyIter_Bin 3 년 전
부모
커밋
73e56610af

+ 25 - 0
TEAMModelFunction/ScsApisHttpTrigger.cs

@@ -41,6 +41,31 @@ namespace TEAMModelFunction
             _azureRedis = azureRedis;
             _thirdApisService = thirdApisService;
         }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [FunctionName("SchoolDataPush")]
+        public async Task<IActionResult> SchoolDataPush([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) {
+            var client = _azureCosmos.GetCosmosClient();
+            string data = await new StreamReader(req.Body).ReadToEndAsync();
+            JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
+            ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
+            JsonElement school = data.ToObject<JsonElement>().GetProperty("school");
+            List<RGroupList> yxtrain = await GroupListService.GetGroupListMemberByType(client, "yxtrain", new List<string> { "school" }, $"{school}", _dingDing);
+            List<TeacherTrain> trains = new List<TeacherTrain>();
+            var members = yxtrain.SelectMany(x => x.members).ToList();
+
+
+            //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+            //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
+            //5.3.1.17学员课堂实录批量回写-UploadKTSLList
+            //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
+            return new OkObjectResult(new { });
+        }
+
         /// <summary>
         /// 
         /// </summary>

+ 4 - 1
TEAMModelOS.SDK/Models/Cosmos/Teacher/Teacher.cs

@@ -43,7 +43,8 @@ namespace TEAMModelOS.SDK.Models
             //public string source { get; set; }
 
             public string userid { get; set; }
-           // public HashSet<string> pxid { get; set; } = new HashSet<string>();
+            public string username { get; set; }
+            // public HashSet<string> pxid { get; set; } = new HashSet<string>();
             public List<string> data { get; set; }= new List<string>();
         }
         public class ScBindData {
@@ -70,6 +71,8 @@ namespace TEAMModelOS.SDK.Models
             public string pid { get; set; }
             
             public string pxid { get; set; }
+            public string userid { get; set; }
+            public string username { get; set; }
         }
 
 

+ 3 - 3
TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

@@ -122,7 +122,7 @@ namespace TEAMModelOS.Controllers
             }
         }
         /// <summary>
-        /// 对某个订阅的能力点进行操作
+        /// 区级数据统计
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
@@ -257,7 +257,7 @@ namespace TEAMModelOS.Controllers
         }
 
         /// <summary>
-        /// 对某个订阅的能力点进行操作
+        /// 校级数据统计
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
@@ -356,7 +356,7 @@ namespace TEAMModelOS.Controllers
 
 
         /// <summary>
-        /// 对某个订阅的能力点进行操作
+        /// 教师个人数据统计
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>

+ 27 - 22
TEAMModelOS/Controllers/Third/ScController.cs

@@ -202,11 +202,12 @@ namespace TEAMModelOS.Controllers.Third
                             var bind = teacher.binds.Find(x => x.userid.Equals($"{scsso.tid}"));
                             if (bind == null)
                             {
-                                teacher.binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } };
+                                teacher.binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}",username=scsso.username, type = type } };
                                 await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
                             }
                             else
                             {
+                                bind.username=scsso.username;
                                 var bindData = scsso.data.ToObject<ScBindData>();
                                 bool isnew = true;
                                 for (int index = 0; index < bind.data.Count; index++)
@@ -222,6 +223,10 @@ namespace TEAMModelOS.Controllers.Third
                                 {
                                     bind.data.Add(bindData.ToJsonString());
                                 }
+                                if (bindData != null) {
+                                    bindData.userid = scsso.tid;
+                                    bindData.username=scsso.username;
+                                }
                                 await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
                                 await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
                             }
@@ -258,7 +263,18 @@ namespace TEAMModelOS.Controllers.Third
                     var container = _azureStorage.GetBlobContainerClient(id);
                     await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                     teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
-                    await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
+
+                    ScBindData bindData = scsso.data.ToObject<ScBindData>();
+                    if (bindData != null)
+                    {
+                        bindData.userid = scsso.tid;
+                        bindData.username = scsso.username;
+                        await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
+                    }
+                    else {
+                        await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
+                    }
+                    
                 }
                 catch (Exception ex) {
                     await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
@@ -338,7 +354,7 @@ namespace TEAMModelOS.Controllers.Third
                 }
                 string accessConfig = setting.accessConfig;
                 Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", accessConfig }, { "pxid", scsso.Pxid }, { "tid", scsso.tid } };
-                string SchoolName="",SchoolID = "", ProjectID = "", ProjectItemID ="" ; 
+                string SchoolName = "", SchoolID = "", ProjectID = "", ProjectItemID = "", TeacherName = "" ; 
 
                 (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
                 if (status == 200)
@@ -351,6 +367,7 @@ namespace TEAMModelOS.Controllers.Third
                         SchoolID = $"{scTeacher.SchoolID}";
                         ProjectID =$"{ scTeacher.ProjectID}";
                         ProjectItemID =$"{ scTeacher.ProjectItemID}";
+                        TeacherName = $"{ scTeacher.TeacherName}";
                     }
                 }
                 ScBindData bindData = new ScBindData
@@ -359,10 +376,14 @@ namespace TEAMModelOS.Controllers.Third
                     sid = SchoolID,
                     pd = ProjectID,
                     pid = ProjectItemID,
-                    pxid = scsso.Pxid
+                    pxid = scsso.Pxid,
+                    userid=scsso.tid,
+                    username=TeacherName
+                    
                 };
                 var data = bindData.ToJsonString();
                 ScSSOData sso = new ScSSOData {
+                    username = TeacherName,
                     path = path,
                     Pxid = scsso.Pxid,
                     Encrypt = scsso.Encrypt,
@@ -425,25 +446,8 @@ namespace TEAMModelOS.Controllers.Third
                             {
                                 bind.data.Add(bindData.ToJsonString());
                             }
+                            bind.username = TeacherName;
                             await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
-                            //var scbind= bind.data.FindAll(x=>x.Contains("scsyxpt"));
-                            //if (scbind != null) {
-                            //    foreach (var bd in scbind) {
-                                   
-                            //    }
-                            //}
-                            //if (bind.pxid != null)
-                            //{
-                            //    if (bind.pxid.Add(sso.Pxid))
-                            //    {
-                            //        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
-                            //    }
-                            //}
-                            //else
-                            //{
-                            //    bind.pxid = new HashSet<string> { sso.Pxid };
-                            //    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
-                            //}
                         }
                         await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{sso.path}/scbind", $"{teacher.id}.json");
                         rurl.Append($"?status=200&id_token={implicit_token.id_token}&access_token={implicit_token.access_token}&expires_in={HttpUtility.UrlEncode(implicit_token.expires_in)}&token_type={HttpUtility.UrlEncode(implicit_token.token_type)}").ToString();
@@ -1041,6 +1045,7 @@ namespace TEAMModelOS.Controllers.Third
             public string time { get; set; }
             public string Encrypt { get; set; }
             public string data { get; set; }
+            public string username { get; set; }
         }
         public record SSO
         {

+ 1 - 1
TEAMModelOS/Program.cs

@@ -19,7 +19,7 @@ namespace TEAMModelOS
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
-                   webBuilder.UseStartup<Startup>().UseKestrel(x => { x.Limits.MaxRequestBodySize = null; });
+                   webBuilder.UseStartup<Startup>();
                });
     }
 }