예제 #1
0
        KeyValuePair<CalendarEvent, TimeLine> ReArrangeClashingEventsofRigid(CalendarEvent MyCalendarEvent, List<CalendarEvent> NoneCommitedCalendarEventsEvents)// this looks at the timeline of the calendar event and then tries to rearrange all subevents within the range to suit final output. Such that there will be sufficient time space for each subevent
        {
            /*
                Name{: Jerome Biotidara
             * this function is responsible for making sure there is some dynamic allotment of time to the subeevents. It takes a calendarevent of a a rigid event. It attempts to rearrange elements around this event. It detects any clashing events and tries to rearrange any non rigid clashing events 
             */

            
            TimeLine RangeForScheduleUpdate;
            DateTime EarliestStartTime;
            DateTime LatestEndTime;

            //AllEventDictionary.Add(MyCalendarEvent.ID, MyCalendarEvent);
            NoneCommitedCalendarEventsEvents.Add(MyCalendarEvent);
            SubCalendarEvent[] ArrayOfInterferringSubEvents = getInterferringSubEvents(MyCalendarEvent, NoneCommitedCalendarEventsEvents);//It gets all the subevents within the time frame
            Tuple<IEnumerable<SubCalendarEvent>, DateTime> refinedStartTimeAndInterferringEvents;
            List<SubCalendarEvent> collectionOfInterferringSubCalEvents;
            if (ArrayOfInterferringSubEvents.Length > 0)
            {
                EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;
                LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();


                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);

                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();
                //collectionOfInterferringSubCalEvents.Add(MyCalendarEvent.AllEvents[0]);//artificially adds the new rigid event
                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();
            }
            else
            {
                NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);//removes my cal event
                return new KeyValuePair<CalendarEvent, TimeLine>(null,null);
            }
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);

            Tuple<TimeLine, IEnumerable<SubCalendarEvent>> allInterferringSubCalEventsAndTimeLine = getAllInterferringEventsAndTimeLineInCurrentEvaluation(ArrayOfInterferringSubEvents, NoneCommitedCalendarEventsEvents, RangeForScheduleUpdate);


            ArrayOfInterferringSubEvents = allInterferringSubCalEventsAndTimeLine.Item2.ToArray();
            RangeForScheduleUpdate = allInterferringSubCalEventsAndTimeLine.Item1;



            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents);


            int i = 0;
            /*
            
            ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);//SortSubCalendarEvents(ArrayOfInterferringSubEvents.ToList(), false).ToArray();
            List<IDefinedRange>[] MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
            EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
            LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
            EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());

            while (SumOfAllEventsTimeSpan >= RangeForScheduleUpdate.TimelineSpan)//loops untill the sum all the interferring events can possibly fit within the timeline. Essentially possibly fittable
            {
                EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;//attempts to get subcalevent with a calendarevent with earliest start time
                LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;//attempts to get subcalevent with a calendarevent with latest Endtime
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates range of scan
                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//updates interferring events list
                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();
                ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);
                MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
                EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
                LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();

                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
                SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());
            }*/

            Dictionary<CalendarEvent, List<SubCalendarEvent>> DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = new Dictionary<CalendarEvent, List<SubCalendarEvent>>();
            List<SubCalendarEvent> RigidSubCalendarEvents = new List<SubCalendarEvent>(0);

            RigidSubCalendarEvents = ArrayOfInterferringSubEvents.Where(obj => obj.Rigid).ToList();
            
            List<BusyTimeLine> RigidSubCalendarEventsBusyTimeLine = new List<BusyTimeLine>(0);
            RigidSubCalendarEventsBusyTimeLine = RigidSubCalendarEvents.Select(obj => obj.ActiveSlot).ToList();
            i = 0;
            double OccupancyOfTimeLineSPan = (double)SumOfAllEventsTimeSpan.Ticks / (double)RangeForScheduleUpdate.TimelineSpan.Ticks;

            ArrayOfInterferringSubEvents = Utility.NotInList(ArrayOfInterferringSubEvents.ToList(), RigidSubCalendarEvents).ToArray();//removes rigid elements

            DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = generateDictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents(ArrayOfInterferringSubEvents.ToList(), NoneCommitedCalendarEventsEvents);
            

            List<CalendarEvent> SortedInterFerringCalendarEvents_Deadline = DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Keys.ToList();
            SortedInterFerringCalendarEvents_Deadline = SortedInterFerringCalendarEvents_Deadline.OrderBy(obj => obj.End).ToList();







            TimeLine ReferenceTimeLine = RangeForScheduleUpdate.CreateCopy();
            ReferenceTimeLine.AddBusySlots(RigidSubCalendarEventsBusyTimeLine.ToArray());//Adds all the rigid elements

            TimeLine[] ArrayOfFreeSpots = getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine), ReferenceTimeLine).ToArray();
            ArrayOfFreeSpots = getOnlyPertinentTimeFrame(ArrayOfFreeSpots, ReferenceTimeLine).ToArray();

            Dictionary<TimeLine, List<CalendarEvent>> DictTimeLineAndListOfCalendarevent = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<CalendarEvent>>();

            



            List<List<List<SubCalendarEvent>>> SnugListOfPossibleSubCalendarEventsClumps = BuildAllPossibleSnugLists(SortedInterFerringCalendarEvents_Deadline, MyCalendarEvent, DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents, ReferenceTimeLine,OccupancyOfTimeLineSPan);
            //Remember Jerome, I need to implement a functionality that permutates through the various options of pin to start option. So take for example two different event timeline that are pertinent to a free spot however one has a dead line preceeding the other, there will be a pin to start for two scenarios, one for each calendar event in which either of them gets pinned first.

            NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);

            return EvaluateEachSnugPossibiliyOfSnugPossibility(SnugListOfPossibleSubCalendarEventsClumps, ReferenceTimeLine, MyCalendarEvent);
        }
예제 #2
0
 public double getDistance(CalendarEvent CalEvent)
 {
     //get
     {
         return DistanceMatrix[this.CalendarEventID.getLevelID(0)][DistanceMatixKeys.IndexOf(CalEvent.CalendarEventID.getLevelID(0))];
     }
 }
예제 #3
0
 public static int CompareByStartDate(CalendarEvent CalendarEvent1, CalendarEvent CalendarEvent2)
 {
     return CalendarEvent1.Start.CompareTo(CalendarEvent2.Start);
 }
예제 #4
0
            public CalendarEvent getCalendarEventObjFromNode(XmlNode EventScheduleNode)
            {
                string ID;
                string Deadline;
                string Split;
                string Completed;
                string Rigid;
                string Name;
                string[] StartDateTime;
                string StartDate;
                string StartTime;
                string[] EndDateTime;
                string EndDate;
                string EndTime;
                string PreDeadline;
                string CalendarEventDuration;
                string PreDeadlineFlag;
                string EventRepetitionflag;
                string PrepTimeFlag;
                string PrepTime;
                string RepeatStart;
                string RepeatEnd;
                string RepeatFrequency;
                string LocationData;
                string EnableFlag;

                Name = EventScheduleNode.SelectSingleNode("Name").InnerText;
                ID = EventScheduleNode.SelectSingleNode("ID").InnerText;
                //EventScheduleNode.SelectSingleNode("ID").InnerXml = "<wetin></wetin>";
                Deadline = EventScheduleNode.SelectSingleNode("Deadline").InnerText;
                Rigid = EventScheduleNode.SelectSingleNode("RigidFlag").InnerText;
                XmlNode RecurrenceXmlNode = EventScheduleNode.SelectSingleNode("Recurrence");
                EventRepetitionflag = EventScheduleNode.SelectSingleNode("RepetitionFlag").InnerText;

                StartDateTime = EventScheduleNode.SelectSingleNode("StartTime").InnerText.Split(' ');

                StartDate = StartDateTime[0];
                StartTime = StartDateTime[1] + StartDateTime[2];
                EndDateTime = EventScheduleNode.SelectSingleNode("Deadline").InnerText.Split(' ');
                EndDate = EndDateTime[0];
                EndTime = EndDateTime[1] + EndDateTime[2];
                DateTime StartTimeConverted = DateTime.Parse(StartDate);// new DateTime(Convert.ToInt32(StartDate.Split('/')[2]), Convert.ToInt32(StartDate.Split('/')[0]), Convert.ToInt32(StartDate.Split('/')[1]));
                DateTime EndTimeConverted = DateTime.Parse(EndDate); //new DateTime(Convert.ToInt32(EndDate.Split('/')[2]), Convert.ToInt32(EndDate.Split('/')[0]), Convert.ToInt32(EndDate.Split('/')[1]));

                Repetition Recurrence;
                if (Convert.ToBoolean(EventRepetitionflag))
                {
                    RepeatStart = RecurrenceXmlNode.SelectSingleNode("RepeatStartDate").InnerText;
                    RepeatEnd = RecurrenceXmlNode.SelectSingleNode("RepeatEndDate").InnerText;
                    RepeatFrequency = RecurrenceXmlNode.SelectSingleNode("RepeatFrequency").InnerText;
                    XmlNode XmlNodeWithList = RecurrenceXmlNode.SelectSingleNode("RepeatCalendarEvents");
                    Recurrence = new Repetition(true, new TimeLine(DateTime.Parse(RepeatStart), DateTime.Parse(RepeatEnd)), RepeatFrequency, getAllRepeatCalendarEvents(XmlNodeWithList));

                    StartTimeConverted = DateTime.Parse(RepeatStart);
                    EndTimeConverted = DateTime.Parse(RepeatEnd);
                }
                else
                {
                    Recurrence = new Repetition();
                }
                Split = EventScheduleNode.SelectSingleNode("Split").InnerText;
                PreDeadline = EventScheduleNode.SelectSingleNode("PreDeadline").InnerText;
                //PreDeadlineFlag = EventScheduleNode.SelectSingleNode("PreDeadlineFlag").InnerText;
                CalendarEventDuration = EventScheduleNode.SelectSingleNode("Duration").InnerText;
                //EventRepetitionflag = EventScheduleNode.SelectSingleNode("RepetitionFlag").InnerText;
                //PrepTimeFlag = EventScheduleNode.SelectSingleNode("PrepTimeFlag").InnerText;
                PrepTime = EventScheduleNode.SelectSingleNode("PrepTime").InnerText;
                Completed = EventScheduleNode.SelectSingleNode("Completed").InnerText;
                EnableFlag = EventScheduleNode.SelectSingleNode("Enabled").InnerText;
                bool EVentEnableFlag = Convert.ToBoolean(EnableFlag);
                bool completedFlag = Convert.ToBoolean(Completed);

                //string Name, string StartTime, DateTime StartDate, string EndTime, DateTime EventEndDate, string eventSplit, string PreDeadlineTime, string EventDuration, bool EventRepetitionflag, bool DefaultPrepTimeflag, bool RigidScheduleFlag, string eventPrepTime, bool PreDeadlineFlag

                //MainWindow.CreateSchedule("","",new DateTime(),"",new DateTime(),"","","",true,true,true,"",false);
                Recurrence = Recurrence;

                Location var3 = getLocation(EventScheduleNode);
                MiscData noteData = getMiscData(EventScheduleNode);
                EventDisplay UiData = getDisplayUINode(EventScheduleNode);

                CalendarEvent RetrievedEvent = new CalendarEvent(ID, Name, StartTime, StartTimeConverted, EndTime, EndTimeConverted, Split, PreDeadline, CalendarEventDuration, Recurrence, false, Convert.ToBoolean(Rigid), PrepTime, false, var3, EVentEnableFlag, UiData, noteData, completedFlag);
                RetrievedEvent = new CalendarEvent(RetrievedEvent, ReadSubSchedulesFromXMLNode(EventScheduleNode.SelectSingleNode("EventSubSchedules"), RetrievedEvent));
                return RetrievedEvent;
            }
예제 #5
0
        public void PinToEnd(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;
            ReferenceTime = EndDateTime;
            DateTime MyStartTime = ReferenceTime - this.EventDuration;
            StartDateTime = MyStartTime;

            //ActiveSlot = new BusyTimeLine(this.ID, (MyStartTime), ReferenceTime);
            TimeSpan BusyTimeLineShift = MyStartTime - ActiveSlot.Start;
            ActiveSlot.shiftTimeline(BusyTimeLineShift);
            EndDateTime = ReferenceTime;
        }
예제 #6
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;
        }
