public CalendarEventUpdater(GoogleCalendar.ActionType UpdateType, CalendarEvent calEvent, RecurrenceSettings calRecurrence)
 {
     this.Type = UpdateType;
     this.CalendarEvent = calEvent;
     this.Recurrence = calRecurrence;
     this.Reminder = 10;
 }
        public UpdateEventOptionsViewModel(IGoogleCalendar googleCalendar, IRepository commonRepository)
        {
            calendar = googleCalendar;
            repository = commonRepository;

            selectedEvent = repository.GetCurrentEvent();

            UpdateOnlyInstanceCommand = new RelayCommand(UpdateOnlyInstance);
            UpdateFollowingEventsCommand = new RelayCommand(UpdateFollowingEvents);
            UpdateAllEventsCommand = new RelayCommand(UpdateAllEvents);
            CancelUpdateCommand = new RelayCommand(CancelUpdate);
        }
        public DeleteEventOptionsViewModel(IGoogleCalendar googleCalendar, IRepository commonRepository, IMessanger commonMessanger)
        {
            calendar = googleCalendar;
            repository = commonRepository;
            selectedEvent = repository.GetCurrentEvent();
            messanger = commonMessanger;

            DeleteOnlyInstanceCommand = new RelayCommand(DeleteOnlyInstance);
            DeleteFollowingEventsCommand = new RelayCommand(DeleteFollowingEvents);
            DeleteAllEventsCommand = new RelayCommand(DeleteAllEvents);
            CancelDeleteCommand = new RelayCommand(CloseWindow);

        }
Exemple #4
0
        public void GetComparingEventsTest()
        {CalendarEventList events ;
        CalendarEventList l;
         
          List<string> s = new List<string>();
          s.Add("*****@*****.**");
            s.Add("aisha.jaddoh@gmail");
             events = calendar.GetComparingEvents(DateTime.Today, DateTime.Today, s, "Free Busy View",false);
           // CalendarEventList events = service.GetComparingEvents(calendar, period.Today(), s, "Free Busy View");
            CalendarEvent ev = new  CalendarEvent("", "all free until ", "",new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 9, 0, 0), new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 10, 0, 0));
            CalendarEvent ev2 = new CalendarEvent("", "all free until ", "", new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 12, 30, 0), new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 2, 0, 0).AddHours(12));

             l = new CalendarEventList();
             l.Add(ev);
             l.Add(ev2);
           
            Assert.AreEqual(l, events,"Events are not equal ");

                 
        }
Exemple #5
0
        public bool CreateEvent(CalendarEvent ev)
        {
            log.Debug("Try to create new event title=\"" + ev.Title + "\"");

            try
            {
                // New event
                Event newEvent = ConvertCalendarEventToGoogleEvent(ev, false);

                service.Events.Insert(newEvent, DEFAULT_CALENDAR).Execute();

                log.Debug("New event was successfully created");

                return true;
            }
            catch (Exception ex)
            {
                log.Error("Event creation failed with error:", ex);
                log.Info("Event Details: " + ev.ToString());
                return false;
            }
        }
Exemple #6
0
        public string StartDateTime(CalendarEvent ev)
        {
            string month = HideMonth ? string.Empty : DateFormatUS ? Month + Delimeter : Delimeter + Month;
            string year = HideYear ? string.Empty : Delimeter + Year;            
            string time = HideStartTimeAndEndDateIfFullDay && ev.IsFullDateEvent ? string.Empty : Time;

            if (HideMonthIfCurrent && ev.Start.Month == DateTime.Today.Month && ev.Start.Year == DateTime.Today.Year)
            {
                return String.Format("{0:" + Day + year + PAUSE + time + "}", ev.Start);
            }

            return DateFormatUS ? String.Format("{0:" + month + Day + year + PAUSE + time + "}", ev.Start) :
                                  String.Format("{0:" + Day + month + year + PAUSE + time + "}", ev.Start);
        }
 public CalendarEventUpdater(GoogleCalendar.ActionType UpdateType, CalendarEvent calEvent)
 {
     this.Type = UpdateType;
     this.CalendarEvent = calEvent;
     this.Reminder = 10;
 }
