コード例 #1
0
ファイル: Schedule.cs プロジェクト: jerbio/WagTapWeb
 public Schedule()
 {
     AllEventDictionary = getAllCalendarFromXml();
     myCalendar = new ThirdPartyCalendarControl[1];
     myCalendar[0] = new ThirdPartyCalendarControl(ThirdPartyCalendarControl.CalendarTool.Outlook);
     CompleteSchedule = getTimeLine();
 }
コード例 #2
0
        public InListOutOfList(List<SubCalendarEvent> FullList, List<List<List<SubCalendarEvent>>> AllMyList, List<TimeLine> MyFreeSpots)
        {
            DictData_TimeLine = new Dictionary<List<TimeLine>, List<SubCalendarEvent>>();
            foreach (List<List<SubCalendarEvent>> ListToCheck in AllMyList)
            {
                List<SubCalendarEvent> TotalList = new List<SubCalendarEvent>();
                int i = 0;
                List<TimeLine> timeLineEntry = new List<TimeLine>();
                foreach (List<SubCalendarEvent> myList in ListToCheck)
                {
                    TimeLine myTimeLine = new TimeLine(MyFreeSpots[i].Start, MyFreeSpots[i].End);
                    TotalList.AddRange(myList);

                    TimeSpan TotalTimeSpan = new TimeSpan(0);
                    foreach (SubCalendarEvent mySubEvent in myList)
                    {
                        TotalTimeSpan=TotalTimeSpan.Add(mySubEvent.ActiveSlot.BusyTimeSpan);
                    }

                    BusyTimeLine EffectivebusySlot = new BusyTimeLine("1000000_1000001", MyFreeSpots[i].Start, MyFreeSpots[i].Start.Add(TotalTimeSpan));
                    myTimeLine.AddBusySlots(EffectivebusySlot);
                    timeLineEntry.Add(myTimeLine);
                    i++;
                }

                DictData_TimeLine.Add(timeLineEntry, Utility.NotInList_NoEffect(FullList, TotalList));
            }
        }
コード例 #3
0
        public EfficientTimeLine(TimeLine RestrictiveTimeLine, Dictionary<SubCalendarEvent, TimeLine> SubCalEvent_RestrictingTimeLine)
        {
            List<SubCalendarEvent> SubCalEventRestricted = SubCalEvent_RestrictingTimeLine.Keys.ToList();
            SubCalEventRestricted=SubCalEventRestricted.OrderBy(obj => obj.End).ToList();
            Dictionary<long, List<SubCalendarEvent>> Dict_DeadlineAndClashingDeadlineSubCalEvents = new Dictionary<long, List<SubCalendarEvent>>();
            foreach (SubCalendarEvent MySubCalEvent in SubCalEventRestricted)
            {

                if (Dict_DeadlineAndClashingDeadlineSubCalEvents.ContainsKey(MySubCalEvent.End.Ticks))
                {
                    Dict_DeadlineAndClashingDeadlineSubCalEvents[MySubCalEvent.End.Ticks].Add(MySubCalEvent);
                }
                else
                {
                    Dict_DeadlineAndClashingDeadlineSubCalEvents.Add(MySubCalEvent.End.Ticks,new List<SubCalendarEvent>());
                    Dict_DeadlineAndClashingDeadlineSubCalEvents[MySubCalEvent.End.Ticks].Add(MySubCalEvent);
                }
            }

            SubCalEventRestricted = new List<SubCalendarEvent>();
            foreach (long DeadLine in Dict_DeadlineAndClashingDeadlineSubCalEvents.Keys.ToArray())
            {
                Dict_DeadlineAndClashingDeadlineSubCalEvents[DeadLine] = Dict_DeadlineAndClashingDeadlineSubCalEvents[DeadLine].OrderBy(obj => obj.Start).ToList();
                SubCalEventRestricted.AddRange(Dict_DeadlineAndClashingDeadlineSubCalEvents[DeadLine]);
            }

            Dictionary<SubCalendarEvent, TimeLine> SubCalEvent_RestrictingTimeLine_Sorted = new Dictionary<SubCalendarEvent, TimeLine>();
            foreach (SubCalendarEvent MySubCalEvent in SubCalEventRestricted)
            {
                SubCalEvent_RestrictingTimeLine_Sorted.Add(MySubCalEvent, SubCalEvent_RestrictingTimeLine[MySubCalEvent]);
            }

            BuildIndex(RestrictiveTimeLine, SubCalEvent_RestrictingTimeLine_Sorted);
            RestrictingTimeLine = RestrictiveTimeLine;
        }
コード例 #4
0
 private void BuildIndex(TimeLine RestrictingTimeLine, Dictionary<SubCalendarEvent, TimeLine> SubCalEvent_RestrictingTimeLine)
 {
     int Index = 0;
     SubCalendarEvent[] ListOfSortedSubCalEvents = SubCalEvent_RestrictingTimeLine.Keys.ToArray();
     TimeLineData.Add(Index, new Tuple<DateTime,TimeLine,DateTime,TimeLine>(RestrictingTimeLine.Start,new TimeLine(RestrictingTimeLine.Start,RestrictingTimeLine.Start), ListOfSortedSubCalEvents[Index].Start,SubCalEvent_RestrictingTimeLine[ListOfSortedSubCalEvents[Index]]));
     for (; Index < ListOfSortedSubCalEvents.Length-1; Index++)
     {
         TimeLineData.Add(Index+1, new Tuple<DateTime, TimeLine, DateTime, TimeLine>(ListOfSortedSubCalEvents[Index].End, SubCalEvent_RestrictingTimeLine[ListOfSortedSubCalEvents[Index]], ListOfSortedSubCalEvents[Index+1].Start, SubCalEvent_RestrictingTimeLine[ListOfSortedSubCalEvents[Index+1]]));
     }
     TimeLineData.Add(Index + 1, new Tuple<DateTime, TimeLine, DateTime, TimeLine>(ListOfSortedSubCalEvents[Index].End, SubCalEvent_RestrictingTimeLine[ListOfSortedSubCalEvents[Index]], RestrictingTimeLine.End,new TimeLine(RestrictingTimeLine.End,RestrictingTimeLine.End)  ));
 }
