public string GetSigninInfo(int depotId, int workerId, DateTime dt) { var s = _signinCache.Get(depotId, workerId, ClcUtils.IsMorning(dt)); if (s == null) { return("未签到"); } return(string.Format("{0} 签到", s.SigninTime.ToString("HH:mm:ss"))); }
public Signin Get(int depotId, int workerId, bool isMorning) { string cacheKey = DateTime.Now.Date.ToString() + depotId.ToString() + workerId.ToString(); var signin = _cacheManager.GetCache(CacheName).Get(cacheKey, () => { return(_signinRepository.GetAll() .Where(x => x.CarryoutDate == DateTime.Now.Date && x.DepotId == depotId && x.WorkerId == workerId && ClcUtils.IsMorning(x.SigninTime) == isMorning).FirstOrDefault()); }); return(signin); }
public (bool, string) DoSignin(int depotId, int workerId, string style) { // Get Signin var signin = _signinRepository.GetAll() .Where(s => s.CarryoutDate == DateTime.Today && s.DepotId == depotId && s.WorkerId == workerId) .LastOrDefault(); if (signin == null) { signin = new Signin() { DepotId = depotId, CarryoutDate = DateTime.Today, WorkerId = workerId, SigninTime = DateTime.Now, SigninStyle = style }; _signinRepository.Insert(signin); if (ClcUtils.IsMorning(DateTime.Now)) { return(true, "上午时段签到成功"); } else { return(true, "下午时段签到成功"); } } else { var signedTz = ClcUtils.IsMorning(signin.SigninTime); if (!ClcUtils.IsMorning(DateTime.Now) && signedTz) { signin = new Signin() { DepotId = depotId, CarryoutDate = DateTime.Today, WorkerId = workerId, SigninTime = DateTime.Now, SigninStyle = style }; _signinRepository.Insert(signin); return(true, "下午时段签到成功"); } else { return(false, string.Format("你已在{0}签到过", signin.SigninTime.ToString("HH:mm:ss"))); } } }