Quellcode durchsuchen

返回urecord结算

CrazyIter_Bin vor 3 Jahren
Ursprung
Commit
ba9bbbb4d1

+ 3 - 2
TEAMModelFunction/TriggerSurvey.cs

@@ -236,10 +236,11 @@ namespace TEAMModelFunction
                             var ContainerClient = _azureStorage.GetBlobContainerClient(blobcntr);
                             List<Task<string>> tasks = new List<Task<string>>();
                             //获取
+                            List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
                             try
                             {
                                 List<string> items = await ContainerClient.List($"survey/{survey.id}/urecord");
-                                List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
+                              
                                 foreach (string item in items)
                                 {
                                     var Download = await _azureStorage.GetBlobContainerClient(blobcntr).GetBlobClient(item).DownloadAsync();
@@ -297,7 +298,7 @@ namespace TEAMModelFunction
                             {
                                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}问卷调查问题结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                             }
-                            var cods = new { records = recs, userids, question = questionRecords };
+                            var cods = new { records = recs, userids, question = questionRecords, urecord = surveyRecords };
                             //问卷整体情况
                             await _azureStorage.UploadFileByContainer(blobcntr, cods.ToJsonString(), "survey", $"{survey.id}/record.json");
                             if (string.IsNullOrEmpty(survey.recordUrl))

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/SurveyRecord.cs

@@ -13,4 +13,5 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
         public long time { get; set; }
         public string userid { get; set; }
     }
+     
 }

+ 31 - 6
TEAMModelOS/Controllers/Research/StandardFileController.cs

@@ -34,7 +34,7 @@ namespace TEAMModelOS.Controllers
         }
 
         /*
-         {"abilityId":"册别id:0baf00db-0768-4b62-a8f7-280f6bcebf71","scope":"school","abilityCode":"册别分区键"}
+         {"areaId":"册别id:0baf00db-0768-4b62-a8f7-280f6bcebf71","scope":"school","abilityCode":"册别分区键"}
         */
         /// <summary>
         /// 查找能力点 
@@ -52,13 +52,38 @@ namespace TEAMModelOS.Controllers
             StandardFile file = null;
             try
             {
-                await  client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>($"{_areaId}",partitionKey:new Azure.Cosmos.PartitionKey ("StandardFile"));
-                return Ok(new {});
+                file= await  client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<StandardFile>($"{_areaId}",partitionKey:new Azure.Cosmos.PartitionKey ("StandardFile"));
+                return Ok(new { file });
             }
             catch (CosmosException ex)
-            { 
-               
-                return Ok(new { file });
+            {
+                return Ok(new { file, error = ex.Status });
+            }
+        }
+        /*
+       {"areaId":"册别id:0baf00db-0768-4b62-a8f7-280f6bcebf71","scope":"school","abilityCode":"册别分区键"}
+      */
+        /// <summary>
+        /// 保存 
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("upsert")]
+        [AuthToken(Roles = "teacher,student,admin,area")]
+        public async Task<IActionResult> upsert(StandardFile file)
+        {
+            var client = _azureCosmos.GetCosmosClient();
+            try
+            {
+                file.pk = "StandardFile";
+                file.code = "StandardFile";
+                file = await client.GetContainer(Constant.TEAMModelOS, "Normal").UpsertItemAsync<StandardFile>(file, partitionKey: new Azure.Cosmos.PartitionKey("StandardFile"));
+                return Ok(new { file, });
+            }
+            catch (CosmosException ex)
+            {
+                return Ok(new {error= ex.Status });
             }
         }
     }

+ 2 - 1
TEAMModelOS/Services/Common/ActivityStudentService.cs

@@ -598,6 +598,7 @@ namespace TEAMModelOS.Services.Common
                                     var value = submit.ToString();
                                     userids.Add(value);
                                 }
+
                                 List<QuestionRecord> questionRecords = new List<QuestionRecord>();
                                 //结算每道题的答题情况
                                 var ContainerClient = _azureStorage.GetBlobContainerClient(blobcntr);
@@ -660,7 +661,7 @@ namespace TEAMModelOS.Services.Common
                                     recds.Add(new { index = rcd.Name.ToString(), ans = value });
                                 }
                                 await Task.WhenAll(tasks);
-                                var cods = new { records = recds, userids, question = questionRecords };
+                                var cods = new { records = recds, userids, question = questionRecords, urecord= surveyRecords };
                                 //问卷整体情况
                                 await _azureStorage.UploadFileByContainer(blobcntr, cods.ToJsonString(), "survey", $"{survey.id}/record.json");
                                 ///end 20210805 huanghb 实时结算