コード例 #5
0
 public SubCalendarEvent(string MySubEventID, DateTime EventStart, DateTime EventDeadline, BusyTimeLine SubEventBusy, bool Rigid, bool Enabled, EventDisplay UiParam, MiscData Notes, bool completeFlag, Location EventLocation = null, TimeLine RangeOfSubCalEvent = null)
 {
     CalendarEventRange = RangeOfSubCalEvent;
     SubEventID = new EventID(MySubEventID.Split('_'));
     StartDateTime = EventStart;
     EndDateTime = EventDeadline;
     EventDuration = SubEventBusy.TimelineSpan;
     BusyFrame = SubEventBusy;
     RigidSchedule = Rigid;
     this.Enabled = Enabled;
     this.EventLocation = EventLocation;
     UiParams = UiParam;
     DataBlob = Notes;
     Complete = completeFlag;
 }
コード例 #6
0
 public ClumpSubCalendarEvent(List<SubCalendarEvent> Appendables, TimeLine BoundaryTimeLine)
 {
     Appendables=Appendables.OrderBy(obj => obj.getCalendarEventRange.End).ToList();
     SubCalendarEvent RelativeSubEvent = Appendables[0];
     Appendables.Remove(RelativeSubEvent);
     ClumpSubCalendarEvent myThis = new ClumpSubCalendarEvent(RelativeSubEvent, Appendables, BoundaryTimeLine.CreateCopy());
     SubCalEventsOverLapWithBase = myThis.SubCalEventsOverLapWithBase;
     //List<SubCalendarEvent> NonOverLapping;
     BaseEvent= myThis.BaseEvent;
     this.BoundaryTimeLine =myThis.BoundaryTimeLine;
     //List<SubCalendarEvent> BaseClump;
     //List<ClumpSubCalendarEvent> NonOverLapping_Clump;
     BreakOffClump= myThis.BreakOffClump;
     ClumpedResults= myThis.ClumpedResults;
     BaseReferenceStartTime = myThis.BaseReferenceStartTime;
 }
コード例 #7
0
        public SubCalendarEvent(string MySubEventID, BusyTimeLine MyBusylot, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, string myParentID, bool Rigid,bool Enabled, EventDisplay UiParam, MiscData Notes, bool completeFlag, Location EventLocation = null, TimeLine RangeOfSubCalEvent = null)
        {
            CalendarEventRange = RangeOfSubCalEvent;
            //string eventName, TimeSpan EventDuration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, TimeSpan PreDeadline, bool EventRigidFlag, bool EventRepetition, int EventSplit
            StartDateTime = EventStart;
            EndDateTime = EventDeadline;
            EventDuration = MyBusylot.End - MyBusylot.Start;
            BusyFrame = MyBusylot;
            PrepTime = EventPrepTime;
            SubEventID = new EventID(MySubEventID.Split('_'));
            this.EventLocation = EventLocation;

            UiParams=UiParam;
            DataBlob= Notes;
            Complete = completeFlag;

            this.Enabled = Enabled;
            EventSequence = new EventTimeLine(SubEventID.ToString(), StartDateTime, EndDateTime);
            RigidSchedule = Rigid;
        }
コード例 #8
0
 public CalendarEvent(CustomErrors Error)
 {
     EventDuration = new TimeSpan();
     CalendarEventName = "";
     StartDateTime = new DateTime();
     EndDateTime = new DateTime();
     EventPreDeadline = new TimeSpan();
     PrepTime = new TimeSpan();
     Priority = 0;
     RepetitionFlag = false;
     EventRepetition = new Repetition();
     RigidSchedule = false;
     Splits = 1;
     LocationData = new Location();
     CalendarEventID = new EventID("");
     SubEvents = new Dictionary<EventID, SubCalendarEvent>();
     SchedulStatus = false;
     otherPartyID = "";
     CalendarError = Error;
     EventSequence = new TimeLine();
 }
コード例 #9
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
 public CalendarEvent()
 {
     EventDuration = new TimeSpan();
     CalendarEventName = "";
     StartDateTime = new DateTime();
     EndDateTime = new DateTime();
     EventPreDeadline = new TimeSpan();
     PrepTime = new TimeSpan();
     Priority = 0;
     RepetitionFlag = false;
     EventRepetition = new Repetition();
     RigidSchedule = false;
     Splits = 1;
     LocationData = new Location();
     CalendarEventID = new EventID("");
     ArrayOfSubEvents = new SubCalendarEvent[0];
     SchedulStatus = false;
     otherPartyID = "";
     CalendarError = new CustomErrors(false, string.Empty);
     EventSequence = new TimeLine();
 }
