|
@@ -17,7 +17,7 @@ namespace TEAMModelFunction
|
|
public class TriggerSurvey
|
|
public class TriggerSurvey
|
|
{
|
|
{
|
|
public static async void Trigger(AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
|
|
public static async void Trigger(AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
|
|
- CosmosClient client, Document input, string code, long stime, long etime, string school)
|
|
|
|
|
|
+ CosmosClient client, Document input, string code, long stime, long etime, string school,AzureRedisFactory _azureRedis)
|
|
{
|
|
{
|
|
Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
|
|
Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{code}"));
|
|
List<ChangeRecord> changeRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", survey.progress } });
|
|
List<ChangeRecord> changeRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", survey.progress } });
|
|
@@ -53,7 +53,7 @@ namespace TEAMModelFunction
|
|
break;
|
|
break;
|
|
case "going":
|
|
case "going":
|
|
ActivityData data;
|
|
ActivityData data;
|
|
- if (survey.scope == "school" || survey.scope == "teacher")
|
|
|
|
|
|
+ if (survey.scope == "school")
|
|
{
|
|
{
|
|
data = new ActivityData
|
|
data = new ActivityData
|
|
{
|
|
{
|
|
@@ -105,7 +105,7 @@ namespace TEAMModelFunction
|
|
else
|
|
else
|
|
{
|
|
{
|
|
long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
|
|
- ChangeRecord changeRecord = new ChangeRecord
|
|
|
|
|
|
+ ChangeRecord changeRecord = new ChangeRecord
|
|
{
|
|
{
|
|
RowKey = input.Id,
|
|
RowKey = input.Id,
|
|
PartitionKey = "going",
|
|
PartitionKey = "going",
|
|
@@ -116,7 +116,14 @@ namespace TEAMModelFunction
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case "finish":
|
|
case "finish":
|
|
-
|
|
|
|
|
|
+ var records =await _azureRedis.GetRedisClient(8).HashGetAllAsync($"Survey:Record:{survey.id}_{survey.code}");
|
|
|
|
+ List<dynamic> recs = new List<dynamic>();
|
|
|
|
+ foreach (var rcd in records) {
|
|
|
|
+ //var key =int.Parse(rcd.Name.ToString());
|
|
|
|
+ var value = rcd.Value.ToString().ToObject<JsonElement>();
|
|
|
|
+ recs.Add(new { index = rcd.Name.ToString(), count = value });
|
|
|
|
+ }
|
|
|
|
+ await _azureStorage.UploadFileByContainer(survey.owner, recs.ToJsonString(), "vote", $"{survey.id}/record.json");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|