Example #1
0
 public CalendarEvent()
 {
     EventDuration = new TimeSpan();
     CalendarEventName = "";
     StartDateTime = new DateTime();
     EndDateTime = new DateTime();
     EventPreDeadline = new TimeSpan();
     PrepTime = new TimeSpan();
     Priority = 0;
     RepetitionFlag = false;
     EventRepetition = new Repetition();
     RigidSchedule = false;
     Splits = 1;
     LocationData = new Location();
     CalendarEventID = new EventID("");
     ArrayOfSubEvents = new SubCalendarEvent[0];
     SchedulStatus = false;
     otherPartyID = "";
     CalendarError = new CustomErrors(false, string.Empty);
     EventSequence = new TimeLine();
 }
Example #2
0
 public CalendarEvent(CustomErrors Error)
 {
     EventDuration = new TimeSpan();
     CalendarEventName = "";
     StartDateTime = new DateTime();
     EndDateTime = new DateTime();
     EventPreDeadline = new TimeSpan();
     PrepTime = new TimeSpan();
     Priority = 0;
     RepetitionFlag = false;
     EventRepetition = new Repetition();
     RigidSchedule = false;
     Splits = 1;
     LocationData = new Location();
     CalendarEventID = new EventID("");
     SubEvents = new Dictionary<EventID, SubCalendarEvent>();
     SchedulStatus = false;
     otherPartyID = "";
     CalendarError = Error;
     EventSequence = new TimeLine();
 }
