using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Collections.Concurrent;
using SqlSugar;
using Newtonsoft.Json;
using HXX.Scanner.Database;
using HXX.Scanner.Common;
using HXX.Scanner.Biz.Socket;
using HXX.Scanner.Socket;
namespace HXX.Scanner.Biz.Socket
{
///
/// 业务处理 扫描完毕时发送信息
///
public class biz_scanFinishBatch
{
///
/// 主业务
///
/// 1:正常完成 2:手动取消 3:异常 4:弹框取消 5:开始重连扫描仪 6:重连扫描仪成功 7:扫描完成(上传尚未完成)
/// 等待标记
public static void Work(int stopStatus, bool immediate)
{
//是否等待所有http上传结束再发送
if (!immediate)
{
while (!http_manager.check_is_queue_empty())
{
Thread.Sleep(100);
}
Thread.Sleep(1000);
}
if (config_environment.web_parameter != null)
{
config_environment.web_parameter.examPaperId = "0";
}
if (config_environment.scan_type == ScanType.Formal || config_environment.scan_type == ScanType.Test_From_Web)
{
//Task.Run(() =>
//{
//SocketServerManager.Send_Family(config_environment.current_invoker, get_cmd(stopStatus).ToJson());
SocketServerManager.Send_Single(config_environment.current_invoker, get_cmd(stopStatus).ToJson());
//});
if (stopStatus == 1|| stopStatus == 3)
{
http_manager.notify_scan_finish();
}
}
}
///
/// 构造返回值
///
///
///
private static cmd_scanFinishBatch get_cmd(int stopStatus)
{
cmd_scanFinishBatch result = new cmd_scanFinishBatch();
result.action = "scanFinishBatch";
result.param = new subCmd_scanFinishBatch();
result.param.stopStatus = stopStatus;
if (config_environment.web_parameter != null)
{
result.param.zipId = config_environment.web_parameter.zipId;
result.param.isTest = config_environment.web_parameter.isTest;
}
return result;
}
}
}