Function1.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //using System;
  2. //using System.IO;
  3. //using System.Threading.Tasks;
  4. //using Microsoft.AspNetCore.Mvc;
  5. //using Microsoft.AspNetCore.Http;
  6. //using Microsoft.Extensions.Logging;
  7. //using Newtonsoft.Json;
  8. //using Microsoft.Azure.Functions.Worker;
  9. //using Microsoft.Azure.Functions.Worker.Http;
  10. //using System.Collections.Generic;
  11. //using System.Net;
  12. //using TEAMModelOS.SDK.DI;
  13. //using TEAMModelOS.SDK.Models;
  14. //using TEAMModelOS.SDK.Extension;
  15. //using System.Text.Json;
  16. //using Microsoft.Azure.Documents;
  17. //namespace FunctionApp1
  18. //{
  19. // public class Function1
  20. // {
  21. // private readonly AzureCosmosFactory _azureCosmos;
  22. // public Function1(AzureCosmosFactory azureCosmos)
  23. // {
  24. // _azureCosmos = azureCosmos;
  25. // }
  26. // [Function("GroupChange")]
  27. // public async Task GroupChangeFunc([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "group-change", Connection = "Azure:ServiceBus:ConnectionString")] string msg)
  28. // {
  29. // try {
  30. // Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
  31. // teacher.name =$"GroupChange{ DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
  32. // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(teacher, teacher.id, new Azure.Cosmos.PartitionKey(teacher.code));
  33. // } catch (Exception ex) {
  34. // }
  35. // }
  36. // [Function("Function1")]
  37. // public async Task<HttpResponseData> Run(
  38. // [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,
  39. // FunctionContext context)
  40. // {
  41. // var log= context.GetLogger<Function1>();
  42. // string name = req.ReadAsString();
  43. // string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
  44. // dynamic data = JsonConvert.DeserializeObject(requestBody);
  45. // name = name ?? data?.name;
  46. // string responseMessage = string.IsNullOrEmpty(name)
  47. // ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
  48. // : $"Hello, {name}. This HTTP triggered function executed successfully.";
  49. // var response = req.CreateResponse(HttpStatusCode.OK);
  50. // //response.Headers.Add("Content-Type", "application/json; charset=utf-8");
  51. // Teacher teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>("1595321354", new Azure.Cosmos.PartitionKey("Base"));
  52. // log.LogInformation(teacher.ToJsonString());
  53. // await response.WriteAsJsonAsync(teacher);
  54. // return response;
  55. // }
  56. // }
  57. //}