public void LoopThroughAddRepeatEvents(Repetition MyRepetition)
 {
     int i = 0;
     for (; i < MyRepetition.RecurringCalendarEvents.Length; i++)
     {
         WriteToOutlook(MyRepetition.RecurringCalendarEvents[i]);
     }
 }
Пример #2
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();
 }
Пример #3
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();
 }
Пример #4
0
 public CalendarEvent(string EventName, TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, TimeSpan Event_PreDeadline, bool EventRigidFlag, Repetition EventRepetitionEntry, int EventSplit, Location EventLocation)
 {
     CalendarEventName = EventName;
     /*CalendarEventName = EventName.Split(',')[0];
     LocationString = "";
     if (EventName.Split(',').Length > 1)
     {
         LocationString = EventName.Split(',')[1];
     }
     CalendarEventLocation = null;
     CalendarEventLocation = new Location();
     if (LocationString != "")
     {
         CalendarEventLocation = new Location(LocationString);
     }
     */
     StartDateTime = EventStart;
     EndDateTime = EventDeadline;
     EventDuration = Event_Duration;
     Splits = EventSplit;
     PrepTime = EventPrepTime;
     EventPreDeadline = Event_PreDeadline;
     RigidSchedule = EventRigidFlag;
     TimePerSplit = TimeSpan.FromTicks(((EventDuration.Ticks / Splits)));
     ArrayOfSubEvents = new SubCalendarEvent[Splits];
     CalendarEventID = new EventID(new string[] { EventIDGenerator.generate().ToString() });
     EventRepetition = EventRepetitionEntry;
     LocationData = EventLocation;
     EventSequence = new TimeLine(StartDateTime, EndDateTime);
     UpdateLocationMatrix(LocationData);
 }
Пример #5
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;
            }
Пример #6
0
 //This takes a repetition object, and creates a Repetition XmlNode
 public XmlElement CreateRepetitionNode(Repetition RepetitionObjEntry)
 {
     int i = 0;
     XmlDocument xmldoc = new XmlDocument();
     XmlElement RepeatCalendarEventsNode = xmldoc.CreateElement("Recurrence");//Defines umbrella Repeat XmlNode
     RepeatCalendarEventsNode.PrependChild(xmldoc.CreateElement("RepeatStartDate"));
     RepeatCalendarEventsNode.ChildNodes[0].InnerText = RepetitionObjEntry.Range.Start.ToString();
     RepeatCalendarEventsNode.PrependChild(xmldoc.CreateElement("RepeatEndDate"));
     RepeatCalendarEventsNode.ChildNodes[0].InnerText = RepetitionObjEntry.Range.End.ToString();
     RepeatCalendarEventsNode.PrependChild(xmldoc.CreateElement("RepeatFrequency"));
     RepeatCalendarEventsNode.ChildNodes[0].InnerText = RepetitionObjEntry.Frequency;
     XmlNode XmlNodeForRepeatListOfEvents = xmldoc.CreateElement("RepeatCalendarEvents");
     XmlElement RepeatCalendarEventNode;//Declares Repeat XmlNode
     for (; i < RepetitionObjEntry.RecurringCalendarEvents.Length; i++)//For loop goes through each classEvent in repeat object and generates an xmlnode
     {
         RepeatCalendarEventNode = xmldoc.CreateElement("RepeatCalendarEvent");
         RepeatCalendarEventNode.InnerXml = CreateEventScheduleNode(RepetitionObjEntry.RecurringCalendarEvents[i]).InnerXml;
         XmlNodeForRepeatListOfEvents.PrependChild(RepeatCalendarEventNode);
     }
     RepeatCalendarEventsNode.PrependChild(XmlNodeForRepeatListOfEvents);
     return RepeatCalendarEventsNode;
 }
Пример #7
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;
        }
