Bladeren bron

返回重复邀请的教师

CrazyIter_Bin 3 jaren geleden
bovenliggende
commit
b3a521e8bc

+ 4 - 4
TEAMModelFunction/MonitorServicesBus.cs

@@ -155,8 +155,8 @@ namespace TEAMModelFunction
                 if (jsonMsg.RootElement.TryGetProperty("name", out JsonElement _name) && _name.ValueKind == JsonValueKind.String
                     && jsonMsg.RootElement.TryGetProperty("root", out JsonElement root) && root.ValueKind == JsonValueKind.String)
                 {
-                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:触发变更,{jsonMsg.ToJsonString()}",
-                      GroupNames.成都开发測試群組);
+                    //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:触发变更,{jsonMsg.ToJsonString()}",
+                    //  GroupNames.成都开发測試群組);
                     List<Dictionary<string, double?>> list = new List<Dictionary<string, double?>>();
                     string[] uls = System.Web.HttpUtility.UrlDecode($"{root}", Encoding.UTF8).Split("/");
                     string u = !string.IsNullOrEmpty(uls[0]) ? uls[0] : uls[1];
@@ -194,8 +194,8 @@ namespace TEAMModelFunction
                         long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                         await _azureRedis.GetRedisClient(8).StringSetAsync(lockKey, now, expiry: timeSpan);
                     }
-                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:{name}使用:{u},文件分类:{list.ToJsonString()}",
-                        GroupNames.成都开发測試群組);
+                    //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,Blob() 容器:{name}使用:{u},文件分类:{list.ToJsonString()}",
+                    //    GroupNames.成都开发測試群組);
                 }
             }
             catch (Exception ex)

+ 23 - 1
TEAMModelOS/Controllers/School/SchoolTeacherController.cs

@@ -232,6 +232,8 @@ namespace TEAMModelOS.Controllers
             }
             try
             {
+
+                List<KeyValuePair<string, int>> keys = new List<KeyValuePair<string, int>>();
                 List<TmdInfo> ids = new List<TmdInfo>();
                 foreach (var obj in user_list.EnumerateArray())
                 {
@@ -249,6 +251,16 @@ namespace TEAMModelOS.Controllers
                         if (school != null)
                         {
                             school.time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                            if (school.status.Equals("invite") && grant_type.ToString().Equals("invite"))
+                            {
+                                keys.Add(new KeyValuePair<string, int>($"{id}", 1));
+                                continue;
+                            }
+                            if (school.status.Equals("join") && grant_type.ToString().Equals("invite"))
+                            {
+                                keys.Add(new KeyValuePair<string, int>($"{id}", 2));
+                                continue;
+                            }
                             school.status = grant_type.GetString();
                         }
                         else
@@ -285,12 +297,22 @@ namespace TEAMModelOS.Controllers
                         await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemStreamAsync(stream, new PartitionKey("Base"));
                     }
                     //學校老師資料
+                      
                     var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
                     //SchoolTeacher schteacher = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(id.ToString(), new PartitionKey($"Teacher-{school_code}"));
                     if (sresponse.Status == 200)
                     {
                         using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
                         SchoolTeacher schteacher = json.ToObject<SchoolTeacher>();
+                        if (schteacher.status.Equals("invite") && grant_type.ToString().Equals("invite")) {
+                            keys.Add(new KeyValuePair<string, int>($"{id}", 1));
+                            continue;
+                        }
+                        if (schteacher.status.Equals("join") && grant_type.ToString().Equals("invite"))
+                        {
+                            keys.Add(new KeyValuePair<string, int>($"{id}", 2));
+                            continue;
+                        }
                         schteacher.status = grant_type.ToString();
                         schteacher.createTime =   DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                         await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schteacher, id.ToString(), new PartitionKey($"Teacher-{school_code}"));
@@ -353,7 +375,7 @@ namespace TEAMModelOS.Controllers
                 var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
                 var location = _option.Location;
                 var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
-                return Ok(new { });
+                return Ok(new { exist = keys }) ;
             }
             catch(Exception ex)
             {