예제 #7
0
 public void CommitEventToLog(CalendarEvent MyCalEvent)
 {
     UserLog.WriteToLog(MyCalEvent);
 }
예제 #8
0
 public Tuple <CustomErrors,Dictionary<string, CalendarEvent>> Procrastinate(CalendarEvent NewEvent)
 {
     NewEvent = EvaluateTotalTimeLineAndAssignValidTimeSpots(NewEvent);
     Dictionary<string, CalendarEvent> AllEventDictionary_Cpy = new Dictionary<string, CalendarEvent>();
     AllEventDictionary_Cpy = AllEventDictionary.ToDictionary(obj => obj.Key, obj => obj.Value.createCopy());
     /*int i = 0;
     foreach (KeyValuePair<string, CalendarEvent> eachKeyValuePair in AllEventDictionary)
     {
         AllEventDictionary_Cpy.Add(eachKeyValuePair.Key, eachKeyValuePair.Value.createCopy());
         i++;
     }
     */
     
     Tuple<CustomErrors, Dictionary<string, CalendarEvent>> retValue = new Tuple<CustomErrors, Dictionary<string, CalendarEvent>>(NewEvent.Error, AllEventDictionary);
     AllEventDictionary=AllEventDictionary_Cpy;
     return retValue;
 }
예제 #9
0
        private CalendarEvent[] getPertinentCalendarEvents(CalendarEvent[] PossibleCalendarEvents, TimeLine VerifiableSpace)
        {
            List<CalendarEvent> MyPertinentCalendarList = new List<CalendarEvent>();

            foreach (CalendarEvent MyCalendarEvent in PossibleCalendarEvents)
            {

                if ((MyCalendarEvent.Start < VerifiableSpace.End) && (MyCalendarEvent.End > VerifiableSpace.Start))
                {
                    MyPertinentCalendarList.Add(MyCalendarEvent);
                }
            }
            return MyPertinentCalendarList.ToArray();
        }
예제 #10
0
        List<List<List<SubCalendarEvent>>> BuildAllPossibleSnugLists(List<CalendarEvent> SortedInterferringCalendarEvents, CalendarEvent ToBeFittedTimeLine, Dictionary<CalendarEvent, List<SubCalendarEvent>> DictionaryWithBothCalendarEventsAndListOfInterferringSubEvents, TimeLine ReferenceTimeLine, double Occupancy)
        {
            /*Name: Jerome Biotidara
             *Description: Function starts by Including all Rigid interferring schedules. Then goes on to setup tightest schedule.
             *Accomplished by:
             *1. stacking subevents of the same calendar event right next to each other.
             *2. Start Snugallotments based on deadline of Calendar Events
             *3. Try creating a snugness that has a snugness duration Greater than or Equal to start time and less than Or equal to the result generated by the difference between the CalendarEvent Deadline and Sum of Interferring subevent durations
             *4  Ensure that when you are assign subcalendar events, the sub calendar events that start within the timeline get noticed and are only allowed to start within the range
             */



            //TimeLine[] JustFreeSpots = ToBeFittedTimeLine.EventTimeLine.getAllFreeSlots();
            TimeLine[] JustFreeSpots = getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine);
            List<SubCalendarEvent>[] MyListOfSubCalendarEvents = DictionaryWithBothCalendarEventsAndListOfInterferringSubEvents.Values.ToArray();
            //TimeLine[] FreeSpotsWithOnlyRigids= ToBeFittedTimeLine.EventTimeLine.getAllFreeSlots();
            TimeLine[] FreeSpotsWithOnlyRigids = getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine);
            List<SubCalendarEvent> ListOfAllInterferringSubCalendarEvents = new List<SubCalendarEvent>();
            List<TimeSpan> ListOfAllInterferringTimeSpans = new List<TimeSpan>();

            foreach (List<SubCalendarEvent> MyList in MyListOfSubCalendarEvents)//Loop creates a List of interferring SubCalendarEvens
            {
                foreach (SubCalendarEvent MySubEvents in MyList)
                {
                    ListOfAllInterferringSubCalendarEvents.Add(MySubEvents);
                    ListOfAllInterferringTimeSpans.Add(MySubEvents.ActiveSlot.BusyTimeSpan);
                }
            }


            List<SubCalendarEvent> ListOfAlreadyAssignedSubCalendarEvents = new System.Collections.Generic.List<SubCalendarEvent>();

            /*foreach (BusyTimeLine MyBusySlot in ReferenceTimeLine.OccupiedSlots)
            {
                SubCalendarEvent MySubCalendarEvent = getSubCalendarEvent(MyBusySlot.TimeLineID);
                if (MySubCalendarEvent != null)
                {
                    ListOfAlreadyAssignedSubCalendarEvents.Add(MySubCalendarEvent);
                }
            }

            ListOfAllInterferringSubCalendarEvents = Utility.NotInList(ListOfAllInterferringSubCalendarEvents, ListOfAlreadyAssignedSubCalendarEvents);*/

            Dictionary<TimeLine, List<CalendarEvent>> DictionaryOfFreeTimeLineAndPertinentCalendarEventList = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<CalendarEvent>>();

            Dictionary<TimeLine, Dictionary<CalendarEvent, List<SubCalendarEvent>>> DictionaryOfFreeTimeLineAndDictionaryOfCalendarEventAndListOfSubCalendarEvent = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.Dictionary<CalendarEvent, System.Collections.Generic.List<SubCalendarEvent>>>();



            foreach (TimeLine MyFreeTimeLine in JustFreeSpots)
            {
                CalendarEvent[] MyListOfPertinentCalendarEventsForMyTimeLine = getPertinentCalendarEvents(SortedInterferringCalendarEvents.ToArray(), MyFreeTimeLine);
                Dictionary<CalendarEvent, List<SubCalendarEvent>> MyDictionaryOfCalendarEventAndPertinentSubCalendarEvent = new System.Collections.Generic.Dictionary<CalendarEvent, System.Collections.Generic.List<SubCalendarEvent>>();
                foreach (CalendarEvent MyCalendarEvent in MyListOfPertinentCalendarEventsForMyTimeLine)
                {
                    List<SubCalendarEvent> MyListwe = DictionaryWithBothCalendarEventsAndListOfInterferringSubEvents[MyCalendarEvent];
                    MyDictionaryOfCalendarEventAndPertinentSubCalendarEvent.Add(MyCalendarEvent, MyListwe);
                }
                DictionaryOfFreeTimeLineAndDictionaryOfCalendarEventAndListOfSubCalendarEvent.Add(MyFreeTimeLine, MyDictionaryOfCalendarEventAndPertinentSubCalendarEvent);
                DictionaryOfFreeTimeLineAndPertinentCalendarEventList.Add(MyFreeTimeLine, MyListOfPertinentCalendarEventsForMyTimeLine.ToList());//Next step is to call the snug array. Note: you will need to ensure that when ever a subevent gets used in a free timeline. It will have to be removed from the List so that it cannot be used in another free timeline. Also you need to create every possible permutation. Take for example a calendar event thats pertinent to two different "free timelines". you need to ensure that you have different calls to the snuglist generator that has the calendar event enabled in one and disabled in the other.
            }


            List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> EmptyIntialListOfSubCalendarEvemts = new List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();

            for (int i = 0; i < JustFreeSpots.Length; i++)
            {
                EmptyIntialListOfSubCalendarEvemts.Add(new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>());
            }



            Tuple<List<TimeSpanWithStringID>, List<mTuple<bool, SubCalendarEvent>>> Arg14 = ConvertSubCalendarEventToTimeSpanWitStringID(ListOfAllInterferringSubCalendarEvents);

            List<TimeSpanWithStringID> SubCalEventsAsTimeSpanWithStringID = Arg14.Item1;//ListOfAllInterferringSubCalendarEvents as TimeSpanWithStringID
            List<mTuple<bool, SubCalendarEvent>> Arg15 = Arg14.Item2;

            Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> Dict_StringTickAndCount = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();
            Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> Dict_StringTickAndCount_Cpy = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();

            foreach (TimeSpanWithStringID eachTimeSpanWithStringID in SubCalEventsAsTimeSpanWithStringID)
            {
                if (Dict_StringTickAndCount.ContainsKey(eachTimeSpanWithStringID.timeSpan))
                {
                    ++Dict_StringTickAndCount[eachTimeSpanWithStringID.timeSpan].Item1;
                    ++Dict_StringTickAndCount_Cpy[eachTimeSpanWithStringID.timeSpan].Item1;
                }
                else
                {
                    Dict_StringTickAndCount.Add(eachTimeSpanWithStringID.timeSpan, new mTuple<int, TimeSpanWithStringID>(1, eachTimeSpanWithStringID));
                    Dict_StringTickAndCount_Cpy.Add(eachTimeSpanWithStringID.timeSpan, new mTuple<int, TimeSpanWithStringID>(1, eachTimeSpanWithStringID));
                }
            }


            Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> TotalSum = new Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();

            TotalSum = SnugArray.CreateCopyOFSnuPossibilities(Dict_StringTickAndCount_Cpy);

            InterferringTimeSpanWithStringID_Cpy = Dict_StringTickAndCount_Cpy;//hack to keep track of available events


            Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> Dict_TimeLine_ListOfSubCalendarEvent = BuildDicitionaryOfTimeLineAndSubcalendarEvents(Arg15, DictionaryOfFreeTimeLineAndDictionaryOfCalendarEventAndListOfSubCalendarEvent, ToBeFittedTimeLine);

            Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> Dict_ConstrainedList = generateConstrainedList(JustFreeSpots.ToList(), Arg15);

            Dictionary<TimeLine, List<mTuple<int, TimeSpanWithStringID>>> Dict_TimeLine_ListOfmTuple = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<int, TimeSpanWithStringID>>>();

            Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> Dict_TimeLine_Dict_string_mTple = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();

            Dictionary<TimeLine, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>> Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents = new Dictionary<TimeLine, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>>();

            Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> Dict_TimeLine_Dict_string_mTple_Constrained = new Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();

            foreach (TimeLine eachTimeLine in Dict_TimeLine_ListOfSubCalendarEvent.Keys)
            {
                List<mTuple<bool, SubCalendarEvent>> LisOfSubCalEvent = Dict_TimeLine_ListOfSubCalendarEvent[eachTimeLine];
                Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> myDict = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();
                Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> myDict0 = new Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>();


                foreach (mTuple<bool, SubCalendarEvent> eachmTuple in LisOfSubCalEvent)//goes Through each Subcalevent in Each timeline and generates a dict for a TimeTick To List of TimeSpanID
                {
                    if (myDict.ContainsKey(eachmTuple.Item2.ActiveDuration))
                    {
                        ++myDict[eachmTuple.Item2.ActiveDuration].Item1;
                    }
                    else
                    {
                        myDict.Add(eachmTuple.Item2.ActiveDuration, new mTuple<int, TimeSpanWithStringID>(1, new TimeSpanWithStringID(eachmTuple.Item2.ActiveDuration, eachmTuple.Item2.ActiveDuration.Ticks.ToString())));

                    }



                    if (myDict0.ContainsKey(eachmTuple.Item2.ActiveDuration))
                    {


                        myDict0[eachmTuple.Item2.ActiveDuration].Add(eachmTuple.Item2.ID, eachmTuple);
                    }
                    else
                    {
                        Dictionary<string, mTuple<bool, SubCalendarEvent>> var17 = new System.Collections.Generic.Dictionary<string, mTuple<bool, SubCalendarEvent>>();
                        var17.Add(eachmTuple.Item2.ID, eachmTuple);
                        myDict0.Add(eachmTuple.Item2.ActiveDuration, var17);
                    }

                }
                Dict_TimeLine_Dict_string_mTple.Add(eachTimeLine, myDict);
                Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents.Add(eachTimeLine, myDict0);
            }


            foreach (TimeLine eachTimeLine in Dict_ConstrainedList.Keys)
            {
                List<mTuple<bool, SubCalendarEvent>> LisOfSubCalEvent = Dict_ConstrainedList[eachTimeLine];
                Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> myDict = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();
                foreach (mTuple<bool, SubCalendarEvent> eachmTuple in LisOfSubCalEvent)//goes Through each Subcalevent in Each timeline and generates a dict for a TimeTick To List of TimeSpanID
                {
                    if (myDict.ContainsKey(eachmTuple.Item2.ActiveDuration))
                    {
                        ++myDict[eachmTuple.Item2.ActiveDuration].Item1;
                    }
                    else
                    {
                        myDict.Add(eachmTuple.Item2.ActiveDuration, new mTuple<int, TimeSpanWithStringID>(1, new TimeSpanWithStringID(eachmTuple.Item2.ActiveDuration, eachmTuple.Item2.ActiveDuration.Ticks.ToString())));
                    }
                }

                Dict_TimeLine_Dict_string_mTple_Constrained.Add(eachTimeLine, myDict);
            }

            /*
            foreach (TimeLine eachTimeLine in Dict_TimeLine_Dict_string_mTple.Keys)
            {
                Dictionary<string, mTuple<int, TimeSpanWithStringID>> stringMtuple = Dict_TimeLine_Dict_string_mTple[eachTimeLine];
                List<mTuple<int, TimeSpanWithStringID>> List_mTuple = new System.Collections.Generic.List<mTuple<int, TimeSpanWithStringID>>();

                foreach (KeyValuePair<string, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in stringMtuple)
                {
                    TimeSpanWithStringID myTimeSpanWithStringID = eachKeyValuePair.Value.Item2;
                    List_mTuple.Add(new mTuple<int, TimeSpanWithStringID>(eachKeyValuePair.Value.Item1, myTimeSpanWithStringID));
                }

                Dict_TimeLine_ListOfmTuple.Add(eachTimeLine, List_mTuple);
            }

            */


            Dictionary<TimeLine, Tuple<Dictionary<string, mTuple<int, TimeSpanWithStringID>>, Dictionary<string, mTuple<int, TimeSpanWithStringID>>>> var6 = new System.Collections.Generic.Dictionary<TimeLine, Tuple<System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>, System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>>>();

            //Dictionary<TimeLine, Dictionary<string, mTuple<int, TimeSpanWithStringID>>>
            int i0 = 0;
            List<TimeLine> var7 = Dict_TimeLine_Dict_string_mTple_Constrained.Keys.ToList();//List Of TimeLines pertaining to COnstrained List i.e restricted elements
            Dictionary<string, mTuple<int, TimeSpanWithStringID>> var10 = new System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>();
            List<KeyValuePair<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> var11 = Dict_TimeLine_Dict_string_mTple_Constrained.ToList(); //Same as Dict_TimeLine_Dict_string_mTple_Constrained only as List of KeyValuePair
            Dictionary<TimeLine, Dictionary<string, mTuple<int, TimeSpanWithStringID>>> var14 = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>>();
            Dictionary<TimeLine, Tuple<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> var15 = new Dictionary<TimeLine, Tuple<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>>();

            foreach (KeyValuePair<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> eachKeyValuePair in Dict_TimeLine_Dict_string_mTple_Constrained)
            {
                i0 = var7.IndexOf(eachKeyValuePair.Key);
                Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> var8 = eachKeyValuePair.Value;
                Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> var9 = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();
                for (; i0 < var7.Count; i0++)
                {
                    Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> var12 = var11[i0].Value;
                    foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> var13 in var12)
                    {
                        if (var9.ContainsKey(var13.Key))
                        {
                            var9[var13.Key].Item1 += var13.Value.Item1;
                        }
                        else
                        {
                            var9.Add(var13.Key, new mTuple<int, TimeSpanWithStringID>(var13.Value.Item1, var13.Value.Item2));
                        }
                    }
                }
                var15.Add(eachKeyValuePair.Key, new Tuple<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>(eachKeyValuePair.Value, var9));
            }



            List<List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> AllTImeLinesWithSnugPossibilities = generateTreeCallsToSnugArray(Dict_StringTickAndCount, JustFreeSpots.ToList(), 0, EmptyIntialListOfSubCalendarEvemts, Dict_TimeLine_Dict_string_mTple, var15);




            List<List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> validMatches = getValidMatches(ListOfAllInterferringSubCalendarEvents, AllTImeLinesWithSnugPossibilities, Dict_TimeLine_Dict_string_mTple_Constrained);

            List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> AverageMatched = getAveragedOutTIimeLine(validMatches, 0);



            Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> AveragedMatchAsDictWithTimeLine = new Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();

            i0 = 0;
            for (; i0 < JustFreeSpots.Length; i0++)
            {
                AveragedMatchAsDictWithTimeLine.Add(JustFreeSpots[i0], AverageMatched[i0]);
                //TotalSum[0] = SnugArray.AddToSnugPossibilityList(TotalSum[0], AverageMatched[i0]);
            }



            Dict_ConstrainedList = stitchRestrictedSubCalendarEvent(JustFreeSpots.ToList(), 0, Dict_ConstrainedList);

            Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> Dict_TimeLine_ListOfSubCalendarEvent_Cpy = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>(Dict_TimeLine_ListOfSubCalendarEvent);

            Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> DictWithTimeLine_ArrangedOptimizedSubCalEvents = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>()