Пример #8
0
        BusyTimeLine[] GetBusySlotsPerRepeat(Repetition RecurringEvents)
        {
            int i = 0;
            BusyTimeLine[] ArrayOfBusySlotsPerRecurringEvents;
            List<BusyTimeLine[]> MyListOfWithArrayOfBusySlots = new List<BusyTimeLine[]>();//this can be used as a list since we know the limits of each repeating element. Only using list becaue it'll be faster to implement
            for (; i < RecurringEvents.RecurringCalendarEvents.Length; i++)
            {
                MyListOfWithArrayOfBusySlots.Add(GetBusySlotPerCalendarEvent(RecurringEvents.RecurringCalendarEvents[i]));
            }
            List<BusyTimeLine> MyListOfBusySlots = new List<BusyTimeLine>();
            i = 0;
            int j = 0;
            for (; i < MyListOfWithArrayOfBusySlots.Count; i++)
            {
                j = 0;
                for (; j < MyListOfWithArrayOfBusySlots[i].Length; j++)
                {
                    MyListOfBusySlots.Add(MyListOfWithArrayOfBusySlots[i][j]);
                }
            }

            return MyListOfBusySlots.ToArray();


        }
Пример #9
0
        private void button5_Click_2(object sender, RoutedEventArgs e)
        {
            string eventName = textBox1.Text;
            string LocationString  = textBox8.Text.Trim();
            /*if (LocationString != "")
            {
                eventName += "," + LocationString;
            }*/

            DateTime CurrentTimeOfExecution =DateTime.Now;
            string eventStartTime = textBox5.Text;
            string locationInformation = textBox8.Text;
            DateTime eventStartDate = (DateTime)datePicker1.SelectedDate.Value;
            string eventEndTime = textBox7.Text;
            DateTime eventEndDate = (DateTime)datePicker2.SelectedDate.Value;
            bool EventRepetitionflag = checkBox2.IsChecked.Value;
            bool DefaultPrepTimeflag = checkBox3.IsChecked.Value;
            string eventPrepTime = textBox3.Text;
            bool RigidScheduleFlag = checkBox5.IsChecked.Value;
            string RepeatFrequency = comboBox2.Text;
            string EventDuration = textBox4.Text;
            string eventSplit = textBox2.Text;
            bool DefaultPreDeadlineFlag = checkBox4.IsChecked.Value;
            string PreDeadlineTime = textBox6.Text;
            eventStartTime=eventStartTime.Trim();
            eventStartTime=eventStartTime.Replace(" ", string.Empty);
            if (eventStartTime == "")
            {
                eventStartTime = CurrentTimeOfExecution.ToString();
                string[] TempString = eventStartTime.Split(' ');
                eventStartTime =TempString[1]+TempString[2];
            }
            //This attempts to detect invalid inputs for start time values
            string[] TimeElements = CalendarEvent.convertTimeToMilitary(eventStartTime).Split(':');
            DateTime EnteredDateTime = new DateTime(eventStartDate.Year, eventStartDate.Month, eventStartDate.Day, Convert.ToInt32(TimeElements[0]), Convert.ToInt32(TimeElements[1]), 0);
            //if checks for StartDateTime
            if (EnteredDateTime < DateTime.Now)
            {
                //DateTime Now=DateTime.Now;
                //MessageBox.Show("Please Adjust Your Start Date, Its less than the current time:");
                //return;
            }

            if (eventEndTime == "")
            {
                DateTime EventEndDateTime = new DateTime(eventEndDate.Year, eventEndDate.Month, eventEndDate.Day, EnteredDateTime.Hour, EnteredDateTime.Minute, EnteredDateTime.Second);

                eventEndTime = EventEndDateTime.ToString();
                //eventEndDate
                //MessageBox.Show("Please Type EndTime in The Format: HH:MM A/PM");
                //return;
            }
            TimeSpan TestTimeSpan = new TimeSpan();
            bool RigidFlag = false;
            bool RepetitionFlag = false;
            Repetition MyRepetition=new Repetition();
            if (checkBox5.IsChecked.Value)
            {
                RigidFlag = true;
            }
            DateTime CurrentNow = DateTime.Now;
            DateTime RepeatStart = CurrentNow;
            DateTime RepeatEnd=RepeatStart;

            if (checkBox2.IsChecked.Value)
            {
                //RepeatStart = (DateTime)calendar3.SelectedDate.Value;
                DateTime FullStartTime = DateTime.Parse(eventStartDate.ToShortDateString() + " " + eventStartTime);
                DateTime FullEndTime = DateTime.Parse(eventEndDate.ToShortDateString() + " " + eventEndTime);

                RepeatStart = DateTime.Parse(eventStartTime);
                RepeatEnd = (DateTime)calendar4.SelectedDate.Value;
                RepetitionFlag = true;
                MyRepetition = new Repetition(RepetitionFlag, new TimeLine(RepeatStart, RepeatEnd), RepeatFrequency, new TimeLine((FullStartTime),(FullEndTime)));
                //eventStartDate = RepeatStart;
                eventEndDate = RepeatEnd;
            }

            CustomErrors ErrorCheck = ValidateInputValues(EventDuration, eventStartTime, eventStartDate.ToString(), eventEndTime, eventEndDate.ToString(), RepeatStart.ToString(), RepeatEnd.ToString(), PreDeadlineTime, eventSplit, eventPrepTime, CurrentNow);

            if (!ErrorCheck.Status)
            {
                MessageBox.Show(ErrorCheck.Message);
                return;
                //
            }
            //C6RXEZ
            Location var0 = new Location(textBox8.Text);

            EventDisplay UiData = new EventDisplay();
            MiscData NoteData = new MiscData();
            bool CompletedFlag = false;

            //CalendarEvent ScheduleUpdated = CreateSchedule(eventName, eventStartTime, eventStartDate, eventEndTime, eventEndDate, eventSplit, PreDeadlineTime, EventDuration, EventRepetitionflag, DefaultPreDeadlineFlag, RigidScheduleFlag, eventPrepTime, DefaultPreDeadlineFlag);
            CalendarEvent ScheduleUpdated = new CalendarEvent(eventName, eventStartTime, eventStartDate, eventEndTime, eventEndDate, eventSplit, PreDeadlineTime, EventDuration, MyRepetition, DefaultPreDeadlineFlag, RigidFlag, eventPrepTime, DefaultPreDeadlineFlag, var0,true,UiData,NoteData,CompletedFlag);
            ScheduleUpdated.Repeat.PopulateRepetitionParameters(ScheduleUpdated);
            textBlock9.Text = "...Loading";
            Stopwatch snugarrayTester = new Stopwatch();
            snugarrayTester.Start();
            CustomErrors ScheduleUpdateMessage = MySchedule.AddToSchedule(ScheduleUpdated);
            snugarrayTester.Stop();
            //MessageBox.Show("It took " + snugarrayTester.ElapsedMilliseconds.ToString() + "ms max thread count is ");

            if (!ScheduleUpdateMessage.Status)
            {
                textBlock9.Text = "Schedule Updated with " + ScheduleUpdated.Name;
                if (ScheduleUpdateMessage.Status)
                {
                    textBlock9.Text = ScheduleUpdateMessage.Message;
                }
            }

            else
            {
                textBlock9.Text = "Failed to update Schedule" + ScheduleUpdated.Name;
                //MessageBox.Show(ScheduleUpdateMessage.Message);
            }
        }
