public bool PreBillSession(int userId, double spanSeconds, bool isNegativeAllowed, decimal creditLimit, int userSessionId, int?hostGroupId, int?userGroupId, int?billProfileId, DateTime currentTime, IGizmoDBContext cx, out bool logout) { logout = false; var userTime = this.GetUserTimes(userId, cx).Single(); int maxDialy = config.DailyLimit; int maxWeekly = config.WeeklyLimit; if (userTime.Value < 60) { logout = true; } //since user balance changed notify this.Service.ScheduleUserBalanceEvent(userId); seconds -= 60; //indicate that normal billing procedure should not occur return(true); }
public bool PreBalanceHandle(int?userId, int?hostGroupId, IGizmoDBContext cx, out Dictionary <int, UserBalance> currentState) { if (cx == null) { throw new ArgumentNullException(nameof(cx)); } currentState = null; //we will not handle pre balance pass which means the normal user balances will be calculated return(false); }
private Dictionary <int, double> GetUserTimes(int?userId, IGizmoDBContext cx) { if (cx == null) { throw new ArgumentNullException(nameof(cx)); } var query = cx.QueryableSet <GizmoDALV2.Entities.UserMember>(); if (userId.HasValue) { query = query.Where(x => x.Id == userId.Value); } return(query.Select(x => new { x.Id }).ToDictionary(x => x.Id, y => seconds)); }
public void PostBalanceHandle(int?userId, int?hostGroupId, Dictionary <int, UserBalance> currentState, IGizmoDBContext cx) { if (cx == null) { throw new ArgumentNullException(nameof(cx)); } if (currentState == null) { throw new ArgumentNullException(nameof(currentState)); } var userTimes = this.GetUserTimes(userId, cx); foreach (var userBalance in currentState) { userBalance.Value.AvailableTime = userTimes[userBalance.Key]; userBalance.Value.AvailableCreditedTime = userTimes[userBalance.Key]; } }