;
            i0 = 0;
            List<mTuple<bool, SubCalendarEvent>> TotalArrangedElements = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();
            List<List<SubCalendarEvent>> TotalArrangedElements_NoMTuple = new System.Collections.Generic.List<System.Collections.Generic.List<SubCalendarEvent>>();
            List<TimeLine> ListOfTimeLines = JustFreeSpots.ToList();//This will be decremented so do not reused

            Dictionary<string, SubCalendarEvent> TestDict = new System.Collections.Generic.Dictionary<string, SubCalendarEvent>();

            List<List<SubCalendarEvent>> restrictedSubCaleventsAfterScheduleUpdate = new List<List<SubCalendarEvent>>();
            Dictionary<TimeLine, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>> copyOfPossibleEvents = createCopyOfPossibleEvents(Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents);

            

            foreach (KeyValuePair<TimeLine, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>> eachKeyValuePair in Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents)
            {
                List<mTuple<bool, SubCalendarEvent>> var16 = Dict_ConstrainedList[eachKeyValuePair.Key];
                List<BusyTimeLine> RestrictedBusySlots = new System.Collections.Generic.List<BusyTimeLine>();
                foreach (mTuple<bool, SubCalendarEvent> eachmTuple in var16)
                {
                    eachmTuple.Item1 = true;
                    RestrictedBusySlots.Add(eachmTuple.Item2.ActiveSlot);
                    TimeSpan ActiveTimespan1 = eachmTuple.Item2.ActiveDuration;
                    string SubEventID = eachmTuple.Item2.ID;
                    eachKeyValuePair.Value[ActiveTimespan1][SubEventID] = eachmTuple;
                }
                eachKeyValuePair.Key.AddBusySlots(RestrictedBusySlots.ToArray());
                if (i0 == 3|| i0 == 12)
                {
                    ;
                }



                List<mTuple<bool, SubCalendarEvent>> ArrangedElements = stitchUnRestrictedSubCalendarEvent(eachKeyValuePair.Key, var16, Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents[eachKeyValuePair.Key], AverageMatched[i0],Occupancy);
                foreach (TimeLine eachTimeLine in JustFreeSpots)
                {
                    foreach (mTuple<bool, SubCalendarEvent> eachmTuple in ArrangedElements)
                    {
                        TimeSpan ActiveTimeSpan0 = eachmTuple.Item2.ActiveDuration;
                        if (Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents[eachTimeLine].ContainsKey(ActiveTimeSpan0))
                        {
                            Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents[eachTimeLine][ActiveTimeSpan0].Remove(eachmTuple.Item2.ID);
                        }
                    }
                }
                /*
                if (i0 + 1 < Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents.Count)
                {
                    Dictionary<TimeLine, Dictionary<string, Dictionary<string, mTuple<bool, SubCalendarEvent>>>> test = Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents;
                    ArrangedElements = FurtherFillTimeLineWithSubCalEvents(ArrangedElements, JustFreeSpots[i0 + 1], AveragedMatchAsDictWithTimeLine, eachKeyValuePair.Key, test);
                    foreach (KeyValuePair<string, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair0 in AveragedMatchAsDictWithTimeLine[eachKeyValuePair.Key])
                    {
                        if (AveragedMatchAsDictWithTimeLine[JustFreeSpots[i0 + 1]].ContainsKey(eachKeyValuePair0.Key))
                        {
                            AveragedMatchAsDictWithTimeLine[JustFreeSpots[i0 + 1]][eachKeyValuePair0.Key].Item1 += eachKeyValuePair0.Value.Item1;
                        }
                        else
                        {
                            AveragedMatchAsDictWithTimeLine[JustFreeSpots[i0 + 1]].Add(eachKeyValuePair0.Key, new mTuple<int, TimeSpanWithStringID>(eachKeyValuePair0.Value));
                        }
                    }

                }*/
                foreach (TimeLine eachTimeLine in JustFreeSpots)
                {
                    foreach (mTuple<bool, SubCalendarEvent> eachmTuple in ArrangedElements)
                    {


                        TimeSpan ActiveTimeSpan2 = eachmTuple.Item2.ActiveDuration;
                        if (Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents[eachTimeLine].ContainsKey(ActiveTimeSpan2))
                        {
                            Dict_TimeLine_Dict_StringID_Dict_SubEventStringID_mTuple_Bool_MatchinfSubCalevents[eachTimeLine][ActiveTimeSpan2].Remove(eachmTuple.Item2.ID);
                        }
                    }
                }



                TotalArrangedElements_NoMTuple.Add(Utility.mTupleToSubCalEvents(ArrangedElements));
                List<mTuple<bool, SubCalendarEvent>> previous = TotalArrangedElements.ToList();
                int BeforeErrorIndex = TotalArrangedElements.Count;
                TotalArrangedElements.AddRange(ArrangedElements);
                int AfterErrorIndex = TotalArrangedElements.Count;
                DictWithTimeLine_ArrangedOptimizedSubCalEvents.Add(eachKeyValuePair.Key, ArrangedElements);
                Dict_TimeLine_ListOfSubCalendarEvent_Cpy.Remove(eachKeyValuePair.Key);





                foreach (List<mTuple<bool, SubCalendarEvent>> eachList in Dict_TimeLine_ListOfSubCalendarEvent_Cpy.Values)
                {
                    int i = 0;
                    for (; i < eachList.Count; i++)
                    {
                        /*if (eachList[i].Item1)
                        {
                            eachList.RemoveAt(i);
                            --i;
                        }*/

                        foreach (mTuple<bool, SubCalendarEvent> eachmTuple in ArrangedElements)
                        {
                            if (eachList[i].Item2.ID == eachmTuple.Item2.ID)
                            {
                                eachList.RemoveAt(i);
                                --i;
                                break;
                            }


                        }


                    }
                }

                if (Dict_ConstrainedList.Count == 2)
                {
                    ;
                }



                List<SubCalendarEvent> UnassignedSubevents = ListOfAllInterferringSubCalendarEvents.ToList();
                List<SubCalendarEvent> AlreadyAssigned = Utility.mTupleToSubCalEvents(TotalArrangedElements);

                
                foreach (SubCalendarEvent eachSubCalendarEvent in AlreadyAssigned)
                {
                    if (eachSubCalendarEvent.ID == "470_482")
                    {
                        ;
                    }
                    TestDict.Add(eachSubCalendarEvent.ID, eachSubCalendarEvent);//if it crashes at this point there is some possible error in your constrained list generating duplicate values. 
                }
                TestDict = new System.Collections.Generic.Dictionary<string, SubCalendarEvent>();
                /*
                UnassignedSubevents=Utility.NotInList(UnassignedSubevents, AlreadyAssigned);
                */
                List<string> MyAssignedIDs = AlreadyAssigned.Select(obj => obj.ID).ToList();

                UnassignedSubevents.RemoveAll(e => MyAssignedIDs.Contains(e.ID));
                int StartIndex = 0;
                if (Dict_ConstrainedList.Count > 1)
                {
                    restrictedSubCaleventsAfterScheduleUpdate.Add(Utility.mTupleToSubCalEvents(Dict_ConstrainedList[ListOfTimeLines[0]]));
                    StartIndex = i0 + 1;
                    ListOfTimeLines.RemoveAt(0);

                    Dict_ConstrainedList = generateConstrainedList(ListOfTimeLines, Utility.SubCalEventsTomTuple(UnassignedSubevents, false));

                    TimeLine PertinentTimeLine=Dict_TimeLine_ListOfSubCalendarEvent_Cpy.Keys.ToList()[0];
                    List<mTuple<bool, SubCalendarEvent>> beforeList = Dict_ConstrainedList[PertinentTimeLine];
                    int before = Dict_ConstrainedList[PertinentTimeLine].Count;
                    
                    Dict_ConstrainedList[PertinentTimeLine] = stitchRestrictedSubCalendarEvent(Dict_ConstrainedList[PertinentTimeLine], PertinentTimeLine);
                    int after = Dict_ConstrainedList[PertinentTimeLine].Count;
                    List<mTuple<bool, SubCalendarEvent>> AfterList = Dict_ConstrainedList[PertinentTimeLine];
                    if (after != before)
                    {
                        ;
                    }
                    //Dict_ConstrainedList = stitchRestrictedSubCalendarEvent(Dict_TimeLine_ListOfSubCalendarEvent_Cpy.Keys.ToList(), 0, Dict_ConstrainedList);
                }
                i0++;
            }


            TimeSpan TotalBusyTimeFrame = Utility.SumOfActiveDuration(ListOfAllInterferringSubCalendarEvents);
            foreach(BusyTimeLine OccupiedSlot in ReferenceTimeLine.OccupiedSlots)
            {
                TotalBusyTimeFrame+=OccupiedSlot.BusyTimeSpan;
            }
            
            TimeSpan TotalTimeSpan = ReferenceTimeLine.TimelineSpan;


            double PercentageOfOccupiedSpace = (double)TotalBusyTimeFrame.Ticks / (double)TotalTimeSpan.Ticks;


            restrictedSubCaleventsAfterScheduleUpdate.Add(Utility.mTupleToSubCalEvents(Dict_ConstrainedList[ListOfTimeLines[0]]));//updates the constrained List one last time

            TotalArrangedElements_NoMTuple=SpreadOutEvents(TotalArrangedElements_NoMTuple, PercentageOfOccupiedSpace, JustFreeSpots.ToList(), copyOfPossibleEvents, restrictedSubCaleventsAfterScheduleUpdate);




            
            List<List<List<SubCalendarEvent>>> ReValue = new System.Collections.Generic.List<System.Collections.Generic.List<System.Collections.Generic.List<SubCalendarEvent>>>();
            //List<List<List<SubCalendarEvent>>> ReValue = FixSubCalEventOrder(AllTImeLinesWithSnugPossibilities, JustFreeSpots);
            ReValue.Add(TotalArrangedElements_NoMTuple);

            return ReValue;
        }
