|
@@ -76,7 +76,7 @@ namespace TEAMModelOS.Services.Common
|
|
|
case "once":
|
|
|
// //如果是只能投票一次的活动则直接获取Redis的第一条 只能投一次
|
|
|
Field = $"{userid}-once";
|
|
|
- HashEntry[] values = _azureRedis.GetRedisClient(8).HashGetAll($"Vote:Record:{vote.id}_{vote.code}");
|
|
|
+ HashEntry[] values = _azureRedis.GetRedisClient(8).HashGetAll($"Vote:Record:{vote.id}");
|
|
|
if (values != null && values.Length > 0)
|
|
|
{
|
|
|
value = new RedisValue();
|
|
@@ -95,22 +95,22 @@ namespace TEAMModelOS.Services.Common
|
|
|
break;
|
|
|
case "day": //周期内每天
|
|
|
Field = $"{userid}-day-{now.ToString("yyyyMMdd")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
msgid = await VoteIng(vote, value, msgid, option, Field, curr, _azureRedis,userid);
|
|
|
break;
|
|
|
case "week": //自然周
|
|
|
Field = $"{userid}-week-{now.ToString("yyyy")}{GetWeek(now)}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
msgid = await VoteIng(vote, value, msgid, option, Field, curr, _azureRedis, userid);
|
|
|
break;
|
|
|
case "month": //月份
|
|
|
Field = $"{userid}-month-{now.ToString("yyyyMM")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
msgid = await VoteIng(vote, value, msgid, option, Field, curr, _azureRedis, userid);
|
|
|
break;
|
|
|
case "year"://年份
|
|
|
Field = $"{userid}-year-{now.ToString("yyyy")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
msgid = await VoteIng(vote, value, msgid, option, Field, curr, _azureRedis, userid);
|
|
|
break;
|
|
|
}
|
|
@@ -157,13 +157,13 @@ namespace TEAMModelOS.Services.Common
|
|
|
record.time = curr;
|
|
|
record.userid = userid;
|
|
|
//保存投票记录
|
|
|
- bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}", Field, record.ToJsonString());
|
|
|
+ bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}", Field, record.ToJsonString());
|
|
|
//单独保存每个人方便查询的记录
|
|
|
- bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}:{userid}", Field, record.ToJsonString());
|
|
|
+ bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}:{userid}", Field, record.ToJsonString());
|
|
|
//当前投票分组计数存入活动的Redis
|
|
|
foreach (var opt in option)
|
|
|
{
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Vote:Count:{vote.id}_{vote.code}", opt.Key, opt.Value);
|
|
|
+ await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Vote:Count:{vote.id}", opt.Key, opt.Value);
|
|
|
}
|
|
|
msgid = 1;
|
|
|
}
|
|
@@ -178,13 +178,13 @@ namespace TEAMModelOS.Services.Common
|
|
|
{
|
|
|
//保存投票记录
|
|
|
VoteRecord record = new VoteRecord { opt = option, time = curr, userid = userid };
|
|
|
- bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}", Field, record.ToJsonString());
|
|
|
+ bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}", Field, record.ToJsonString());
|
|
|
//单独保存每个人方便查询的记录
|
|
|
- bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}:{userid}", Field, record.ToJsonString());
|
|
|
+ bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}:{userid}", Field, record.ToJsonString());
|
|
|
//当前投票分组计数存入活动的Redis
|
|
|
foreach (var opt in option)
|
|
|
{
|
|
|
- await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Vote:Count:{vote.id}_{vote.code}", opt.Key, opt.Value);
|
|
|
+ await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Vote:Count:{vote.id}", opt.Key, opt.Value);
|
|
|
}
|
|
|
if (status)
|
|
|
{
|
|
@@ -487,7 +487,7 @@ namespace TEAMModelOS.Services.Common
|
|
|
if (recs.IsNotEmpty() && recs.Count == survey.ans.Count)
|
|
|
{
|
|
|
//处理问卷调查表的每一题选项数
|
|
|
- List<Task<string>> tasks = new List<Task<string>>();
|
|
|
+ // List<Task<string>> tasks = new List<Task<string>>();
|
|
|
for (int index = 0; index < recs.Count; index++) {
|
|
|
Dictionary<string, int> dict = new Dictionary<string, int>();
|
|
|
if (recs[index].IsNotEmpty()) {
|
|
@@ -511,44 +511,37 @@ namespace TEAMModelOS.Services.Common
|
|
|
{
|
|
|
dict["other"] = 1;
|
|
|
}
|
|
|
- tasks.Add(_azureStorage.UploadFileByContainer(survey.owner,new { other=x, userid, time =curr }.ToJsonString(), "survey", $"{survey.id}/other/{index}/{userid}.json", false));
|
|
|
+ //这里暂不处理, 结算再处理other
|
|
|
+ // tasks.Add(_azureStorage.UploadFileByContainer(survey.owner,new { other=x, userid, time =curr }.ToJsonString(), "survey", $"{survey.id}/other/{index}/{userid}.json", false));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- var value= azureRedis.GetRedisClient(8).HashGet($"Survey:Record:{survey.id}_{survey.code}",index);
|
|
|
+ var value= azureRedis.GetRedisClient(8).HashGet($"Survey:Record:{survey.id}",index);
|
|
|
if (value != default && !value.IsNullOrEmpty)
|
|
|
{
|
|
|
- RdsRecord dt = value.ToString().ToObject<RdsRecord>();
|
|
|
+ Dictionary<string, int> dt = value.ToString().ToObject<Dictionary<string, int>>();
|
|
|
foreach (var kp in dict)
|
|
|
{ //不建议放在reids
|
|
|
- if (dt.srecord.ContainsKey(kp.Key))
|
|
|
+ if (dt.ContainsKey(kp.Key))
|
|
|
{
|
|
|
- dt.srecord[kp.Key] = dt.srecord[kp.Key] + kp.Value;
|
|
|
+ dt[kp.Key] = dt[kp.Key] + kp.Value;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- dt.srecord.Add(kp.Key, kp.Value);
|
|
|
- }
|
|
|
- if (dt.urecord.ContainsKey(userid))
|
|
|
- {
|
|
|
- dt.urecord[userid] = recs[index].ToArray();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dt.urecord.Add(userid, recs[index].ToArray());
|
|
|
+ dt.Add(kp.Key, kp.Value);
|
|
|
}
|
|
|
}
|
|
|
- await azureRedis.GetRedisClient(8).HashSetAsync($"Survey:Record:{survey.id}_{survey.code}", index, dt.ToJsonString());
|
|
|
+ await azureRedis.GetRedisClient(8).HashSetAsync($"Survey:Record:{survey.id}", index, dt.ToJsonString());
|
|
|
}
|
|
|
else {
|
|
|
- await azureRedis.GetRedisClient(8).HashSetAsync($"Survey:Record:{survey.id}_{survey.code}", index, dict.ToJsonString());
|
|
|
+ await azureRedis.GetRedisClient(8).HashSetAsync($"Survey:Record:{survey.id}", index, dict.ToJsonString());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //处理other
|
|
|
- await Task.WhenAll(tasks);
|
|
|
+
|
|
|
+ //处理other ,这里暂不处理, 结算再处理other
|
|
|
+ //await Task.WhenAll(tasks);
|
|
|
//保存当前提交人的记录
|
|
|
- await _azureStorage.UploadFileByContainer(survey.owner,new { record= record, userid, time = curr }.ToJsonString(), "survey", $"{survey.id}/record/{userid}.json");
|
|
|
+ await _azureStorage.UploadFileByContainer(survey.owner,new { record= record, userid, time = curr }.ToJsonString(), "survey", $"{survey.id}/urecord/{userid}.json");
|
|
|
msgid = 1;
|
|
|
}
|
|
|
else {
|
|
@@ -599,7 +592,7 @@ namespace TEAMModelOS.Services.Common
|
|
|
case "once":
|
|
|
// //如果是只能投票一次的活动则直接获取Redis的第一条 只能投一次
|
|
|
Field = $"{userid}-once";
|
|
|
- RedisValue[] values = _azureRedis.GetRedisClient(8).HashValues($"Vote:Record:{vote.id}_{vote.code}");
|
|
|
+ RedisValue[] values = _azureRedis.GetRedisClient(8).HashValues($"Vote:Record:{vote.id}");
|
|
|
if (values != null && values.Length>0)
|
|
|
{
|
|
|
value = values[0];
|
|
@@ -607,21 +600,21 @@ namespace TEAMModelOS.Services.Common
|
|
|
break;
|
|
|
case "day": //周期内每天
|
|
|
Field = $"{userid}-day-{now.ToString("yyyyMMdd")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
break;
|
|
|
case "week": //自然周
|
|
|
Field = $"{userid}-week-{now.ToString("yyyy")}{GetWeek(now)}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
|
|
|
break;
|
|
|
case "month": //月份
|
|
|
Field = $"{userid}-month-{now.ToString("yyyyMM")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
|
|
|
break;
|
|
|
case "year"://年份
|
|
|
Field = $"{userid}-year-{now.ToString("yyyy")}";
|
|
|
- value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}_{vote.code}", Field);
|
|
|
+ value = _azureRedis.GetRedisClient(8).HashGet($"Vote:Record:{vote.id}", Field);
|
|
|
|
|
|
break;
|
|
|
}
|