/// <summary> /// 清理所有未签退用户 /// </summary> public async Task ClearAllUnSignOutAsync() { // 查找所有未签到的人员 var records = await(from r in _dbContext.Records where r.SignOutTime == null select r).ToListAsync(); // 为所有人签退 records.ForEach(r => r.SignOut()); // 记录未签到人员的学号 var studentIds = records .Select(r => r.StudentId) .Distinct().ToList(); // 扣除积分 List <User> users = await _dbContext.Users .Where(u => studentIds.Contains(u.StudentId)).ToListAsync(); users.ForEach(u => u.Points += timeoutDeductedPoints); List <PointLog> logs = users.Select( u => PointLog.Create( u.StudentId, timeoutDeductedPoints, "超时清退")).ToList(); // 更新数据库 _dbContext.UpdateRange(records); _dbContext.AddRange(logs); _dbContext.UpdateRange(users); await _dbContext.SaveChangesAsync(); }
/// <summary> /// 签退 /// </summary> /// <param name="studentId">学号</param> public async Task SignOutAsync(string studentId) { // 查找签到记录 Record record = await(from r in _dbContext.Records where r.StudentId == studentId && r.SignOutTime == null select r).FirstAsync(); // 签退 record.SignOut(); // 保存到数据库 _dbContext.Update(record); // 清算积分 if (record.Duration > TimeSpan.FromHours(2)) { User user = await _dbContext.Users.FindAsync(record.StudentId); int pointChange = record.Duration?.Hours ?? 0; user.Points += pointChange; PointLog log = PointLog.CreateBySign(user, pointChange); _dbContext.Add(log); _dbContext.Update(user); } await _dbContext.SaveChangesAsync(); }
protected string GetOperateName(PointLog log) { PointLogType lt = this.PointTypeList.GetValue(log.OperateID); if (lt != null) { return(lt.OperateName); } return(string.Empty); }
private void BindPointChange() { PointLog bllPoint = new PointLog(); string strSql = this.QueryCondition(); strSql += " and PointLog.PointMemID = Mem.MemID "; strSql = PubFunction.GetShopAuthority(this._UserShopID, "PointShopID", strSql); int intPoint = bllPoint.GetPointChange(strSql); this.lblChangePoint.Text = intPoint.ToString(); }
protected void btnRptPointChangeExcel_Click(object sender, EventArgs e) { PointLog bllPointLog = new PointLog(); int Counts = this.NetPagerParameter.RecordCount; string strSql = this.QueryCondition(); strSql += "and PointLog.PointShopID = SysShop.ShopID and PointLog.PointMemID = Mem.MemID and Mem.MemLevelID=MemLevel.LevelID and PointLog.PointUserID = SysUser.UserID"; strSql = PubFunction.GetShopAuthority(this._UserShopID, "PointShopID", strSql); DataTable dtPointLog = bllPointLog.GetListSP(100000, 1, out Counts, new string[] { strSql }).Tables[0]; DataExcelInfo.PointChangeReportExcel(dtPointLog, this._UserName); }
private void Get_ParameterList(string strSql) { PointLog bllPointLog = new PointLog(); int Counts = this.NetPagerParameter.RecordCount; strSql += "and PointLog.PointShopID = SysShop.ShopID and PointLog.PointMemID = Mem.MemID and Mem.MemLevelID=MemLevel.LevelID and PointLog.PointUserID = SysUser.UserID"; DataTable db = bllPointLog.GetListSP(this.NetPagerParameter.PageSize, this.NetPagerParameter.CurrentPageIndex, out Counts, new string[] { strSql }).Tables[0]; this.NetPagerParameter.RecordCount = Counts; this.NetPagerParameter.CustomInfoHTML = string.Format("<div class=\"results\"><span>当前第{0}/{1}页 共{2}条记录 每页{3}条</span></div>", new object[] { this.NetPagerParameter.CurrentPageIndex, this.NetPagerParameter.PageCount, this.NetPagerParameter.RecordCount, this.NetPagerParameter.PageSize }); this.gvRptPointChange.DataSource = db; this.gvRptPointChange.DataBind(); PageBase.BindSerialRepeater(this.gvRptPointChange, this.NetPagerParameter.PageSize * (this.NetPagerParameter.CurrentPageIndex - 1)); }
protected string GetOperateName(PointLog log) { PointLogType lt = this.PointTypeList.GetValue(log.OperateID); if (lt != null) return lt.OperateName; return string.Empty; }
public void AddPointLog(PointLog pointLog) { _dbContext.PointLogs.Add(pointLog); }