예제 #11
0
        private Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> BuildDicitionaryOfTimeLineAndSubcalendarEvents(List<mTuple<bool, SubCalendarEvent>> MyListOfInterferringmTupleSubCalendarEvents, Dictionary<TimeLine, Dictionary<CalendarEvent, List<SubCalendarEvent>>> DicitonaryTimeLineAndPertinentCalendarEventDictionary, CalendarEvent MyEvent)
        {


            List<TimeLine> MyListOfFreeTimelines = DicitonaryTimeLineAndPertinentCalendarEventDictionary.Keys.ToList();
            Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> DictionaryofTimeLineAndPertinentSubcalendar = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>();


            foreach (TimeLine MyTimeLine in MyListOfFreeTimelines)
            {
                //Dictionary<TimeLine, Dictionary<CalendarEvent, List<SubCalendarEvent>>> DicitonaryTimeLineAndPertinentCalendarEventDictionary1;

                Dictionary<CalendarEvent, List<SubCalendarEvent>> MyListOfDictionaryOfCalendarEventAndSubCalendarEvent = DicitonaryTimeLineAndPertinentCalendarEventDictionary[MyTimeLine];
                List<CalendarEvent> MyListOfPertitnentCalendars = MyListOfDictionaryOfCalendarEventAndSubCalendarEvent.Keys.ToList();
                MyListOfPertitnentCalendars = MyListOfPertitnentCalendars.OrderBy(obj => obj.End).ToList();
                List<mTuple<bool, SubCalendarEvent>> MyListOfPertinentSubEvent = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();
                foreach (CalendarEvent MyCalendarEvent in MyListOfPertitnentCalendars)
                {
                    List<SubCalendarEvent> InterFerringSubCalendarEventS = MyListOfDictionaryOfCalendarEventAndSubCalendarEvent[MyCalendarEvent];
                    if (MyCalendarEvent.Repeat.Enable)
                    {
                        List<CalendarEvent> MyListOfAffectedRepeatingCalendarEvent = getClashingCalendarEvent(MyCalendarEvent.Repeat.RecurringCalendarEvents.ToList(), MyTimeLine);



                        List<mTuple<bool, SubCalendarEvent>> ListOfAffectedSubcalendarEvents = new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>();
                        foreach (CalendarEvent MyRepeatCalendarEvent in MyListOfAffectedRepeatingCalendarEvent)
                        {
                            SubCalendarEvent[] MyListOfSubCalendarEvents = MyRepeatCalendarEvent.AllEvents;
                            foreach (SubCalendarEvent PosibleClashingSubCalEvent in MyListOfSubCalendarEvents)
                            {
                                foreach (SubCalendarEvent eachInterFerringSubCalendarEvent in InterFerringSubCalendarEventS)
                                {
                                    if (PosibleClashingSubCalEvent.ID == eachInterFerringSubCalendarEvent.ID)
                                    {
                                        ListOfAffectedSubcalendarEvents.Add(getmTupleSubCalendarEvent(MyListOfInterferringmTupleSubCalendarEvents, eachInterFerringSubCalendarEvent));
                                    }
                                }
                            }
                        }
                        MyListOfPertinentSubEvent.AddRange(ListOfAffectedSubcalendarEvents);
                    }
                    else
                    {
                        MyListOfPertinentSubEvent.AddRange(getmTupleSubCalendarEvent(MyListOfInterferringmTupleSubCalendarEvents, MyListOfDictionaryOfCalendarEventAndSubCalendarEvent[MyCalendarEvent]));

                    }
                }
                //var ConcatVar = MyListOfPertinentSubEvent.Concat(TempSubCalendarEventsForMyCalendarEvent.ToList());
                //MyListOfPertinentSubEvent = ConcatVar.ToList();
                DictionaryofTimeLineAndPertinentSubcalendar.Add(MyTimeLine, MyListOfPertinentSubEvent);
            }

            return DictionaryofTimeLineAndPertinentSubcalendar;

            /*foreach(TimeLine MyTimeLine in MyListOfFreeTimelines)
            {
                List<SubCalendarEvent> MyTimeLineListToWorkWith = getIntersectionList(MyInterferringSubCalendarEvents, DictionsryofTimeLineAndPertinentSubcalenda[MyTimeLine]);
                
            }
            */


        }
예제 #12
0
        Dictionary<string, double> BuildDictionaryDistanceEdge(TimeLine ReferenceTimeline, CalendarEvent ReferenceCalendarEvent, Dictionary<string, double> CurrentDictionary)
        {
            BusyTimeLine[] ListOfBusySlots = ReferenceTimeline.OccupiedSlots;
            int i = 0;
            //Dictionary<string, double> CurrentDictionaryFrom
            int j = 0;
            for (i = 0; i < (ListOfBusySlots.Length - 1); i++)
            {
                j = i + 1;
                string generatedIndexMatch = BuildStringIndexForMatch(ListOfBusySlots[i], ListOfBusySlots[j]);
                CalendarEvent MyPrecedingCalendarEvent;
                CalendarEvent MyNextCalendarEvent;
                try
                {
                    MyPrecedingCalendarEvent = AllEventDictionary[generatedIndexMatch.Split('_')[0]];
                }
                catch
                {
                    MyPrecedingCalendarEvent = ReferenceCalendarEvent;
                }

                try
                {
                    MyNextCalendarEvent = AllEventDictionary[generatedIndexMatch.Split('_')[1]];
                }

                catch
                {
                    MyNextCalendarEvent = ReferenceCalendarEvent;
                }
                if (!(CurrentDictionary.ContainsKey(generatedIndexMatch)))
                {
                    double Distance = Location.calculateDistance(MyPrecedingCalendarEvent.myLocation, MyNextCalendarEvent.myLocation);
                    CurrentDictionary.Add(generatedIndexMatch, Distance);
                }
            }

            return CurrentDictionary;
        }
예제 #13
0
        KeyValuePair<CalendarEvent, TimeLine> EvaluateEachSnugPossibiliyOfSnugPossibility(List<List<List<SubCalendarEvent>>> SnugPossibilityPermutation, TimeLine ReferenceTimeLine, CalendarEvent ReferenceCalendarEvent)
        {
            TimeLine CopyOfReferenceTimeLine;
            List<TimeLine> SnugPossibilityTimeLine = new System.Collections.Generic.List<TimeLine>();
            Dictionary<BusyTimeLine, SubCalendarEvent> MyBusyTimeLineToSubCalendarEventDict = new System.Collections.Generic.Dictionary<BusyTimeLine, SubCalendarEvent>();

            Dictionary<CalendarEvent, TimeLine> CalendarEvent_EvaluationIndexDict = new System.Collections.Generic.Dictionary<CalendarEvent, TimeLine>();

            foreach (List<List<SubCalendarEvent>> SnugPermutation in SnugPossibilityPermutation)//goes each permutation of snug possibility generated
            {
                List<SubCalendarEvent> AllSubEvents = new System.Collections.Generic.List<SubCalendarEvent>();

                foreach (List<SubCalendarEvent> eachList in SnugPermutation)
                {
                    AllSubEvents.AddRange(eachList);
                    foreach (SubCalendarEvent eachSubCalendarEvent in eachList)
                    {
                        ReferenceCalendarEvent.updateSubEvent(eachSubCalendarEvent.SubEvent_ID, eachSubCalendarEvent);
                        /*if (SubEvent != null)
                        {
                            SubEvent.updateSubEvent(SubEvent.SubEvent_ID, eachSubCalendarEvent);
                        }*/
                    }

                }

                ReferenceTimeLine = Utility.AddSubCaleventsToTimeLine(ReferenceTimeLine, AllSubEvents);
                CalendarEvent_EvaluationIndexDict.Add(ReferenceCalendarEvent, ReferenceTimeLine);

                /*
                CopyOfReferenceTimeLine = ReferenceTimeLine.CreateCopy();
                //SnugPossibilityTimeLine.Add(CopyOfReferenceTimeLine);
                List<TimeLine> ListOfFreeSpots=getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(CopyOfReferenceTimeLine), CopyOfReferenceTimeLine);
                List<SubCalendarEvent> ReassignedSubEvents = new System.Collections.Generic.List<SubCalendarEvent>();
                for (int i=0; i<ListOfFreeSpots.Count;i++)
                {
                    DateTime RelativeStartTime = ListOfFreeSpots[i].Start;

                    TimeLine UpdatedTimeLine=Utility.AddSubCaleventsToTimeLine(ListOfFreeSpots[i], SnugPermutation[i]);
                    ListOfFreeSpots[i].AddBusySlots(UpdatedTimeLine.OccupiedSlots);
                    
                    foreach (SubCalendarEvent MySubCalendarEvent in SnugPermutation[i])
                    {//tries to reassign each element in a snug permutation into the referencetimeLine
                        SubCalendarEvent CopyOfMySubCalendarEvent = MySubCalendarEvent.createCopy();
                        TimeSpan MySubCalendarDuration = (CopyOfMySubCalendarEvent.End - CopyOfMySubCalendarEvent.Start);
                        DateTime RelativeEndtime = RelativeStartTime + MySubCalendarDuration;
                        CopyOfMySubCalendarEvent.ReassignTime(RelativeStartTime, RelativeEndtime);
                        CopyOfMySubCalendarEvent.ActiveSlot = new BusyTimeLine(CopyOfMySubCalendarEvent.ID, RelativeStartTime, RelativeEndtime);//Note this is a hack to resolve the reassignment of time since we dont know currently know the distiction between BusyTimeLine and SubCalendarEvent(TimeLine)
                        TimeLine MyTimeLine=CopyOfMySubCalendarEvent.EventTimeLine;
                        CopyOfReferenceTimeLine.MergeTimeLines(MyTimeLine);
                        RelativeStartTime = CopyOfMySubCalendarEvent.End;
                        MyBusyTimeLineToSubCalendarEventDict.Add(CopyOfMySubCalendarEvent.ActiveSlot, CopyOfMySubCalendarEvent);
                    }
                }
                SnugPossibilityTimeLine.Add(CopyOfReferenceTimeLine);*/
            }

            Dictionary<string, double> DictionaryGraph = new System.Collections.Generic.Dictionary<string, double>();

            /*
            foreach (TimeLine MyTimeLine in SnugPossibilityTimeLine)
            {
                
                CalendarEvent MyEventCopy=ReferenceCalendarEvent.createCopy();
                
                foreach (BusyTimeLine MyBusyPeriod in MyTimeLine.OccupiedSlots)
                {
                    EventID MyEventID = new EventID(MyBusyPeriod.TimeLineID);
                    string ParentCalendarEventID = MyEventID.getLevelID(0);
                    if (MyEventCopy.ID == ParentCalendarEventID)
                    {

                        SubCalendarEvent MySubCalendarEvent=MyBusyTimeLineToSubCalendarEventDict[MyBusyPeriod];
                        for (int i = 0; i < MyEventCopy.AllEvents.Length; i++)
                        {
                            if (MyEventCopy.AllEvents[i].ID == MySubCalendarEvent.ID)
                            {
                                MyEventCopy.AllEvents[i] = MySubCalendarEvent;
                                break;
                            }
                        }
                        
                    }
                }
                
                //MyEventCopy=EvaluateTotalTimeLineAndAssignValidTimeSpotsWithReferenceTimeLine(MyEventCopy, MyTimeLine);

                
            }*/

            double HighestValue = 0;

            KeyValuePair<CalendarEvent, TimeLine> FinalSuggestion = new System.Collections.Generic.KeyValuePair<CalendarEvent, TimeLine>(CalendarEvent_EvaluationIndexDict.Keys.ToList()[0], CalendarEvent_EvaluationIndexDict.Values.ToList()[0]);

            /*TimeLine TimeLineUpdated = null;
            Dictionary<string, double> LocationVector = new System.Collections.Generic.Dictionary<string,double>();
            LocationVector.Add("sameElement", 10000000000);


            foreach (KeyValuePair<CalendarEvent, TimeLine> MyCalendarEvent_TimeLine in CalendarEvent_EvaluationIndexDict)
            {
                int RandomIndex = EvaluateRandomNetIndex(MyCalendarEvent_TimeLine.Value);
                RandomIndex = 0;
                LocationVector=BuildDictionaryDistanceEdge(MyCalendarEvent_TimeLine.Value, MyCalendarEvent_TimeLine.Key, LocationVector);
                double ClumpIndex = EvaluateClumpingIndex(MyCalendarEvent_TimeLine.Value, LocationVector);
                ClumpIndex = 1 / ClumpIndex;
                double EvaluationSum = ClumpIndex + RandomIndex;
                if (EvaluationSum < 0)
                {
                    EvaluationSum *= -1;
                }

                if ( EvaluationSum > HighestValue)
                {
                    HighestValue = EvaluationSum;
                    FinalSuggestion = MyCalendarEvent_TimeLine;
                }
            }

            if (FinalSuggestion.Equals(new KeyValuePair<CalendarEvent,TimeLine>()))
            {
                MessageBox.Show("Oh oh J, you'll need to look outside this range...Think of moving other events out of white box space");
            }
            */
            return FinalSuggestion;
        }