Пример #10
0
        public CalendarEvent(string EventName, TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, TimeSpan Event_PreDeadline, bool EventRigidFlag, Repetition EventRepetitionEntry, int EventSplit, Location EventLocation, bool EnableFlag, EventDisplay UiData, MiscData NoteData, bool CompletionFlag)
        {
            CalendarEventName = EventName;
            /*CalendarEventName = EventName.Split(',')[0];
            LocationString = "";
            if (EventName.Split(',').Length > 1)
            {
                LocationString = EventName.Split(',')[1];
            }
            CalendarEventLocation = null;
            CalendarEventLocation = new Location();
            if (LocationString != "")
            {
                CalendarEventLocation = new Location(LocationString);
            }
            */
            StartDateTime = EventStart;
            EndDateTime = EventDeadline;
            EventDuration = Event_Duration;
            PrepTime = EventPrepTime;
            EventPreDeadline = Event_PreDeadline;
            RigidSchedule = EventRigidFlag;
            LocationData = EventLocation;
            CalendarEventID = new EventID(new string[] { EventIDGenerator.generate().ToString() });
            EventRepetition = EventRepetitionEntry;

            UiParams = UiData;
            DataBlob = NoteData;
            Complete = CompletionFlag;


            if (EventRepetition.Enable)
            {
                Splits = EventSplit;
                TimePerSplit = new TimeSpan();
            }
            else
            {
                Splits = EventSplit;
                TimePerSplit = TimeSpan.FromTicks(((EventDuration.Ticks / Splits)));
            }

            SubEvents = new Dictionary<EventID, SubCalendarEvent>();
            for (int i = 0; i < Splits; i++)
            {
                SubCalendarEvent newSubCalEvent = new SubCalendarEvent(TimePerSplit, (EndDateTime - TimePerSplit), this.End, new TimeSpan(), CalendarEventID.ToString(), RigidSchedule, this.Enabled, this.UiParams, this.Notes, this.Complete, EventLocation, this.RangeTimeLine); //new SubCalendarEvent(CalendarEventID);
                SubEvents.Add(newSubCalEvent.SubEvent_ID, newSubCalEvent);
            }

            
            
            EventSequence = new TimeLine(StartDateTime, EndDateTime);
            UpdateLocationMatrix(LocationData);
        }
