//判断员工是否存在
        public IList<PM_EM_TS_ATTENDANCE> GetAttendance(String EmployeeCardID)
        {


            IList<PM_EM_TS_ATTENDANCE> AtList = new List<PM_EM_TS_ATTENDANCE>();
            try
            {
                //根据员工id查询guid(employee)
                //if (EmployeeCardID != null)
                {

                    PM_EM_EMPLOYEE em = new PM_EM_EMPLOYEE();
                    em.EmployeeCardID = EmployeeCardID;
                    IList<PM_EM_EMPLOYEE> EmList = new List<PM_EM_EMPLOYEE>();
                    //根据CardId查询员工的Uuid
                    EmList = EmployeeBo.GetEntities(em);
                    if (EmList != null && EmList.Count > 0)
                    {

                        PM_EM_TS_ATTENDANCE attendance = new PM_EM_TS_ATTENDANCE();
                        attendance.EmployeeGuid = EmList[0].EmployeeGuid;

                        AtList = AttendanceBo.GetEntities(attendance);

                    }
                    return AtList;
                }
            }


            catch (Exception e)
            {
                throw e;
            }


        }
        /// <summary>
        /// 员工上岗验证
        /// </summary>
        /// <param name="EmployeeCardID"></param>
        /// <returns></returns>
        public String IsStart(String EmployeeCardID, String TerminalName)
        {
            Boolean flag = false;
           // string mes = "";

            IList<PM_EM_TS_ATTENDANCE> AtList = new List<PM_EM_TS_ATTENDANCE>();
            try
            {
                //AtList = this.GetAttendance(EmployeeCardID);
                ////根据员工id查询员工信息(employee)
                //if (AtList == null || AtList.Count == 0)
                //{
                //    return Request.CreateResponse(HttpStatusCode.InternalServerError, "上岗失败,请先录入员工信息");
                //}
                //else
               // {
                   
                    PM_EM_TS_ATTENDANCE attendance = new PM_EM_TS_ATTENDANCE();
                    attendance = AtList[0];
                    //判断是否重复上岗
                    //DateTime NowDate = new System.DateTime();
                    DateTime NowDate = DateTime.Now;
                    String strNowDate = NowDate.ToShortDateString();
                    //返回实体信息
                    //_stringJson = JsonConvert.SerializeObject(AtList);
                    //result = new HttpResponseMessage { Content = new StringContent(_stringJson, Encoding.GetEncoding("UTF-8"), "application/json") };
                    //return result;
                    if (strNowDate == ((DateTime)attendance.Day).ToShortDateString() && attendance.OnlineTime != null && attendance.LeaveTime == null)
                    {
                         this.mes="上岗失败,请先下岗";
                        
                       
                    }
                    else
                    {//上岗成功,插入实体返回信息
                        attendance.OnlineTime = DateTime.Now;
                        attendance.Day = DateTime.Now;
                        PM_BPM_TERMINAL_QueryParam qb = new PM_BPM_TERMINAL_QueryParam();
                        qb.TerminalName = TerminalName;
                        if (TerCO.getTerminal(qb) == null || TerCO.getTerminal(qb).Count == 0)
                        {
                           this.mes="上岗失败,该工位不存在";
                          
                        }
                        else
                        {


                            attendance.TerminalGuid = TerCO.getTerminal(qb)[0].TerminalGuid;
                        }
                        //添加上岗信息
                        //attendance.EmployeeGuid =
                        // attendance.AttendanceGuid =new  new Guid//();
                        //attendanceGuid
                        attendance.AttendanceGuid = Guid.NewGuid();
                        AttendanceBo.Insert(attendance);
                        flag = true;
                        if (flag == true)
                        {
                            //return Request.CreateResponse(HttpStatusCode.OK, "上岗成功!");  
                            this.mes ="上岗成功!";
                        

                        }
                        else
                        {
                            this.mes = "上岗失败!";
                            
                        }
                       
                    }
                    
                }
           
            catch (Exception e)
            {
                throw e;
            }
            return mes;
        }
        //验证下岗信息
        public HttpResponseMessage IsEnd(String EmployeeCardID, String TerminalName, String LeaveRe)
        {
            Boolean flag = false;
            IList<PM_EM_TS_ATTENDANCE> AtList = new List<PM_EM_TS_ATTENDANCE>();
            try
            {
                AtList = this.GetAttendance(EmployeeCardID);
                //根据员工id查询员工信息(employee)
                if (AtList == null || AtList.Count == 0)
                {
                    return Request.CreateResponse(HttpStatusCode.InternalServerError, "上岗失败,请先录入员工信息");
                }

                else
                {
                    PM_EM_TS_ATTENDANCE attendance = new PM_EM_TS_ATTENDANCE();
                    attendance = AtList[0];

                    //上岗时间
                    DateTime StartTime = (DateTime)attendance.OnlineTime;
                    //考勤日期
                    DateTime Date = (DateTime)attendance.Day;
                    String strOnDutyDate = Date.ToShortDateString();
                    //当前日期
                    DateTime NowDate = DateTime.Now;
                    String strNowDate = NowDate.ToShortDateString();
                    //离岗时间
                    DateTime EndTime = (DateTime)attendance.LeaveTime;
                    if (strOnDutyDate != strNowDate || StartTime == null)
                    {
                        return Request.CreateResponse(HttpStatusCode.InternalServerError, "离岗失败,请先上岗!");
                    }
                    else
                    {

                        PM_BPM_TERMINAL_QueryParam qb = new PM_BPM_TERMINAL_QueryParam();
                        qb.TerminalName = TerminalName;
                        if (TerCO.getTerminal(qb) == null || TerCO.getTerminal(qb).Count == 0)
                        {
                            return Request.CreateResponse(HttpStatusCode.InternalServerError, "离岗失败,该工位不存在");
                        }
                        else
                        {


                            attendance.TerminalGuid = TerCO.getTerminal(qb)[0].TerminalGuid;
                        }
                        //离岗时间赋值
                        attendance.LeaveTime = DateTime.Now;
                        //离岗原因
                        attendance.LeaveReason = LeaveRe;

                        //更新离岗信息
                        AttendanceBo.UpdateSome(attendance);
                        flag = true;
                        if (flag == true)
                        {
                            return Request.CreateResponse(HttpStatusCode.InternalServerError, "离岗成功!");
                        }
                        else
                        {
                            return Request.CreateResponse(HttpStatusCode.InternalServerError, "离岗失败!");
                        }

                    }

                }

            }
            catch (Exception e)
            {
                throw e;
            }
        }