예제 #14
0
        KeyValuePair<CalendarEvent, TimeLine> ReArrangeTimeLineWithinWithinCalendaEventRange(CalendarEvent MyCalendarEvent, List<CalendarEvent> NoneCommitedCalendarEventsEvents)// this looks at the timeline of the calendar event and then tries to rearrange all subevents within the range to suit final output. Such that there will be sufficient time space for each subevent
        {
            /*
                Name{: Jerome Biotidara
             * this function is responsible for making sure there is some dynamic allotment of time to the subeevents. It takes a calendarevent, checks the alloted time frame and tries to move subevents within the time frame to satisfy the final goal.
             */
               int i = 0;

            if (MyCalendarEvent.RepetitionStatus == false)//Artificially generates random subevents for the calendar event
            {
                SubCalendarEvent[] TempSubCalendarEventsForMyCalendarEvent = new SubCalendarEvent[MyCalendarEvent.NumberOfSplit];
                for (i = 0; i < TempSubCalendarEventsForMyCalendarEvent.Length; i++)//populates the subevents for the calendar event
                {
                    TimeSpan MyActiveTimeSpanPerSplit = TimeSpan.FromTicks((long)((MyCalendarEvent.ActiveDuration.Ticks / MyCalendarEvent.NumberOfSplit) ));
                    TempSubCalendarEventsForMyCalendarEvent[i] = new SubCalendarEvent(MyActiveTimeSpanPerSplit, (MyCalendarEvent.End - MyActiveTimeSpanPerSplit), MyCalendarEvent.End, new TimeSpan(), MyCalendarEvent.ID, MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                    TempSubCalendarEventsForMyCalendarEvent[i] = new SubCalendarEvent(TempSubCalendarEventsForMyCalendarEvent[i].ID, TempSubCalendarEventsForMyCalendarEvent[i].Start, TempSubCalendarEventsForMyCalendarEvent[i].End, new BusyTimeLine(TempSubCalendarEventsForMyCalendarEvent[i].ID, TempSubCalendarEventsForMyCalendarEvent[i].Start, TempSubCalendarEventsForMyCalendarEvent[i].End), MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                    MyCalendarEvent.AllEvents[i] = TempSubCalendarEventsForMyCalendarEvent[i];
                }
            }
            else
            {
                throw new Exception("invalid calendar event detected in ReArrangeTimeLineWithinWithinCalendaEventRange. Repat not allowed");
            }
            

            TimeLine RangeForScheduleUpdate;
            DateTime EarliestStartTime;
            DateTime LatestEndTime;
            Tuple<IEnumerable<SubCalendarEvent>, DateTime> refinedStartTimeAndInterferringEvents;
            NoneCommitedCalendarEventsEvents.Add(MyCalendarEvent);
            SubCalendarEvent[] ArrayOfInterferringSubEvents = getInterferringSubEvents(MyCalendarEvent, NoneCommitedCalendarEventsEvents);//It gets all the subevents within the time frame

            List<SubCalendarEvent> collectionOfInterferringSubCalEvents;
            EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;
            LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;
            EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();


            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);

            collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();
            //collectionOfInterferringSubCalEvents.Add(MyCalendarEvent.AllEvents[0]);//artificially adds the new rigid event
            ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();



            Tuple<TimeLine,IEnumerable<SubCalendarEvent>> allInterferringSubCalEventsAndTimeLine = getAllInterferringEventsAndTimeLineInCurrentEvaluation(ArrayOfInterferringSubEvents, NoneCommitedCalendarEventsEvents, RangeForScheduleUpdate);


            ArrayOfInterferringSubEvents = allInterferringSubCalEventsAndTimeLine.Item2.ToArray();
            RangeForScheduleUpdate=allInterferringSubCalEventsAndTimeLine.Item1;

            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents);
            /*
            ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);//SortSubCalendarEvents(ArrayOfInterferringSubEvents.ToList(), false).ToArray();
            List<IDefinedRange>[] MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
            EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
            LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
            EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;

            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
            
            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());//sum all events

            while (SumOfAllEventsTimeSpan >= RangeForScheduleUpdate.TimelineSpan)//loops untill the sum all the interferring events can possibly fit within the timeline. Essentially possibly fittable
            {
                EarliestStartTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.Start).ToList()[0].getCalendarEventRange.Start;//attempts to get subcalevent with a calendarevent with earliest start time
                LatestEndTime = ArrayOfInterferringSubEvents.OrderBy(obj => obj.getCalendarEventRange.End).ToList()[ArrayOfInterferringSubEvents.Length - 1].getCalendarEventRange.End;//attempts to get subcalevent with a calendarevent with latest Endtime
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates range of scan
                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//updates interferring events list
                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToArray();
                ArrayOfInterferringSubEvents.OrderBy(obj => obj.End);
                MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
                EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;
                LatestEndTime = MyEdgeElements[1].Count > 0 ? MyEdgeElements[1].OrderBy(obj => obj.End).ToList()[MyEdgeElements[1].Count - 1].End : RangeForScheduleUpdate.End;
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;


                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime);
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToArray();

                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
                TimeSpan newSumOfAllTimeSpans = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());
                if (newSumOfAllTimeSpans == SumOfAllEventsTimeSpan)
                {
                    throw new Exception("You have events that cannot fit our time frame");
                }
                else 
                {
                    SumOfAllEventsTimeSpan = newSumOfAllTimeSpans;
                }

            }*/

            
            
            Dictionary<CalendarEvent, List<SubCalendarEvent>> DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = new Dictionary<CalendarEvent, List<SubCalendarEvent>>();
            List<SubCalendarEvent> RigidSubCalendarEvents = new List<SubCalendarEvent>(0);
            List<BusyTimeLine> RigidSubCalendarEventsBusyTimeLine = new List<BusyTimeLine>(0);


            RigidSubCalendarEvents = ArrayOfInterferringSubEvents.Where(obj => obj.Rigid).ToList();
            RigidSubCalendarEventsBusyTimeLine = RigidSubCalendarEvents.Select(obj => obj.ActiveSlot).ToList();

            double OccupancyOfTimeLineSPan = (double)SumOfAllEventsTimeSpan.Ticks / (double)RangeForScheduleUpdate.TimelineSpan.Ticks;
            
            ArrayOfInterferringSubEvents = Utility.NotInList(ArrayOfInterferringSubEvents.ToList(), RigidSubCalendarEvents).ToArray();//remove rigid elements
            
            
            //List<CalendarEvent>[]SubEventsTimeCategories= CategorizeSubEventsTimeLine
            /*
             * SubEventsTimeCategories has 4 list of containing lists.
             * 1st is a List with Elements Starting before The Mycalendaervent timeline and ends after the busytimeline
             * 2nd is a list with elements starting before the mycalendarvent timeline but ending before the myevent timeline
             * 3rd is a list with elements starting after the Mycalendar event start time but ending after the Myevent timeline
             * 4th is a list with elements starting after the MyCalendar event start time and ends before the Myevent timeline 
             * */
            DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents = generateDictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents(ArrayOfInterferringSubEvents.ToList(), NoneCommitedCalendarEventsEvents);//generates a dictionary of a Calendar Event and the interferring events in the respective Calendar event
            //DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Add(MyCalendarEvent, MyCalendarEvent.AllEvents.ToList());//artificially adds enew calendar event to dictionary


            List<CalendarEvent> SortedInterFerringCalendarEvents_Deadline = DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents.Keys.ToList();
            SortedInterFerringCalendarEvents_Deadline = SortedInterFerringCalendarEvents_Deadline.OrderBy(obj => obj.End).ToList();

            TimeLine ReferenceTimeLine = RangeForScheduleUpdate.CreateCopy();


            ReferenceTimeLine.AddBusySlots(RigidSubCalendarEventsBusyTimeLine.ToArray());//Adds all the rigid elements

            TimeLine[] ArrayOfFreeSpots = getOnlyPertinentTimeFrame(getAllFreeSpots_NoCompleteSchedule(ReferenceTimeLine), ReferenceTimeLine).ToArray();
            ArrayOfFreeSpots = getOnlyPertinentTimeFrame(ArrayOfFreeSpots, ReferenceTimeLine).ToArray();

            Dictionary<TimeLine, List<CalendarEvent>> DictTimeLineAndListOfCalendarevent = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<CalendarEvent>>();
            List<List<List<SubCalendarEvent>>> SnugListOfPossibleSubCalendarEventsClumps = BuildAllPossibleSnugLists(SortedInterFerringCalendarEvents_Deadline, MyCalendarEvent, DictionaryWithBothCalendarEventIDAndListOfInterferringSubEvents, ReferenceTimeLine, OccupancyOfTimeLineSPan);
            //Remember Jerome, I need to implement a functionality that permutates through the various options of pin to start option. So take for example two different event timeline that are pertinent to a free spot however one has a dead line preceeding the other, there will be a pin to start for two scenarios, one for each calendar event in which either of them gets pinned first.

            List<SubCalendarEvent>SerializedResult=SnugListOfPossibleSubCalendarEventsClumps[0].SelectMany(obj => obj).ToList();

            int TotalUpdatedSchedule= SerializedResult.Count+RigidSubCalendarEvents.Count;

            if (TotalUpdatedSchedule != collectionOfInterferringSubCalEvents.Count)
            {
                MyCalendarEvent.UpdateError(new CustomErrors(true, "There is a clash in event"));
            }
            NoneCommitedCalendarEventsEvents.Remove(MyCalendarEvent);

            return EvaluateEachSnugPossibiliyOfSnugPossibility(SnugListOfPossibleSubCalendarEventsClumps, ReferenceTimeLine, MyCalendarEvent);
            ;//this will not be the final output. I'll need some class that stores the current output of both rearrange busytimelines and deleted timelines
        }
