zhouj1203@hotmail.com 2 years ago
parent
commit
d5db4967b3
1 changed files with 15 additions and 3 deletions
  1. 15 3
      TEAMModelOS.FunctionV4/CosmosDB/TriggerArt.cs

+ 15 - 3
TEAMModelOS.FunctionV4/CosmosDB/TriggerArt.cs

@@ -339,11 +339,23 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
                                 studentArtResults.Add(item);
                             }
                             //根据学校编码去获取区级ID
-                            School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
-                            ArtSetting setting = null;
+                            School scInfo = new();
+                            //School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
+                            var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
+                            if (response.Status == 200)
+                            {
+                                using var cJson = await JsonDocument.ParseAsync(response.ContentStream);
+                                scInfo = cJson.ToObject<School>();
+                            }
+                            ArtSetting setting = new();
                             try
                             {
-                                setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<ArtSetting>($"{scInfo.areaId}", partitionKey: new Azure.Cosmos.PartitionKey("ArtSetting"));
+                                var artResponse = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{scInfo.areaId}", partitionKey: new Azure.Cosmos.PartitionKey("ArtSetting"));
+                                if (response.Status == 200)
+                                {
+                                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                                    setting = json.ToObject<ArtSetting>();
+                                }
                             }
                             catch (Exception e)
                             {