Пример #11
0
 public CalendarEvent(string NameEntry, string StartTime, DateTime StartDateEntry, string EndTime, DateTime EventEndDateEntry, string eventSplit, string PreDeadlineTime, string EventDuration, Repetition EventRepetitionEntry, bool DefaultPrepTimeflag, bool RigidScheduleFlag, string eventPrepTime, bool PreDeadlineFlag,Location EventLocation)
     : this(new ConstructorModified(NameEntry, StartTime, StartDateEntry, EndTime, EventEndDateEntry, eventSplit, PreDeadlineTime, EventDuration, EventRepetitionEntry, DefaultPrepTimeflag, RigidScheduleFlag, eventPrepTime, PreDeadlineFlag), EventLocation)
 {
 }
 public void LoopThroughRemoveRepeatEvents(Repetition MyRepetition)
 {
     int i = 0;
     for (; i < MyRepetition.RecurringCalendarEvents.Length; i++)
     {
         RemoveFromOutlook(MyRepetition.RecurringCalendarEvents[i]);
     }
 }
Пример #13
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;
            if (MyUpdated.ID != null)
            {
                CalendarEventID = new EventID(MyUpdated.ID.Split('_'));
            }
            Enabled = MyUpdated.isEnabled;

            SubEvents = new Dictionary<EventID, SubCalendarEvent>();
            for (int i = 0; i < MySubEvents.Length; i++)//using MySubEvents.length for the scenario of the call for repeat event. Remember the parent event does not generate subevents
            {
                SubCalendarEvent newSubCalEvent = MySubEvents[i];
                if (SubEvents.ContainsKey(newSubCalEvent.SubEvent_ID))
                { 
                    SubEvents[newSubCalEvent.SubEvent_ID]=newSubCalEvent;
                }
                else
                {
                    SubEvents.Add(newSubCalEvent.SubEvent_ID, newSubCalEvent);
                }   
            }

            SchedulStatus = false;
            EventRepetition = MyUpdated.Repeat;
            LocationData = MyUpdated.LocationData;
            UpdateLocationMatrix(LocationData);
            EventSequence = new TimeLine(StartDateTime, EndDateTime);
        }