Exemple #8
0
        private static CalendarEvent ConvertFreeBusyGoogleEventToCalendarEvent(KeyValuePair<FreeTime, String> f)
        {
            CalendarEvent calendarEvent;
            try
            {
                if (f.Value.Count(Char.IsWhiteSpace) == numberOfEmails - 1)
                calendarEvent = new CalendarEvent("", "all free ", "", f.Key.Start, f.Key.End);
                else
                calendarEvent = new CalendarEvent("", f.Value, "", f.Key.Start, f.Key.End);


            }
            catch (Exception ex)
            {
                log.Error("Failed to convert Google Calendar event to Calendar event with error:", ex);
                log.Info("Event Details");
                // log.Info("Event Id: " + ev.Id);
                //log.Info("Event Summary: " + ev.Summary);
                //log.Info("Event Description: " + ev.Description);
                //log.Info("Event Location: " + ev.Location);
                //log.Info("Event Start: " + ev.Start.DateTime);
                // log.Info("Event End: " + ev.End.DateTime);
                calendarEvent = new CalendarEvent();
            }

            return calendarEvent;
        }
Exemple #9
0
        private static Event ConvertCalendarEventToGoogleEvent(CalendarEvent ev, bool rememberId)
        {
            try
            {
                Event googleEvent = new Event();

                if (!string.IsNullOrEmpty(ev.Id) && rememberId)
                {
                    googleEvent.Id = ev.Id;
                }

                googleEvent.Summary = ev.Title;
                googleEvent.Location = ev.Location;
                googleEvent.Description = ev.Content;

                googleEvent.Start = ConvertToEventDateTime(ev.Start, ev.IsFullDateEvent);
                googleEvent.End = ev.IsFullDateEvent ? ConvertToEventDateTime(ev.Start, true) : ConvertToEventDateTime(ev.End, false);

                // Recurrence
                if (!String.IsNullOrEmpty(ev.RRule))
                {
                    googleEvent.Recurrence = new String[] { ev.RRule };
                }

                // Reminder
                googleEvent.Reminders = ConvertMinutesToGoogleEventReminder(ev.Reminder);

                // Status
                googleEvent.Status = ev.Confirmed ? CONFIRMED : TENTATIVE;

                return googleEvent;
            }
            catch (Exception ex)
            {
                log.Error("CalendarEvent convertation to GoogleEvent failed with error:", ex);
                log.Info("Event Details: " + ev.ToString());
                return null;
            }
        }
Exemple #10
0
        private static CalendarEvent ConvertGoogleEventToCalendarEvent(Event ev)
        {
            CalendarEvent calendarEvent;
            try
            {
                calendarEvent = new CalendarEvent(ev.Id, ev.Summary, ev.Description, ev.Location, GetEventStartDate(ev), GetEventEndDate(ev), IsFullDayEvent(ev), IsRecurringEvent(ev), IsConfirmedEvent(ev));
            }
            catch (Exception ex)
            {
                log.Error("Failed to convert Google Calendar event to Calendar event with error:", ex);
                log.Info("Event Details");
                log.Info("Event Id: " + ev.Id);
                log.Info("Event Summary: " + ev.Summary);
                log.Info("Event Description: " + ev.Description);
                log.Info("Event Location: " + ev.Location);
                log.Info("Event Start: " + ev.Start.DateTime);
                log.Info("Event End: " + ev.End.DateTime);
                calendarEvent = new CalendarEvent();
            }

            return calendarEvent;
        }
Exemple #11
0
        private static CalendarEvent ConvertMutualGoogleEventToCalendarEvent(KeyValuePair<FreeTime, String> f)
        {
            CalendarEvent calendarEvent;
            try

            {
                
                calendarEvent = new CalendarEvent("", "", "", f.Key.Start, f.Key.End);
               
            }
            catch (Exception ex)
            {
                log.Error("Failed to convert Google Calendar event to Calendar event with error:", ex);
                log.Info("Event Details");
                // log.Info("Event Id: " + ev.Id);
                //log.Info("Event Summary: " + ev.Summary);
                //log.Info("Event Description: " + ev.Description);
                //log.Info("Event Location: " + ev.Location);
                //log.Info("Event Start: " + ev.Start.DateTime);
                // log.Info("Event End: " + ev.End.DateTime);
                calendarEvent = new CalendarEvent();
            }

            return calendarEvent;
        }
