zhouj1203@hotmail.com 4 năm trước cách đây
mục cha
commit
112b40162a

+ 18 - 13
TEAMModelFunction/MonitorCosmosDB.cs

@@ -29,11 +29,11 @@ namespace TEAMModelFunction
             _azureStorage = azureStorage;
         }
 
-        [FunctionName("ActiveChange")]
-        public async Task School([CosmosDBTrigger(
+        [FunctionName("Common")]
+        public async Task Common([CosmosDBTrigger(
             databaseName: "TEAMModelOS",
             collectionName: "Common",
-            ConnectionStringSetting = "AzureServiceCosmosConnectionString",
+            ConnectionStringSetting = "Azure:Cosmos:ConnectionString",
             LeaseCollectionName = "leases")]IReadOnlyList<Document> input, ILogger log)
         {
             if (input != null && input.Count > 0)
@@ -41,7 +41,7 @@ namespace TEAMModelFunction
                 log.LogInformation("Documents modified " + input.Count);
                 log.LogInformation("First document Id " + input[0].Id);
             }
-            string pk = input[0].GetPropertyValue<string>("pk");          
+            string pk = input[0].GetPropertyValue<string>("pk");
             if (!string.IsNullOrEmpty(pk))
             {
                 var client = _azureCosmos.GetCosmosClient();
@@ -49,9 +49,10 @@ namespace TEAMModelFunction
                 long etime = input[0].GetPropertyValue<long>("endTime");
                 string school = input[0].GetPropertyValue<string>("school");
                 string code = input[0].GetPropertyValue<string>("code");
-                switch (pk) {
+                switch (pk)
+                {
                     case "Exam":
-                        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(input[0].Id,new Azure.Cosmos.PartitionKey($"{code}"));
+                        ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(input[0].Id, new Azure.Cosmos.PartitionKey($"{code}"));
                         List<ExamClassResult> examClassResults = new List<ExamClassResult>();
                         await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{school}") }))
                         {
@@ -67,7 +68,8 @@ namespace TEAMModelFunction
                        
                         List<ChangeRecord> records = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input[0].Id }, { "PartitionKey", info.progress } });
                         //ChangeRecord record = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ChangeRecord>(input[0].Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));
-                        switch (info.progress) {
+                        switch (info.progress)
+                        {
                             case "pending":
                                 var message = new ServiceBusMessage(new { id = input[0].Id, progress = "going", code = code }.ToJsonString());
                                 message.Properties.Add("name", "Exam");
@@ -79,7 +81,8 @@ namespace TEAMModelFunction
                                     await _azureStorage.SaveOrUpdate<ChangeRecord>(records[0]);
                                     //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
                                 }
-                                else {
+                                else
+                                {
                                     long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync("active-task", message, DateTimeOffset.FromUnixTimeMilliseconds(stime));
                                     ChangeRecord changeRecord = new ChangeRecord
                                     {
@@ -90,10 +93,11 @@ namespace TEAMModelFunction
                                     };
                                     await _azureStorage.Save<ChangeRecord>(changeRecord);
                                     //await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
-                                }                                
+                                }
                                 break;
                             case "going":
-                                if (examClassResults.Count < 0) {
+                                if (examClassResults.Count < 0)
+                                {
                                     for (int j = 0; j < info.subjects.Count; j++)
                                     {
                                         for (int k = 0; k < info.targetClassIds.Count; k++)
@@ -219,13 +223,14 @@ namespace TEAMModelFunction
                                     await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{result.school}"));
                                 }
                                 break;
-                        }                       
+                        }
                         break;
                     case "Vote":
                         Vote vote = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Vote>(input[0].Id, new Azure.Cosmos.PartitionKey($"{code}"));                       
                         List<ChangeRecord> voteRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input[0].Id }, { "PartitionKey", vote.progress } });
                         //ChangeRecord voteRecord = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ChangeRecord>(input[0].Id, new Azure.Cosmos.PartitionKey($"{vote.progress}"));
-                        switch (vote.progress) {
+                        switch (vote.progress)
+                        {
                             case "pending":
                                 var messageVote = new ServiceBusMessage(new { id = input[0].Id, progress = "going", code = code }.ToJsonString());
                                 messageVote.Properties.Add("name", "Vote");
@@ -338,7 +343,7 @@ namespace TEAMModelFunction
                         }
                         break;
 
-                }               
+                }
             }
         }
     }

