public DB_CalendarEventRestricted(CalendarEvent CalendarEventData, RestrictionProfile restrictionData, ReferenceNow now) { //CalendarEventRestricted MyCalendarEventCopy = CalendarEventData.new CalendarEventRestricted(); this._EventDuration = CalendarEventData.getActiveDuration; this._Name = CalendarEventData.getName; this._EventPreDeadline = CalendarEventData.getPreDeadline; this._PrepTime = CalendarEventData.getPreparation; this._Priority = CalendarEventData.getEventPriority; //this.RepetitionFlag = CalendarEventData.RepetitionStatus; this._EventRepetition = (CalendarEventData).Repeat; // EventRepetition != CalendarEventData.null ? EventRepetition.CreateCopy() : EventRepetition; this._Complete = CalendarEventData.getIsComplete; this._RigidSchedule = CalendarEventData.isRigid; //hack this._Splits = CalendarEventData.NumberOfSplit; this._AverageTimePerSplit = CalendarEventData.AverageTimeSpanPerSubEvent; this.UniqueID = CalendarEventData.Calendar_EventID;//hack this._SubEvents = new SubEventDictionary <string, SubCalendarEvent>(); this._UiParams = CalendarEventData.getUIParam; this._DataBlob = CalendarEventData.Notes; this._Enabled = CalendarEventData.isEnabled; this._LocationInfo = CalendarEventData.Location;//hack you might need to make copy this._ProfileOfProcrastination = CalendarEventData.getProcrastinationInfo; this._AutoDeleted = CalendarEventData.getIsUserDeleted; this._CompletedCount = CalendarEventData.CompletionCount; this._DeletedCount = CalendarEventData.DeletionCount; this._ProfileOfRestriction = restrictionData; this._isEventRestricted = true; this._Now = now; this.updateStartTime(CalendarEventData.Start); this.updateEndTime(CalendarEventData.End); if (this._EventRepetition != null && !this._EventRepetition.EnableRepeat) { foreach (SubCalendarEventRestricted eachSubCalendarEvent in CalendarEventData.AllSubEvents) { this._SubEvents.Add(eachSubCalendarEvent.Id, eachSubCalendarEvent); eachSubCalendarEvent.ParentCalendarEvent = this; } } else if (this._EventRepetition == null) { isRepeatLoaded_DB = false; } this._otherPartyID = CalendarEventData.ThirdPartyID;// == CalendarEventData.null ? null : otherPartyID.ToString(); this._Users = CalendarEventData.getAllUsers(); this._Creator = CalendarEventData.getCreator; this._TimeZone = CalendarEventData.getTimeZone; this._ProfileOfNow = CalendarEventData.getNowInfo; //return MyCalendarEventCopy; }
public RestrictionProfile getRestrictionProfile(DateTimeOffset currentTime) { bool EveryDayFlag = Boolean.Parse(isEveryDay); bool WorkWeek = Boolean.Parse(isWorkWeek); DateTimeOffset myNow = currentTime; DateTimeOffset RestrictStart = new DateTimeOffset(myNow.Year, myNow.Month, myNow.Day, 0, 0, 0, new TimeSpan()); RestrictStart = RestrictStart.Add(-getTimeSpan); DateTimeOffset RestrictEnd = RestrictStart.AddSeconds(-1); RestrictionProfile retValue = null; DayOfWeek[] selectedDaysOftheweek = { }; if (EveryDayFlag || WorkWeek) { if ((DateTimeOffset.TryParse(RestrictionStart, out RestrictStart)) && ((DateTimeOffset.TryParse(RestrictionEnd, out RestrictEnd)))) { RestrictStart = RestrictStart.Add(-getTimeSpan); RestrictEnd = RestrictEnd.Add(-getTimeSpan); selectedDaysOftheweek = RestrictionProfile.AllDaysOfWeek.ToArray(); if (WorkWeek) { retValue = new RestrictionProfile(7, DayOfWeek.Monday, RestrictStart, RestrictEnd); } else { RestrictionTimeLine RestrictionTimeLine = new TilerElements.RestrictionTimeLine(RestrictStart, RestrictEnd); retValue = new RestrictionProfile(selectedDaysOftheweek, RestrictionTimeLine); } return(retValue); } else { retValue = null; } } if (RestrictiveWeek != null) { retValue = RestrictiveWeek.getRestriction(getTimeSpan); } return(retValue); }
public RestrictionProfile getRestriction(TimeSpan TimeDiff) { RestrictionProfile RetValue = null; bool Enabled = false; if (Boolean.TryParse(isEnabled, out Enabled)) { if (Enabled) { List <DayOfWeek> myDays = new List <DayOfWeek>(); List <RestrictionTimeLine> RestrictingTimeLines = new List <RestrictionTimeLine>(); foreach (WeekDays eachWeekDays in WeekDayOption) { DateTimeOffset Start; bool parseCheck = DateTimeOffset.TryParse(eachWeekDays.Start, out Start); if (!parseCheck) { throw new Exception("Error parsing one of your Start times in restrictive week data"); } DateTimeOffset revisedStart = Start.Add(-TimeDiff); int startDayIndexIncrement = revisedStart.DayOfYear - Start.DayOfYear; Start = revisedStart; DateTimeOffset End; parseCheck = DateTimeOffset.TryParse(eachWeekDays.End, out End); if (!parseCheck) { throw new Exception("Error parsing one of your End times in restrictive week data"); } DateTimeOffset revisedEnd = End.Add(-TimeDiff); int endDayIndexIncrement = revisedEnd.DayOfYear - End.DayOfYear; End = revisedEnd; int DayIndex; parseCheck = int.TryParse(eachWeekDays.Index, out DayIndex); if (!parseCheck) { throw new Exception("Invalid day index provided in restrictive week data"); } DayOfWeek myDay; try { myDay = (DayOfWeek)((DayIndex + startDayIndexIncrement) % Utility.daysInAWeek); } catch (Exception e) { throw new Exception("Invalid day index provided in restrictive week data"); } RestrictionTimeLine restrictingFrame = new RestrictionTimeLine(Start, End); myDays.Add(myDay); RestrictingTimeLines.Add(restrictingFrame); } RetValue = new RestrictionProfile(myDays, RestrictingTimeLines); } } return(RetValue);; }