biz_scanFinish.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using System.Threading;
  8. using System.Collections.Concurrent;
  9. using SqlSugar;
  10. using Newtonsoft.Json;
  11. using HXX.Scanner.Database;
  12. using HXX.Scanner.Common;
  13. using HXX.Scanner.Biz.Socket;
  14. using HXX.Scanner.Socket;
  15. namespace HXX.Scanner.Biz.Socket
  16. {
  17. /// <summary>
  18. /// 业务处理 扫描完成发送给网页端
  19. /// </summary>
  20. public class biz_scanFinish
  21. {
  22. /// <summary>
  23. /// 主业务
  24. /// </summary>
  25. /// <param name="entity"></param>
  26. /// <param name="http_result"></param>
  27. public static void Work(tb_file_info entity, ResponseEntity<response_http_uploadImg2> http_result)
  28. {
  29. cmd_scanFinish cmd = new cmd_scanFinish();
  30. try
  31. {
  32. if (entity != null)
  33. {
  34. cmd = get_cmd(entity, http_result);
  35. }
  36. else
  37. {
  38. cmd = get_cmd(http_result);
  39. }
  40. }
  41. catch (Exception ee)
  42. {
  43. LogManager.WriteLog(ee);
  44. }
  45. if (cmd != null)
  46. {
  47. //SocketServerManager.Send_Family(config_environment.current_invoker, cmd.ToJson());
  48. SocketServerManager.Send_Single(config_environment.current_invoker, cmd.ToJson());
  49. }
  50. }
  51. /// <summary>
  52. /// 构造返回值,成功时
  53. /// </summary>
  54. /// <param name="entity"></param>
  55. /// <param name="http_result"></param>
  56. /// <returns></returns>
  57. private static cmd_scanFinish get_cmd(tb_file_info entity, ResponseEntity<response_http_uploadImg2> http_result)
  58. {
  59. cmd_scanFinish result = new cmd_scanFinish();
  60. result.action = "scanFinish";
  61. result.param = new subCmd_scanFinish();
  62. result.param.isTest = entity.fi_isTest;
  63. result.param.examId = entity.fi_examId;
  64. result.param.examPaperId = entity.fi_examPaperId;
  65. result.param.accountId = entity.fi_accountId.ToString();
  66. result.param.zipId = entity.fi_zipId;
  67. if (http_result.Status == 1)
  68. {
  69. result.code = 200;
  70. result.msg = "上传成功";
  71. //result.param.uniquePageMarker = http_result.Data.data.uniquePageMarker;
  72. }
  73. else if (http_result.Status == -2)
  74. {
  75. result.code = 400;
  76. result.msg = "上传超时";
  77. }
  78. else
  79. {
  80. result.code = 509;
  81. result.msg = http_result.Message;
  82. }
  83. return result;
  84. }
  85. /// <summary>
  86. /// 构造返回值,异常时
  87. /// </summary>
  88. /// <param name="http_result"></param>
  89. /// <returns></returns>
  90. private static cmd_scanFinish get_cmd(ResponseEntity<response_http_uploadImg2> http_result)
  91. {
  92. if (config_environment.scan_type != ScanType.Test_Panel_1_Side && config_environment.scan_type != ScanType.Test_Panel_2_Sides)
  93. {
  94. cmd_scanFinish result = new cmd_scanFinish();
  95. result.action = "scanFinish";
  96. result.param = new subCmd_scanFinish();
  97. result.param.isTest = config_environment.web_parameter.isTest;
  98. result.param.examId = config_environment.web_parameter.examId;
  99. result.param.examPaperId = config_environment.web_parameter.examPaperId;
  100. result.param.accountId = config_environment.web_parameter.accountId.ToString();
  101. result.param.zipId = config_environment.web_parameter.zipId;
  102. result.code = 509;
  103. result.msg = http_result.Message;
  104. return result;
  105. }
  106. else
  107. {
  108. return null;
  109. }
  110. }
  111. }
  112. }