コード例 #1
0
        /// <summary>
        /// 获取当天考勤记录集合
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static List <WeixinClock> GetTargetDateTargetUserClockRecords(this PinhuaContext context, DateTime target, string userid)
        {
            var result = new List <WeixinClock>();
            var bret   = context.GetTargetDateClockRangesBorder(target, out var earliest, out var latest);

            if (bret)
            {
                var records1 = from p in context.WeixinClock.AsNoTracking()
                               where p.Userid == userid
                               select p;
                var records2 = from p in context.Wx异常说明.AsNoTracking()
                               where p.用户号 == userid && p.是否处理 == 1
                               select new WeixinClock
                {
                    Clocktype = p.类型,
                    Clocktime = p.时间,
                    Name      = p.姓名,
                    Userid    = p.用户号,
                };
                var records = records1.ToList().Union(records2.ToList()).OrderBy(p => p.Clocktime);

                foreach (var clockinfo in records)
                {
                    if (clockinfo.Clocktime.Value.IsBetween(earliest, latest))
                    {
                        result.Add(clockinfo);
                    }
                }
            }
            return(result);
        }