コード例 #10
0
 public SubCalendarEvent(TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, string myParentID, bool Rigid, bool Enabled, EventDisplay UiParam,MiscData Notes,bool completeFlag, Location EventLocation =null, TimeLine RangeOfSubCalEvent = null)
 {
     CalendarEventRange = RangeOfSubCalEvent;
     StartDateTime = EventStart;
     EndDateTime = EventDeadline;
     EventDuration = Event_Duration;
     PrepTime = EventPrepTime;
     if (myParentID == "16")
     {
         ;
     }
     UiParams=UiParam;
     DataBlob = Notes;
     Complete=completeFlag;
     SubEventID = new EventID(myParentID + "_" + EventIDGenerator.generate().ToString());
     BusyFrame = new BusyTimeLine(this.ID, StartDateTime, EndDateTime);//this is because in current implementation busy frame is the same as CalEvent frame
     this.EventLocation = EventLocation;
     EventSequence = new EventTimeLine(SubEventID.ToString(), StartDateTime, EndDateTime);
     RigidSchedule = Rigid;
     this.Enabled = Enabled;
 }
コード例 #11
0
        public bool canExistTowardsStartWithoutSpace(TimeLine PossibleTimeLine)
        {
            TimeLine ParentCalRange = getCalendarEventRange;
             bool retValue = ((PossibleTimeLine.Start + ActiveDuration) <= ParentCalRange.End) && (ParentCalRange.Start <= PossibleTimeLine.Start);

             return retValue;
        }
コード例 #12
0
        string getJSONData(Dictionary<string, My24HourTimerWPF.CalendarEvent> CalendarData, TimeLine RangeOfSchedule,string Name,TimeSpan TimeZoneSpan)
        {
            string TotalString = " ";

            IEnumerable<CalendarEvent> RepeatCalendarEvent = CalendarData.Values.Where(obj => obj.RepetitionStatus);
            IEnumerable<CalendarEvent> NonRepeatCalendarEvent = CalendarData.Values.Where(obj => !obj.RepetitionStatus);
            string repeatDelimited = string.Join(",", RepeatCalendarEvent.Select(obj => RepeatCalendarEventToString(obj, RangeOfSchedule, TimeZoneSpan)));
            string nonrepeatDelimited = string.Join(",", NonRepeatCalendarEvent.Select(obj => CalendarEventToString(obj, RangeOfSchedule, TimeZoneSpan)));

            string repeatCalendarEventJSON = "\"RepeatCalendarEvent\":[" + repeatDelimited + "]";
            string nonrepeatCalendarEventJSON = "\"NonRepeatCalendarEvent\":[" + nonrepeatDelimited + "]";

            TotalString = repeatCalendarEventJSON + "," + nonrepeatCalendarEventJSON;
            string retValue = "{\"Schedule\":{" + TotalString + "},\"Name\":\"" + Name + "\"}";
            return retValue;
        }
コード例 #13
0
        public bool UpdateThis(SubCalendarEvent SubEventEntry)
        {
            if ((this.ID == SubEventEntry.ID)&&canExistWithinTimeLine(SubEventEntry.getCalendarEventRange))
            {
                StartDateTime= SubEventEntry.Start;
                EndDateTime= SubEventEntry.End;
                BusyFrame.updateBusyTimeLine(SubEventEntry.BusyFrame);
                AvailablePreceedingFreeSpace = SubEventEntry.AvailablePreceedingFreeSpace;
                RigidSchedule = SubEventEntry.Rigid;
                CalendarEventRange = SubEventEntry.CalendarEventRange;
                EventLocation = SubEventEntry.LocationData;
                Enabled = SubEventEntry.Enabled;
                ThirdPartyID = SubEventEntry.ThirdPartyID;
                return true;
            }

            throw new Exception("Error Detected: Trying to update SubCalendar Event with non matching ID");
        }
コード例 #14
0
 public override void updateEventSequence()
 {
     EventSequence = new TimeLine(this.Start, this.End);
     EventSequence.AddBusySlots(BusyFrame);
 }
コード例 #15
0
 public bool shiftEvent(TimeSpan ChangeInTime, bool force=false)
 {
     TimeLine UpdatedTimeLine = new TimeLine(this.Start + ChangeInTime, this.End + ChangeInTime);
     if (!(this.getCalendarEventRange.IsTimeLineWithin(UpdatedTimeLine))&&!force)
     {
         return false;
     }
     StartDateTime += ChangeInTime;
     EndDateTime += ChangeInTime;
     ActiveSlot.shiftTimeline(ChangeInTime);
     return true;
 }