Example #3
0
        public CustomErrors deleteUser()
        {
            CustomErrors retValue;

            Tuple<bool,int,string> LoginStatus=LogIn();
            if (!LoginStatus.Item1)
            {
                retValue = new CustomErrors(true, "invalid user",1);
            }

            try
            {
                Wagtap.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            try
            {
                SqlDataReader myReader = null;

                SqlCommand deleteUserInfo = new SqlCommand("DELETE FROM DatabaseWaggy.dbo.UserInfo  where ID=" + ID, Wagtap);
                myReader = deleteUserInfo.ExecuteReader();
                myReader.Close();
                deleteUserInfo.CommandText = "DELETE FROM DatabaseWaggy.dbo.UserLog where ID=" + ID + " AND UserName=\'" + UserName + "\'";
                myReader = deleteUserInfo.ExecuteReader();
                retValue = new CustomErrors(false, "success");
                myReader.Close();
            }
            catch (Exception e)
            {
                retValue = new CustomErrors(true, e.ToString(), 30000000);
            }

            Wagtap.Close();

            return retValue;
        }
Example #4
0
 public void ClearErrorMessage()
 {
     CalendarError = new CustomErrors(false, string.Empty);
 }
Example #5
0
 public void UpdateError(CustomErrors Error)
 {
     CalendarError = Error;
 }
Example #6
0
            //creates a new xml log file. Uses the passed UserID
            public CustomErrors genereateNewLogFile(int UserID)
            {
                CustomErrors retValue = new CustomErrors(false, "success");
                try
                {

                    string NameOfFile = WagTapLogLocation + UserID.ToString() + ".xml";
                    if (File.Exists(NameOfFile))
                    {
                        File.Delete(NameOfFile);
                    }

                    FileStream myFileStream= File.Create(NameOfFile);
                    myFileStream.Close();

                    CurrentLog = NameOfFile;
                    EmptyCalendarXMLFile(CurrentLog);
                    //EmptyCalendarXMLFile();
                }
                catch (Exception e)
                {
                    retValue = new CustomErrors(true, "Error generating log\n" + e.ToString(), 20000000);
                }

                return retValue;
            }
Example #7
0
            public CustomErrors DeleteLog()
            {
                CustomErrors retValue=new CustomErrors(false,"Success");
                try
                {
                    File.Delete(CurrentLog);
                }
                catch(Exception e)
                {
                    retValue = new CustomErrors(true, e.ToString(), 20002000);
                }

                return retValue;
            }
Example #8
0
        public CustomErrors Register(string FirstName, string LastName, string Email, string UserName, string PassWord)
        {
            CustomErrors retValue = new CustomErrors(false,"success");
            UserAccountDBAccess = new DBControl(UserName, PassWord);
            Tuple<int, CustomErrors> registrationStatus = UserAccountDBAccess.RegisterUser(FirstName, LastName, Email, UserName, PassWord);

            UserLog = new LogControl(UserName,PassWord);
            UserLog.Initialize();
            if (!registrationStatus.Item2.Status)
            {
                Username = UserName;
                Password = PassWord;
                retValue =UserLog.genereateNewLogFile(registrationStatus.Item1);

                if (retValue.Status && retValue.Code >= 20000000)//error 20000000 denotes log creation issue
                {
                    UserAccountDBAccess.deleteUser();
                }
            }

            return retValue;
        }
Example #9
0
 public virtual void UpdateThis(CalendarEvent CalendarEventEntry)
 {
     if ((this.ID == CalendarEventEntry.ID))
     {
         EventDuration=CalendarEventEntry.ActiveDuration;
         CalendarEventName=CalendarEventEntry.Name;
         StartDateTime=CalendarEventEntry.StartDateTime;
         EndDateTime=CalendarEventEntry.EndDateTime;
         EventPreDeadline=CalendarEventEntry.PreDeadline;
         PrepTime=CalendarEventEntry.PrepTime;
         Priority=CalendarEventEntry.Priority;
         RepetitionFlag=CalendarEventEntry.RepetitionFlag;
         EventRepetition=CalendarEventEntry.EventRepetition;
         Complete = CalendarEventEntry.Complete;
         RigidSchedule = CalendarEventEntry.RigidSchedule;
         Splits=CalendarEventEntry.Splits;
         TimePerSplit=CalendarEventEntry.TimePerSplit;
         CalendarEventID=CalendarEventEntry.CalendarEventID;
         EventSequence=CalendarEventEntry.EventSequence;;
         SubEvents=CalendarEventEntry.SubEvents;
         SchedulStatus=CalendarEventEntry.SchedulStatus;
         CalendarError = CalendarEventEntry.CalendarError;
         Enabled=CalendarEventEntry.Enabled;
         UiParams=CalendarEventEntry.UiParams;
         DataBlob=CalendarEventEntry.DataBlob;
         LocationData =CalendarEventEntry.LocationData;
         otherPartyID = CalendarEventEntry.otherPartyID;
         return;
     }
 
     throw new Exception("Invalid Calendar ID used in Update Calendar Event");    
 }
Example #10
0
        Tuple<TimeLine, IEnumerable<SubCalendarEvent>, CustomErrors> getAllInterferringEventsAndTimeLineInCurrentEvaluation(CalendarEvent initializingCalendarEvent, List<CalendarEvent> NoneCommitedCalendarEventsEvents,int FlagType, HashSet<SubCalendarEvent> NotDoneYet)
        {
            
            DateTime EarliestStartTime;
            DateTime LatestEndTime;
            List<SubCalendarEvent> collectionOfInterferringSubCalEvents;
            Tuple<IEnumerable<SubCalendarEvent>, DateTime, int> refinedStartTimeAndInterferringEvents;
            List<SubCalendarEvent> SubEventsholder;
            TimeLine RangeForScheduleUpdate = initializingCalendarEvent.RangeTimeLine;
            IEnumerable<SubCalendarEvent> PertinentNotDoneYet = NotDoneYet.Where(obj => obj.getCalendarEventRange.InterferringTimeLine(RangeForScheduleUpdate) != null);


            LatestEndTime = PertinentNotDoneYet != null ? (PertinentNotDoneYet.Count() > 0 ? PertinentNotDoneYet.Select(obj => obj.getCalendarEventRange.End).Max() > RangeForScheduleUpdate.End ? PertinentNotDoneYet.Select(obj => obj.getCalendarEventRange.End).Max() : RangeForScheduleUpdate.End : RangeForScheduleUpdate.End) : RangeForScheduleUpdate.End;

            LatestEndTime=LatestEndTime.AddDays(6);

            RangeForScheduleUpdate = new TimeLine(RangeForScheduleUpdate.Start, LatestEndTime);//updates the range for scheduling

            
            List<SubCalendarEvent> ArrayOfInterferringSubEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//It gets all the subevents within the time frame
            SubEventsholder = ArrayOfInterferringSubEvents.ToList();//holder List object for ArrayOfInterferringSubEvents
            SubEventsholder.AddRange(PertinentNotDoneYet.ToList());//Pins the Not done yet elements

            ArrayOfInterferringSubEvents=ArrayOfInterferringSubEvents.OrderBy(obj => obj.End).ToList();// sorts the elements by end date
            List<IDefinedRange>[] MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);//gets the subevents crossing over the timeLine
            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;
            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates the range of schedule

            /*
             * Continue from here Jerome: You need to move all the unnecessary code from rearrange ReArrangeClashingEventsofRigid and  in to this function. The first section will be getting the initializing interferring events. After which you will update the interferring list with the not done yets.
             * These not done yets will get pinned to end of the timeline. Remember we are already moving the excess functionality of the preceeding callers code into this section.
             */


            refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime, FlagType);//gets the start time relatve to the ArrayOfInterferringSubEvents and flag type
            FlagType = refinedStartTimeAndInterferringEvents.Item3;//updates the flag type
            EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;//updates the earliest time from preceding function call
            ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToList();//Updates the ArrayOfInterferringSubEvents just in case the Now element is dropped
            ArrayOfInterferringSubEvents.ToList();
            ArrayOfInterferringSubEvents.AddRange(PertinentNotDoneYet.ToList());//adds the PertinentNotDoneYet to the SubEventsholder list
            
            /*
            TimeLine pinningTimeLine = new TimeLine(ReferenceDayTIime, LatestEndTime);
            Tuple<IEnumerable<SubCalendarEvent>, IEnumerable<SubCalendarEvent>> PinningInformation_NotDoneYet = PintNotDoneYestSubEventToEndOfTimeLine(pinningTimeLine,SubEventsholder);
            pinningTimeLine = null;
            */

            RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates the RangeForScheduleUpdate timeline
            CustomErrors errorStatus = new CustomErrors(false, "");
            TimeSpan SumOfAllEventsTimeSpan = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents.ToList());//sum all events

            while (SumOfAllEventsTimeSpan > RangeForScheduleUpdate.TimelineSpan-new TimeSpan(4,0,0))//loops untill the sum all the interferring events can possibly fit within the timeline. Essentially possibly fittable//hack alert to ensure usage of time space. THe extra addition has to be one pertaining to the occupancy
            {
                PertinentNotDoneYet = NotDoneYet.Where(obj => obj.getCalendarEventRange.InterferringTimeLine(RangeForScheduleUpdate) != null);
                ArrayOfInterferringSubEvents.AddRange(PertinentNotDoneYet.ToList());
                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.Count() - 1].getCalendarEventRange.End;//attempts to get subcalevent with a calendarevent with latest Endtime
                EarliestStartTime = EarliestStartTime < Now ? Now : EarliestStartTime;
                
                
                refinedStartTimeAndInterferringEvents = getStartTimeWhenCurrentTimeClashesWithSubcalevent(ArrayOfInterferringSubEvents, EarliestStartTime, FlagType);
                FlagType = refinedStartTimeAndInterferringEvents.Item3;
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToList();
                ArrayOfInterferringSubEvents.AddRange(PertinentNotDoneYet.ToList());
                
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);//updates range of scan
                collectionOfInterferringSubCalEvents = getInterferringSubEvents(RangeForScheduleUpdate, NoneCommitedCalendarEventsEvents).ToList();//updates interferring events list


                ArrayOfInterferringSubEvents = collectionOfInterferringSubCalEvents.ToList();
                ArrayOfInterferringSubEvents=ArrayOfInterferringSubEvents.OrderBy(obj => obj.End).ToList();
                MyEdgeElements = getEdgeElements(RangeForScheduleUpdate, ArrayOfInterferringSubEvents);
                EarliestStartTime = MyEdgeElements[0].Count > 0 ? MyEdgeElements[0].OrderBy(obj => obj.Start).ToList()[0].Start : RangeForScheduleUpdate.Start;//if there is crossover with start time RangeForScheduleUpdate select the crossover subcalevent start time
                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, FlagType);
                FlagType = refinedStartTimeAndInterferringEvents.Item3;
                EarliestStartTime = refinedStartTimeAndInterferringEvents.Item2;
                
                ArrayOfInterferringSubEvents = refinedStartTimeAndInterferringEvents.Item1.ToList();
                ArrayOfInterferringSubEvents.AddRange(PertinentNotDoneYet.ToList());
                RangeForScheduleUpdate = new TimeLine(EarliestStartTime, LatestEndTime);
                TimeSpan newSumOfAllTimeSpans = Utility.SumOfActiveDuration(ArrayOfInterferringSubEvents);
                if (newSumOfAllTimeSpans == SumOfAllEventsTimeSpan)
                {
                    errorStatus = new CustomErrors(true, "Total sum of events exceeds available time span");
                    break;
                    //throw new Exception("You have events that cannot fit our time frame");
                }
                else
                {
                    SumOfAllEventsTimeSpan = newSumOfAllTimeSpans;
                }
            }

            
            return new Tuple<TimeLine, IEnumerable<SubCalendarEvent>, CustomErrors>(RangeForScheduleUpdate, ArrayOfInterferringSubEvents, errorStatus);
        }