biz_scanFinishBatch.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_scanFinishBatch
  21. {
  22. /// <summary>
  23. /// 主业务
  24. /// </summary>
  25. /// <param name="stopStatus"> 1:正常完成 2:手动取消 3:异常 4:弹框取消 5:开始重连扫描仪 6:重连扫描仪成功 7:扫描完成(上传尚未完成)</param>
  26. /// <param name="immediate">等待标记</param>
  27. public static void Work(int stopStatus, bool immediate)
  28. {
  29. //是否等待所有http上传结束再发送
  30. if (!immediate)
  31. {
  32. while (!http_manager.check_is_queue_empty())
  33. {
  34. Thread.Sleep(100);
  35. }
  36. Thread.Sleep(1000);
  37. }
  38. if (config_environment.web_parameter != null)
  39. {
  40. config_environment.web_parameter.examPaperId = "0";
  41. }
  42. if (config_environment.scan_type == ScanType.Formal || config_environment.scan_type == ScanType.Test_From_Web)
  43. {
  44. //Task.Run(() =>
  45. //{
  46. //SocketServerManager.Send_Family(config_environment.current_invoker, get_cmd(stopStatus).ToJson());
  47. SocketServerManager.Send_Single(config_environment.current_invoker, get_cmd(stopStatus).ToJson());
  48. //});
  49. if (stopStatus == 1|| stopStatus == 3)
  50. {
  51. http_manager.notify_scan_finish();
  52. }
  53. }
  54. }
  55. /// <summary>
  56. /// 构造返回值
  57. /// </summary>
  58. /// <param name="stopStatus"></param>
  59. /// <returns></returns>
  60. private static cmd_scanFinishBatch get_cmd(int stopStatus)
  61. {
  62. cmd_scanFinishBatch result = new cmd_scanFinishBatch();
  63. result.action = "scanFinishBatch";
  64. result.param = new subCmd_scanFinishBatch();
  65. result.param.stopStatus = stopStatus;
  66. if (config_environment.web_parameter != null)
  67. {
  68. result.param.zipId = config_environment.web_parameter.zipId;
  69. result.param.isTest = config_environment.web_parameter.isTest;
  70. }
  71. return result;
  72. }
  73. }
  74. }