Пример #14
0
 public CalendarEvent(string NameEntry, string StartTime, DateTime StartDateEntry, string EndTime, DateTime EventEndDateEntry, string eventSplit, string PreDeadlineTime, string EventDuration, Repetition EventRepetitionEntry, bool DefaultPrepTimeflag, bool RigidScheduleFlag, string eventPrepTime, bool PreDeadlineFlag,Location EventLocation,bool EnabledEventFlag, EventDisplay UiData,MiscData NoteData,bool CompletionFlag)
     : this(new ConstructorModified(NameEntry, StartTime, StartDateEntry, EndTime, EventEndDateEntry, eventSplit, PreDeadlineTime, EventDuration, EventRepetitionEntry, DefaultPrepTimeflag, RigidScheduleFlag, eventPrepTime, PreDeadlineFlag, EnabledEventFlag,  UiData, NoteData, CompletionFlag), EventLocation)
 {
 }
Пример #15
0
            public ConstructorModified(string EventIDEntry, string NameEntry, string StartTime, DateTime StartDateEntry, string EndTime, DateTime EventEndDateEntry, string eventSplit, string PreDeadlineTime, string EventDuration, Repetition EventRepetition, bool DefaultPrepTimeflag, bool RigidScheduleFlag, string eventPrepTime, bool PreDeadlineFlag, bool EnabledEventFlag, EventDisplay UiData, MiscData NoteData, bool CompletionFlag)
            {
                CalendarEventID = new EventID(EventIDEntry.Split('_'));
                Enabled = EnabledEventFlag;
                Name = NameEntry;
                EventDuration=EventDuration.Replace(".", ":");
                //EventDuration = EventDuration + ":00";
                string MiltaryStartTime = convertTimeToMilitary(StartTime);
                StartDate = new DateTime(StartDateEntry.Year, StartDateEntry.Month, StartDateEntry.Day, Convert.ToInt32(MiltaryStartTime.Split(':')[0]), Convert.ToInt32(MiltaryStartTime.Split(':')[1]), 0);
                string MiltaryEndTime = convertTimeToMilitary(EndTime);
                EndDate = new DateTime(EventEndDateEntry.Year, EventEndDateEntry.Month, EventEndDateEntry.Day, Convert.ToInt32(MiltaryEndTime.Split(':')[0]), Convert.ToInt32(MiltaryEndTime.Split(':')[1]), 0);
                
                string[] TimeDuration = EventDuration.Split(':');
                double AllMinutes = TimeSpan.Parse(EventDuration).TotalMinutes;
                Duration = TimeSpan.Parse(EventDuration);

                if (RigidScheduleFlag)//enforces rigid restriction
                {
                    Duration = EndDate - StartDate;
                }
                Split = Convert.ToInt32(eventSplit);

                ui = UiData;
                complete = CompletionFlag;
                noteData = NoteData;



                if (PreDeadlineFlag)
                {
                    PreDeadline = new TimeSpan(((int)AllMinutes % 10) * 60);
                }
                else
                {
                    PreDeadline = new TimeSpan(ConvertToMinutes(PreDeadlineTime) * 60 * 10000000);
                }
                if (DefaultPrepTimeflag)
                {
#if (SetDefaultPreptimeToZero)
                    PrepTime = new TimeSpan(0);
#else
                    PrepTime = new TimeSpan((long)((15 * 60)*10000000));
#endif
                }
                else
                {
                    //uint MyNumber = Convert.ToInt32(eventPrepTime);
                    PrepTime = new TimeSpan((long)ConvertToMinutes(eventPrepTime) * 60 * 10000000);
                }
                Rigid = RigidScheduleFlag;
                Repeat = EventRepetition;
            }
