PrintHelp.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 
  2. using Newtonsoft.Json;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace HRT_Measure
  9. {
  10. public class PrintHelp
  11. {
  12. public static string CombineDynamicCmd(string strBC)
  13. {
  14. //正确返回:
  15. // { "status":"ok","code":0,"descript":"ok"}
  16. var objJson = new
  17. {
  18. request_type = "post",
  19. path = "/engine/dynamic",
  20. print_mode = "single",
  21. data = new []
  22. {
  23. new
  24. {
  25. type = "text",
  26. name = "Msg",
  27. content = strBC
  28. }
  29. }
  30. };
  31. string postContent = JsonConvert.SerializeObject(objJson);
  32. ProgramHelp.Instance.SaveMsg("Print", $"添加动态打印命令{postContent}", true);
  33. return postContent;
  34. }
  35. public static string AddPrintTast()
  36. {
  37. //正确返回:
  38. // {
  39. // "status":"ok","hash":11112,"id":949817907,"attribute":{ "create_time":949817907}
  40. // }
  41. //错误返回:
  42. // {
  43. // "status":"error","id":949817351,"code":24581,"descript":"print engine is
  44. //running"}
  45. var objJson = new
  46. {
  47. request_type = "post",
  48. path = "/engine/printjob",
  49. hash = 1,
  50. attribute = new
  51. {
  52. print_data_name = "Msg"
  53. }
  54. };
  55. string postContent = JsonConvert.SerializeObject(objJson);
  56. ProgramHelp.Instance.SaveMsg("Print", $"添加打印任务命令{postContent}", true);
  57. return postContent;
  58. }
  59. }
  60. }