コード例 #16
0
        string RepeatCalendarEventToString(CalendarEvent arg1,TimeLine RangeOfSchedule,TimeSpan TimeZoneSpan)
        {
            /*
             * This funciton takes a repeating CalendarEvent and converts it to a JSON formatted string;
             */
            string IDString="\""+arg1.ID+"\"";
            string TotalString = "";
            string RepeatCalendarName = "\"" + arg1.Name + "\"";
            string RepeatStartDate = "\"" + arg1.Start.ToString() + "\"";
            string RepeatEndDate = "\"" + arg1.End.ToString() + "\"";
            string RepeatTotalDuration = "\"" + arg1.ActiveDuration.ToString() + "\"";
            string RepeatRigid = "\"" + arg1.Rigid + "\"";
            string RepeatAddressDescription = "\"" + arg1.myLocation.Description + "\"";
            string RepeatAddress = "\"" + arg1.myLocation.Address + "\"";
            string Long = "\"" + arg1.myLocation.YCoordinate + "\"";
            string Lat = "\"" + arg1.myLocation.XCoordinate + "\"";

            string Delimited = string.Join(",", arg1.Repeat.RecurringCalendarEvents.Select(obj => CalendarEventToString(obj, RangeOfSchedule, TimeZoneSpan)));
            string AllCalEventString = "["+Delimited+"]";
            TotalString = "{\"ID\":" + IDString + ",\"RepeatCalendarName\":" + RepeatCalendarName + ",\"RepeatStartDate\":" + RepeatStartDate + ",\"RepeatEndDate\":" + RepeatEndDate + ",\"RepeatTotalDuration\":" + RepeatTotalDuration + ",\"RepeatRigid\":" + RepeatRigid + ",\"RepeatAddressDescription\": " + RepeatAddressDescription + ",\"RepeatAddress\":" + RepeatAddress + ",\"RepeatCalendarEvents\":" + AllCalEventString + ",\"Latitude\":" + Lat + ",\"Longitude\":" + Long + "}";
            string retValue=TotalString ;
            return retValue;
        }
コード例 #17
0
        public ClumpSubCalendarEvent(DateTime ReferenceStartTime, DateTime PreCeedingBaseEndtime,List<SubCalendarEvent> Appendables, TimeLine BoundaryTimeLine)
        {
            /*
             * This Constructor is called when a continuation in Clumping is made.  Look at diagram below
             *
             *  |     |Clump1||baseEvent||         |
             *
             * The vertical bars represent the various boundaries(StartTime and Stop Time). Note there is no TimeSpace between Clump1 and baseEvent
             *
             *  Clump1 in the image is a continuation in the clumping. Remember Clumping tries to build towards the Left. The ReferenceStartTime is the calculated start time of Clump1. PreCeedingBaseEndtime is the End time of the Base Event in the diagram. It will be used in the line with "BreakOffClump = new ClumpSubCalendarEvent..."

             */
            int i = 0;
            //NonOverLapping_Clump = new List<ClumpSubCalendarEvent>();
            //OverLapping_Clump = new List<ClumpSubCalendarEvent>();
            SubCalEventsOverLapWithBase = new List<SubCalendarEvent>();
            List<SubCalendarEvent> UnClumppable = new List<SubCalendarEvent>();
            ClumpedResults = new Dictionary<SubCalendarEvent, ClumpSubCalendarEvent>();
            BreakOffClump = null;
            this.BoundaryTimeLine = new TimeLine(BoundaryTimeLine.Start, ReferenceStartTime); ;
            /*BaseEvent = BaseClump[0];//this can be reevaluated to cater to the most constrained. i.e the one with limted a later sart time and percentage fill for whatever is left.
            ReferenceStartTime = BaseEvent.getCalendarEventRange.End < BoundaryTimeLine.End ? BaseEvent.getCalendarEventRange.End : BoundaryTimeLine.End;
            foreach (SubCalendarEvent mySubCalendarEvent in BaseClump)
            {
                ReferenceStartTime -= BaseEvent.ActiveDuration;
            }*/

            for (; i < Appendables.Count; i++)
            {

                //List<SubCalendarEvent> ReferenceClump = new List<SubCalendarEvent>(BaseClump);
                DateTime TimeLimit = ReferenceStartTime - Appendables[i].ActiveDuration;
                bool Zero = (Appendables[i].getCalendarEventRange.Start <= TimeLimit);
                bool One = (TimeLimit >= BoundaryTimeLine.Start);
                //bool Two = (BoundaryTimeLine.TimelineSpan >= Appendables[i].EventTimeLine.TimelineSpan);

                if (Zero && One)// && Two)
                {
                    List<SubCalendarEvent> Removed_Unnecessary = Appendables.ToList();

                    SubCalendarEvent RelativeSubEvent = Appendables[i];

                    Removed_Unnecessary.Remove(RelativeSubEvent);

                    ClumpedResults.Add(RelativeSubEvent, null);

                    /*if (CompleteResolvedNonOverlapping.Count > 100)//This is a hack to resolve the memory issue
                    {
                        break;
                    }*/
                }
                else
                {
                    SubCalEventsOverLapWithBase.Add(Appendables[i]);
                }
            }

            List<SubCalendarEvent> arg1 = ClumpedResults.Keys.ToList();
            int j = 0;
            for (; j < arg1.Count; j++)
            {
                ClumpedResults[arg1[j]] = populateClumpedResults(PreCeedingBaseEndtime, arg1[j], ClumpedResults[arg1[j]], ReferenceStartTime - arg1[j].ActiveDuration, BoundaryTimeLine);
            }

            if (SubCalEventsOverLapWithBase.Count > 0)
            {
                SubCalendarEvent BreakOffSubCalEvent = SubCalEventsOverLapWithBase[0];
                SubCalEventsOverLapWithBase.Remove(BreakOffSubCalEvent);
                BreakOffClump = new ClumpSubCalendarEvent(BreakOffSubCalEvent, SubCalEventsOverLapWithBase, new TimeLine(PreCeedingBaseEndtime, BoundaryTimeLine.End));
            }
        }