Пример #16
0
            public ConstructorModified(string NameEntry, string StartTime, DateTime StartDateEntry, string EndTime, DateTime EventEndDateEntry, string eventSplit, string PreDeadlineTime, string EventDuration, Repetition EventRepetition, bool DefaultPrepTimeflag, bool RigidScheduleFlag, string eventPrepTime, bool PreDeadlineFlag)
            {
                Name = NameEntry;//.Split(',')[0];
                
                //EventDuration = EventDuration
                string MiltaryStartTime = convertTimeToMilitary(StartTime);
                StartDate = new DateTime(StartDateEntry.Year, StartDateEntry.Month, StartDateEntry.Day, Convert.ToInt32(MiltaryStartTime.Split(':')[0]), Convert.ToInt32(MiltaryStartTime.Split(':')[1]), 0);
                string MiltaryEndTime = convertTimeToMilitary(EndTime);
                EndDate = new DateTime(EventEndDateEntry.Year, EventEndDateEntry.Month, EventEndDateEntry.Day, Convert.ToInt32(MiltaryEndTime.Split(':')[0]), Convert.ToInt32(MiltaryEndTime.Split(':')[1]), 0);
                //
                //string[] TimeDuration = EventDuration.Split(':');
                double AllMinutes = TimeSpan.Parse(EventDuration).TotalMinutes;
                Duration = new TimeSpan((int)(AllMinutes / 60), (int)(AllMinutes % 60), 0);
                Split = Convert.ToInt32(eventSplit);
                if (PreDeadlineFlag)
                {
                    PreDeadline = new TimeSpan(((int)AllMinutes % 10) * 60);
                }
                else
                {
                    PreDeadline = new TimeSpan(Convert.ToInt64(PreDeadlineTime));
                }
                if (DefaultPrepTimeflag)
                {
#if (SetDefaultPreptimeToZero)
                    PrepTime = new TimeSpan(0);
#else
                    PrepTime = new TimeSpan((long)((15 * 60)*10000000));
#endif
                }
                else
                {
                    //uint MyNumber = Convert.ToInt32(eventPrepTime);
                    PrepTime = new TimeSpan((long)ConvertToMinutes(eventPrepTime) * 60 * 10000000);
                }
                Rigid = RigidScheduleFlag;
                Repeat = EventRepetition;
            }
Пример #17
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");    
 }