Exemple #12
0
        public string EndDateTime(CalendarEvent ev)
        {
            if (HideEndDate)
            {
                return string.Empty;
            }

            if (HideStartTimeAndEndDateIfFullDay && ev.IsFullDateEvent)
            {
                return string.Empty;
            }

            if (ev.End == null)
            {
                return string.Empty;
            }

            string month = HideMonth ? string.Empty : DateFormatUS ? Month + Delimeter : Delimeter + Month;
            string year = HideYear ? string.Empty : Delimeter + Year;
            DateTime end = ev.End ?? DateTime.Today;

            if (HideMonthIfCurrent && end.Month == DateTime.Today.Month && end.Year == DateTime.Today.Year)
            {
                return String.Format("{0:" + Time + "}", end);
            }

            return DateFormatUS ? String.Format("{0:" + month + Day + year + PAUSE + Time + "}", end) :
                                  String.Format("{0:" + Day + month + year + PAUSE + Time + "}", end);
        }
        private CalendarEvent GetCalendarEvent()
        {
            CalendarEvent ev = new CalendarEvent(Title, Content, Location, GetStartDateTime(), GetEndDateTime());

            if (IsRecurringEvent)
            {
                GetRecurrenceSettings();
                ev.RRule = recurrence.ToString();
            }

            if (IsFullDayEvent)
            {
                ev.IsFullDateEvent = true;
            }

            ev.Reminder = CalculateReminderMinutes();
            ev.Confirmed = IsConfirmed;

            return ev;
        }
Exemple #14
0
 public bool DeleteEvent(CalendarEvent ev, ActionType type)
 {
     try
     {
         switch (type)
         {
             case ActionType.single:
                 {
                     service.Events.Delete(DEFAULT_CALENDAR, ev.Id).Execute();
                     break;
                 }
             case ActionType.all:
                 {
                     ev.Id = GetMainEventId(ev.Id);
                     service.Events.Delete(DEFAULT_CALENDAR, ev.Id).Execute();
                     break;
                 }
             case ActionType.following:
                 {
                     UpdateEvent(GetAllPreviousEvents(ev), ActionType.all);
                     break;
                 }
         }
         return true;
     }
     catch (Exception ex)
     {
         log.Error("Event deleting failed with error:", ex);
         log.Info("Event Details: " + ev.ToString());
         return false;
     }
 }
Exemple #15
0
        private CalendarEvent GetAllPreviousEvents(CalendarEvent ev)
        {
            // Get recurrence event using it's single instance event id
            CalendarEvent old = ConvertGoogleEventToCalendarEvent(GetGoogleEventById(GetMainEventId(ev.Id)));

            // Get old event recurrence settings
            RecurrenceSettings previous = GetRecurrenceSettings(old);

            // Change it to end one day before new event
            previous.EndsOn(ev.Start.AddDays(-1));
            old.RRule = previous.ToString();

            return old;
        }
Exemple #16
0
        private CalendarEvent GetMainEventData(CalendarEvent ev)
        {
            ev.Id = GetMainEventId(ev.Id);

            // Find start and end dates of the first event in the series using main part of event ID
            CalendarEventList events = GetEvents(DateTime.Today.AddYears(-4), DateTime.Today.AddYears(4));

            int i = 0;
            while (!events[i].Id.Contains(ev.Id))
            {
                i++;
            }

            ev.Start = events[i].Start;
            ev.End = events[i].End;

            return ev;
        }
Exemple #17
0
        public bool UpdateEvent(CalendarEvent ev, ActionType type)
        {
            log.Debug("Try to update event title=\"" + ev.Title + "\"");
            try
            {
                switch (type)
                {
                    case ActionType.single:
                        {
                            ev.RRule = String.Empty;
                            break;
                        }
                    case ActionType.all:
                        {
                            ev = GetMainEventData(ev); //.Id = GetMainEventId(ev.Id);
                            break;
                        }
                    case ActionType.following:
                        {
                            // Create recurrence event with new settings
                            CreateEvent(ev);
                            ev = GetAllPreviousEvents(ev);
                            break;
                        }
                }

                Event newEvent = ConvertCalendarEventToGoogleEvent(ev, true);

                // Increate sequence number... I hate you Google API for your crazy things >_<
                newEvent = UpdateSequenceNumber(newEvent);

                service.Events.Update(newEvent, DEFAULT_CALENDAR, newEvent.Id).Execute();

                log.Debug("New event was successfully updated");

                return true;
            }
            catch (Exception ex)
            {
                log.Error("Event update failed with error:", ex);
                log.Info("Event Details: " + ev.ToString());
                return false;
            }
        }
Exemple #18
0
 public CalendarEventUpdater(GoogleCalendar.ActionType UpdateType, CalendarEvent calEvent)
 {
     this.Type          = UpdateType;
     this.CalendarEvent = calEvent;
     this.Reminder      = 10;
 }
Exemple #19
0
 public void SetCurrentEvent(CalendarEvent calEvent)
 {
     currentEvent = calEvent;
 }
Exemple #20
0
        public RecurrenceSettings GetRecurrenceSettings(CalendarEvent ev)
        {
            if (!ev.IsRecurrenceEvent)
            {
                return new RecurrenceSettings();
            }

            return new RecurrenceSettings(ev.Start, GetGoogleEventById(GetMainEventId(ev.Id)).Recurrence[0]);
        }