HomeModule.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Nancy;
  2. using Nancy.Json;
  3. using Nancy.ModelBinding;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace xicheji
  11. {
  12. public class HomeModule : NancyModule
  13. {
  14. public HomeModule()
  15. {
  16. Get("/hello", (req) =>
  17. {
  18. return "ok~";
  19. });
  20. Get("/update-test", (req) =>
  21. {
  22. Program.MainForm.UpdateTest(DateTime.Now);
  23. return "ok~";
  24. });
  25. Post("/update-car", (req) =>
  26. {
  27. var requestRoot = this.Bind<RequestRoot>();
  28. Program.MainForm.UpdateCar(requestRoot.AlarmInfoPlate.result.PlateResult);
  29. return JsonConvert.SerializeObject(new
  30. {
  31. Response_AlarmInfoPlate = new
  32. {
  33. info = "ok",
  34. content = "...",
  35. is_pay = "true",
  36. }
  37. });
  38. });
  39. }
  40. }
  41. public class RequestRoot
  42. {
  43. public Alarminfoplate AlarmInfoPlate { get; set; }
  44. }
  45. public class Alarminfoplate
  46. {
  47. public Result result { get; set; }
  48. }
  49. public class Result
  50. {
  51. public Plateresult PlateResult { get; set; }
  52. }
  53. public class Plateresult
  54. {
  55. public int plateid { get; set; } = -1;
  56. public string license { get; set; }//车牌号字符串,如 “京AAAAAA”
  57. public string imageFile { get; set; }//识别大图片内容经过base64后的字符串,需要开启发送大图片
  58. public ColorType colorType { get; set; }
  59. }
  60. public enum ColorType
  61. {
  62. Unknown,
  63. Blue,
  64. Yellow,
  65. White,
  66. Black,
  67. Green,
  68. YellowGreen,
  69. }
  70. }