コード例 #18
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
        virtual public bool shiftEvent(TimeSpan ChangeInTime, SubCalendarEvent[] UpdatedSubCalEvents)
        {
            TimeLine UpdatedTimeLine = new TimeLine(this.Start+ChangeInTime,this.End+ChangeInTime);
            
            foreach (SubCalendarEvent eachSubCalendarEvent in UpdatedSubCalEvents)
            { 
                if(!(UpdatedTimeLine.IsTimeLineWithin(eachSubCalendarEvent.RangeTimeLine)))
                {
                    return false;
                }
            }
            StartDateTime = StartDateTime + ChangeInTime;
            EndDateTime = EndDateTime + ChangeInTime;
            ArrayOfSubEvents = UpdatedSubCalEvents.ToArray();

            return true;
        }
コード例 #19
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
        virtual public TimeLine PinToEnd(TimeLine MyTimeLine, List<SubCalendarEvent> MySubCalendarEventList)
        {
            /*
             *Name: Jerome Biotidara
             *Description: This funciton is only called when the Timeline can fit the total timeline ovcupied by the Subcalendarevent. essentially it tries to pin itself to the last available spot
             */
            TimeSpan SubCalendarTimeSpan = new TimeSpan();
            foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)
            {
                SubCalendarTimeSpan.Add(MySubCalendarEvent.ActiveSlot.BusyTimeSpan);//  you might be able to combine the implementing for lopp with this in order to avoid several loops
            }
            if (SubCalendarTimeSpan > MyTimeLine.TimelineSpan)
            {
                throw new Exception("Oh oh check PinSubEventsToEnd Subcalendar is longer than timeline");
            }
            if (!MyTimeLine.IsDateTimeWithin(Start))
            {
                throw new Exception("Oh oh Calendar event isn't within Timeline range. Check PinSubEventsToEnd :(");
            }
            DateTime ReferenceTime = new DateTime();
            if (End > MyTimeLine.End)
            {
                ReferenceTime = MyTimeLine.End;
            }
            else
            {
                ReferenceTime = End;
            }
            List<BusyTimeLine> MyActiveSlot = new List<BusyTimeLine>();
            foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)
            {
                MySubCalendarEvent.PinToEndAndIncludeInTimeLine(MyTimeLine, this);//hack you need to handle cases where you cant shift subcalevent
            }

            
            return MyTimeLine;
        }
コード例 #20
0
        /*public ClumpSubCalendarEvent(List<SubCalendarEvent> BaseClump, List<SubCalendarEvent> Appendables, TimeLine BoundaryTimeLine)
        {
            int i = 0;
            NonOverLapping_Clump = new List<ClumpSubCalendarEvent>();
            OverLapping_Clump = new List<ClumpSubCalendarEvent>();
            List<SubCalendarEvent> UnClumppable = new List<SubCalendarEvent>();
            if (BaseClump.Count < 1)
            {
                if (Appendables.Count > 0)
                {
                    Appendables = Appendables.OrderBy(obj => obj.getCalendarEventRange.End).ToList();
                    SubCalendarEvent RelativeSubEvent = Appendables[0];
                    Appendables.Remove(Appendables[0]);
                    ClumpSubCalendarEvent myThis = new ClumpSubCalendarEvent(RelativeSubEvent, Appendables, BoundaryTimeLine);
                    NonOverLapping_Clump = myThis.NonOverLapping_Clump;
                    BaseEvent = myThis.BaseEvent;
                    NonOverLapping_Clump = myThis.NonOverLapping_Clump;
                    OverLapping_Clump = myThis.OverLapping_Clump;
                    ReferenceStartTime = myThis.ReferenceStartTime;
                    SubCalEventsOverLapWithBase = myThis.SubCalEventsOverLapWithBase;
                    BreakOffClump = myThis.BreakOffClump;

                }

            }
            else
            {
                BaseEvent = BaseClump[0];//this can be reevaluated to cater to the most constrained. i.e the one with limted a later sart time and percentage fill for whatever is left.
                ReferenceStartTime = BaseEvent.getCalendarEventRange.End < BoundaryTimeLine.End ? BaseEvent.getCalendarEventRange.End : BoundaryTimeLine.End;
                foreach (SubCalendarEvent mySubCalendarEvent in BaseClump)
                {
                    ReferenceStartTime -= BaseEvent.ActiveDuration;
                }

                for (; i < Appendables.Count; i++)
                {

                    List<SubCalendarEvent> ReferenceClump = new List<SubCalendarEvent>(BaseClump);
                    DateTime TimeLimit = ReferenceStartTime - Appendables[i].ActiveDuration;
                    bool Zero = (Appendables[i].getCalendarEventRange.Start <= TimeLimit);
                    bool One = (TimeLimit >= BoundaryTimeLine.Start);
                    //bool Two = (BoundaryTimeLine.TimelineSpan >= Appendables[i].EventTimeLine.TimelineSpan);

                    if (Zero && One)// && Two)
                    {
                        List<SubCalendarEvent> Removed_Unnecessary = Appendables.ToList();
                        List<SubCalendarEvent> ExtendedList = ReferenceClump.ToList();
                        Removed_Unnecessary.Remove(Appendables[i]);
                        ExtendedList.Add((Appendables[i]));
                        ClumpSubCalendarEvent NewClump = new ClumpSubCalendarEvent(ExtendedList, Removed_Unnecessary, BoundaryTimeLine);
                        NonOverLapping_Clump.Add(NewClump);
                        if (CompleteResolvedNonOverlapping.Count > 100)//This is a hack to resolve the memory issue
                        {
                            break;
                        }
                    }
                    else
                    {
                        SubCalEventsOverLapWithBase.Add(Appendables[i]);
                    }

                    if (SubCalEventsOverLapWithBase.Count > 0)
                    {
                        SubCalendarEvent BreakOffSubCalEvent = SubCalEventsOverLapWithBase[0];
                        SubCalEventsOverLapWithBase.Remove(BreakOffSubCalEvent);
                        BreakOffClump = new ClumpSubCalendarEvent(BreakOffSubCalEvent, SubCalEventsOverLapWithBase, new TimeLine((getLeftMostPossibleStartLine(BaseEvent, BoundaryTimeLine) + BaseEvent.ActiveDuration), BoundaryTimeLine.End));
                    }

                }
            }
        }*/
        DateTime getLeftMostPossibleStartLine(SubCalendarEvent Sorted, TimeLine Boundary)
        {
            if (Boundary.Start >= Sorted.getCalendarEventRange.Start)
            {
                return new DateTime(Boundary.Start.Ticks);
            }
            else
            {
                return new DateTime(Sorted.getCalendarEventRange.Start.Ticks);
            }
        }