Пример #18
0
        private void RunEvaluation(object sender, RoutedEventArgs e)
        {
            int NumberOfRetries = Convert.ToInt32(textBox10.Text);
            long[] AllData = new long[NumberOfRetries];

            while(--NumberOfRetries>=0)
            {
                UserAccount currentUser = new UserAccount(UserNameTextBox.Text, PasswordTextBox.Text);
                MySchedule = new Schedule(currentUser,DateTime.Now);

                string eventName = textBox1.Text;
                string LocationString = textBox8.Text.Trim();
                /*if (LocationString != "")
                {
                    eventName += "," + LocationString;
                }*/

                DateTime CurrentTimeOfExecution = DateTime.Now;
                string eventStartTime = textBox5.Text;
                string locationInformation = textBox8.Text;
                DateTime eventStartDate = (DateTime)datePicker1.SelectedDate.Value;
                string eventEndTime = textBox7.Text;
                DateTime eventEndDate = (DateTime)datePicker2.SelectedDate.Value;
                bool EventRepetitionflag = checkBox2.IsChecked.Value;
                bool DefaultPrepTimeflag = checkBox3.IsChecked.Value;
                string eventPrepTime = textBox3.Text;
                bool RigidScheduleFlag = checkBox5.IsChecked.Value;
                string RepeatFrequency = comboBox2.Text;
                string EventDuration = textBox4.Text;
                string eventSplit = textBox2.Text;
                bool DefaultPreDeadlineFlag = checkBox4.IsChecked.Value;
                string PreDeadlineTime = textBox6.Text;
                eventStartTime = eventStartTime.Trim();
                eventStartTime = eventStartTime.Replace(" ", string.Empty);
                if (eventStartTime == "")
                {
                    eventStartTime = CurrentTimeOfExecution.ToString();
                    string[] TempString = eventStartTime.Split(' ');
                    eventStartTime = TempString[1] + TempString[2];
                }
                //This attempts to detect invalid inputs for start time values
                string[] TimeElements = CalendarEvent.convertTimeToMilitary(eventStartTime).Split(':');
                DateTime EnteredDateTime = new DateTime(eventStartDate.Year, eventStartDate.Month, eventStartDate.Day, Convert.ToInt32(TimeElements[0]), Convert.ToInt32(TimeElements[1]), 0);
                //if checks for StartDateTime
                if (EnteredDateTime < DateTime.Now)
                {
                    //DateTime Now=DateTime.Now;
                    //MessageBox.Show("Please Adjust Your Start Date, Its less than the current time:");
                    //return;
                }

                if (eventEndTime == "")
                {
                    DateTime EventEndDateTime = new DateTime(eventEndDate.Year, eventEndDate.Month, eventEndDate.Day, EnteredDateTime.Hour, EnteredDateTime.Minute, EnteredDateTime.Second);

                    eventEndTime = EventEndDateTime.ToString();
                    //eventEndDate
                    //MessageBox.Show("Please Type EndTime in The Format: HH:MM A/PM");
                    //return;
                }
                TimeSpan TestTimeSpan = new TimeSpan();
                bool RigidFlag = false;
                bool RepetitionFlag = false;
                Repetition MyRepetition = new Repetition();
                if (checkBox5.IsChecked.Value)
                {
                    RigidFlag = true;
                }
                DateTime CurrentNow = DateTime.Now;
                DateTime RepeatStart = CurrentNow;
                DateTime RepeatEnd = RepeatStart;

                if (checkBox2.IsChecked.Value)
                {

                    DateTime FullStartTime = DateTime.Parse(eventStartDate.ToShortDateString() + " " + eventStartTime);
                    DateTime FullEndTime = DateTime.Parse(eventEndDate.ToShortDateString() + " " + eventEndTime);

                    //RepeatStart = (DateTime)calendar3.SelectedDate.Value;
                    RepeatStart = DateTime.Parse(eventStartTime);
                    RepeatEnd = (DateTime)calendar4.SelectedDate.Value;
                    //RepeatEnd = (DateTime.Now).AddDays(7);
                    RepetitionFlag = true;
                    MyRepetition = new Repetition(RepetitionFlag, new TimeLine(RepeatStart, RepeatEnd), RepeatFrequency, new TimeLine((FullStartTime),(FullEndTime)));

                    //eventStartDate = RepeatStart;
                    eventEndDate = RepeatStart;
                }

                CustomErrors ErrorCheck = ValidateInputValues(EventDuration, eventStartTime, eventStartDate.ToString(), eventEndTime, eventEndDate.ToString(), RepeatStart.ToString(), RepeatEnd.ToString(), PreDeadlineTime, eventSplit, eventPrepTime, CurrentNow);

                if (!ErrorCheck.Status)
                {
                    //MessageBox.Show(ErrorCheck.Message);
                    return;
                    //
                }
                //C6RXEZ
                Location var0 = new Location(textBox8.Text);

                EventDisplay UiData = new EventDisplay();
                MiscData NoteData = new MiscData();
                bool CompletedFlag = false;

                //CalendarEvent ScheduleUpdated = CreateSchedule(eventName, eventStartTime, eventStartDate, eventEndTime, eventEndDate, eventSplit, PreDeadlineTime, EventDuration, EventRepetitionflag, DefaultPreDeadlineFlag, RigidScheduleFlag, eventPrepTime, DefaultPreDeadlineFlag);
                CalendarEvent ScheduleUpdated = new CalendarEvent(eventName, eventStartTime, eventStartDate, eventEndTime, eventEndDate, eventSplit, PreDeadlineTime, EventDuration, MyRepetition, DefaultPreDeadlineFlag, RigidFlag, eventPrepTime, DefaultPreDeadlineFlag, var0, true, UiData, NoteData,CompletedFlag);
                ScheduleUpdated.Repeat.PopulateRepetitionParameters(ScheduleUpdated);

                Stopwatch snugarrayTester = new Stopwatch();
                snugarrayTester.Start();
                CustomErrors ScheduleUpdateMessage = MySchedule.AddToSchedule(ScheduleUpdated);
                snugarrayTester.Stop();
                AllData[NumberOfRetries] = snugarrayTester.ElapsedMilliseconds;

            }

            int q= 0;
            double totalTIme = 0;
            for(q=0;q<AllData.Length;q++)
            {
                textBlock9.Text += AllData[q] + ",";
                totalTIme += AllData[q];
            }
            totalTIme /= q;

            textBlock9.Text += "Average is " + totalTIme;
        }
