/// <summary> /// 算法请求 /// </summary> public void InitAlgorithm(string typeName = "") { try { using (var con = new MyContext()) { var components = con.Component.Where(c => c.Type == ComponentType.AI && c.Line == 0).ToList(); if (components.Count > 0) { var algorithmInfos = ProtoBDManager.AlgorithmQuery(false, typeName); foreach (var item in algorithmInfos) { //配置的是缺岗类型则传入设备的通讯ID if (item.type != AlgorithmInfo.Type.CAPTURE) { string name = Enum.GetName(typeof(AlgorithmType), Convert.ToInt32(item.type)); if (name == "ATTENDANCE_IN" || name == "ATTENDANCE_OUT") { name = ManagerHelp.FaceName.ToUpper(); } if (components.Where(c => c.Name.ToUpper() == name).Any()) { string identity = components.FirstOrDefault(c => c.Name.ToUpper() == name).Cid; assembly.SendAlgorithmSet(item, identity); } } } } } } catch (Exception ex) { } }
private int SendData(ProtoBuffer.Models.AlgorithmInfo algorithmInfo, string nextIdentity) { int result = 1; try { assembly.SendAlgorithmSet(algorithmInfo, nextIdentity); bool flag = true; new TaskFactory().StartNew(() => { while (flag && ManagerHelp.AlgorithmResult == "") { Thread.Sleep(1000); } }).Wait(timeout); flag = false; if (ManagerHelp.AlgorithmResult != "") { result = Convert.ToInt32(ManagerHelp.AlgorithmResult); ManagerHelp.AlgorithmResult = ""; } else { result = 400;//网络超时 } } catch (Exception ex) { } return(result); }