+ 123 - 6
TEAMModelFunction/MonitorServicesBus.cs

@@ -1,17 +1,134 @@
 using System;
+using System.Collections.Generic;
+using System.Text.Json;
+using System.Threading.Tasks;
+using Azure.Cosmos;
 using Microsoft.Azure.WebJobs;
 using Microsoft.Azure.WebJobs.Host;
 using Microsoft.Extensions.Logging;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
 
 namespace TEAMModelFunction
 {
-    public static class MonitorServicesBus
+    public class MonitorServicesBus
     {
-/*        [FunctionName("test_queue_activetask")]
-        public static void Run([ServiceBusTrigger("test_topic_ActiveTask", Connection = "ServiceBusConnection")]string myQueueItem, ILogger log)
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        public MonitorServicesBus(AzureCosmosFactory azureCosmos, DingDing dingDing)
         {
-            ///ÖØÊÔ´ÎÊý
-            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
-        }*/
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+        }
+        [FunctionName("Exam")]
+        public async Task Exam([ServiceBusTrigger("active-task", "exam", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        {
+            try
+            {
+                var json = JsonDocument.Parse(msg);
+                json.RootElement.TryGetProperty("id", out JsonElement id);
+                json.RootElement.TryGetProperty("name", out JsonElement name);
+                json.RootElement.TryGetProperty("code", out JsonElement code);
+                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
+                var client = _azureCosmos.GetCosmosClient();
+                /*                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)
+            {
+                await _dingDing.SendBotMsg($"ServiceBus,ExamBus()\n{ex.Message}", GroupNames.�摩豆�務�維群組);
+            }
+
+        }
+        [FunctionName("Vote")]
+        public async Task Vote([ServiceBusTrigger("active-task", "vote", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        {
+            try
+            {
+                var jsonMsg = JsonDocument.Parse(msg);
+                jsonMsg.RootElement.TryGetProperty("id", out JsonElement id);
+                jsonMsg.RootElement.TryGetProperty("name", out JsonElement name);
+                jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
+                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
+                var client = _azureCosmos.GetCosmosClient();
+                /*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)
+            {
+                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.�摩豆�務�維群組);
+            }
+
+        }
+        [FunctionName("Survey")]
+        public async Task Survey([ServiceBusTrigger("active-task", "survey", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
+        {
+            try
+            {
+                var jsonMsg = JsonDocument.Parse(msg);
+                jsonMsg.RootElement.TryGetProperty("id", out JsonElement id);
+                jsonMsg.RootElement.TryGetProperty("name", out JsonElement name);
+                jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
+                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
+                var client = _azureCosmos.GetCosmosClient();
+                /*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)
+            {
+                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.�摩豆�務�維群組);
+            }
+        }
     }
 }

+ 0 - 126
TEAMModelFunction/ServiceBusTopic.cs

@@ -1,126 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Azure.Cosmos;
-using Microsoft.Azure.WebJobs;
-using Microsoft.Azure.WebJobs.Host;
-using Microsoft.Extensions.Logging;
-using TEAMModelOS.SDK.DI;
-using TEAMModelOS.SDK.Extension;
-
-namespace TEAMModelFunction
-{
-    public  class ServiceBusTopic
-    {
-        private readonly AzureCosmosFactory _azureCosmos;
-        private readonly DingDing _dingDing;
-        public ServiceBusTopic(  AzureCosmosFactory azureCosmos, DingDing dingDing)
-        {
-            _azureCosmos = azureCosmos;
-            _dingDing = dingDing;
-        }
-        [FunctionName("exam")]
-        public async Task ExamBus([ServiceBusTrigger("active-task", "exam", Connection = "AzureServiceBusConnectionString")] string mySbMsg)
-        {
-            try
-            {
-                var json = JsonDocument.Parse(mySbMsg);                
-                json.RootElement.TryGetProperty("id", out JsonElement id);
-                json.RootElement.TryGetProperty("progress", out JsonElement progress);
-                json.RootElement.TryGetProperty("code", out JsonElement code);
-                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
-                var client = _azureCosmos.GetCosmosClient();
-/*                keyValuePairs.TryGetValue("id", out object id);
-                keyValuePairs.TryGetValue("name", out object name);
-                keyValuePairs.TryGetValue("code", out object code);*/
-                //keyValuePairs.TryGetValue("status", out object progress);
-                    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 = progress.ToString(); ;
-/*                    }
-                    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) {
-                await _dingDing.SendBotMsg($"ServiceBus,ExamBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);               
-            }
-                              
-        }
-        [FunctionName("vote")]
-        public async Task VoteBus([ServiceBusTrigger("active-task", "vote", Connection = "AzureServiceBusConnectionString")] string mySbMsg)
-        {
-            try {
-                var jsonMsg = JsonDocument.Parse(mySbMsg);
-                jsonMsg.RootElement.TryGetProperty("id", out JsonElement id);
-                jsonMsg.RootElement.TryGetProperty("progress", out JsonElement progress);
-                jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
-                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
-                var client = _azureCosmos.GetCosmosClient();
-                /*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>();
-                        vote.progress = progress.ToString();
-                    /*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){
-                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);               
-            }
-                         
-        }
-        [FunctionName("survey")]
-        public async Task SurveyBus([ServiceBusTrigger("active-task", "survey", Connection = "AzureServiceBusConnectionString")] string mySbMsg)
-        {
-            try {
-                var jsonMsg = JsonDocument.Parse(mySbMsg);
-                jsonMsg.RootElement.TryGetProperty("id", out JsonElement id);
-                jsonMsg.RootElement.TryGetProperty("progress", out JsonElement progress);
-                jsonMsg.RootElement.TryGetProperty("code", out JsonElement code);
-                //Dictionary<string, object> keyValuePairs = mySbMsg.ToObject<Dictionary<string, object>>();
-                var client = _azureCosmos.GetCosmosClient();
-                /*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";
-                }*/
-                    survey.progress = progress.ToString();
-                    await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(survey, id.ToString(), new PartitionKey($"{code}"));
-                //}
-            }
-            catch (Exception ex){
-                await _dingDing.SendBotMsg($"ServiceBus,VoteBus()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);                
-            }                       
-        }
-    }
-}

+ 12 - 13
TEAMModelFunction/Startup.cs

@@ -16,22 +16,21 @@ namespace TEAMModelFunction
     { 
         public override void Configure(IFunctionsHostBuilder builder)
         {
-            var ConnectionString = System.Environment.GetEnvironmentVariable("AzureServiceCosmosConnectionString");
-            var ScanModel = System.Environment.GetEnvironmentVariable("ScanModel");
-            var Database = System.Environment.GetEnvironmentVariable("Database");
-            var ServiceBusConnectionString = System.Environment.GetEnvironmentVariable("AzureServiceBusConnectionString");
-            var AzureStarageConnectionString = System.Environment.GetEnvironmentVariable("AzureStarageConnectionString");
+            var ConnectionString = Environment.GetEnvironmentVariable("Azure:Cosmos:ConnectionString");
+            var ScanModel = Environment.GetEnvironmentVariable("ScanModel");
+            var Database = Environment.GetEnvironmentVariable("Database");  
+            
             builder.Services.AddHttpClient();
-            builder.Services.AddAzureCosmos(new AzureCosmosFactoryOptions 
-            { 
-                ConnectionString= ConnectionString,
-                Name= "Default",
-                ScanModel= ScanModel.Split(","),
+            builder.Services.AddHttpClient<DingDing>();
+            builder.Services.AddAzureServiceBus(Environment.GetEnvironmentVariable("Azure:ServiceBus:ConnectionString"));
+            builder.Services.AddAzureStorage(Environment.GetEnvironmentVariable("Azure:Starage:ConnectionString"));
+            builder.Services.AddAzureCosmos(new AzureCosmosFactoryOptions
+            {
+                ConnectionString = ConnectionString,
+                Name = "Default",
+                ScanModel = ScanModel.Split(","),
                 Database = Database.Split(","),
             });
-            builder.Services.AddAzureServiceBus(ServiceBusConnectionString);
-            builder.Services.AddHttpClient<DingDing>();
-            builder.Services.AddAzureStorage(AzureStarageConnectionString);
         }
     }
 }

+ 3 - 3
TEAMModelFunction/TEAMModelFunction.csproj

@@ -7,9 +7,9 @@
     <Compile Remove="AServiceBus.cs" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
-    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.7" />
-    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.2" />
+    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
+    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.8" />
+    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.2.0" />
     <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
     <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
     <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.1.6" />

+ 9 - 2
TEAMModelFunction/host.json

@@ -1,10 +1,17 @@
 {
   "version": "2.0",
+  "cosmosDB": {
+    "connectionMode": "Direct",
+    "protocol": "Tcp"
+  },
   "logging": {
+    "console": {
+      "isEnabled": "true"
+    },
     "applicationInsights": {
-      "samplingExcludedTypes": "Request",
       "samplingSettings": {
-        "isEnabled": true
+        "isEnabled": true,
+        "ExcludedTypes": "Request"
       }
     }
   }

+ 4 - 4
TEAMModelFunction/local.settings.json

@@ -1,11 +1,11 @@
 {
   "IsEncrypted": false,
   "Values": {
-    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
+    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
+    "Azure:Starage: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==;",
     "FUNCTIONS_WORKER_RUNTIME": "dotnet",
-    "AzureServiceBusConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
-    "AzureServiceCosmosConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;",
-    "AzureStarageConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn",
     "ScanModel": "TEAMModelOS",
     "Database": "TEAMModelOS"
   }  

+ 12 - 14
TEAMModelFunction/model/Classroom.cs

@@ -10,8 +10,7 @@ using TEAMModelOS.SDK.Context.Attributes.Azure;
 using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelFunction
-{
-    //[CosmosDB(Database = "TEAMModelOS", Name = "School")]
+{    
     public class Classroom:ID
     {
         public string pk { get; set; }
@@ -24,35 +23,34 @@ namespace TEAMModelFunction
         [JsonPropertyName("id")]
         public string id { get; set; }
         public float x { get; set; }
-        //[ProtoMember(2)]
+       
         public float y { get; set; }
-        [ProtoMember(5)]
+        
         public string name { get; set; }
-        [ProtoMember(6)]
+       
         public Teachers teacher { get; set; }
-        [ProtoMember(7)]
+        
         public string periodId { get; set; }
-        [ProtoMember(8)]
+        
         public string gradeId { get; set; }
-        [ProtoMember(9)]
+        
         public string sn { get; set; }
-        /*[ProtoMember(10)]
-        public int studentCount { get; set; }*/
+        
+        public int studentCount { get; set; }
         public List<StudentSimple> students { get; set; }
         /// <summary>
         /// TBL IRS 类型区分
         /// </summary>
-        [ProtoMember(11)]
+       
         public string style { get; set; }
-        [ProtoMember(12)]
+        
         public int status { get; set; } = 1;
         /// <summary>
         /// </summary>
         /*[ProtoMember(13)]
         [Required(ErrorMessage = "{0} 必须填写,请设置个人教室还是学校教室")]
         public int type { get; set; } = 1;*/
-        [PartitionKey]
-        [Required(ErrorMessage = "{0} 必须填写")]
+        [PartitionKey]        
         public string code { get; set; }
         /// <summary>
         /// 教室属性,普通 /专设的教室

+ 2 - 3
TEAMModelFunction/model/ExamClassResult.cs

@@ -6,8 +6,7 @@ using TEAMModelOS.SDK.Context.Attributes.Azure;
 using TEAMModelOS.SDK.DI;
 
 namespace TEAMModelFunction
-{
-    //[CosmosDB(Database = "TEAMModelOS", Name = "Common")]
+{   
     public class ExamClassResult : ID
     {
         public ExamClassResult() {
@@ -32,7 +31,7 @@ namespace TEAMModelFunction
         //public PaperSimple paper { get; set; }
         //public List<double> point { get; set; }
         public List<string> studentIds { get; set; }
-        public List<List<List<string>>> studentAnswers { get; set; }
+        public List<List<List<string>>> studentAnswers { get; set; } = new List<List<List<string>>>();
         public List<List<double>> studentScores { get; set; }
         public string scope { get; set; }
         public int? ttl { get; set; }

+ 1 - 2
TEAMModelFunction/model/ExamInfo.cs

@@ -12,8 +12,7 @@ namespace TEAMModelFunction
 {
     /// <summary>
     /// 考试基础信息
-    /// </summary>
-    //[CosmosDB(Database = "TEAMModelOS", Name = "School")]
+    /// </summary>   
     public class ExamInfo : ID
     {
         [PartitionKey]

+ 1 - 2
TEAMModelFunction/model/ExamResult.cs

@@ -9,8 +9,7 @@ namespace TEAMModelFunction
 {
     /// <summary>
     /// 考试成绩信息
-    /// </summary>
-    //[CosmosDB(Database = "TEAMModelOS", Name = "School")]
+    /// </summary>    
     public  class ExamResult:ID
     {
         [PartitionKey]

+ 4 - 4
TEAMModelFunction/model/Survey.cs

@@ -11,7 +11,7 @@ namespace TEAMModelFunction
     /// <summary>
     /// 问卷调查
     /// </summary>
-    [CosmosDB(Database = "TEAMModelOS",Name = "School")]
+    
     public class Survey : ID
     {
         public Survey() {
@@ -47,19 +47,19 @@ namespace TEAMModelFunction
         /// <summary>
         /// 发布模式 0 立即发布 1 定时
         /// </summary>
-        [ProtoMember(5)]
+       
         public string publishModel { get; set; }
 
         /// <summary>
         /// 开始时间
         /// </summary>
-        [ProtoMember(6)]
+       
         public long startTime { get; set; }
 
         /// <summary>
         /// 结束时间
         /// </summary>
-        [ProtoMember(7)]
+        
         public long endTime { get; set; }
         public long createTime { get; set; } // 问卷发布时间
         public List<Classes> classes { get; set; }

+ 7 - 7
TEAMModelFunction/model/Vote.cs

@@ -24,12 +24,12 @@ namespace TEAMModelFunction
 
         }
 
-        [ProtoMember(1)]
+       
         public string id { get; set; }
         /// <summary>
         /// 投票名称
         /// </summary>
-        [ProtoMember(3)]
+       
         public string name { get; set; }
         public string school { get; set; }
         public string creatorId { get; set; }
@@ -44,27 +44,27 @@ namespace TEAMModelFunction
         /// <summary>
         /// 发布模式 0 立即发布 1 定时
         /// </summary>
-        [ProtoMember(5)]
+        
         public string publishModel { get; set; }
 
         /// <summary>
         /// 开始时间
         /// </summary>
-        [ProtoMember(6)]
+        
         public long startTime { get; set; }
         public long createTime { get; set; }
 
         /// <summary>
         /// 结束时间
         /// </summary>
-        [ProtoMember(7)]
+        
         public long endTime { get; set; }
 
 
         /// <summary>
         /// 投票描述
         /// </summary>
-        [ProtoMember(8)]
+        
         public string description { get; set; }
 
 
@@ -78,7 +78,7 @@ namespace TEAMModelFunction
         /// <summary>
         /// 状态 (100:待发布 200:已发布 300:已结束)
         /// </summary>
-        [ProtoMember(10)]
+        
         public int status { get; set; }