public async System.Threading.Tasks.Task <IHttpActionResult> AddEqAsync(EqVM model)
        {
            if (ModelState.IsValid)
            {
                try {
                    //        string Url = @"http://" + model.EquipmentIP + ":8080/queryDeviceDetail";
                    //         var result = HTTP.Http.Get(Url, "application / json");
                    //反序列化
                    //       JObject ResponObj = JsonConvert.DeserializeObject<JObject>(result);
                    //     if (ResponObj["errCode"].ToString() == "0") {
                    //       string deviceSerial = ResponObj["deviceSerial"].ToString();
                    //        if (deviceSerial == model.EquipmentNum) {
                    //通过token获取用户名
                    string token    = HttpContext.Current.Request.Headers["token"];
                    var    userInfo = JwtTools.DEcode(token);
                    //调用usermanager.getuserinfo 获取用户信息
                    var user = UserManager.GetUserInfo(userInfo["name"]);
                    //查询此用户的学校ID,将其赋值给设备表的外键 :SchoolId
                    await EqManager.AddEq(model.EquipmentNum, model.Local, user.organizationID);

                    return(this.SendData("成功"));
                }



                catch (Exception ex) {
                    return(this.ErrorData(ex.Message));
                }
            }
            else
            {
                return(this.ErrorData("发生异常,请重新登录"));
            }
        }
 public IHttpActionResult DelEq(int Id, int SchoolId)
 {
     if (ModelState.IsValid)
     {
         try {
             EqManager.DelEq(Id, SchoolId);
             return(this.SendData(true));
         }
         catch (Exception ex) {
             return(this.ErrorData(ex.Message));
         }
     }
     else
     {
         return(this.ErrorData("请求错误"));
     }
 }
 public IHttpActionResult QueryEq()
 {
     if (ModelState.IsValid)
     {
         //通过token获取用户名
         string token    = HttpContext.Current.Request.Headers["token"];
         var    userInfo = JwtTools.DEcode(token);
         //调用usermanager.getuserinfo 获取用户信息
         var user   = UserManager.GetUserInfo(userInfo["name"]);
         var result = EqManager.GetEq(user.organizationID);
         return(this.SendData(result));
     }
     else
     {
         return(this.ErrorData("发生错误"));
     }
 }
        public async Task <object> notifyAsync(EnterAndLeaveViewModel model)
        {
            //通过查询设备ID获取到学校ID,再将学校ID赋值给进出记录ID
            try {
                #region 前置设置
                string inouttype = "";
                switch (model.authType)
                {
                case "ICCard":
                    model.authType = "IC卡";
                    break;

                case "QRCode":
                    model.authType = "二维码";
                    break;

                case "FaceReco":
                    model.authType = "人脸识别";
                    break;
                }
                switch (model.inOutType)
                {
                case 0:
                    inouttype = "进";
                    break;

                case 1:
                    inouttype = "出";
                    break;
                }
                string State = "正常";


                #endregion
                int SchoolID = EqManager.GetSchoolIdByEqNum(model.deviceSerial);
                var result   = AttendanceManager.GetTime(SchoolID);
                if (result == null)
                {
                    State = "未设置考勤范围";
                }
                else
                {
                    if (model.inOutType == 0)
                    {
                        DateTime jinTime = DateTime.Parse(model.time);
                        if (jinTime.Hour >= result.InTime.Hour)
                        {
                            if (jinTime.Minute > 0)
                            {
                                //迟到,增加一个考勤字段,在这里将这个考勤字段设置为迟到
                                State = "迟到";
                            }
                        }
                    }

                    if (model.inOutType == 1)
                    {
                        DateTime jinTime = DateTime.Parse(model.time);
                        if (jinTime.Hour <= result.OutTime.Hour)
                        {
                            if (jinTime.Minute < 60)
                            {
                                //早退
                                State = "早退";
                            }
                        }
                    }
                }

                await NotifyManager.AddNotify(SchoolID, model.faceID, model.deviceSerial, model.faceName, model.authType, inouttype, model.time, State, model.deviceID, model.snapshotUrl, "data:image/jpeg;base64," + model.snapshotContent, model.temperature);

                var rst = new { errCode = 0, errMsg = "success" };
                return(rst);
            }
            catch (Exception ex) {
                var err = new { errCode = 1, errMsg = ex.Message };
                return(err);
            }
        }