Cons <FastToken> MkTokenList(object first, object rest) { FastToken f = (FastToken)first; Cons <FastToken> r = (Cons <FastToken>)rest; return(new Cons <FastToken>(f, r)); }
public async Task <FastToken> SaveFastToken(FastToken entity) { var result = await Task.Run(() => { var token = _fastTokenRepository.Insert(entity); return(token); }); return(result); }
EnumDef MkEnumDef(object name, object elems) { FastToken ft = (FastToken)name; Check(char.IsUpper(ft.text[0]), ft.Location, "Invalid Enum type name '{0}', must start with upper case letter", ft.text); Cons <FastToken> members = (Cons <FastToken>)elems; EnumDef enumdef = new EnumDef(ft); foreach (var token in members) { enumdef.Add(token); } return(enumdef); }
TreeDef MkTreeDef(object acc, object alph, object arg) { FastToken accToken = (FastToken)acc; FastToken alphToken = (FastToken)alph; if (arg is object[]) { BuiltinTransExp tran = (BuiltinTransExp)(((object[])arg)[0]); FExp tree = (FExp)(((object[])arg)[1]); return(new TreeAppDef(accToken, alphToken, tran, tree)); } else if (arg is BuiltinLangExp) { BuiltinLangExp lang = (BuiltinLangExp)arg; return(new TreeWitnessDef(accToken, alphToken, lang)); } else { FExp expr = (FExp)arg; return(new TreeExpDef(accToken, alphToken, expr)); } }
public async Task <FastTokenResult> TakeFastToken(FastTokenDto dto) { var collection = await this.GetTimeSpanCollection(); var timespan = collection.Where(x => x.Id == dto.Id).FirstOrDefault(); var fastTokenResult = new FastTokenResult(); var success = true; //0. Check the token later than configured UsersInQueueCountForFastToken hours var delayedHoursForFastToken = Convert.ToInt32(ConfigurationManager.AppSettings["DelayedHoursForFastToken"]); var theTimeAvailable = DateTime.Now.AddHours(delayedHoursForFastToken); if (theTimeAvailable < timespan.EndTime) { success = true; } else { success = false; fastTokenResult.Message = "领取失败,在此时间段,您不可以领取快速通行令牌。"; } //1. Check UserFastToken is exists or not in the same time span. var exists = await _queueSystemManager.Exists(dto.NtId, dto.Id); if (exists && success) { success = false; fastTokenResult.Message = "领取失败,您在此时间段,已领取过快速通行令牌。"; } //2. do not more than TotalCountOfFastTokenForOneTimeSpan var count = await _queueSystemManager.GetTotalCountOfFastTokenForThisTimeSpan(timespan.StartTime, timespan.EndTime); var configuredCount = Convert.ToInt32(ConfigurationManager.AppSettings["TotalCountOfFastTokenForOneTimeSpan"]); if (count >= configuredCount && success) { success = false; fastTokenResult.Message = string.Format("领取失败,在此时间段,系统发放的快速通行令牌 (总数:{0}) 已经被领取完毕。", configuredCount.ToString()); } //3. the total count of fast token for the same day for one user <= TotalCountForFastTokenForOneUser var totalCountForFastTokenForOneUser = await _queueSystemManager.GetTotalCountOfFastTokenForUser(dto.NtId); var configuredTotalCountForFastTokenForOneUser = Convert.ToInt32(ConfigurationManager.AppSettings["TotalCountForFastTokenForOneUser"]); if (totalCountForFastTokenForOneUser >= configuredTotalCountForFastTokenForOneUser && success) { success = false; fastTokenResult.Message = string.Format("领取失败,您今天领取的快速通行令牌已经超过系统配置的最大数 ({0})。", configuredTotalCountForFastTokenForOneUser.ToString()); } fastTokenResult.Success = success; if (fastTokenResult.Success) { if (timespan != null) { FastToken token = new FastToken { UserEID = dto.NtId, Date = DateTime.Now.Date.ToString("yyyyMMdd"), TimeSpanId = timespan.Id, StartTime = timespan.StartTime, EndTime = timespan.EndTime }; var entity = await _queueSystemManager.SaveFastToken(token); fastTokenResult.FastToken = entity; } } return(fastTokenResult); }