예제 #15
0
        public void ProcessRequest(HttpContext context)
        {
            //write your handler implementation here.

            context.Response.ContentType = "text/plain";

            string Command = context.Request["WagCommand"];
            string UserID = context.Request["UI"];
            string UserName = context.Request["UN"];

            string serverDirectoryOfCalLogs = System.Web.HttpContext.Current.Server.MapPath("..\\WagTapCalLogs\\");
            DateTime refNow = DateTime.UtcNow;
            TimeSpan TimeZoneSpan = new TimeSpan(0);
            string TimeZoneString = context.Request.Form["TimeZoneOffset"];
            if (!string.IsNullOrEmpty(TimeZoneString))
            {
                int TimeSpanint = Convert.ToInt32(TimeZoneString);
                TimeZoneSpan = TimeSpan.FromMinutes(TimeSpanint);
                refNow=refNow.Add(-TimeZoneSpan);
            }

            /*//forces copying of my log online
            string serverDirectoryOfFiles = System.Web.HttpContext.Current.Server.MapPath("..\\18.xml");
            {
                Directory.CreateDirectory(serverDirectoryOfCalLogs);
                File.Copy(serverDirectoryOfFiles, serverDirectoryOfCalLogs + "18.xml", true);
            }

            context.Response.Write("Name of Dir: " + UserAccount.WagTapLogLocation + "\nRest Of File:" + serverDirectoryOfCalLogs);
            //*/
            string User = context.Request.Form["UserName"];
            string Password = context.Request.Form["Password"];

            UserAccount myUser;
            if (string.IsNullOrEmpty(Password))
            {
                int UserIDEntry =0;
                try
                {
                    UserIDEntry = Convert.ToInt32(context.Request.Form["UserID"]);
                    myUser = new UserAccount(User, UserIDEntry, serverDirectoryOfCalLogs);
                }
                catch(Exception e)
                {
                    PostBackData invalid = new PostBackData("Incorrect Username or password", 1);
                    context.Response.Write(invalid.getPostBackData);
                    return;
                }

            }
            else
            {
                myUser = new UserAccount(User, Password, serverDirectoryOfCalLogs);
            }

            if (Command == "3")
            {
                string FirstName = context.Request.Form["FirstName"];
                string LastName = context.Request.Form["LastName"];
                string Email = context.Request.Form["Email"];
                string UserNameRegister = context.Request.Form["UserName"];
                string regPasswordPassword = context.Request.Form["Password"];
                UserAccount newUser = new UserAccount(serverDirectoryOfCalLogs);
                string retValue;
                CustomErrors registerStatus=newUser.Register(FirstName, LastName, Email, UserNameRegister, regPasswordPassword);
                PostBackData myPostBackData;
                if (!registerStatus.Status)
                {
                    newUser.Login();

                    retValue = "{\"ID\":\"" + newUser.UserID + "\",\"User\":\"" + newUser.UserName + "\"}";
                    myPostBackData = new PostBackData(retValue, registerStatus.Code);
                }
                else
                {
                    myPostBackData = new PostBackData(registerStatus.Message, registerStatus.Code);

                }

                context.Response.Write(myPostBackData.getPostBackData);
            }
            else
            {
                myUser.Login();
                if (!myUser.Status)
                {
                    PostBackData invalid = new PostBackData("\"\"", 1);
                    context.Response.Write(invalid.getPostBackData);
                    return;
                }

                //TimeSpan referenceShift=
                switch (Command)
                {
                    case "0"://get user schedule
                    {

                        string MiscCounter = context.Request.Form["Misc"];
                        string mydirectory = "";
                        string StartRange = context.Request.Form["StartRange"];
                        string EndRange = context.Request.Form["EndRange"];
                        Tuple<Dictionary<string, My24HourTimerWPF.CalendarEvent>, DateTime> ProfileData = myUser.getProfileInfo();

                        /*
                        if (!string.IsNullOrEmpty(MiscCounter))
                        {
                            int counter = Convert.ToInt32( MiscCounter);
                            if (counter == 0)
                            {
                                mydirectory = "WagTapCalLogs\\Older18.xml";
                            }
                            else
                            {
                                mydirectory = "WagTapCalLogs\\Newer18.xml";
                            }

                            mydirectory = System.Web.HttpContext.Current.Server.MapPath("..\\" + mydirectory);
                        }
                        */

                        Dictionary<string, My24HourTimerWPF.CalendarEvent> myDict = ProfileData.Item1;// getAllCalendarElements(mydirectory);
                        PostBackData myPostBackData;
                        if (myDict != null)
                        {
                            TimeLine ScheduleRange;
                            DateTime Now=DateTime.Now;
                            DateTime StartWeekDateInMS=DateTime.Parse(Now.Date.ToShortDateString());
                            int StartOfWeekDay =(int) StartWeekDateInMS.DayOfWeek;
                            StartOfWeekDay = 0 - StartOfWeekDay;

                            TimeSpan OneDayInMs= new TimeSpan(1,0,0,0);
                            TimeSpan OneWeekInMs= new TimeSpan(7,0,0,0);

                            DateTime StartOfRangeDate= StartWeekDateInMS.Add((TimeSpan.FromTicks((StartOfWeekDay *OneDayInMs.Ticks))));
                            StartOfRangeDate =StartOfRangeDate.AddDays(-7);
                            DateTime EndOfRangeDate=StartOfRangeDate.AddDays(21);

                            if (! (String.IsNullOrEmpty(StartRange) || String.IsNullOrEmpty(EndRange)))
                            {
                                long TotalTIcks = Convert.ToInt64(StartRange) ;
                                TotalTIcks  *= TimeSpan.TicksPerMillisecond;
                                StartOfRangeDate = new DateTime(TotalTIcks);
                                StartOfRangeDate=StartOfRangeDate.AddYears(1969);

                                TotalTIcks = Convert.ToInt64(EndRange);
                                TotalTIcks *=TimeSpan.TicksPerMillisecond;
                                EndOfRangeDate = new DateTime(TotalTIcks);
                                EndOfRangeDate = EndOfRangeDate.AddYears(1969);
                            }

                            ScheduleRange = new TimeLine(StartOfRangeDate, EndOfRangeDate);

                            string jsonText = getJSONData(myDict, ScheduleRange, myUser.Usersname, TimeZoneSpan);

                            myPostBackData = new PostBackData(jsonText, 0);
                            context.Response.Write(myPostBackData.getPostBackData);
                        }
                        else
                        {
                            string message = "invalid user";
                            myPostBackData = new PostBackData(message, 4);

                            context.Response.Write(myPostBackData.getPostBackData);
                        }
                    }
                    break;
                    case "1"://Add new event
                        {
                            string BColor = context.Request.Form["BColor"];
                            string RColor = context.Request.Form["RColor"];
                            string GColor = context.Request.Form["GColor"];
                            string Count = context.Request.Form["Count"];
                            string DurationDays = context.Request.Form["DurationDays"];
                            string DurationHours = context.Request.Form["DurationHours"];
                            string DurationMins = context.Request.Form["DurationMins"];
                            string EndDay = context.Request.Form["EndDay"];
                            string EndHour = context.Request.Form["EndHour"];
                            string EndMins = context.Request.Form["EndMins"];
                            string EndMonth = context.Request.Form["EndMonth"];
                            string EndYear = context.Request.Form["EndYear"];

                            string LocationAddress = context.Request.Form["LocationAddress"];
                            string LocationTag = context.Request.Form["LocationTag"];
                            string Name = context.Request.Form["Name"];

                            string RepeatData = context.Request.Form["RepeatData"];
                            string RepeatEndDay = context.Request.Form["RepeatEndDay"];
                            string RepeatEndMonth = context.Request.Form["RepeatEndMonth"];
                            string RepeatEndYear = context.Request.Form["RepeatEndYear"];
                            string RepeatStartDay = context.Request.Form["RepeatStartDay"];
                            string RepeatStartMonth = context.Request.Form["RepeatStartMonth"];
                            string RepeatStartYear = context.Request.Form["RepeatStartYear"];
                            string RepeatType = context.Request.Form["RepeatType"];
                            string RepeatWeeklyData = context.Request.Form["RepeatWeeklyData"];
                            string Rigid = context.Request.Form["Rigid"];
                            string StartDay = context.Request.Form["StartDay"];
                            string StartHour = context.Request.Form["StartHour"];
                            string StartMins = context.Request.Form["StartMins"];
                            string StartMonth = context.Request.Form["StartMonth"];
                            string StartYear = context.Request.Form["StartYear"];
                            string RepeatFrequency =  context.Request.Form["RepeatFrequency"];

                            string StartTime=StartHour+":"+StartMins;
                            string EndTime=EndHour+":"+EndMins;
                            DateTime StartDateEntry = new DateTime(Convert.ToInt32(StartYear),Convert.ToInt32(StartMonth),Convert.ToInt32( StartDay));
                            DateTime EndDateEntry = new DateTime(Convert.ToInt32(EndYear),Convert.ToInt32(EndMonth),Convert.ToInt32( EndDay));

                            TimeSpan fullTimeSpan = new TimeSpan(Convert.ToInt32(DurationDays),Convert.ToInt32(DurationHours),Convert.ToInt32(DurationMins),0);
                            string EventDuration = TimeSpan.FromSeconds(fullTimeSpan.TotalSeconds*Convert.ToInt32(Count)).ToString();

                            bool RigidScheduleFlag = Convert.ToBoolean(Rigid);
                            Location EventLocation = new Location(LocationAddress);

                            Repetition MyRepetition=new Repetition();
                            DateTime RepeatStart = new DateTime();
                            DateTime RepeatEnd= new DateTime();
                            bool RepetitionFlag = false;
                            Color userColor= new Color();

                            if (RigidScheduleFlag)
                            {
                                DateTime FullStartTime = DateTime.Parse(StartDateEntry.ToShortDateString() + " " + StartTime);
                                DateTime FullEndTime = DateTime.Parse(EndDateEntry.ToShortDateString() + " " + EndTime);

                                EventDuration = (FullEndTime - FullStartTime).ToString();
                            }

                             if (!string.IsNullOrEmpty(RepeatType))
                            {

                                DateTime FullStartTime = DateTime.Parse(StartDateEntry.ToShortDateString() + " " + StartTime);
                                DateTime FullEndTime = DateTime.Parse(EndDateEntry.ToShortDateString() + " " + EndTime);

                                RepeatStart = StartDateEntry;

                                RepeatEnd = new DateTime(Convert.ToInt32(RepeatEndYear),Convert.ToInt32(RepeatEndMonth),Convert.ToInt32(RepeatEndDay));
                                //RepeatEnd = (DateTime.Now).AddDays(7);
                                RepetitionFlag = true;
                                MyRepetition = new Repetition(RepetitionFlag, new TimeLine(RepeatStart, RepeatEnd), RepeatFrequency, new TimeLine(FullStartTime,FullEndTime));
                                EndDateEntry = RepeatEnd;
                            }

                            Schedule MySchedule = new Schedule(myUser,refNow);
                            CalendarEvent newCalendarEvent = new CalendarEvent(Name, StartTime, StartDateEntry, EndTime, EndDateEntry, Count, "", EventDuration, MyRepetition, true, RigidScheduleFlag, "", true, EventLocation, true, new EventDisplay(true,userColor),new MiscData(),false);

                            newCalendarEvent.Repeat.PopulateRepetitionParameters(newCalendarEvent);

                            string BeforemyName = newCalendarEvent.ToString(); //BColor + " -- " + Count + " -- " + DurationDays + " -- " + DurationHours + " -- " + DurationMins + " -- " + EndDay + " -- " + EndHour + " -- " + EndMins + " -- " + EndMonth + " -- " + EndYear + " -- " + GColor + " -- " + LocationAddress + " -- " + LocationTag + " -- " + Name + " -- " + RColor + " -- " + RepeatData + " -- " + RepeatEndDay + " -- " + RepeatEndMonth + " -- " + RepeatEndYear + " -- " + RepeatStartDay + " -- " + RepeatStartMonth + " -- " + RepeatStartYear + " -- " + RepeatType + " -- " + RepeatWeeklyData + " -- " + Rigid + " -- " + StartDay + " -- " + StartHour + " -- " + StartMins + " -- " + StartMonth + " -- " + StartYear;

                            string AftermyName = newCalendarEvent.ToString();
                            MySchedule.AddToSchedule(newCalendarEvent);
                            PostBackData myPostData = new PostBackData("\"Success\"", 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "2"://procrastinate
                        {
                            string EventID = context.Request.Form["EventID"];
                            string DurationDays = context.Request.Form["DurationDays"];
                            string DurationHours = context.Request.Form["DurationHours"];
                            string DurationMins = context.Request.Form["DurationMins"];

                            Schedule MySchedule = new Schedule(myUser, refNow);
                            TimeSpan fullTimeSpan = new TimeSpan(Convert.ToInt32(DurationDays), Convert.ToInt32(DurationHours), Convert.ToInt32(DurationMins), 0);
                            Tuple<CustomErrors, Dictionary<string, CalendarEvent>> ScheduleUpdateMessage = MySchedule.ProcrastinateJustAnEvent(EventID, fullTimeSpan);
                            MySchedule.UpdateWithProcrastinateSchedule(ScheduleUpdateMessage.Item2);

                            PostBackData myPostData = new PostBackData("\"Success\"", 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "4"://SignInToUerAccount
                        {

                            string retValue;
                            retValue = "{\"ID\":\"" + myUser.UserID + "\",\"User\":\"" + myUser.UserName + "\",\"Name\":\"" + myUser.Usersname + "\"}";
                            PostBackData myPostData = new PostBackData(retValue, 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "5"://CreateLogFolder
                        {
                            string serverDirectoryOfFile = System.Web.HttpContext.Current.Server.MapPath("..\\18.xml");
                            {
                                Directory.CreateDirectory(serverDirectoryOfCalLogs);
                                File.Copy(serverDirectoryOfFile, serverDirectoryOfCalLogs + "18.xml",true);
                            }

                            context.Response.Write("Name of Dir: " + UserAccount.WagTapLogLocation + "\nRest Of File:" + serverDirectoryOfCalLogs);
                        }
                        break;
                    case "6"://Delete an event and readjust
                        {
                            string EventID = context.Request.Form["EventID"];
                            Schedule MySchedule = new Schedule(myUser, refNow);
                            MySchedule.deleteSubCalendarEvent(EventID);
                            PostBackData myPostData = new PostBackData("\"Success\"", 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "7"://Mark as Complete and readjust
                        {
                            string EventID = context.Request.Form["EventID"];
                            Schedule MySchedule = new Schedule(myUser, refNow);
                            MySchedule.markSubEventAsCompleteCalendarEventAndReadjust(EventID);
                            PostBackData myPostData = new PostBackData("\"Success\"", 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "8"://Set as now
                        {
                            string EventID = context.Request.Form["EventID"];
                            Schedule MySchedule = new Schedule(myUser, refNow);
                            Tuple<CustomErrors, Dictionary<string, CalendarEvent>> retValue = MySchedule.SetEventAsNow(EventID);
                            MySchedule.UpdateWithProcrastinateSchedule(retValue.Item2);
                            PostBackData myPostData = new PostBackData("\"Success\"", 0);
                            context.Response.Write(myPostData.getPostBackData);
                        }
                        break;
                    case "9"://Download Log
                        {
                            string serverDirectoryOfFile = System.Web.HttpContext.Current.Server.MapPath("..\\"+myUser.UserID+".xml");

                            byte[] FileData = File.ReadAllBytes(myUser.getFullLogDir);
                            string SaveAsName = myUser.UserName + "Log.xml";
                            string SomeXLog= myUser.getFullLogDir;

                            ResponseOpenFileBytes(FileData, null, SaveAsName, context.Response);
                            context.Response.Write("sent: " + SaveAsName + "\nSomeXLog is:" + SomeXLog + "\nRest Of File:" + serverDirectoryOfCalLogs + "Current Time is: " + DateTime.Now.ToString());
                            context.Response.End();
                        }
                        break;

                    default:
                        break;
                }

            }

            DateTime dt;
        }
예제 #16
0
        public CustomErrors AddToSchedule(CalendarEvent NewEvent)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            NewEvent = EvaluateTotalTimeLineAndAssignValidTimeSpots(NewEvent);

            sw.Stop();
            ///

            if (NewEvent == null)//checks if event was assigned and ID ehich means it was successfully able to find a spot
            {
                return new CustomErrors(NewEvent.ErrorStatus, NewEvent.ErrorMessage);
            }

            if (NewEvent.ID == "" || NewEvent == null)//checks if event was assigned and ID ehich means it was successfully able to find a spot
            {
                return new CustomErrors(NewEvent.ErrorStatus, NewEvent.ErrorMessage);
            }

            

            RemoveAllCalendarEventFromLogAndCalendar();
            try
            {
                AllEventDictionary.Add(NewEvent.ID, NewEvent);
            }
            catch
            {
                AllEventDictionary[NewEvent.ID] = NewEvent;
            }


            WriteFullScheduleToLogAndOutlook();

            CompleteSchedule = getTimeLine();

            return new CustomErrors(NewEvent.ErrorStatus, NewEvent.ErrorMessage);
        }
예제 #17
0
        string CalendarEventToString(CalendarEvent arg1, TimeLine RangeOfSchedule, TimeSpan TimeZoneSpan)
        {
            /*
             * This funciton takes a non repeat CalendarEvent and converts it to a JSON formatted string;
             */
            string IDString="\""+arg1.ID+"\"";
            string TotalString = "";
            string CalendarName = "\"" + arg1.Name + "\"";
            string StartDate = "\""+arg1.Start.ToString() + "\"";
            string EndDate = "\"" + arg1.End.ToString() + "\"";
            string TotalDuration = "\"" + arg1.ActiveDuration.ToString() + "\"";
            string Rigid = "\""+arg1.Rigid+"\"";
            string AddressDescription = "\""+arg1.myLocation.Description+"\"";
            string Address = "\""+arg1.myLocation.Address+"\"";
            string Long = "\"" + arg1.myLocation.YCoordinate + "\"";
            string Lat = "\"" + arg1.myLocation.XCoordinate + "\"";
            string NumberOfCompletedTasks = "" + arg1.AllSubEvents.Where(obj => obj.isComplete).Count().ToString() + "";
            int NumberOfSubEvents_int=arg1.AllSubEvents.Count();
            string NumberOfSubEvents = "\"" + NumberOfSubEvents_int + "\"";
            string NumberOfDeletedEvents = "\"" + (NumberOfSubEvents_int - arg1.EnabledSubEvents.Count()).ToString() + "\"";

            TimeSpan spanPerTier = TimeSpan.FromTicks((arg1.RangeSpan - Utility.SumOfActiveDuration(arg1.ActiveSubEvents)).Ticks / 3);

            DateTime DateZero = new DateTime(1970, 1, 1, 0, 0, 0, 0, 0);//.ToLocalTime();
            DateZero = DateZero.Add(-TimeZoneSpan);

            if (arg1.ID == "151_209")
            {
                ;
            }

            DateTime Tier0 = (arg1.RangeTimeLine.Start.Add(spanPerTier));// - DateZero);
            DateTime Tier1 = (arg1.RangeTimeLine.Start.Add((spanPerTier + spanPerTier)));// - DateZero)
            DateTime Tier2 = (arg1.RangeTimeLine.Start.Add((spanPerTier + spanPerTier + spanPerTier)));// - DateZero)

            string Tier0String = (Tier0 - DateZero).TotalSeconds.ToString();
            string Tier1String = (Tier1 - DateZero).TotalSeconds.ToString();
            string Tier2String = (Tier2 - DateZero).TotalSeconds.ToString();
            string FullTierString = "[" + Tier0String + "," + Tier1String + "," + Tier2String + "]";
            string Delimited = string.Join(",", arg1.ActiveSubEvents.Where(obj => obj.RangeTimeLine.InterferringTimeLine(RangeOfSchedule) != null).Select(obj => SubCalendarEventToString(obj, obj.Name, arg1.ID)));
            string AllSubCalEventString = "[" + Delimited + "]";

            TotalString = "{\"ID\":" + IDString + ",\"CalendarName\":" + CalendarName + ",\"StartDate\":" + StartDate + ",\"EndDate\":" + EndDate + ",\"TotalDuration\":" + TotalDuration + ",\"Rigid\":" + Rigid + ",\"AddressDescription\": " + AddressDescription + ",\"Address\":" + Address + ",\"AllSubCalEvents\":" + AllSubCalEventString + ",\"Latitude\":" + Lat + ",\"Longitude\":" + Long + ",\"NumberOfSubEvents\":" + NumberOfSubEvents + ",\"NumberOfCompletedTasks\":" + NumberOfCompletedTasks + ",\"NumberOfDeletedEvents\":" + NumberOfDeletedEvents + ",\"Tiers\":" + FullTierString + "}";
            string retValue = TotalString;
            return retValue;
        }
예제 #18
0
 private SubCalendarEvent[] getInterferringSubEvents(CalendarEvent MyCalendarEvent, List<CalendarEvent>NonCOmmitedCalendarEvemts)
 {
     if (MyCalendarEvent.RepetitionStatus)
     {
         throw new Exception("Weird error, found repeating event repeaing evemt");
     }
     return getInterferringSubEvents(MyCalendarEvent.RangeTimeLine, NonCOmmitedCalendarEvemts);
 }
예제 #19
0
            SubCalendarEvent[] ReadSubSchedulesFromXMLNode(XmlNode MyXmlNode, CalendarEvent MyParent)
            {
                SubCalendarEvent[] MyArrayOfNodes = new SubCalendarEvent[MyXmlNode.ChildNodes.Count];
                string ID = "";
                DateTime Start = new DateTime();
                DateTime End = new DateTime();
                TimeSpan SubScheduleDuration = new TimeSpan();
                TimeSpan PrepTime = new TimeSpan();
                BusyTimeLine BusySlot = new BusyTimeLine();
                bool Enabled;
                for (int i = 0; i < MyXmlNode.ChildNodes.Count; i++)
                {
                    BusyTimeLine SubEventActivePeriod = new BusyTimeLine(MyXmlNode.ChildNodes[i].SelectSingleNode("ID").InnerText, stringToDateTime(MyXmlNode.ChildNodes[i].SelectSingleNode("ActiveStartTime").InnerText), stringToDateTime(MyXmlNode.ChildNodes[i].SelectSingleNode("ActiveEndTime").InnerText));
                    ID = MyXmlNode.ChildNodes[i].SelectSingleNode("ID").InnerText;
                    Start = DateTime.Parse(MyXmlNode.ChildNodes[i].SelectSingleNode("ActiveStartTime").InnerText);
                    End = DateTime.Parse(MyXmlNode.ChildNodes[i].SelectSingleNode("ActiveEndTime").InnerText);
                    BusySlot = new BusyTimeLine(ID, Start, End);
                    PrepTime = new TimeSpan(ConvertToMinutes(MyXmlNode.ChildNodes[i].SelectSingleNode("PrepTime").InnerText) * 60 * 10000000);
                    //stringToDateTime();
                    Start = DateTime.Parse(MyXmlNode.ChildNodes[i].SelectSingleNode("StartTime").InnerText);
                    End = DateTime.Parse(MyXmlNode.ChildNodes[i].SelectSingleNode("EndTime").InnerText);
                    Enabled=Convert.ToBoolean(MyXmlNode.ChildNodes[i].SelectSingleNode("Enabled").InnerText);
                    bool CompleteFlag = Convert.ToBoolean(MyXmlNode.ChildNodes[i].SelectSingleNode("Complete").InnerText);
                    Location var1 = getLocation(MyXmlNode.ChildNodes[i]);
                    MiscData noteData = getMiscData(MyXmlNode.ChildNodes[i]);
                    EventDisplay UiData = getDisplayUINode(MyXmlNode.ChildNodes[i]);

                    MyArrayOfNodes[i] = new SubCalendarEvent(ID, BusySlot, Start, End, PrepTime, MyParent.ID, MyParent.Rigid, Enabled, UiData, noteData, CompleteFlag, var1, MyParent.RangeTimeLine);
                    MyArrayOfNodes[i].ThirdPartyID = MyXmlNode.ChildNodes[i].SelectSingleNode("ThirdPartyID").InnerText;//this is a hack to just update the Third partyID
                }

                return MyArrayOfNodes;
            }
예제 #20
0
 public void WriteToLog(CalendarEvent MyEvent)//writes to an XML Log file. Takes calendar event as an argument
 {
     XmlDocument xmldoc = new XmlDocument();
     xmldoc.Load("MyEventLog.xml");
     xmldoc.DocumentElement.SelectSingleNode("/ScheduleLog/LastIDCounter").InnerText = MyEvent.ID;
     XmlNodeList EventSchedulesNodes = xmldoc.DocumentElement.SelectNodes("/ScheduleLog/EventSchedules");
     XmlNodeList EventScheduleNodes = xmldoc.DocumentElement.SelectNodes("/ScheduleLog/EventSchedules/EventSchedule");
     //EventScheduleNodes = new XmlNodeList();
     //XmlElement EventScheduleNode = CreateEventScheduleNode(MyEvent, xmldoc);
     XmlElement EventScheduleNode = CreateEventScheduleNode(MyEvent);
     //EventSchedulesNodes[0].PrependChild(xmldoc.CreateElement("EventSchedule"));
     //EventSchedulesNodes[0].ChildNodes[0].InnerXml = CreateEventScheduleNode(MyEvent).InnerXml;
     XmlNode MyImportedNode = xmldoc.ImportNode(EventScheduleNode as XmlNode, true);
     //(EventScheduleNode, true);
     if (!UpdateInnerXml(ref EventScheduleNodes, "ID", MyEvent.ID.ToString(), EventScheduleNode))
     {
         xmldoc.DocumentElement.SelectSingleNode("/ScheduleLog/EventSchedules").AppendChild(MyImportedNode);
     }
     xmldoc.Save("MyEventLog.xml");
 }
예제 #21
0
            public XmlElement CreateEventScheduleNode(CalendarEvent MyEvent)
            {
                XmlDocument xmldoc = new XmlDocument();

                XmlElement MyEventScheduleNode = xmldoc.CreateElement("EventSchedule");
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Completed"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.isComplete.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("RepetitionFlag"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.RepetitionStatus.ToString();

                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("EventSubSchedules"));
                //MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Repetition.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("RigidFlag"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Rigid.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Duration"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.ActiveDuration.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Split"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.NumberOfSplit.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Deadline"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.End.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("PrepTime"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Preparation.ToString();
                //MyEventScheduleNode.PrependChild(xmldoc.CreateElement("PreDeadlineFlag"));
                //MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Pre.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("PreDeadline"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.PreDeadline.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("StartTime"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Start.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Name"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.Name.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("ID"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.ID.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Enabled"));
                MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.isEnabled.ToString();
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Location"));
                MyEventScheduleNode.ChildNodes[0].InnerXml = CreateLocationNode(MyEvent.myLocation, "EventScheduleLocation").InnerXml;
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("UIParams"));
                MyEventScheduleNode.ChildNodes[0].InnerXml = createDisplayUINode(MyEvent.UIParam, "UIParams").InnerXml;
                MyEventScheduleNode.PrependChild(xmldoc.CreateElement("MiscData"));
                MyEventScheduleNode.ChildNodes[0].InnerXml = createMiscDataNode(MyEvent.Notes, "MiscData").InnerXml;

                if (MyEvent.RepetitionStatus)
                {
                    MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Recurrence"));
                    MyEventScheduleNode.ChildNodes[0].InnerXml = CreateRepetitionNode(MyEvent.Repeat).InnerXml;
                    //MyEventScheduleNode.PrependChild();
                    //MyEventScheduleNode.PrependChild(CreateRepetitionNode(MyEvent.Repeat));

                    return MyEventScheduleNode;
                }
                else
                {
                    MyEventScheduleNode.PrependChild(xmldoc.CreateElement("Recurrence"));

                }
                XmlNode SubScheduleNodes = MyEventScheduleNode.SelectSingleNode("EventSubSchedules");
                foreach (SubCalendarEvent MySubEvent in MyEvent.AllSubEvents)
                {
                    SubScheduleNodes.PrependChild(xmldoc.CreateElement("EventSubSchedule"));
                    SubScheduleNodes.ChildNodes[0].InnerXml = CreateSubScheduleNode(MySubEvent).InnerXml;
                }
                //MyEventScheduleNode.ChildNodes[0].InnerText = MyEvent.ID;

                return MyEventScheduleNode;
            }
예제 #22
0
 bool ShiftEvent(CalendarEvent CurrentEvent, TimeSpan DelayTime)
 {
     return true;
 }
예제 #23
0
            //writes to an XML Log file. Takes calendar event as an argument
            public void WriteToLog(CalendarEvent MyEvent, string LogFile = "")
            {
                if (LogFile == "")
                { LogFile = WagTapLogLocation + CurrentLog; }
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(LogFile);
                xmldoc.DocumentElement.SelectSingleNode("/ScheduleLog/LastIDCounter").InnerText = MyEvent.ID;
                XmlNodeList EventSchedulesNodes = xmldoc.DocumentElement.SelectNodes("/ScheduleLog/EventSchedules");
                XmlNodeList EventScheduleNodes = xmldoc.DocumentElement.SelectNodes("/ScheduleLog/EventSchedules/EventSchedule");

                XmlElement EventScheduleNode = CreateEventScheduleNode(MyEvent);
                //EventSchedulesNodes[0].PrependChild(xmldoc.CreateElement("EventSchedule"));
                //EventSchedulesNodes[0].ChildNodes[0].InnerXml = CreateEventScheduleNode(MyEvent).InnerXml;
                XmlNode MyImportedNode = xmldoc.ImportNode(EventScheduleNode as XmlNode, true);
                //(EventScheduleNode, true);
                if (!UpdateInnerXml(ref EventScheduleNodes, "ID", MyEvent.ID.ToString(), EventScheduleNode))
                {
                    xmldoc.DocumentElement.SelectSingleNode("/ScheduleLog/EventSchedules").AppendChild(MyImportedNode);
                }
                while(true)
                {
                    try
                    {
                        xmldoc.Save(LogFile);
                        break;
                    }
                    catch (Exception e)
                    {
                        Thread.Sleep(160);
                    }
                }
            }
예제 #24
0
        public CalendarEvent GenerateRigidSubEvents(CalendarEvent MyCalendarEvent)
        {
            int i = 0;
            List<SubCalendarEvent> MyArrayOfSubEvents = new List<SubCalendarEvent>();
            for (; i < MyCalendarEvent.AllEvents.Length; i++)
            {

            }

            if (MyCalendarEvent.RepetitionStatus)
            {
                
                SubCalendarEvent MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start, MyCalendarEvent.Repeat.Range.End, MyCalendarEvent.Preparation, MyCalendarEvent.ID,MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
   
                
                //new SubCalendarEvent(MyCalendarEvent.End, MyCalendarEvent.Repeat.Range.Start, MyCalendarEvent.Repeat.Range.End, MyCalendarEvent.Preparation, MyCalendarEvent.ID);

                for (; MySubEvent.Start < MyCalendarEvent.Repeat.Range.End; )
                {
                    MyArrayOfSubEvents.Add(MySubEvent);
                    switch (MyCalendarEvent.Repeat.Frequency)
                    {
                        case "DAILY":
                            {
                                MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start.AddDays(1), MyCalendarEvent.Repeat.Range.End.AddDays(1), MyCalendarEvent.Preparation, MyCalendarEvent.ID,MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                                break;
                            }
                        case "WEEKLY":
                            {
                                MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start.AddDays(7), MyCalendarEvent.Repeat.Range.End.AddDays(7), MyCalendarEvent.Preparation, MyCalendarEvent.ID, MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                                break;
                            }
                        case "BI-WEEKLY":
                            {
                                MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start.AddDays(14), MyCalendarEvent.Repeat.Range.End.AddDays(14), MyCalendarEvent.Preparation, MyCalendarEvent.ID, MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                                break;
                            }
                        case "MONTHLY":
                            {
                                MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start.AddMonths(1), MyCalendarEvent.Repeat.Range.End.AddMonths(1), MyCalendarEvent.Preparation, MyCalendarEvent.ID, MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                                break;
                            }
                        case "YEARLY":
                            {
                                MySubEvent = new SubCalendarEvent(MyCalendarEvent.ActiveDuration, MyCalendarEvent.Repeat.Range.Start.AddYears(1), MyCalendarEvent.Repeat.Range.End.AddYears(1), MyCalendarEvent.Preparation, MyCalendarEvent.ID, MyCalendarEvent.Rigid, MyCalendarEvent.myLocation, MyCalendarEvent.RangeTimeLine);
                                break;
                            }
                    }


                }
            }

            return MyCalendarEvent;
            //
        }
예제 #25
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;
        }
예제 #26
0
        bool[] CheckIfPotentialSubEventClashesWithAnyOtherSubEvents(CalendarEvent MyPotentialCalendarEvent, TimeLine MyTimeLineOfEvent)
        {
            BusyTimeLine[] ArrayOfBusySlots = MyTimeLineOfEvent.OccupiedSlots;
            bool[] StatusOfCollision = new bool[] { false, false };
            foreach (BusyTimeLine MyBusySlot in ArrayOfBusySlots)
            {
                if (MyBusySlot.doesTimeLineInterfere(MyPotentialCalendarEvent.RangeTimeLine))
                {
                    StatusOfCollision[0] = true;
                    if (AllEventDictionary[(new EventID(MyBusySlot.TimeLineID)).getLevelID(0)].Rigid)
                    {
                        StatusOfCollision[1] = true;
                    }

                }
            }

            return StatusOfCollision;
        }
예제 #27
0
 public static int CompareByEndDate(CalendarEvent CalendarEvent1, CalendarEvent CalendarEvent2)
 {
     return CalendarEvent1.End.CompareTo(CalendarEvent2.End);
 }
예제 #28
0
        CalendarEvent ResolveWithDataOutsideCalendarEventSchedule(CalendarEvent MyEvent, List<CalendarEvent> ListOfOtherCalendarEvents)
        {

            return new CalendarEvent();
        }
예제 #29
0
 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
        BusyTimeLine[] GetBusySlotPerCalendarEvent(CalendarEvent MyEvent)
        {
            int i = 0;
            List<BusyTimeLine> MyTotalSubEventBusySlots = new List<BusyTimeLine>(0);
            BusyTimeLine[] ArrayOfBusySlotsInRepeat = new BusyTimeLine[0];
            DateTime LastDeadline = Now.AddHours(1);

            if (MyEvent.RepetitionStatus)
            {
                ArrayOfBusySlotsInRepeat = GetBusySlotsPerRepeat(MyEvent.Repeat);
            }

            /*for (;i<MyEvent.AllEvents.Length;i++)
            {
                {*/
            foreach (SubCalendarEvent MySubCalendarEvent in MyEvent.AllEvents)
            {
                if (!MyEvent.RepetitionStatus)
                { MyTotalSubEventBusySlots.Add(MySubCalendarEvent.ActiveSlot); }
            }

            //MyTotalSubEventBusySlots.Add(MyEvent.AllEvents[i].ActiveSlot);
            /*}
        }*/

            //BusyTimeLine[] ConcatenatSumOfAllBusySlots = new BusyTimeLine[ArrayOfBusySlotsInRepeat.Length + MyTotalSubEventBusySlots.Count];
            /*
            i = 0;
            for (; i < ArrayOfBusySlotsInRepeat.Length; i++)
            {
                ConcatenatSumOfAllBusySlots[i] = ArrayOfBusySlotsInRepeat[i];
            }
            i = ArrayOfBusySlotsInRepeat.Length;
            int LengthOfConcatenatSumOfAllBusySlots = ConcatenatSumOfAllBusySlots.Length;
            int j = 0;
            j = i;
            for (; j < LengthOfConcatenatSumOfAllBusySlots;)
            {
                ConcatenatSumOfAllBusySlots[j] = MyTotalSubEventBusySlots[i];
                i++;
                j++;
            }*/
            var Holder = MyTotalSubEventBusySlots.Concat(ArrayOfBusySlotsInRepeat);
            BusyTimeLine[] ConcatenatSumOfAllBusySlots = Holder.ToArray();
            //ArrayOfBusySlotsInRepeat.CopyTo(ConcatenatSumOfAllBusySlots, 0);
            //MyTotalSubEventBusySlots.CopyTo(ConcatenatSumOfAllBusySlots, ConcatenatSumOfAllBusySlots.Length);
            //ArrayOfBusySlotsInRepeat.CopyTo(ConcatenatSumOfAllBusySlots, 0);
            return ConcatenatSumOfAllBusySlots;
        }