コード例 #21
0
        public ClumpSubCalendarEvent(SubCalendarEvent BaseSubCalendarEvent, List<SubCalendarEvent> Appendables, TimeLine BoundaryTimeLine)
        {
            SubCalEventsOverLapWithBase = new List<SubCalendarEvent>();

            BaseEvent = BaseSubCalendarEvent;
            DateTime var1 = BaseEvent.getCalendarEventRange.End < BoundaryTimeLine.End ? BaseEvent.getCalendarEventRange.End : BoundaryTimeLine.End;//hack assumes base can fit within boundary
            this.BoundaryTimeLine = new TimeLine(BoundaryTimeLine.Start, var1);
            DateTime  ReferenceStartTime = var1 - BaseEvent.ActiveDuration;
            BreakOffClump = null;
            ClumpedResults = new Dictionary<SubCalendarEvent, ClumpSubCalendarEvent>();
            int i = 0;
            for (; i < Appendables.Count; i++)
            {
                List<SubCalendarEvent> ReferenceClump = new List<SubCalendarEvent>();
                ReferenceClump.Add(BaseSubCalendarEvent);
                DateTime TimeLimit = ReferenceStartTime - Appendables[i].ActiveDuration;
                bool Zero = (Appendables[i].getCalendarEventRange.Start <= TimeLimit);
                bool One = (TimeLimit >= BoundaryTimeLine.Start);
                //bool Two = (BoundaryTimeLine.TimelineSpan>=Appendables[i].EventTimeLine.TimelineSpan);//this is a hack, since the length of SubcalEvent Event TimeLine is the same length of time as its busy time span

                if (Zero && One)// && Two)
                {
                    List<SubCalendarEvent> Removed_Unnecessary = Appendables.ToList();
            //                    List<SubCalendarEvent> ExtendedList = ReferenceClump.ToList();
                    SubCalendarEvent RelativeSubEvent = Appendables[i];

                    Removed_Unnecessary.Remove(RelativeSubEvent);

              //                  ExtendedList.Add((Appendables[i]));
                    ClumpedResults.Add(RelativeSubEvent, null);

                    //NonOverLapping_Clump.Add();
                    if (Removed_Unnecessary.Count > 0)
                    {

                        ++Completed;
                        if (Completed >= 100)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    //List<SubCalendarEvent> Removed_Unnecessary = Appendables.ToList();
                    //List<SubCalendarEvent> ExtendedList = ReferenceClump.ToList();
                    //Removed_Unnecessary.Remove(Appendables[i]);
                    SubCalEventsOverLapWithBase.Add(Appendables[i]);
                }
            }

            List<SubCalendarEvent> arg1=ClumpedResults.Keys.ToList();
            //if(arg1!=null)
            {
                int j=0;
                DateTime BaseReferenceEndTime = BaseEvent.getCalendarEventRange.End > BoundaryTimeLine.End ? BoundaryTimeLine.End : BaseEvent.getCalendarEventRange.End;//End Time for Base to be used as the reference for the current base end time
                for (;j<arg1.Count;j++)
                {

                    ClumpedResults[arg1[j]] = populateClumpedResults(BaseReferenceEndTime, arg1[j], ClumpedResults[arg1[j]], ReferenceStartTime - arg1[j].ActiveDuration, BoundaryTimeLine);
                }

            }

            if (SubCalEventsOverLapWithBase.Count > 0)
            {
                SubCalendarEvent BreakOffSubCalEvent = SubCalEventsOverLapWithBase[0];
                SubCalEventsOverLapWithBase.Remove(BreakOffSubCalEvent);
                BreakOffClump = new ClumpSubCalendarEvent(BreakOffSubCalEvent, SubCalEventsOverLapWithBase, new TimeLine((getLeftMostPossibleStartLine(BaseEvent, BoundaryTimeLine) + BaseEvent.ActiveDuration), BoundaryTimeLine.End));
            }
            List<SubCalendarEvent> Fittable = new List<SubCalendarEvent>();
        }
コード例 #22
0
 ClumpSubCalendarEvent populateClumpedResults(DateTime BaseEndTime,SubCalendarEvent refSubCalendarEvent, ClumpSubCalendarEvent refClumpSubCalendarEvent, DateTime RefereceStartTime, TimeLine BoundaryTimeLine)
 {
     List<SubCalendarEvent> Arg1 = ClumpedResults.Keys.ToList();
     bool temp = Arg1.Remove(refSubCalendarEvent);
     refClumpSubCalendarEvent = new ClumpSubCalendarEvent(RefereceStartTime,BaseEndTime, Arg1, BoundaryTimeLine);
     return refClumpSubCalendarEvent;
 }
コード例 #23
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
 public CalendarEvent(string EventName, TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, TimeSpan Event_PreDeadline, bool EventRigidFlag, Repetition EventRepetitionEntry, int EventSplit, Location EventLocation)
 {
     CalendarEventName = EventName;
     /*CalendarEventName = EventName.Split(',')[0];
     LocationString = "";
     if (EventName.Split(',').Length > 1)
     {
         LocationString = EventName.Split(',')[1];
     }
     CalendarEventLocation = null;
     CalendarEventLocation = new Location();
     if (LocationString != "")
     {
         CalendarEventLocation = new Location(LocationString);
     }
     */
     StartDateTime = EventStart;
     EndDateTime = EventDeadline;
     EventDuration = Event_Duration;
     Splits = EventSplit;
     PrepTime = EventPrepTime;
     EventPreDeadline = Event_PreDeadline;
     RigidSchedule = EventRigidFlag;
     TimePerSplit = TimeSpan.FromTicks(((EventDuration.Ticks / Splits)));
     ArrayOfSubEvents = new SubCalendarEvent[Splits];
     CalendarEventID = new EventID(new string[] { EventIDGenerator.generate().ToString() });
     EventRepetition = EventRepetitionEntry;
     LocationData = EventLocation;
     EventSequence = new TimeLine(StartDateTime, EndDateTime);
     UpdateLocationMatrix(LocationData);
 }
コード例 #24
0
 public bool canExistWithinTimeLine(TimeLine PossibleTimeLine)
 {
     SubCalendarEvent thisCopy = this.createCopy();
      return (thisCopy.PinSubEventsToStart(PossibleTimeLine) && thisCopy.PinToEnd(PossibleTimeLine));
 }
コード例 #25
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
        virtual public TimeLine PinSubEventsToStart(TimeLine MyTimeLine, List<SubCalendarEvent> MySubCalendarEventList)
        {
            TimeSpan SubCalendarTimeSpan = new TimeSpan();
            DateTime ReferenceStartTime = new DateTime();
            DateTime ReferenceEndTime = new DateTime();
            
            ReferenceStartTime = MyTimeLine.Start;
            if (this.Start > MyTimeLine.Start)
            {
                ReferenceStartTime = this.Start;
            }

            ReferenceEndTime = this.End;
            if (this.End > MyTimeLine.End)
            {
                ReferenceEndTime = MyTimeLine.End;
            }

            foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)
            {
                SubCalendarTimeSpan = SubCalendarTimeSpan.Add(MySubCalendarEvent.ActiveDuration);//  you might be able to combine the implementing for lopp with this in order to avoid several loops
            }
            TimeSpan TimeDifference = (ReferenceEndTime- ReferenceStartTime);

            if (this.Rigid)
            {
                return null;
            }

            if (SubCalendarTimeSpan > TimeDifference)
            {
                return null;
                //throw new Exception("Oh oh check PinSubEventsToStart Subcalendar is longer than available timeline");
            }
            if ((ReferenceStartTime>this.End)||(ReferenceEndTime<this.Start))
            {
                return null;
                //throw new Exception("Oh oh Calendar event isn't Timeline range. Check PinSubEventsToEnd :(");
            }

            List<BusyTimeLine> MyActiveSlot = new List<BusyTimeLine>();
            foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)
            {
                DateTime MyStartTime = ReferenceStartTime;
                DateTime EndTIme = MyStartTime + MySubCalendarEvent.ActiveDuration;
                MySubCalendarEvent.ActiveSlot = new BusyTimeLine(MySubCalendarEvent.ID, (MyStartTime), EndTIme);
                ReferenceStartTime = EndTIme;
                MyActiveSlot.Add(MySubCalendarEvent.ActiveSlot);
            }

            MyTimeLine.OccupiedSlots = MyActiveSlot.ToArray();
            return MyTimeLine;
        }
