CrazyIter_Bin 4 rokov pred
rodič
commit
adb4f0acd5

+ 1 - 1
TEAMModelFunction/CourseServiceBus.cs

@@ -30,7 +30,7 @@ namespace TEAMModelFunction
         /// <param name="msg"></param>
         /// <returns></returns>
         [FunctionName("Course")]
-        public async Task Course([ServiceBusTrigger("active-task", "course", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        public async Task Course([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "course", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
         {
             var client = _azureCosmos.GetCosmosClient();
             try

+ 4 - 62
TEAMModelFunction/MonitorServicesBus.cs

@@ -30,8 +30,7 @@ namespace TEAMModelFunction
             _azureRedis = azureRedis;
         }
         [FunctionName("Exam")]
-         public async Task Exam([ServiceBusTrigger("active-task", "exam", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
-       // public async Task Exam([ServiceBusTrigger("active-task", "exam", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+         public async Task Exam([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "exam", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
         {
             try
             {
@@ -44,23 +43,6 @@ namespace TEAMModelFunction
                 ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
                 exam.progress = progress.ToString();
                 await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{code}"));
-                /*                keyValuePairs.TryGetValue("id", out object id);
-                                keyValuePairs.TryGetValue("name", out object name);
-                                keyValuePairs.TryGetValue("code", out object code);*/
-                //keyValuePairs.TryGetValue("status", out object progress);
-                /*if (name.ToString().Equals("Exam", StringComparison.OrdinalIgnoreCase))
-                {
-                    ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
-                    if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(exam.startTime) > 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(exam.endTime) < 0)
-                    {
-                        exam.progress = "going";
-                    }
-                    else if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(exam.endTime) > 0)
-                    {
-                        exam.progress = "finish";
-                    }
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{code}"));
-                }*/
             }
             catch (Exception ex)
             {
@@ -69,7 +51,7 @@ namespace TEAMModelFunction
 
         }
         [FunctionName("Vote")]
-        public async Task Vote([ServiceBusTrigger("active-task", "vote", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        public async Task Vote([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "vote", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
         {
             try
             {
@@ -82,29 +64,6 @@ namespace TEAMModelFunction
                 Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(id.ToString(), new PartitionKey($"{code}"));
                 vote.progress = progress.ToString();
                 await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(vote, id.ToString(), new PartitionKey($"{code}"));
-                /*keyValuePairs.TryGetValue("id", out object id);
-                keyValuePairs.TryGetValue("name", out object name);
-                keyValuePairs.TryGetValue("code", out object code);*/
-                //keyValuePairs.TryGetValue("status", out object progress);
-                /*if (name.ToString().Equals("Vote", StringComparison.OrdinalIgnoreCase))
-                {
-                    Vote vote;
-                    var sresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"{code}"));
-                    if (sresponse.Status == 200)
-                    {
-                        using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
-                        vote = json.ToObject<Vote>();
-                        if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(vote.startTime) > 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(vote.endTime) < 0)
-                        {
-                            vote.progress = "going";
-                        }
-                        else if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(vote.endTime) > 0)
-                        {
-                            vote.progress = "finish";
-                        }
-                        await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(vote, id.ToString(), new PartitionKey($"{code}"));
-                    }
-                }*/
             }
             catch (Exception ex)
             {
@@ -113,7 +72,7 @@ namespace TEAMModelFunction
 
         }
         [FunctionName("Survey")]
-        public async Task Survey([ServiceBusTrigger("active-task", "survey", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        public async Task Survey([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "survey", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
         {
             try
             {
@@ -126,23 +85,6 @@ namespace TEAMModelFunction
                 Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(id.ToString(), new PartitionKey($"{code}"));
                 survey.progress = progress.ToString();
                 await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey, id.ToString(), new PartitionKey($"{code}"));
-                /*keyValuePairs.TryGetValue("id", out object id);
-                keyValuePairs.TryGetValue("name", out object name);
-                keyValuePairs.TryGetValue("code", out object code);*/
-                //keyValuePairs.TryGetValue("status", out object progress);
-                /*if (name.ToString().Equals("Survey", StringComparison.OrdinalIgnoreCase))
-                {
-                    Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(id.ToString(), new PartitionKey($"{code}"));
-                    if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(survey.startTime) > 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(survey.endTime) < 0)
-                    {
-                        survey.progress = "going";
-                    }
-                    else if (DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().CompareTo(survey.endTime) > 0)
-                    {
-                        survey.progress = "finish";
-                    }
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey, id.ToString(), new PartitionKey($"{code}"));
-                }*/
             }
             catch (Exception ex)
             {
@@ -150,7 +92,7 @@ namespace TEAMModelFunction
             }
         }
         [FunctionName("Blob")]
-        public async Task Blob([ServiceBusTrigger("active-task", "blob", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
+        public async Task Blob([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "blob", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
             try
             {
                // await _dingDing.SendBotMsg($"ServiceBus,Blob(){msg}", GroupNames.醍摩豆服務運維群組);

+ 1 - 1
TEAMModelFunction/NoticeServiceBus.cs

@@ -28,7 +28,7 @@ namespace TEAMModelFunction
             _serviceBus = serviceBus;
         }
         [FunctionName("Notice")]
-        public async  Task Notice([ServiceBusTrigger("notice-task", "notice", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
+        public async  Task Notice([ServiceBusTrigger("%Azure:ServiceBus:NoticeTask%", "notice", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
            var client = _azureRedis.GetRedisClient(8);
             try {
 

+ 1 - 1
TEAMModelFunction/StuListServiceBus.cs

@@ -51,7 +51,7 @@ namespace TEAMModelFunction
         /// <param name="msg"></param>
         /// <returns></returns>
         [FunctionName("StuList")]
-        public async Task StuList([ServiceBusTrigger("active-task", "stulist", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        public async Task StuList([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "stulist", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
         {
             var client = _azureCosmos.GetCosmosClient();
             try

+ 7 - 46
TEAMModelFunction/TriggerExam.cs

@@ -69,15 +69,15 @@ namespace TEAMModelFunction
                     message.ApplicationProperties.Add("name", "Exam");
                     if (records.Count > 0)
                     {
-                        await _serviceBus.GetServiceBusClient().cancelMessage("active-task", records[0].sequenceNumber);
-                        long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
+                        await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
+                        long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
                         records[0].sequenceNumber = start;
                         await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
                         //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
                     }
                     else
                     {
-                        long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
+                        long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
                         ChangeRecord changeRecord = new ChangeRecord
                         {
                             RowKey = input.Id,
@@ -90,45 +90,6 @@ namespace TEAMModelFunction
                     }
                     break;
                 case "going":
-                    //ActivityData data;
-                    //if (info.scope == "school")
-                    //{
-                    //    data = new ActivityData
-                    //    {
-                    //        id = info.id,
-                    //        code = $"Activity-{info.school}",
-                    //        type = "exam",
-                    //        name = info.name,
-                    //        startTime = info.startTime,
-                    //        endTime = info.endTime,
-                    //        scode = info.code,
-                    //        scope = info.scope,
-                    //        classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
-                    //        tmdids =  new List<string> { "" },
-                    //        progress = "going",
-                    //        subjects = sub
-                    //    };
-                    //    await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
-                    //}
-                    //else if (info.scope == "private")
-                    //{
-                    //    data = new ActivityData
-                    //    {
-                    //        id = info.id,
-                    //        code = $"Activity-Common",
-                    //        type = "exam",
-                    //        name = info.name,
-                    //        startTime = info.startTime,
-                    //        endTime = info.endTime,
-                    //        scode = info.code,
-                    //        scope = info.scope,
-                    //        progress = "going",
-                    //        classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
-                    //        tmdids = new List<string> { "" },
-                    //        subjects = sub
-                    //    };
-                    //    await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
-                    //}
                     (List<string> tmdids, List<Students> studentss) = await TriggerStuActivity.GetStuList(client, info.classes, info.school);
                     List<StuActivity> stuActivities = new List<StuActivity>();
                     List<StuActivity> tmdActivities = new List<StuActivity>();
@@ -198,7 +159,7 @@ namespace TEAMModelFunction
                     };
                     //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
                     //messageBlob.ApplicationProperties.Add("name", "Notice");
-                    //await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+                    //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:NoticeTask"), messageBlob);
                     #endregion
                     if (examClassResults.Count == 0)
                     {
@@ -321,15 +282,15 @@ namespace TEAMModelFunction
                         messageEnd.ApplicationProperties.Add("name", "Exam");
                         if (records.Count > 0)
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage("active-task", records[0].sequenceNumber);
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
+                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
                             records[0].sequenceNumber = end;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
                             //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
                         }
                         else
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(etime));
                             ChangeRecord changeRecord = new ChangeRecord
                             {
                                 RowKey = input.Id,

+ 7 - 20
TEAMModelFunction/TriggerSurvey.cs

@@ -41,19 +41,6 @@ namespace TEAMModelFunction
                 adcode = $"Activity-{tdata.creatorId}";
                  blobcntr = tdata.creatorId;
             }
-            //ActivityData data = null;
-            //try
-            //{
-            //    if (tdata.scope == "school")
-            //    {
-            //        data = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
-            //    }
-            //    else if (tdata.scope == "private")
-            //    {
-            //        data = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
-            //    }
-            //}
-            //catch { data = null; }
             Survey survey = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Survey>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
             List<ChangeRecord> changeRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", survey.progress } });
             if (survey != null) {
@@ -64,14 +51,14 @@ namespace TEAMModelFunction
                         messageSurvey.ApplicationProperties.Add("name", "Survey");
                         if (changeRecords.Count > 0)
                         {
-                            await _serviceBus.GetServiceBusClient().cancelMessage("active-task", changeRecords[0].sequenceNumber);
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurvey, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), changeRecords[0].sequenceNumber);
+                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageSurvey, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
                             changeRecords[0].sequenceNumber = start;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(changeRecords[0]);
                         }
                         else
                         {
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurvey, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageSurvey, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
                             ChangeRecord changeRecord = new ChangeRecord
                             {
                                 RowKey = input.Id,
@@ -150,7 +137,7 @@ namespace TEAMModelFunction
                         };
                         //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
                         //messageBlob.ApplicationProperties.Add("name", "Notice");
-                        //await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+                        //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:NoticeTask"), messageBlob);
                         #endregion
 #if DEBUG
                         await _dingDing.SendBotMsg($"问卷调查{tdata.id}写入完成!", GroupNames.成都开发測試群組);
@@ -159,14 +146,14 @@ namespace TEAMModelFunction
                         messageSurveyEnd.ApplicationProperties.Add("name", "Survey");
                         if (changeRecords.Count > 0)
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage("active-task", changeRecords[0].sequenceNumber);
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), changeRecords[0].sequenceNumber);
                             changeRecords[0].sequenceNumber = end;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(changeRecords[0]);
                         }
                         else
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageSurveyEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
                             ChangeRecord changeRecord = new ChangeRecord
                             {
                                 RowKey = input.Id,

+ 8 - 36
TEAMModelFunction/TriggerVote.cs

@@ -40,22 +40,6 @@ namespace TEAMModelFunction
                 adcode = $"Activity-{tdata.creatorId}";
                 blobcntr = tdata.creatorId;
             }
-            // ActivityData data = null;
-            //try
-            //{
-            //    if (tdata.scope == "school")
-            //    {
-            //        data = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
-            //    }
-            //    else if (tdata.scope == "private")
-            //    {
-            //        data = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
-            //    }
-            //}
-            //catch
-            //{
-            //    data = null;
-            //}
 #if DEBUG
             await _dingDing.SendBotMsg($"投票活动【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在操作", GroupNames.成都开发測試群組);
 #endif
@@ -69,14 +53,14 @@ namespace TEAMModelFunction
                         messageVote.ApplicationProperties.Add("name", "Vote");
                         if (voteRecords.Count > 0)
                         {
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageVote, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage("active-task", voteRecords[0].sequenceNumber);
+                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageVote, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), voteRecords[0].sequenceNumber);
                             voteRecords[0].sequenceNumber = start;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(voteRecords[0]);
                         }
                         else
                         {
-                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageVote, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
+                            long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageVote, DateTimeOffset.FromUnixTimeMilliseconds(tdata.stime));
                             ChangeRecord changeRecord = new ChangeRecord
                             {
                                 RowKey = input.Id,
@@ -158,23 +142,23 @@ namespace TEAMModelFunction
                             body = new Body { sid = vote.id, scode = vote.code, spk = vote.pk,  biztype = "vote-join" }
 
                         };
-                      
+
                         //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
                         //messageBlob.ApplicationProperties.Add("name", "Notice");
-                        //await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+                        //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:NoticeTask"), messageBlob);
                         #endregion
                         var messageVoteEnd = new ServiceBusMessage(new { id = input.Id, progress = "finish", code = tdata.code }.ToJsonString());
                         messageVoteEnd.ApplicationProperties.Add("name", "Vote");
                         if (voteRecords.Count > 0)
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageVoteEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
-                            await _serviceBus.GetServiceBusClient().cancelMessage("active-task", voteRecords[0].sequenceNumber);
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageVoteEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                            await _serviceBus.GetServiceBusClient().cancelMessage(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), voteRecords[0].sequenceNumber);
                             voteRecords[0].sequenceNumber = end;
                             await _azureStorage.SaveOrUpdate<ChangeRecord>(voteRecords[0]);
                         }
                         else
                         {
-                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", messageVoteEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
+                            long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageVoteEnd, DateTimeOffset.FromUnixTimeMilliseconds(tdata.etime));
                             ChangeRecord changeRecord = new ChangeRecord
                             {
                                 RowKey = input.Id,
@@ -234,18 +218,6 @@ namespace TEAMModelFunction
                             break; 
                         }
                         await Task.WhenAll(tasks);
-                        //data.progress = "finish";
-                        //更新结束状态
-                        //if (vote.scope == "school")
-                        //{
-                        //    await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
-                        //}
-                        //else if (vote.scope == "private")
-                        //{
-                        //    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
-                        //}
-                        //_azureRedis.GetRedisClient(8).KeyDelete($"Vote:Record:{vote.id}");
-                        //_azureRedis.GetRedisClient(8).KeyDelete($"Vote:Count:{vote.id}");
                         break;
                 }
             }

+ 8 - 4
TEAMModelFunction/local.settings.json

@@ -4,10 +4,14 @@
     "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
     "Azure:Storage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn",
     "Azure:ServiceBus:ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
-    "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;",
-    "Azure:Redis:ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False",
-    "Azure:ServiceBus:ActiveTask": "active-task",
-    "Azure:ServiceBus:NoticeTask": "notice-task",
+    //"Azure:Cosmos:ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;",
+    //"Azure:Redis:ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False",
+    //"Azure:ServiceBus:ActiveTask": "active-task",
+    //"Azure:ServiceBus:NoticeTask": "notice-task",
+    "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
+    "Azure:Redis:ConnectionString": "106.12.23.251:6379,password=habook,ssl=True,abortConnect=False",
+    "Azure:ServiceBus:ActiveTask": "dep-active-task",
+    "Azure:ServiceBus:NoticeTask": "dep-notice-task",
     "FUNCTIONS_WORKER_RUNTIME": "dotnet"
   }  
 }

+ 9 - 4
TEAMModelOS/Controllers/Core/BlobController.cs

@@ -33,12 +33,14 @@ namespace TEAMModelOS.Controllers.Core
         private readonly IHttpClientFactory _clientFactory;
         private readonly AzureRedisFactory _azureRedis;
         private readonly AzureServiceBusFactory _serviceBus;
-        public BlobController(AzureStorageFactory azureStorage, AzureServiceBusFactory serviceBus, IHttpClientFactory clientFactory, AzureRedisFactory azureRedis)
+        public IConfiguration _configuration { get; set; }
+        public BlobController(AzureStorageFactory azureStorage, AzureServiceBusFactory serviceBus, IHttpClientFactory clientFactory, AzureRedisFactory azureRedis, IConfiguration configuration)
         {
             _azureStorage = azureStorage;
             _clientFactory = clientFactory;
             _serviceBus = serviceBus;
             _azureRedis = azureRedis;
+            _configuration = configuration;
         }
 
         /// <summary>
@@ -129,7 +131,8 @@ namespace TEAMModelOS.Controllers.Core
                 }
                 var messageBlob = new ServiceBusMessage(new { id = Guid.NewGuid().ToString(), progress = "update", name = blobContainerName }.ToJsonString());
                 messageBlob.ApplicationProperties.Add("name", "Blob");
-                await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+                var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
                 return Ok(new { status, catalog,size=useSize });
             }
             else {
@@ -214,7 +217,8 @@ namespace TEAMModelOS.Controllers.Core
                     }
                     var messageBlob = new ServiceBusMessage(new { id = Guid.NewGuid().ToString(), progress = "update", name = blobContainerName }.ToJsonString());
                     messageBlob.ApplicationProperties.Add("name", "Blob");
-                    await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+                    var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                    await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
                     return Ok(new { status,size= useSize,catalog });
                 }
                 else
@@ -410,7 +414,8 @@ namespace TEAMModelOS.Controllers.Core
             }
             var messageBlob = new ServiceBusMessage(new {id=Guid.NewGuid().ToString(), progress = "update",name=name}.ToJsonString());
             messageBlob.ApplicationProperties.Add("name", "Blob");
-            await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageBlob);
+            var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+            await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
             return Ok(new { size=useSize, catalog });
         }
 

+ 8 - 3
TEAMModelOS/Controllers/School/CourseController.cs

@@ -23,6 +23,7 @@ using System.Dynamic;
 using Azure;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
 using Azure.Messaging.ServiceBus;
+using Microsoft.Extensions.Configuration;
 
 namespace TEAMModelOS.Controllers
 {
@@ -37,12 +38,14 @@ namespace TEAMModelOS.Controllers
         private readonly DingDing _dingDing;
         private readonly Option _option;
         private readonly AzureServiceBusFactory _serviceBus;
-        public CourseController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option , AzureServiceBusFactory serviceBus)
+        public IConfiguration _configuration { get; set; }
+        public CourseController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option , AzureServiceBusFactory serviceBus, IConfiguration configuration)
         {
             _azureCosmos = azureCosmos;
             _dingDing = dingDing;
             _option = option?.Value;
             _serviceBus = serviceBus;
+            _configuration = configuration;
         }
 
         /// <summary>
@@ -258,7 +261,8 @@ namespace TEAMModelOS.Controllers
                         }
                         var messageChange = new ServiceBusMessage(change.ToJsonString());
                         messageChange.ApplicationProperties.Add("name", "StuList");
-                        await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageChange);
+                        var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                        await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                     }
                     stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").UpsertItemAsync(stuList, new PartitionKey($"StuList-{originCode}"));
                 }
@@ -326,7 +330,8 @@ namespace TEAMModelOS.Controllers
                         }
                         var messageChange = new ServiceBusMessage(change.ToJsonString());
                         messageChange.ApplicationProperties.Add("name", "StuList");
-                        await _serviceBus.GetServiceBusClient().SendMessageAsync("active-task", messageChange);
+                        var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                        await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                     }
                     stuList.code = "StuList";
                     stuList = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(stuList, new PartitionKey($"StuList"));