/// <summary> /// Initializes a new instance of the <see cref="Deadline"/> class. /// </summary> /// <param name="deadlineType"></param> /// <param name="name">the deadline name</param> public Deadline( DeadlineType deadlineType, string name ) { DeadlineType = deadlineType; Name = name; Escalations = new List<Escalation>(); }
public Contest( EntryType participationType = EntryType.Open, EntryType votingType = EntryType.Open, RankingType rewardType = RankingType.Multiple, DeadlineType deadlineType = DeadlineType.Time) { this._winners = new HashSet <ContestEntry>(); this._contestEntries = new HashSet <ContestEntry>(); this._participants = new HashSet <User>(); this._participationStrategy = new ParticipationStrategy(participationType); this._votingStrategy = new VotingStrategy(votingType); this._rewardStrategy = new RewardStrategy(rewardType); this._deadlineStrategy = new DeadlineStrategy(deadlineType); }
public Contest( EntryType participationType = EntryType.Open, EntryType votingType = EntryType.Open, RankingType rewardType = RankingType.Multiple, DeadlineType deadlineType = DeadlineType.Time) { this._winners = new HashSet<ContestEntry>(); this._contestEntries = new HashSet<ContestEntry>(); this._participants = new HashSet<User>(); this._participationStrategy = new ParticipationStrategy(participationType); this._votingStrategy = new VotingStrategy(votingType); this._rewardStrategy = new RewardStrategy(rewardType); this._deadlineStrategy = new DeadlineStrategy(deadlineType); }
private void setDateEnd(CaseDeadline deadline, DeadlineType deadlineType, bool isSpecial = false) { int?months = isSpecial ? deadlineType.DeadlineSpecialMonths : deadlineType.DeadlineMonths; if (months != null) { int month = months ?? 0; deadline.EndDate = deadline.StartDate.AddMonths(month).Date; while (!workingDaysService.IsWorkingDay(userContext.CourtId, deadline.EndDate)) { deadline.EndDate = deadline.EndDate.AddDays(1).Date; } } int?workingDays = isSpecial ? deadlineType.DeadlineSpecialWorkingDays : deadlineType.DeadlineWorkingDays; if (workingDays != null) { deadline.EndDate = deadline.StartDate.Date; int wDays = (workingDays ?? 0) - 1; while (wDays > 0) { deadline.EndDate = deadline.EndDate.AddDays(1); if (workingDaysService.IsWorkingDay(userContext.CourtId, deadline.EndDate)) { wDays--; } } } int?normalDays = isSpecial ? deadlineType.DeadlineSpecialDays : deadlineType.DeadlineDays; if (normalDays != null) { int days = normalDays ?? 0; deadline.EndDate = deadline.StartDate.AddDays(days - 1).Date; while (!workingDaysService.IsWorkingDay(userContext.CourtId, deadline.EndDate)) { deadline.EndDate = deadline.EndDate.AddDays(1).Date; } } }
public FindItemReponse <ImportantDeadlineModel> FindImportantDeadlineByType(DeadlineType type) { try { IImportantDeadlineRepository importantDeadlineRepository = RepositoryClassFactory.GetInstance().GetImportantDeadlineRepository(); ImportantDeadline importantDeadline = importantDeadlineRepository.FindByType((int)type); var _importantDeadlines = MapperUtil.CreateMapper().Mapper.Map <ImportantDeadline, ImportantDeadlineModel>(importantDeadline); return(new FindItemReponse <ImportantDeadlineModel> { Item = _importantDeadlines, ErrorCode = (int)ErrorCode.None, Message = string.Empty }); } catch (Exception ex) { return(new FindItemReponse <ImportantDeadlineModel> { ErrorCode = (int)ErrorCode.Error, Message = ex.Message }); } }
/// <summary> /// Initializes a new instance of the <see cref="Deadline"/> class. /// </summary> public Deadline(DeadlineType deadlineType) : this(deadlineType , string.Empty) { }
/// <summary> /// 设置缓存数据并且设置默认过期时间 /// </summary> /// <param name="cacheKey">键</param> /// <param name="content">值</param> /// <param name="timeOut">过期时间,单位:秒,默认3600s</param> /// <param name="deadlineType">缓存过期方式</param> public static void SetCache(string cacheKey, object content, int timeOut = 3600, DeadlineType deadlineType = DeadlineType.TimeSpan) { try { if (content == null) { return; } var objCache = HttpRuntime.Cache; if (deadlineType == DeadlineType.DateTime) { //绝对时间过期,TimeSpan.Zero表示不使用平滑过期策略。 objCache.Insert(cacheKey, content, null, System.DateTime.Now.AddSeconds(timeOut), TimeSpan.Zero); } else if (deadlineType == DeadlineType.TimeSpan) { //相对过期,DateTime.MaxValue表示不使用绝对时间过期策略,TimeSpan.FromSeconds(10)表示缓存连续10秒没有访问就过期。 objCache.Insert(cacheKey, content, null, DateTime.MaxValue, TimeSpan.FromSeconds(timeOut)); } } catch (Exception) { throw; } }