コード例 #26
0
        public bool PinSubEventsToStart(TimeLine MyTimeLine)
        {
            TimeSpan SubCalendarTimeSpan = new TimeSpan();
            DateTime ReferenceStartTime = new DateTime();
            DateTime ReferenceEndTime = new DateTime();

            ReferenceStartTime = MyTimeLine.Start;
            if (this.getCalendarEventRange.Start > MyTimeLine.Start)
            {
                ReferenceStartTime = this.getCalendarEventRange.Start;
            }

            ReferenceEndTime = this.getCalendarEventRange.End;
            if (this.getCalendarEventRange.End > MyTimeLine.End)
            {
                ReferenceEndTime = MyTimeLine.End;
            }

            /*foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)
            {
                SubCalendarTimeSpan = SubCalendarTimeSpan.Add(MySubCalendarEvent.ActiveDuration);//  you might be able to combine the implementing for lopp with this in order to avoid several loops
            }*/
            TimeSpan TimeDifference = (ReferenceEndTime - ReferenceStartTime);

            if (this.Rigid)
            {
                return true;
            }

            if (this.EventDuration > TimeDifference)
            {
                return false;
                //throw new Exception("Oh oh check PinSubEventsToStart Subcalendar is longer than available timeline");
            }
            if ((ReferenceStartTime > this.getCalendarEventRange.End) || (ReferenceEndTime < this.getCalendarEventRange.Start))
            {
                return false;
                //throw new Exception("Oh oh Calendar event isn't Timeline range. Check PinSubEventsToEnd :(");
            }

            List<BusyTimeLine> MyActiveSlot = new List<BusyTimeLine>();
            //foreach (SubCalendarEvent MySubCalendarEvent in MySubCalendarEventList)

                this.StartDateTime= ReferenceStartTime;
                this.EndDateTime = this.StartDateTime + this.ActiveDuration;
                //this.ActiveSlot = new BusyTimeLine(this.ID, (this.StartDateTime), this.EndDateTime);
                TimeSpan BusyTimeLineShift = this.StartDateTime - ActiveSlot.Start;
                ActiveSlot.shiftTimeline(BusyTimeLineShift);
                return true;
        }
