public static void TaskEnqueue(ClientTask task) { lock (_readWriteLock1) { if (_taskQueueHelper._taskList.Where(m => m.ClientID == task.ClientID).Count() == 0) { _taskQueueHelper._taskList.Add(task); } } BEMAttendance.Models.LogHelper.Info(string.Format("设备{0}更新任务入队列", task.ClientID)); }
/// <summary> /// 获取指定设备的任务列表 /// </summary> /// <param name="clientID"></param> /// <returns></returns> public static UpdatesJsonObj GetTasks(string clientID) { ClientTask task = _taskQueueHelper._taskList.Where(item => item.ClientID == clientID).First(); if (task == null) { return(null); } UpdatesJsonObj obj = new UpdatesJsonObj(); obj.taskID = task.TaskID; using (BemEntities db = new BemEntities()) { var updates = from devRel in db.deviceemployeerelation join user in db.employee on devRel.EmpCode equals user.EmpCode into dic from item in dic.DefaultIfEmpty() where devRel.DevCode == clientID where devRel.Operate != 0 group new { devRel, item } by devRel.Operate into g select new { g.Key, g }; obj.updatesSubItems = new List <UpdatesSubItem>(); foreach (var itm in updates) { UpdatesSubItem subItem = new UpdatesSubItem(); subItem.operateType = (sbyte)itm.Key; subItem.employees = new List <EmployeeJsonObj>(); foreach (var emp in itm.g) { EmployeeJsonObj employee1 = new EmployeeJsonObj(); if (emp.item != null) { employee1.empCode = emp.item.EmpCode; employee1.empID = emp.item.EmpIDCard; employee1.empName = emp.item.EmpName; employee1.empTelephone = emp.item.Telephone == null ? string.Empty : emp.item.Telephone; employee1.empAdmin = emp.item.Administrator == null ? string.Empty : emp.item.Administrator; employee1.empBirth = emp.item.EmpBirth.ToString("yyyy-MM-dd HH:mm:ss"); employee1.empGender = emp.item.EmpGender.HasValue ? (emp.item.EmpGender == 0 ? "女" : "男") : "女"; employee1.empGroupName = emp.item.EmpGroupName; employee1.empGroupCode = emp.item.EmpGroupCode; employee1.empLeftNum = emp.item.LeftNum.HasValue ? (int)emp.item.LeftNum : 0; employee1.empRightNum = emp.item.RightNum.HasValue ? (int)emp.item.RightNum : 0; employee1.empTemplate = emp.item.Template == null ? string.Empty : Convert.ToBase64String(emp.item.Template); employee1.empLeftEyeImg = string.Empty; employee1.empRightEyeImg = string.Empty; employee1.empTemplateSize = emp.item.TemplateSize.HasValue ? (int)emp.item.TemplateSize : 0; employee1.empFaceTemplate = emp.item.FaceTemplate == null ? string.Empty : Convert.ToBase64String(emp.item.FaceTemplate); employee1.empFaceImg = string.Empty; } else { employee1.empCode = emp.devRel.EmpCode; employee1.empID = string.Empty; employee1.empName = string.Empty; employee1.empTelephone = string.Empty; employee1.empAdmin = string.Empty; employee1.empBirth = string.Empty; employee1.empGender = string.Empty; employee1.empGroupName = string.Empty; employee1.empGroupCode = string.Empty; employee1.empLeftNum = 0; employee1.empRightNum = 0; employee1.empTemplate = string.Empty; employee1.empLeftEyeImg = string.Empty; employee1.empRightEyeImg = string.Empty; employee1.empTemplateSize = 0; employee1.empFaceTemplate = string.Empty; employee1.empFaceImg = string.Empty; } subItem.employees.Add(employee1); } obj.updatesSubItems.Add(subItem); } } return(obj); }