|
@@ -1,62 +1,62 @@
|
|
|
-using System;
|
|
|
-using System.IO;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using Microsoft.AspNetCore.Mvc;
|
|
|
-using Microsoft.AspNetCore.Http;
|
|
|
-using Microsoft.Extensions.Logging;
|
|
|
-using Newtonsoft.Json;
|
|
|
-using Microsoft.Azure.Functions.Worker;
|
|
|
-using Microsoft.Azure.Functions.Worker.Http;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Net;
|
|
|
-using TEAMModelOS.SDK.DI;
|
|
|
-using TEAMModelOS.SDK.Models;
|
|
|
-using TEAMModelOS.SDK.Extension;
|
|
|
-using System.Text.Json;
|
|
|
-using Microsoft.Azure.Documents;
|
|
|
+//using System;
|
|
|
+//using System.IO;
|
|
|
+//using System.Threading.Tasks;
|
|
|
+//using Microsoft.AspNetCore.Mvc;
|
|
|
+//using Microsoft.AspNetCore.Http;
|
|
|
+//using Microsoft.Extensions.Logging;
|
|
|
+//using Newtonsoft.Json;
|
|
|
+//using Microsoft.Azure.Functions.Worker;
|
|
|
+//using Microsoft.Azure.Functions.Worker.Http;
|
|
|
+//using System.Collections.Generic;
|
|
|
+//using System.Net;
|
|
|
+//using TEAMModelOS.SDK.DI;
|
|
|
+//using TEAMModelOS.SDK.Models;
|
|
|
+//using TEAMModelOS.SDK.Extension;
|
|
|
+//using System.Text.Json;
|
|
|
+//using Microsoft.Azure.Documents;
|
|
|
|
|
|
-namespace FunctionApp1
|
|
|
-{
|
|
|
- public class Function1
|
|
|
- {
|
|
|
- private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+//namespace FunctionApp1
|
|
|
+//{
|
|
|
+// public class Function1
|
|
|
+// {
|
|
|
+// private readonly AzureCosmosFactory _azureCosmos;
|
|
|
|
|
|
- public Function1(AzureCosmosFactory azureCosmos)
|
|
|
- {
|
|
|
- _azureCosmos = azureCosmos;
|
|
|
- }
|
|
|
+// public Function1(AzureCosmosFactory azureCosmos)
|
|
|
+// {
|
|
|
+// _azureCosmos = azureCosmos;
|
|
|
+// }
|
|
|
|
|
|
|
|
|
|
|
|
- [Function("GroupChange")]
|
|
|
- public async Task GroupChangeFunc([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "group-change", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
|
|
|
- {
|
|
|
- try {
|
|
|
- Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
|
|
|
- teacher.name =$"GroupChange{ DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(teacher, teacher.id, new Azure.Cosmos.PartitionKey(teacher.code));
|
|
|
- } catch (Exception ex) {
|
|
|
- }
|
|
|
- }
|
|
|
- [Function("Function1")]
|
|
|
- public async Task<HttpResponseData> Run(
|
|
|
- [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,
|
|
|
- FunctionContext context)
|
|
|
- {
|
|
|
- var log= context.GetLogger<Function1>();
|
|
|
- string name = req.ReadAsString();
|
|
|
- string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
- dynamic data = JsonConvert.DeserializeObject(requestBody);
|
|
|
- name = name ?? data?.name;
|
|
|
- string responseMessage = string.IsNullOrEmpty(name)
|
|
|
- ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
|
|
|
- : $"Hello, {name}. This HTTP triggered function executed successfully.";
|
|
|
- var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
- //response.Headers.Add("Content-Type", "application/json; charset=utf-8");
|
|
|
- Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
|
|
|
- log.LogInformation(teacher.ToJsonString());
|
|
|
- await response.WriteAsJsonAsync(teacher);
|
|
|
- return response;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+// [Function("GroupChange")]
|
|
|
+// public async Task GroupChangeFunc([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "group-change", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
|
|
|
+// {
|
|
|
+// try {
|
|
|
+// Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+// teacher.name =$"GroupChange{ DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
|
|
|
+// await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(teacher, teacher.id, new Azure.Cosmos.PartitionKey(teacher.code));
|
|
|
+// } catch (Exception ex) {
|
|
|
+// }
|
|
|
+// }
|
|
|
+// [Function("Function1")]
|
|
|
+// public async Task<HttpResponseData> Run(
|
|
|
+// [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,
|
|
|
+// FunctionContext context)
|
|
|
+// {
|
|
|
+// var log= context.GetLogger<Function1>();
|
|
|
+// string name = req.ReadAsString();
|
|
|
+// string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+// dynamic data = JsonConvert.DeserializeObject(requestBody);
|
|
|
+// name = name ?? data?.name;
|
|
|
+// string responseMessage = string.IsNullOrEmpty(name)
|
|
|
+// ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
|
|
|
+// : $"Hello, {name}. This HTTP triggered function executed successfully.";
|
|
|
+// var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
+// //response.Headers.Add("Content-Type", "application/json; charset=utf-8");
|
|
|
+// Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+// log.LogInformation(teacher.ToJsonString());
|
|
|
+// await response.WriteAsJsonAsync(teacher);
|
|
|
+// return response;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|