Пример #19
0
        public CalendarEvent(EventID EventIDEntry, string EventName, TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, TimeSpan Event_PreDeadline, bool EventRigidFlag, Repetition EventRepetitionEntry, int EventSplit, Location EventLocation, bool enabledFlag, EventDisplay UiData, MiscData NoteData, bool CompletionFlag)
        {
            CalendarEventName = EventName;
            StartDateTime = EventStart;
            EndDateTime = EventDeadline;
            EventDuration = Event_Duration;
            Enabled = enabledFlag;
            EventRepetition = EventRepetitionEntry;
            PrepTime = EventPrepTime;
            EventPreDeadline = Event_PreDeadline;
            RigidSchedule = EventRigidFlag;
            LocationData = EventLocation;
            CalendarEventID = EventIDEntry;
            UiParams = UiData;
            DataBlob = NoteData;
            Complete = CompletionFlag;

            if (EventRepetition.Enable)
            {
                Splits = EventSplit;
                TimePerSplit = new TimeSpan();
            }
            else
            {
                Splits = EventSplit;
                TimePerSplit = TimeSpan.FromTicks(((EventDuration.Ticks / Splits)));
            }
            SubEvents = new Dictionary<EventID, SubCalendarEvent>();
            for (int i = 0; i < Splits; i++)
            {
                //(TimeSpan Event_Duration, DateTime EventStart, DateTime EventDeadline, TimeSpan EventPrepTime, string myParentID, bool Rigid, Location EventLocation =null, TimeLine RangeOfSubCalEvent = null)
                SubCalendarEvent newSubCalEvent = new SubCalendarEvent(TimePerSplit, (EndDateTime - TimePerSplit), this.End, new TimeSpan(), CalendarEventID.ToString(), RigidSchedule,this.isEnabled, this.UiParams,this.Notes,this.Complete, EventLocation, this.RangeTimeLine);
                SubEvents.Add(newSubCalEvent.SubEvent_ID, newSubCalEvent);
            }

            EventSequence = new TimeLine(StartDateTime, EndDateTime);
            UpdateLocationMatrix(EventLocation);
        }
Пример #20
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);
 }
Пример #21
0
 public Repetition CreateCopy()
 {
     Repetition repetition_cpy = new Repetition();
     if (this.RepeatingEvents.Length < 1)
     {
         return repetition_cpy;
     }
     repetition_cpy.RepetitionFrequency = this.RepetitionFrequency;
     repetition_cpy.RepetitionRange = this.RepetitionRange.CreateCopy();
     repetition_cpy.RepeatingEvents = RepeatingEvents.Select(obj => obj.createCopy()).ToArray();
     repetition_cpy.RepeatLocation = RepeatLocation.CreateCopy();
     repetition_cpy.EnableRepeat = EnableRepeat;
     repetition_cpy.DictionaryOfIDAndCalendarEvents = DictionaryOfIDAndCalendarEvents.ToDictionary(obj => obj.Key, obj1 => obj1.Value.createCopy());
     return repetition_cpy;
 }