コード例 #27
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
 virtual public void updateEventSequence()
 {
     EventSequence = new TimeLine(this.Start, this.End);
     foreach (SubCalendarEvent mySubCalendarEvent in ArrayOfSubEvents)
     {
         if (mySubCalendarEvent != null)
         {
             EventSequence.MergeTimeLines(mySubCalendarEvent.RangeTimeLine);
         }
         
     }
 }
コード例 #28
0
        public bool PinToEndAndIncludeInTimeLine(TimeLine LimitingTimeLine)
        {
            DateTime ReferenceTime = new DateTime();
            EndDateTime = this.getCalendarEventRange.End;
            ReferenceTime = EndDateTime;
            if (EndDateTime > LimitingTimeLine.End)
            {
                ReferenceTime = LimitingTimeLine.End;
            }
            DateTime MyStartTime = ReferenceTime - this.EventDuration;
            if(this.getCalendarEventRange.IsTimeLineWithin(new TimeLine(MyStartTime,ReferenceTime)))
            {

                StartDateTime = MyStartTime;
                //ActiveSlot = new BusyTimeLine(this.ID, (MyStartTime), ReferenceTime);
                TimeSpan BusyTimeLineShift = MyStartTime - ActiveSlot.Start;
                ActiveSlot.shiftTimeline(BusyTimeLineShift);
                EndDateTime = ReferenceTime;
                LimitingTimeLine.AddBusySlots(ActiveSlot);
                return true;
            }
            return false;
        }
コード例 #29
0
ファイル: CalendarEvent.cs プロジェクト: jerbio/WagTapWeb
 public CalendarEvent(CalendarEvent MyUpdated, SubCalendarEvent[] MySubEvents)
 {
     CalendarEventName = MyUpdated.Name;
     
     StartDateTime = MyUpdated.StartDateTime;
     EndDateTime = MyUpdated.End;
     EventSequence = new TimeLine(StartDateTime, EndDateTime);
     EventDuration = MyUpdated.ActiveDuration;
     Splits = MyUpdated.Splits;
     PrepTime = MyUpdated.PrepTime;
     EventPreDeadline = MyUpdated.PreDeadline;
     RigidSchedule = MyUpdated.Rigid;
     TimePerSplit = MyUpdated.TimePerSplit;
     ArrayOfSubEvents = new SubCalendarEvent[Splits];
     if (MyUpdated.ID != null)
     {
         CalendarEventID = new EventID(MyUpdated.ID.Split('_'));
     }
     //CalendarEventID = new EventID(new string[] { EventIDGenerator.generate().ToString() });
     //ArrayOfSubEvents = generateSubEvent(ArrayOfSubEvents, 4, EventDuration, CalendarEventID.ToString());
     ArrayOfSubEvents = MySubEvents;
     SchedulStatus = false;
     EventRepetition = MyUpdated.Repeat;
     LocationData = MyUpdated.LocationData;
     UpdateLocationMatrix(LocationData);
     EventSequence = new TimeLine(StartDateTime, EndDateTime);
     //EventRepetition = new Repetition(EventRepetition.Enable, this, EventRepetition.Range, EventRepetition.Frequency);
 }
コード例 #30
0
        public bool PinToEndAndIncludeInTimeLine(TimeLine LimitingTimeLine, CalendarEvent RestrctingCalendarEvent)
        {
            if (new EventID(RestrctingCalendarEvent.ID).getLevelID(0) != SubEventID.getLevelID(0))
            {
                throw new Exception("Oh oh Sub calendar event Trying to pin to end of invalid calendar event. Check that you have matchin IDs");
            }
            DateTime ReferenceTime = new DateTime();
            EndDateTime=RestrctingCalendarEvent.End;
            if (EndDateTime > LimitingTimeLine.End)
            {
                ReferenceTime = LimitingTimeLine.End;
            }
            /*else
            {
                ReferenceTime = End;
            }*/

            DateTime MyStartTime = ReferenceTime - this.EventDuration;

            if (this.getCalendarEventRange.IsTimeLineWithin(new TimeLine(MyStartTime, ReferenceTime)))
            {
                StartDateTime = MyStartTime;
                //ActiveSlot = new BusyTimeLine(this.ID, (MyStartTime), ReferenceTime);
                TimeSpan BusyTimeLineShift = MyStartTime - ActiveSlot.Start;
                ActiveSlot.shiftTimeline(BusyTimeLineShift);
                EndDateTime = ReferenceTime;
                LimitingTimeLine.AddBusySlots(ActiveSlot);
                return true;
            }

            return false;
        }