| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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 Newtonsoft.Json;
- using Saraff.Twain;
- using HXX.Scanner.Socket;
- using HXX.Scanner.Common;
- namespace HXX.Scanner.Biz.Socket
- {
- /// <summary>
- /// 业务处理 对每个连接发送间歇1秒的已扫描过的batch编号
- /// </summary>
- public class biz_scannedBatch
- {
- /// <summary>
- /// 本次运行后已扫描的batch的列表
- /// </summary>
- public static ConcurrentDictionary<string, string> dic_scanned_batch_list = new ConcurrentDictionary<string, string>();
- /// <summary>
- /// 添加batch
- /// </summary>
- /// <param name="batch"></param>
- public static void add_batch(string batch)
- {
- if (!dic_scanned_batch_list.ContainsKey(batch))
- {
- dic_scanned_batch_list[batch] = string.Empty;
- }
- }
- /// <summary>
- /// 主业务 从程序运行到退出始终发送
- /// </summary>
- public static void Work()
- {
- Task.Run(() =>
- {
- Thread.Sleep(2000);
- while (true)
- {
- Thread.Sleep(1000);
- //SocketServerManager.Send_All(get_cmd().ToJson());
- }
- });
- }
- /// <summary>
- /// 构造返回值
- /// </summary>
- /// <returns></returns>
- private static cmd_scannedBatch get_cmd()
- {
- cmd_scannedBatch result = new cmd_scannedBatch();
- result.action = "scannedBatch";
- result.param = new subcmd_scannedBatch();
- result.param.zipId = get_batch();
- return result;
- }
- /// <summary>
- /// 获取所有batch的字符串
- /// </summary>
- /// <returns></returns>
- private static string get_batch()
- {
- string result = string.Empty;
- foreach (var b in dic_scanned_batch_list)
- {
- result += "," + b.Key;
- }
- if (result.Length > 0)
- {
- result = result.Substring(1);
- }
- return result;
- }
- }
- }
|