|
@@ -25,6 +25,7 @@ using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
using TEAMModelOS.SDK.Models.Cosmos;
|
|
using TEAMModelOS.SDK.Models.Cosmos;
|
|
using Azure.Messaging.ServiceBus;
|
|
using Azure.Messaging.ServiceBus;
|
|
|
|
+using Azure.Storage.Sas;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
@@ -535,59 +536,73 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
var ContainerClient = _azureStorage.GetBlobContainerClient(survey.owner);
|
|
var ContainerClient = _azureStorage.GetBlobContainerClient(survey.owner);
|
|
var route = ContainerClient.Uri.ToString();
|
|
var route = ContainerClient.Uri.ToString();
|
|
- List<BlobItem> items = await ContainerClient.List($"survey/{survey.id}/urecord");
|
|
|
|
- List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
|
|
|
|
|
|
+
|
|
//获取
|
|
//获取
|
|
|
|
|
|
- foreach (BlobItem item in items)
|
|
|
|
- {
|
|
|
|
- BlobAuth blobAuth = _azureStorage.GetBlobSasUriRead(survey.owner, $"{item.Name}");
|
|
|
|
- var url = $"{route}/{item.Name}?{blobAuth.sas}";
|
|
|
|
- var response = await _clientFactory.CreateClient().GetAsync(new Uri(url));
|
|
|
|
- var json = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
|
|
|
|
- var Record = json.RootElement.ToObject<SurveyRecord>();
|
|
|
|
- surveyRecords.Add(Record);
|
|
|
|
- }
|
|
|
|
- List<Task<string>> tasks = new List<Task<string>>();
|
|
|
|
- for (int index = 0; index < survey.ans.Count; index++)
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- string url = $"{survey.id}/qrecord/{index}.json";
|
|
|
|
- QuestionRecord question = new QuestionRecord() { index = index };
|
|
|
|
- foreach (SurveyRecord record in surveyRecords)
|
|
|
|
|
|
+ List<string> items = await ContainerClient.List($"survey/{survey.id}/urecord");
|
|
|
|
+ List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
|
|
|
|
+ (string uri, string sas) blobAuth = _azureStorage.GetBlobContainerSAS(survey.owner, BlobContainerSasPermissions.Read);
|
|
|
|
+ string sas = blobAuth.sas;
|
|
|
|
+ var rcode = await _clientFactory.CreateClient().GetAsync(new Uri($"{route}/survey/{survey.id}/record.json?{sas}"));
|
|
|
|
+ var jsonc = await JsonDocument.ParseAsync(await rcode.Content.ReadAsStreamAsync());
|
|
|
|
+ var Recordc = jsonc.RootElement.ToObject<JsonElement>();
|
|
|
|
+ HttpClient httpClient = _clientFactory.CreateClient();
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查问题结算数据11111--->>{Recordc.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
|
|
+ foreach (string item in items)
|
|
{
|
|
{
|
|
- if (record.ans.Count == survey.ans.Count)
|
|
|
|
|
|
+ var url = $"{route}/{item}?{sas}";
|
|
|
|
+ var response = await httpClient.GetAsync(new Uri(url));
|
|
|
|
+ var json = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
|
|
|
|
+ var Record = json.RootElement.ToObject<SurveyRecord>();
|
|
|
|
+ surveyRecords.Add(Record);
|
|
|
|
+ }
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查问题结算数据{surveyRecords.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
|
|
+ for (int index = 0; index < survey.ans.Count; index++)
|
|
|
|
+ {
|
|
|
|
+ string url = $"{survey.id}/qrecord/{index}.json";
|
|
|
|
+ QuestionRecord question = new QuestionRecord() { index = index };
|
|
|
|
+ foreach (SurveyRecord record in surveyRecords)
|
|
{
|
|
{
|
|
- foreach (var an in record.ans[index])
|
|
|
|
|
|
+ if (record.ans.Count == survey.ans.Count)
|
|
{
|
|
{
|
|
- //
|
|
|
|
- if (question.opt.ContainsKey(an))
|
|
|
|
- {
|
|
|
|
- if (question.opt[an] != null)
|
|
|
|
- {
|
|
|
|
- question.opt[an].Add(record.userid);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- question.opt[an] = new HashSet<string>() { record.userid };
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ foreach (var an in record.ans[index])
|
|
{
|
|
{
|
|
- if (survey.ans[index].Contains(an))
|
|
|
|
|
|
+ //
|
|
|
|
+ if (question.opt.ContainsKey(an))
|
|
{
|
|
{
|
|
- //如果是客观题code
|
|
|
|
- question.opt.Add(an, new HashSet<string> { record.userid });
|
|
|
|
|
|
+ if (question.opt[an] != null)
|
|
|
|
+ {
|
|
|
|
+ question.opt[an].Add(record.userid);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ question.opt[an] = new HashSet<string>() { record.userid };
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //如果不是客观code
|
|
|
|
- question.other[record.userid] = an;
|
|
|
|
|
|
+ if (survey.ans[index].Contains(an))
|
|
|
|
+ {
|
|
|
|
+ //如果是客观题code
|
|
|
|
+ question.opt.Add(an, new HashSet<string> { record.userid });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //如果不是客观code
|
|
|
|
+ question.other[record.userid] = an;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ await _azureStorage.UploadFileByContainer(survey.owner, question.ToJsonString(), "survey", url);
|
|
}
|
|
}
|
|
- tasks.Add(_azureStorage.UploadFileByContainer(survey.owner, question.ToJsonString(), "survey", url, false));
|
|
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查问题结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(survey.recordUrl))
|
|
if (string.IsNullOrEmpty(survey.recordUrl))
|
|
{
|
|
{
|
|
@@ -597,9 +612,9 @@ namespace TEAMModelOS.Controllers
|
|
else
|
|
else
|
|
{
|
|
{
|
|
//异动,且已经有结算记录则不必再继续。
|
|
//异动,且已经有结算记录则不必再继续。
|
|
- // break;
|
|
|
|
|
|
+ //break;
|
|
}
|
|
}
|
|
- await Task.WhenAll(tasks);
|
|
|
|
|
|
+ // await Task.WhenAll(tasks);
|
|
//更新结束状态
|
|
//更新结束状态
|
|
data.progress = "finish";
|
|
data.progress = "finish";
|
|
if (survey.scope == "school")
|
|
if (survey.scope == "school")
|