Esempio n. 1
0
 public EventCalendar()
 {
     Start = new EventDateTime()
     {
         TimeZone = "Europe/Kiev"
     };
     End = new EventDateTime()
     {
         TimeZone = "Europe/Kiev"
     };
     Attendees = new EventAttendee[] { new EventAttendee()
                                       {
                                           Email = "*****@*****.**"
                                       } };
     Reminders = new Event.RemindersData()
     {
         UseDefault = false,
         Overrides  = new EventReminder[]
         {
             new EventReminder()
             {
                 Method = "email", Minutes = 24 * 60
             },
             new EventReminder()
             {
                 Method = "sms", Minutes = 10
             },
         }
     };
     Transparency = "opaque";
 }
        /// <summary>
        /// Checks if a event is activated today
        /// </summary>
        /// <param name="e">event to check</param>
        /// <returns>True if the event is scheduled for activation of today</returns>
        private bool IsActiveToday(EventDateTime e)
        {
            DayOfWeek day = DateTime.Today.DayOfWeek;

            if (day == DayOfWeek.Monday)
            {
                return((e.Flags & 4) == 4);
            }
            else if (day == DayOfWeek.Tuesday)
            {
                return((e.Flags & 8) == 8);
            }
            else if (day == DayOfWeek.Wednesday)
            {
                return((e.Flags & 16) == 16);
            }
            else if (day == DayOfWeek.Thursday)
            {
                return((e.Flags & 32) == 32);
            }
            else if (day == DayOfWeek.Friday)
            {
                return((e.Flags & 64) == 64);
            }
            else if (day == DayOfWeek.Saturday)
            {
                return((e.Flags & 128) == 128);
            }
            else if (day == DayOfWeek.Sunday)
            {
                return((e.Flags & 256) == 256);
            }
            return(false);
        }
    public static void MakeAllDay(EventDateTime eventDate)
    {
        DateTime dateTime = eventDate.DateTime.Value;

        eventDate.DateTime    = null;
        eventDate.DateTimeRaw = CalendarApiHelper.GetRawDate(dateTime.Date);
    }
        /// <summary>
        /// Metoda tworząca listę wydarzeń do kalendarza.
        /// </summary>
        /// <param name="booking">Pojedyncza rezerwacja z listą gości.</param>
        public void MakeEventRequest(SimpleBookingUser booking)
        {
            Logs.WriteErrorLog("Robie request eventa (wrzucam zdarzenia na kolejke).");
            Logs.WriteErrorLog(booking.BookingEndTime.ToString("g"));
            Logs.WriteErrorLog(booking.BookingBeginTime.ToString("g"));
            var eventStartDateTime = new EventDateTime {
                DateTime = booking.BookingBeginTime
            };

            Logs.WriteErrorLog("Moja data rozp: " + eventStartDateTime.DateTime.ToString());
            var eventEndDateTime = new EventDateTime {
                DateTime = booking.BookingEndTime
            };

            Logs.WriteErrorLog("Moja data zakonczenia: " + eventEndDateTime.DateTime.ToString());
            Request = new BatchRequest(Service);
            Logs.WriteErrorLog("tytul: " + booking.BookingTitle);
            Logs.WriteErrorLog("Opis" + booking.BookingDescription);
            Request.Queue <Event>(Service.Events.Insert(
                                      new Event
            {
                Summary     = booking.BookingTitle,
                Description = booking.BookingDescription,
                Start       = eventStartDateTime,
                End         = eventEndDateTime
            }, CalendarId),
                                  (content, error, i, message) =>
            {
                //Do wypełnienia "Callback"
            });
            Logs.WriteErrorLog("Wrzucilem.");
        }
Esempio n. 5
0
        async public Task updateSubEvent(TilerFront.Models.EditCalEventModel mySubEvent)
        {
            Event         googleEvent = CalendarServiceInfo.Events.Get(EmailID, mySubEvent.ThirdPartyEventID).Execute();
            EventDateTime googleStart = googleEvent.Start;
            EventDateTime googleEnd   = googleEvent.End;

            googleEvent.Summary = mySubEvent.EventName;

            //googleStart.Date = mySubEvent.getStart().Date.ToShortDateString();
            googleStart.DateTime = mySubEvent.getStart().DateTime;
            //googleStart.DateTime = mySubEvent.getStart().DateTime;
            //googleStart.DateTimeRaw = mySubEvent.getStart().DateTime.ToString("r");
            googleStart.DateTimeRaw = XmlConvert.ToString(mySubEvent.getStart().DateTime, XmlDateTimeSerializationMode.Utc);

            //googleEnd.Date = mySubEvent.getEnd().Date.ToShortDateString();
            googleEnd.DateTime = mySubEvent.getEnd().DateTime;
            //googleEnd.DateTime = mySubEvent.getEnd().DateTime;
            //googleEnd.DateTimeRaw = mySubEvent.getEnd().DateTime.ToString("r");
            googleEnd.DateTimeRaw = XmlConvert.ToString(mySubEvent.getEnd().DateTime, XmlDateTimeSerializationMode.Utc);
            try
            {
                CalendarServiceInfo.Events.Update(googleEvent, EmailID, mySubEvent.ThirdPartyEventID).Execute();
            }
            catch (Exception e)
            {
                ;
            }
        }
Esempio n. 6
0
        private Event MakeEvent(string summary, string location, string description, DateTime startTime, DateTime startHour, DateTime endTime, DateTime endHour)
        {
            Event newEvent = new Event()
            {
                Summary     = summary,
                Location    = location,
                Description = description
            };

            DateTime      inTheStart = new DateTime(startTime.Year, startTime.Month, startTime.Day, startHour.Hour, startHour.Minute, startHour.Second);
            EventDateTime start      = new EventDateTime()
            {
                DateTime = inTheStart
            };

            newEvent.Start = start;

            DateTime      inTheEnd = new DateTime(endTime.Year, endTime.Month, endTime.Day, endHour.Hour, endHour.Minute, endHour.Second);
            EventDateTime end      = new EventDateTime()
            {
                DateTime = inTheEnd
            };

            newEvent.End = end;

            return(newEvent);
        }
Esempio n. 7
0
        public static async Task <Event> CreateEvent(string calendarId, string summary, string description, DateTime startTime, TimeSpan duration)
        {
            UserCredential credential;

            if (string.IsNullOrEmpty(calendarId))
            {
                throw new ArgumentException("calendarId is null or empty");
            }

            CalendarService service;

            SetupRequest(out credential, out service);
            var @event         = new Event();
            var eventStartTime = new EventDateTime();
            var eventEndTime   = new EventDateTime();

            eventStartTime.DateTime = startTime;
            eventEndTime.DateTime   = startTime.Add(duration);
            @event.Start            = eventStartTime;
            @event.End         = eventEndTime;
            @event.Description = description;
            @event.Summary     = summary;
            var request = service.Events.Insert(@event, calendarId);
            var result  = await request.ExecuteAsync();

            if (result != null)
            {
                Console.WriteLine("Event Created");
                return(result);
            }

            Console.WriteLine("Event Not Created");
            return(null);
        }
Esempio n. 8
0
        public static void CreateEvent(CalendarService service)
        {
            // https://developers.google.com/calendar/v3/reference/events/insert
            Event NewEvent = new Event();

            NewEvent.GuestsCanInviteOthers = true;
            NewEvent.Location = "In the middle of no where";
            EventDateTime StartTime = new EventDateTime();

            StartTime.TimeZone    = "America/Chicago";
            StartTime.DateTimeRaw = ExtendedMethods.ToRfc3339String(new DateTime(2020, 07, 14, (10 + 5), 00, 00));
            NewEvent.Start        = StartTime;
            EventDateTime EndTime = new EventDateTime();

            EndTime.DateTimeRaw   = ExtendedMethods.ToRfc3339String(new DateTime(2020, 07, 14, (11 + 5), 00, 00));
            NewEvent.End          = EndTime;
            NewEvent.Summary      = "This is a super important meeting";
            NewEvent.Transparency = "transparent";
            List <EventAttendee> attendees = new List <EventAttendee>()
            {
                new EventAttendee {
                    DisplayName = "Ben", Email = "*****@*****.**", Organizer = true
                },
                new EventAttendee {
                    DisplayName = "Benjamin", Email = "*****@*****.**",
                }
            };

            NewEvent.Attendees = attendees;
            EventsResource.InsertRequest InsertEvent = service.Events.Insert(NewEvent, "*****@*****.**");
            InsertEvent.Execute();
        }
        private void CreateEvent(CalendarService _service, string UserEmail)
        {
            Event         body = new Event();
            EventAttendee a    = new EventAttendee();

            a.Email = "*****@*****.**";
            List <EventAttendee> attendes = new List <EventAttendee>();

            attendes.Add(a);
            body.Attendees = attendes;
            EventDateTime start   = new EventDateTime();
            string        iString = "2020-05-30 06:12 PM";
            DateTime      oDate   = DateTime.ParseExact(iString, "yyyy-MM-dd hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);

            start.DateTime = oDate;

            EventDateTime end      = new EventDateTime();
            string        ieString = "2020-05-30 08:12 PM";
            DateTime      oeDate   = DateTime.ParseExact(ieString, "yyyy-MM-dd hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);

            end.DateTime = oeDate;

            body.Start    = start;
            body.End      = end;
            body.Location = "Newberg, OR 97132, USA";
            body.Summary  = "Video ";
            // body.Description = "prayag";
            EventsResource.InsertRequest request = new EventsResource.InsertRequest(_service, body, UserEmail);
            Event response = request.Execute();
        }
 /// <summary>
 /// Получение преобразованной даты даты события
 /// </summary>
 /// <param name="dateTime"></param>
 /// <returns></returns>
 public DateTime DateEvent(EventDateTime dateTime)
 {
     if (string.IsNullOrWhiteSpace(dateTime.Date))
     {
         if (string.IsNullOrWhiteSpace(dateTime.DateTime.ToString()))
         {
             if (string.IsNullOrWhiteSpace(dateTime.DateTimeRaw))
             {
                 return(new DateTime(1970, 1, 1, 0, 0, 0));
             }
             else
             {
                 return(Convert.ToDateTime(dateTime.DateTimeRaw));
             }
         }
         else
         {
             return(Convert.ToDateTime(dateTime.DateTime.ToString()));
         }
     }
     else
     {
         return(Convert.ToDateTime(dateTime.Date));
     }
 }
    public static EventDateTime ToEventDateTime(this DateTime dDateTime)
    {
        EventDateTime edtDateTime = new EventDateTime();

        edtDateTime.DateTime = DateTime.ParseExact(dDateTime.ToString("MM/dd/yyyy HH:mm"), "MM/dd/yyyy HH:mm", null);
        return(edtDateTime);
    }
        public static async Task <Event> EditEvent(EventDto eventDto, string Id)
        {
            CalendarService service = await InitializeCalendar();

            string        calendarId = @"*****@*****.**";
            EventDateTime start      = new EventDateTime()
            {
                DateTime = eventDto.StartTime
            };
            EventDateTime end = new EventDateTime()
            {
                DateTime = eventDto.EndTime
            };
            var myevent = new Event()
            {
                Start       = start,
                End         = end,
                Location    = eventDto.Location,
                Summary     = eventDto.Description,
                Description = eventDto.Message,
                Id          = Id
            };
            var updateRequest = service.Events.Update(myevent, calendarId, myevent.Id);

            try
            {
                await updateRequest.ExecuteAsync();
            }
            catch (Exception)
            {
                return(null);
            }
            return(myevent);
        }
        /// <summary>
        /// 新しいイベントをGoogleCalendarに追加する
        /// </summary>
        /// <param name="add_item">追加するイベントアイテム</param>
        /// <param name="calendar_id">イベントを追加するカレンダー</param>
        /// <returns>追加したイベント</returns>
        public CalendarEvent AddCalendarEvent(CalendarEvent add_item, string calendar_id)
        {
            Event         insert         = new Event();
            EventDateTime items_datetime = new EventDateTime();

            insert.Summary = add_item.summary;
            if (add_item.color != null)
            {
                insert.ColorId = add_item.color;
            }
            EventDateTime start = new EventDateTime();
            EventDateTime end   = new EventDateTime();

            if (add_item.dateonly == true)
            {
                start.Date = add_item.start.Date.ToString();
                end.Date   = add_item.end.Date.ToString();
            }
            else
            {
                start.DateTime = add_item.start;
                end.DateTime   = add_item.end;
            }
            insert.Start       = start;
            insert.End         = end;
            insert.Description = add_item.description;
            insert.Location    = add_item.location;
            Event.RemindersData remindersData = new Event.RemindersData();
            remindersData.UseDefault = false;
            insert.Reminders         = null;
            add_item.id = _service.Events.Insert(insert, calendar_id).Execute().Id;
            return(add_item);
        }
        private static Event CreateCalendarEvent(string description, DateTime timeFrom, DateTime timeTo)
        {
            var start = new EventDateTime { DateTime = timeFrom };
            var end = new EventDateTime { DateTime = timeTo };

            return new Event { Start = start, End = end, Description = description, Summary = description };
        }
        private static void PostEvent(Lector l, CalendarService service, int year, DateTime startDay, string calendarId)
        {
            Console.WriteLine("Posting Event");
            var ev = new Event();

            var timeS = l.Start.Split(':');
            var timeE = l.End.Split(':');

            var date = startDay.AddDays(l.Day);

            // Format the date and time of the lector
            EventDateTime start = new EventDateTime();

            start.DateTime = new DateTime(year, date.Month, date.Day, int.Parse(timeS[0]), int.Parse(timeS[1]), 0);
            EventDateTime end = new EventDateTime();

            end.DateTime = new DateTime(year, date.Month, date.Day, int.Parse(timeE[0]), int.Parse(timeE[1]), 0);

            // Set event data
            ev.Start       = start;
            ev.End         = end;
            ev.Location    = l.Location;
            ev.Summary     = l.Class;
            ev.Description = l.Teacher + "\n" + l.Note;

            try
            {
                // Post event
                service.Events.Insert(ev, calendarId).Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("You need to supply a valid CalendarID in the properties.txt file");
            }
        }
        public static EventDateTime ToEventDateTime(this string dDateTime)
        {
            EventDateTime edtDateTime = new EventDateTime();

            edtDateTime.DateTime = DateTime.ParseExact(Convert.ToDateTime(dDateTime).ToString("yyyy/MM/dd HH:mm"), "yyyy/MM/dd HH:mm", null);
            return(edtDateTime);
        }
Esempio n. 17
0
 public void SaveSetting(XElement element)
 {
     element.Add(new XAttribute("Name", Name));
     element.Add(new XAttribute("Descripting", Description));
     element.Add(new XAttribute("Urgent", Urgent.ToString()));
     element.Add(new XAttribute("Enabled", Enabled.ToString()));
     element.Add(new XAttribute("EventDateTime", EventDateTime.ToString(CultureInfo.InvariantCulture)));
 }
 public static bool IsAllDay(EventDateTime start)
 {
     if (start == null)
     {
         return(false);
     }
     return(!start.DateTime.HasValue);
 }
Esempio n. 19
0
        public override int GetHashCode()
        {
            int hash = 13;

            hash = (hash * 7) + EventDateTime.GetHashCode();
            hash = (hash * 7) + EventName.GetHashCode();
            return(hash);
        }
        public static EventDateTime GetEventStart(DateTime start)
        {
            var eventDateTime = new EventDateTime();

            eventDateTime.DateTimeRaw = start.ToString("yyyy-MM-dd") + "T" + start.TimeOfDay.ToString() + "+01:00";

            return eventDateTime;
        }
        public static EventDateTime GetEventEnd(DateTime end)
        {
            var eventDateTime = new EventDateTime();

            eventDateTime.DateTimeRaw = end.Date.ToString("yyyy-MM-dd") + "T" + end.TimeOfDay.ToString() + "+01:00";

            return eventDateTime;
        }
 DateTime ConvertDateTime(EventDateTime start)
 {
     if (start.DateTime.HasValue)
     {
         return(start.DateTime.Value);
     }
     return(DateTime.Parse(start.Date));
 }
Esempio n. 23
0
        private Event createEventBody()
        {
            int startYear, startMonth, startDay, startHour, startMinute,
                endYear, endMonth, endDay, endHour, endMinute;

            try
            {
                startYear   = Convert.ToInt32(txtStartYear.Text);
                startMonth  = Convert.ToInt32(txtStartMonth.Text);
                startDay    = Convert.ToInt32(txtStartDay.Text);
                startHour   = Convert.ToInt32(txtStartHour.Text);
                startMinute = Convert.ToInt32(txtStartMinute.Text);

                endYear   = Convert.ToInt32(txtEndYear.Text);
                endMonth  = Convert.ToInt32(txtEndMonth.Text);
                endDay    = Convert.ToInt32(txtEndDay.Text);
                endHour   = Convert.ToInt32(txtEndHour.Text);
                endMinute = Convert.ToInt32(txtEndMinute.Text);

                EventDateTime evtStart = new EventDateTime();
                EventDateTime evtEnd   = new EventDateTime();

                evtStart.DateTime = new DateTime(startYear, startMonth, startDay, startHour, startMinute, 0);
                evtEnd.DateTime   = new DateTime(endYear, endMonth, endDay, endHour, endMinute, 0);

                Event newEvent = new Event();
                newEvent.Start   = evtStart;
                newEvent.End     = evtEnd;
                newEvent.ColorId = "5";
                addAttendees(newEvent); //Adds attendees to the event.

                if (txtSummary.Text.Trim() != "")
                {
                    newEvent.Summary = txtSummary.Text;
                }

                if (txtDescription.Text.Trim() != "")
                {
                    newEvent.Description = txtDescription.Text;
                }

                if (txtLocation.Text.Trim() != "")
                {
                    newEvent.Location = txtLocation.Text;
                }
                return(newEvent);
            }
            catch (FormatException)
            {
                MessageBox.Show("A non number or blank space has been entered into the date. Please use numbers when entering the date.");
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("An invalid date has been entered. Please make sure you enter a valid date.");
            }
            return(null);
        }
Esempio n. 24
0
        private static bool CompareEventsDates(Event existingEvent, EventDateTime newEventTime)
        {
            if (newEventTime.DateTime == existingEvent.Start.DateTime || newEventTime.Date == existingEvent.Start.Date)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 25
0
        public static EventDateTime ConvertEventDateTime(DateTime dateTime)
        {
            EventDateTime result = new EventDateTime();

            result.DateTime = dateTime;

            result.TimeZone = ToIana(TimeZoneInfo.Local.Id);
            return(result);
        }
        public void CreateEvent(DateTime date, string roomName, string name, string phone, string email, string googleCredPath)
        {
            var myEventStart = new EventDateTime();

            myEventStart.DateTime = date;
            myEventStart.TimeZone = _settings.TimeZone;

            var myEventEnd = new EventDateTime();

            myEventEnd.DateTime = date.AddHours(1);
            myEventEnd.TimeZone = _settings.TimeZone;
            var reminders = new Event.RemindersData()
            {
                UseDefault = false,
                Overrides  = new EventReminder[] {
                    new EventReminder()
                    {
                        Method = "email", Minutes = 2 * 60
                    },
                    new EventReminder()
                    {
                        Method = "popup", Minutes = 60
                    }
                }
            };



            var myEvent = new Event();

            myEvent.Summary     = $"Interview - {name}";
            myEvent.Description = $"{name}, {email}, {phone}";
            myEvent.Start       = myEventStart;
            myEvent.End         = myEventEnd;
            myEvent.Location    = $"Kolektif House - Maslak, {roomName}";
            myEvent.Reminders   = reminders;

            //File.AppendAllText("googleCalendar.txt", JsonConvert.SerializeObject(myEvent));

            UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets {
                ClientId     = _settings.ClientId,
                ClientSecret = _settings.ClientSecret,
            },
                new[] { CalendarService.Scope.Calendar },
                "user",
                CancellationToken.None, new FileDataStore(googleCredPath)).Result;

            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = _settings.ApplicationName,
            });

            EventsResource.InsertRequest request = service.Events.Insert(myEvent, _settings.CalendarId);
            Event createdEvent = request.Execute();
        }
Esempio n. 27
0
        public Event ConvertMyEventToGoogle(SynchronEvent synchronEvent)
        {
            var eventDateTime = new EventDateTime
            {
                DateTime = synchronEvent.GetStart(),
                TimeZone = "Europe/Moscow"
            };
            var eventDateTimeEnd = new EventDateTime
            {
                DateTime = synchronEvent.GetFinish(),
                TimeZone = "Europe/Moscow"
            };
            var googleEvent = new Event
            {
                Location    = synchronEvent.GetLocation(),
                Summary     = synchronEvent.GetSubject(),
                Start       = eventDateTime,
                End         = eventDateTimeEnd,
                Description = synchronEvent.GetDescription(),
                ColorId     = "11",
            };

            if (synchronEvent.GetAllDay())
            {
                googleEvent.Start.DateTime    = null;
                googleEvent.Start.DateTimeRaw = null;
                googleEvent.Start.Date        = synchronEvent.GetStart().Year.ToString() + "-" + "0" + synchronEvent.GetStart().Month.ToString() + "-" + synchronEvent.GetStart().Day.ToString();
                googleEvent.End.DateTime      = null;
                googleEvent.End.DateTimeRaw   = null;
                googleEvent.End.Date          = synchronEvent.GetStart().Year.ToString() + "-" + "0" + synchronEvent.GetStart().Month.ToString() + "-" + synchronEvent.GetStart().AddDays(1).Day.ToString();
            }
            if (synchronEvent.GetSource() == _outlook)
            {
                googleEvent.ExtendedProperties = new Event.ExtendedPropertiesData
                {
                    Shared = new BiDictionary <string, string> {
                        { _outlook, synchronEvent.GetId() }
                    }
                };
            }

            EventAttendee[] attendees       = new EventAttendee[synchronEvent.GetParticipants().Count];
            List <string>   AllParticipants = synchronEvent.GetParticipants();

            for (int i = 0; i < AllParticipants.Count; ++i)
            {
                var evAt = new EventAttendee
                {
                    Email          = AllParticipants[i],
                    ResponseStatus = "needsAction"
                };
                attendees[i] = evAt;
            }
            googleEvent.Attendees = attendees;
            //googleEvent.Attendees.Add(evAt);
            return(googleEvent);
        }
Esempio n. 28
0
        private void postponeEvent(String id, string s_date)
        {
            Console.WriteLine(id);
            Event         ev = service.Events.Get("primary", id).Execute();
            DateTime      s  = (DateTime)ev.Start.DateTime;
            DateTime      e  = (DateTime)ev.End.DateTime;
            EventDateTime new_start;
            EventDateTime new_end;

            String[] date = s_date.Split(' ');
            if (s_date == "TODAY")
            {
                new_start = new EventDateTime()
                {
                    DateTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, s.Hour, s.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
                new_end = new EventDateTime()
                {
                    DateTime = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, e.Hour, e.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
            }
            else if (s_date == "TOMORROW")
            {
                var today    = DateTime.Now;
                var tomorrow = today.AddDays(1);
                new_start = new EventDateTime()
                {
                    DateTime = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, s.Hour, s.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
                new_end = new EventDateTime()
                {
                    DateTime = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day, e.Hour, e.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
            }
            else
            {
                new_start = new EventDateTime()
                {
                    DateTime = new DateTime(2020, Int32.Parse(date[1]), Int32.Parse(date[0]), s.Hour, s.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
                new_end = new EventDateTime()
                {
                    DateTime = new DateTime(2020, Int32.Parse(date[1]), Int32.Parse(date[0]), e.Hour, e.Minute, 00),
                    TimeZone = "Europe/Lisbon",
                };
            }

            ev.Start = new_start;
            ev.End   = new_end;
            service.Events.Update(ev, "primary", id).Execute();
        }
Esempio n. 29
0
        public void Create(CreateNewAccountCommand command)
        {
            var accountId = new AccountId(command.AccountId);

            var createdOn = new EventDateTime(_clock.Now);

            var account = BankAccount.Factory.OpenNewAccount(accountId, createdOn);

            _repository.Save(account);
        }
        /// <summary>
        /// Checks if a event is between the correctly setted dates
        /// </summary>
        /// <param name="e">event to check</param>
        /// <returns>True if the event is between correct dates</returns>
        private bool IsBetweenDateTime(EventDateTime e)
        {
            if ((e.Flags & 1) == 1)
            {
                DateTime today = DateTime.Today;
                return(today >= e.start.Date && today <= e.end.Date);
            }

            return(true);
        }
        /// <summary>
        /// Checks if a event is between the correctly setted timestamps
        /// </summary>
        /// <param name="e">event to check</param>
        /// <returns>True if the event is between correct timestamps</returns>
        private bool IsBetweenTimeStamp(EventDateTime e)
        {
            if ((e.Flags & 2) == 2)
            {
                TimeSpan time = DateTime.Now.TimeOfDay;
                return(time > e.start.TimeOfDay && time < e.end.TimeOfDay);
            }

            return(true);
        }
        public void AddEvent(string summary,
                             string location,
                             string description,
                             DateTime eventStartDateTime,
                             DateTime eventEndDateTime,
                             string timezone,
                             bool isRecurringEvent     = false,
                             string recurringFrequency = "",
                             int nbOfRecurringEvents   = 0)
        {
            Event newEvent = new Event()
            {
                Summary     = summary,
                Location    = location,
                Description = description
            };

            DateTime      startDateTime = eventStartDateTime;
            EventDateTime start         = new EventDateTime()
            {
                DateTime = startDateTime,
                TimeZone = timezone
            };

            newEvent.Start = start;

            DateTime      endDateTime = eventEndDateTime;
            EventDateTime end         = new EventDateTime()
            {
                DateTime = endDateTime,
                TimeZone = timezone
            };

            newEvent.End = end;

            if (isRecurringEvent)
            {
                String[] recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=7" };
                newEvent.Recurrence = recurrence.ToList();
            }

            // FOR FUTURE - ADD ATTENDEES
            //EventAttendee[] attendees = new EventAttendee[]
            //{
            //    new EventAttendee() { Email = "<---email-address--->@gmail.com" },
            //};
            //newEvent.Attendees = attendees.ToList();

            String calendarId = "primary";

            var createdEvent = calendarService.Events.Insert(newEvent, calendarId).Execute();

            Console.WriteLine($"Event created {createdEvent.HtmlLink}");
        }
Esempio n. 33
0
 private static DateTime GetDateTimeFromEventDateTime(EventDateTime dateTime)
 {
     if (dateTime.DateTime.HasValue)
     {
         return(dateTime.DateTime.Value);
     }
     else
     {
         return(DateTime.Parse(dateTime.Date));
     }
 }
        private void SaveEvent(object sender, RoutedEventArgs e)
        {
            var start = new EventDateTime();

            start.DateTime = App.ViewModel.DateTimeConvert(Estart_date.Text,Estart_time.Text);
            start.TimeZone = "+0400";

            var end = new EventDateTime();
            end.DateTime = App.ViewModel.DateTimeConvert(Eend_date.Text, Eend_time.Text);
            end.TimeZone = "+0400";

            var ev = new Event();

            ev.End = end;
            ev.Kind = "calendar#event";
            ev.Start = start;
            ev.Summary = Etitle.Text;
            ev.Description = Edescription.Text;
            ev.Id = null;
            ev.ICalUID = null;
            ev.Location = Ewhere.Text;

            var eventReminder = new EventReminder();
            switch (Enotifytype.Text)
            {
                case "sms": eventReminder.Method = "sms"; break;
                case "email": eventReminder.Method = "email"; break;
            }
            switch (Enotifytime.Text)
            {
                case "minutes": eventReminder.Minutes = Convert.ToInt32(Enotifyvalue.Text); break;
                case "hours": eventReminder.Minutes = (Convert.ToInt32(Enotifyvalue.Text)*60); break;
                case "days": eventReminder.Minutes = (Convert.ToInt32(Enotifyvalue.Text) * 60 * 24); break;
            }
            ev.Reminders = new Event.RemindersData();
            ev.Reminders.UseDefault = false;
            ev.Reminders.Overrides = new List<EventReminder>();
            ev.Reminders.Overrides.Add(eventReminder);

            ev.OriginalStartTime = start;

            App.ViewModel.AddEvent(ev);
            Close();
        }
Esempio n. 35
0
        /// <summary>
        /// Создает и добавляет новое событие в календарь
        /// </summary>
        /// <param name="title"></param>
        /// <param name="location"></param>
        /// <param name="description"></param>
        /// <param name="startdate"></param>
        /// <param name="enddate"></param>
        /// <returns></returns>
        public static bool CreateNewEvent(DateTime startdate, DateTime enddate, string title, bool remind, string location = "", string description = "")
        {
            if (startdate == null || enddate == null)
                throw new ArgumentNullException("Аргументы startdate и enddate не могут быть null");
            if (startdate < DateTime.Today || enddate < DateTime.Today || enddate < startdate)
                throw new ArgumentOutOfRangeException("Даты события не могут быть меньше сегодняшней. Дата окончания события не может быть меньше даты начала события");
            if (String.IsNullOrEmpty(title))
                throw new ArgumentException("Аргумент title не может быть пустым или null");

            Event eventdata = new Event();
            eventdata.Summary = title;
            eventdata.Location = location;
            eventdata.Description = description;

            EventDateTime start = new EventDateTime();
            start.DateTime = startdate;
            eventdata.Start = start;
            EventDateTime end = new EventDateTime();
            end.DateTime = enddate;
            eventdata.End = end;

            eventdata.Transparency = "transparent";

            if(remind)
            {

                EventReminder rem = new EventReminder();
                rem.Method = "popup";
                rem.Minutes = 15;
                Event.RemindersData rd = new Event.RemindersData();
                rd.UseDefault = false;
                IList<EventReminder> list = new List<EventReminder>();
                list.Add(rem);
                rd.Overrides = list;
                eventdata.Reminders = rd;
            }
            //   k06n3almls6oo2f3grmdtt4kh4 @group.calendar.google.com
            //[email protected]
            var insertevent = _calService.Events.Insert(eventdata, "*****@*****.**");
            Event createdevent = insertevent.Execute();

            return true;
        }
Esempio n. 36
0
        public void InitializeCorrectlyInitialize()
        {
            UserCredential credential;

            using (var stream = new FileStream("client_secret.json", FileMode.Open,FileAccess.Read))
            {
                string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                   GoogleClientSecrets.Load(stream).Secrets,
                  Scopes,
                  "user",
                  CancellationToken.None,
                  new FileDataStore(credPath, true)).Result;

                Console.WriteLine("Credential file saved to: " + credPath);
            }

            // Create Calendar Service.
            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });

            // Define parameters of request.
            DateTime begin = DateTime.Now.Add(new TimeSpan(1, 1, 0));
            DateTime end = DateTime.Now.Add(new TimeSpan(1, 1, 0));
            EventDateTime beginEventDate = new EventDateTime() { DateTime = begin };
            EventDateTime endEventDate = new EventDateTime() { DateTime = end };
            Event event1 = new Event
            {
                Description = "TEST QUT2 " + DateTime.Now.ToLongTimeString(),
                Summary = "TEST QUT2 " + DateTime.Now.ToLongTimeString(),
                Created = DateTime.Now,
                Start = beginEventDate,
                End = endEventDate
            };

            EventsResource.InsertRequest request = service.Events.Insert(event1, "primary");
            request.Execute();
        }
        /// <summary>
        /// Checks if a event is between the correctly setted timestamps
        /// </summary>
        /// <param name="e">event to check</param>
        /// <returns>True if the event is between correct timestamps</returns>
        private bool IsBetweenTimeStamp(EventDateTime e)
        {
            if ((e.Flags & 2) == 2)
            {
                TimeSpan time = DateTime.Now.TimeOfDay;
                return time > e.start.TimeOfDay && time < e.end.TimeOfDay;
            }

            return true;
        }
        private DateTime GetDateTime(EventDateTime eventDateTime)
        {
            DateTime gDateTime;

            if (eventDateTime.DateTime != null)
            {
                int year = Convert.ToInt32(eventDateTime.DateTime.Value.Year);
                int month = Convert.ToInt32(eventDateTime.DateTime.Value.Month);
                int day = Convert.ToInt32(eventDateTime.DateTime.Value.Day);
                int hour = Convert.ToInt32(eventDateTime.DateTime.Value.Hour);
                int minute = Convert.ToInt32(eventDateTime.DateTime.Value.Minute);

                gDateTime = new DateTime(year, month, day, hour, minute, 0);
                AllDay = false;
            }
            else if (eventDateTime.Date != null)
            {
                int year = Convert.ToInt32(eventDateTime.Date.Substring(0, 4));
                int month = Convert.ToInt32(eventDateTime.Date.Substring(5, 2));
                int day = Convert.ToInt32(eventDateTime.Date.Substring(8, 2));

                gDateTime = new DateTime(year, month, day);
                AllDay = true;
            }
            else
                gDateTime = new DateTime();

            return gDateTime;
        }
Esempio n. 39
0
 private void TransferCalEvents(List<LocalCalendarEvent> sourceEvents)
 {
     if (sourceEvents != null)
     {
         // Create a list of description, start and end times from second (destination) calendar
         IList<string> existingDescription = EventList2.Select(x => x.Description).ToList<string>();
         IList<DateTime> existingStart = EventList2.Select(x => x.StartDateTime).ToList<DateTime>();
         IList<DateTime> existingEnd = EventList2.Select(x => x.EndDateTime).ToList<DateTime>();
         foreach (LocalCalendarEvent sourceEvent in sourceEvents)
         {
             // Check that the event from the source calendar isn't already in the destination calendar
             if (!(existingDescription.Contains(sourceEvent.Description) &&
                 existingStart.Contains(sourceEvent.StartDateTime) &&
                 existingEnd.Contains(sourceEvent.EndDateTime)))
             {
                 // Add event to kid's calendar
                 Event newEvent = new Event();
                 newEvent.Summary = sourceEvent.Description;
                 EventDateTime startTime = new EventDateTime();
                 EventDateTime endTime = new EventDateTime();
                 if (sourceEvent.AllDay)
                 {
                     startTime.Date = sourceEvent.StartDateTime.ToString("yyyy-MM-dd");
                     newEvent.Start = startTime;
                     endTime.Date = sourceEvent.EndDateTime.ToString("yyyy-MM-dd");
                     newEvent.End = endTime;
                 }
                 else
                 {
                     DateTime StartTime = sourceEvent.StartDateTime;
                     startTime.DateTime = new DateTime(StartTime.Year, StartTime.Month, StartTime.Day, StartTime.Hour, StartTime.Minute, StartTime.Second);
                     newEvent.Start = startTime;
                     DateTime EndTime = sourceEvent.EndDateTime;
                     endTime.DateTime = new DateTime(EndTime.Year, EndTime.Month, EndTime.Day, EndTime.Hour, EndTime.Minute, EndTime.Second);
                     newEvent.End = endTime;
                 }
                 service.Events.Insert(newEvent, DestinationCalendar.Id).Execute();
             }
         }
         SetCurrentList(2);  // force update of destination event list
     }
 }
        /// <summary>
        /// Mettre à jour un Evénement GOOGLE CALENDAR
        /// </summary>
        /// <param name="infoEcole"></param>
        /// <param name="IdGoogleCalendar"></param>
        public void UpdateEvent(Ecole infoEcole, string IdGoogleCalendar, Event googleEvent)
        {
            Log.Debug("Mise à jour d'un évènement Google Calendar");

            if (!p_isActivated) { return; }     // Si la fonction n'est pas activée, on sort de la fonction
            
            bool _returnGoogle = true;
            if (p_myService == null) { _returnGoogle = this.InitCnx(); }
            if (_returnGoogle)
            {
                try
                {
                    evnt = new Event();
                    StringBuilder _libelleEvent = new StringBuilder();
                    _libelleEvent.AppendFormat("{0} - {1}", infoEcole.Libelle, infoEcole.Ville);
                    if (infoEcole.Confirme) { _libelleEvent.AppendLine(" [Ecole confirmée]"); }
                    evnt.Summary = _libelleEvent.ToString();
                    evnt.Location = infoEcole.Adresse + " " + infoEcole.CodePostal + " " + infoEcole.Ville;
                    StringBuilder _description = new StringBuilder();
                    _description.AppendLine(infoEcole.IdEcole);
                    _description.AppendLine("Libelle : " + infoEcole.Libelle);
                    _description.AppendLine("Adresse : " + infoEcole.Adresse);
                    _description.AppendFormat("          {0} {1}\n", infoEcole.CodePostal, infoEcole.Ville);
                    _description.AppendLine("-------------------------------");
                    _description.AppendFormat("Contact :   {0} {1} ({2})\n", infoEcole.Contact.TitreCTC, infoEcole.Contact.NomCTC, infoEcole.Contact.FonctionCTC);
                    _description.AppendFormat("Téléphone : {0}\n", infoEcole.Contact.TelephoneCTC);
                    _description.AppendFormat("Portable  : {0}\n", infoEcole.Contact.PortableCTC);
                    _description.AppendFormat("EMail     : {0}\n", infoEcole.Contact.EmailCTC);
                    _description.AppendLine("-------------------------------");
                    _description.AppendLine("Compléments :");
                    _description.AppendLine(infoEcole.Contact.ComplementsCTC);
                    evnt.Description = _description.ToString();

                    EventDateTime startTime = new EventDateTime()
                    {
                        //DateTime = infoEcole._planifEnCours.StartDate.ToString("yyyy-MM-dd") + "T" + infoEcole._planifEnCours.StartDate.ToString("HH:mm:ss"),
                        DateTime = infoEcole._planifEnCours.StartDate,
                        TimeZone = "Europe/Paris"
                    };
                    EventDateTime endTime = new EventDateTime()
                    {
                        //DateTime = infoEcole._planifEnCours.EndDate.ToString("yyyy-MM-dd") + "T" + infoEcole._planifEnCours.EndDate.ToString("HH:mm:ss"),
                        DateTime = infoEcole._planifEnCours.EndDate,
                        TimeZone = "Europe/Paris"
                    };
                    evnt.Start = startTime;
                    evnt.End = endTime;

                    EventsResource er = new EventsResource(p_myService);
                    Event evntAfte = er.Patch(evnt, IdGoogleCalendar, googleEvent.Id).Execute();
                }
                catch (Exception _exc)
                {
                    Log.Error("Erreur lors de la mise à jour de l'événement Google {" + p_googleAccount + "} - {" + p_privateKey + "}", _exc);
                }
            }
        }
Esempio n. 41
0
        static ZonedDateTime FromGoogleEventDateTime(EventDateTime dateTime, bool isAllDay)
        {
            var instant = isAllDay
                ? Instant.FromDateTimeUtc(DateTime.SpecifyKind(DateTime.Parse(dateTime.Date), DateTimeKind.Utc))
                : Instant.FromDateTimeOffset(dateTime.DateTime.Value);
            
            var timezone = isAllDay
                ? DateTimeZoneProviders.Tzdb.GetSystemDefault()
                : DateTimeZoneProviders.Tzdb[dateTime.TimeZone];

            return instant.InZone(timezone);
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    try
                    {
                        int Flags = 0;
                        byte eventid = Convert.ToByte(fields[0]);            //Unique id of the event
                        byte UseDate = Convert.ToByte(fields[6]);            //1   - Use a date to check
                        byte UseTime = Convert.ToByte(fields[7]);            //2   - Use a timespan to check
                        byte EnableMonday = Convert.ToByte(fields[8]);       //4   - Is active on monday
                        byte EnableThuesday = Convert.ToByte(fields[9]);     //8   - Is active on thuesday
                        byte EnableWednesday = Convert.ToByte(fields[10]);   //16  - Is active on wednessday
                        byte EnableThursday = Convert.ToByte(fields[11]);    //32  - Is active on thursday
                        byte EnableFriday = Convert.ToByte(fields[12]);      //64  - Is active on friday
                        byte EnableSaturday = Convert.ToByte(fields[13]);    //128 - Is active on saturday
                        byte EnableSunday = Convert.ToByte(fields[14]);      //256 - Is active on sunday
                        string EventName = fields[1];                        //Name of the event

                        if (UseDate == 1)
                            Flags |= 1;
                        if (UseTime == 1)
                            Flags |= 2;
                        if (EnableMonday == 1)
                            Flags |= 4;
                        if (EnableThuesday == 1)
                            Flags |= 8;
                        if (EnableWednesday == 1)
                            Flags |= 16;
                        if (EnableThursday == 1)
                            Flags |= 32;
                        if (EnableFriday == 1)
                            Flags |= 64;
                        if (EnableSaturday == 1)
                            Flags |= 128;
                        if (EnableSunday == 1)
                            Flags |= 256;

                        DateTime eventstart = DateTime.Parse(fields[2], CultureInfo.InvariantCulture);
                        DateTime eventend = DateTime.Parse(fields[3], CultureInfo.InvariantCulture);
                        TimeSpan timestart = TimeSpan.Parse(fields[4]);
                        TimeSpan timetend = TimeSpan.Parse(fields[5]);

                        EventDateTime date = new EventDateTime();
                        date.end = eventend.Add(timetend);
                        date.start = eventstart.Add(timestart);
                        date.eventname = EventName;
                        date.Flags = Flags;
                        if (CanCheckTimespan(date))
                            date.IsActive = IsActiveToday(date) && IsBetweenDateTime(date) && IsBetweenTimeStamp(date);
                        else
                            date.IsActive = true;

                        _eventdates.Add(eventid, date);
                    }
                    catch (Exception e)
                    {
                        HostContext.AddUnhandeldException(e);
                    }
                }
            }
        }
        private DateTime WindowsTimeZone(EventDateTime time) {
            DateTime theDate = DateTime.Parse(time.DateTime ?? time.Date);
            if (time.TimeZone == null) return theDate;

            LocalDateTime local = new LocalDateTime(theDate.Year, theDate.Month, theDate.Day, theDate.Hour, theDate.Minute);
            DateTimeZone zone = DateTimeZoneProviders.Tzdb[time.TimeZone];
            ZonedDateTime zonedTime = local.InZoneLeniently(zone);
            DateTime zonedUTC = zonedTime.ToDateTimeUtc();
            log.Fine("IANA Timezone \"" + time.TimeZone + "\" mapped to \""+ zone.Id.ToString() +"\" with a UTC of "+ zonedUTC.ToString("dd/MM/yyyy HH:mm:ss"));
            return zonedUTC;
        }
        /// <summary>
        /// Deactivates the event and announches the change
        /// </summary>
        /// <param name="e">event to activate</param>
        internal void Deactivate(EventDateTime e)
        {
            bool result = true;
            if (CanCheckTimespan(e))
                result = IsBetweenTimeStamp(e) && IsBetweenDateTime(e) && IsActiveToday(e);

            if (result == false && e.IsActive == true)
            {
                e.IsActive = false;
                Console.WriteLine("Deactivate");
                string message = string.Format(CultureInfo.InvariantCulture, "Event {0} ended", e.eventname);
                DoGlobalAnnounchment(message);
            }
        }
Esempio n. 45
0
        private void subULEvent(string _strTitle, string _strDesc, string _strLocation, string _strCalendarID, DateTime _dteStart, DateTime _dteEnd, ListBox _lstStatus)
        {
            try
            {
                Event evtNew = new Event();

                // Set the title and content of the entry.
                evtNew.Summary = _strTitle;
                evtNew.Description = _strDesc;

                // Set a location for the event.
                evtNew.Location = _strLocation;

                EventDateTime dteStart = new EventDateTime();
                EventDateTime dteEnd = new EventDateTime();

                dteStart.DateTime = XmlConvert.ToString(_dteStart);
                dteEnd.DateTime = XmlConvert.ToString(_dteEnd);

                evtNew.Start = dteStart;
                evtNew.End = dteEnd;

                // Send the request and receive the response:
                Event evtInsertedEvent = svcCTCal.Events.Insert(evtNew, _strCalendarID).Fetch();

                if (_lstStatus != null)
                    _lstStatus.Items.Insert(0, "Added calendar event: " + evtInsertedEvent.Id);

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                Console.Write("Error: " + ex.Message);

                if (_lstStatus != null)
                    _lstStatus.Items.Insert(0, "Error adding calendar event: " + ex.Message);
                Application.DoEvents();
            }
        }
 /// <summary>
 /// Checks if the event is scheduled for periodic updates
 /// </summary>
 /// <param name="e">event to check</param>
 /// <returns></returns>
 private bool CanCheckTimespan(EventDateTime e)
 {
     return (e.Flags & 3) == 3;
 }
Esempio n. 47
0
        public static void Main(string[] args)
        {
            // Register the authenticator. The Client ID and secret have to be copied from the API Access
            // tab on the Google APIs Console.
            var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
            provider.ClientIdentifier = "788219901674.apps.googleusercontent.com";
            provider.ClientSecret = "wkhtoCEaTUrHXml_yL0jl1hg";
            // Create the service. This will automatically call the authenticator.
            var service = new CalendarService(new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication));

            Google.Apis.Calendar.v3.CalendarListResource.ListRequest clrq = service.CalendarList.List();
            var result = clrq.Fetch();

            if (result.Error != null)
            {
                Console.WriteLine(result.Error.Message);
                Console.ReadKey();
                return;
            }

            // Print available calendarListEntry colors.
            // It Works!!!
            /*Colors colors = service.Colors.Get().Fetch();
            foreach (KeyValuePair<String, ColorDefinition> color in colors.Calendar)
            {
                Console.WriteLine("ColorId : " + color.Key);
                Console.WriteLine("  Background: " + color.Value.Background);
                Console.WriteLine("  Foreground: " + color.Value.Foreground);
            }*/

            // Insert event
            // It Works!!!
            /*Event evt1 = new Event();
            evt1.Summary = "drink beer";
            evt1.Location = "Kyiv";
            EventDateTime start = new EventDateTime() { DateTime = "2012-07-07T10:00:00.000-07:00" };
            EventDateTime end = new EventDateTime() { DateTime = "2012-07-07T10:00:00.000-08:00" };
            evt1.Start = start;
            evt1.End = end;
            Event e = service.Events.Insert(evt1, "primary").Fetch();*/

            // Insert calendar
            // It Works!!!
            /*Calendar cld = new Calendar();
            cld.Summary = "wtf400";
            cld.Location = "Europe/Zurich";
            Calendar c = service.Calendars.Insert(cld).Fetch();
            Console.WriteLine(c.Id);*/

            // Insert recurring events
            // Doesn't work
            Event evt = new Event();
            evt.Summary = "Create event";
            evt.Location = "Kyiv";
            EventDateTime start = new EventDateTime() { DateTime = "2012-07-07T10:00:00.000-07:00", TimeZone = "Europe/Zurich" };
            EventDateTime end = new EventDateTime() { DateTime = "2012-07-07T10:00:00.000-09:00", TimeZone = "Europe/Zurich" };
            evt.Start = start;
            evt.End = end;
            evt.Recurrence = new String[] {"RRULE:FREQ=WEEKLY;UNTIL=20120803T100000-09:00" };
            Event recurringEvent = service.Events.Insert(evt, "*****@*****.**").Fetch();
            Console.WriteLine(recurringEvent.Id);

            Console.WriteLine("the end");
            Console.ReadLine();

            /*Console.WriteLine("Calendars: ");
            foreach (CalendarListEntry calendar in result.Items)
            {
                Console.WriteLine("{0}", calendar.Id);
                Console.WriteLine("\tAppointments:");
                Google.Apis.Calendar.v3.EventsResource.ListRequest elr = service.Events.List(calendar.Id);
                var events = elr.Fetch();
                foreach (Event e in events.Items)
                {
                    Console.WriteLine("\t From: {0} To: {1} Description: {2}, Location: {3}", e.Start, e.End, e.Description, e.Location);
                }
            }
            Console.ReadKey();*/
        }
 /// <summary>
 /// Metoda tworząca listę wydarzeń do kalendarza.
 /// </summary>
 /// <param name="booking">Pojedyncza rezerwacja z listą gości.</param>
 public void MakeEventRequest(SimpleBookingUser booking)
 {
     Logs.WriteErrorLog("Robie request eventa (wrzucam zdarzenia na kolejke).");
     Logs.WriteErrorLog(booking.BookingEndTime.ToString("g"));
     Logs.WriteErrorLog(booking.BookingBeginTime.ToString("g"));
     var eventStartDateTime = new EventDateTime { DateTime = booking.BookingBeginTime };
     Logs.WriteErrorLog("Moja data rozp: " + eventStartDateTime.DateTime.ToString());
     var eventEndDateTime = new EventDateTime { DateTime = booking.BookingEndTime };
     Logs.WriteErrorLog("Moja data zakonczenia: " + eventEndDateTime.DateTime.ToString());
     Request = new BatchRequest(Service);
     Logs.WriteErrorLog("tytul: " + booking.BookingTitle);
     Logs.WriteErrorLog("Opis" + booking.BookingDescription);
     Request.Queue<Event>(Service.Events.Insert(
         new Event
         {
             Summary = booking.BookingTitle,
             Description = booking.BookingDescription,
             Start = eventStartDateTime,
             End = eventEndDateTime
         }, CalendarId),
         (content, error, i, message) =>
         {
             //Do wypełnienia "Callback"
         });
     Logs.WriteErrorLog("Wrzucilem.");
 }
 /// <summary>
 /// Checks if a event is activated today
 /// </summary>
 /// <param name="e">event to check</param>
 /// <returns>True if the event is scheduled for activation of today</returns>
 private bool IsActiveToday(EventDateTime e)
 {
     DayOfWeek day = DateTime.Today.DayOfWeek;
     if (day == DayOfWeek.Monday)
         return (e.Flags & 4) == 4;
     else if (day == DayOfWeek.Tuesday)
         return (e.Flags & 8) == 8;
     else if (day == DayOfWeek.Wednesday)
         return (e.Flags & 16) == 16;
     else if (day == DayOfWeek.Thursday)
         return (e.Flags & 32) == 32;
     else if (day == DayOfWeek.Friday)
         return (e.Flags & 64) == 64;
     else if (day == DayOfWeek.Saturday)
         return (e.Flags & 128) == 128;
     else if (day == DayOfWeek.Sunday)
         return (e.Flags & 256) == 256;
     return false;
 }
Esempio n. 50
0
        public void AddEvent(ProgramItem item)
        {
            const string GoogleDateFormatString = "yyyy-MM-ddTHH:mm:00Z";
            //service.Key = Key;

            var list = service.Events.List("primary");
            var fetch = list.Fetch();

            var start = new EventDateTime();
            start.DateTime = "2013-03-05T10:30:00Z";
            start.TimeZone = "+0000";

            var end = new EventDateTime();
            end.DateTime = "2013-03-05T10:35:00Z";
            end.TimeZone = "+0000";

            var e = new Event();

            e.End = end;
            e.Kind = "calendar#event";
            e.Start = start;
            e.Summary = "Summary";
            e.Id = null;
            e.ICalUID = null;
            e.Location = "";

            var eventReminder = new EventReminder();
            eventReminder.Method = "sms";
            eventReminder.Minutes = 15;

            e.Reminders = new Event.RemindersData();
            e.Reminders.UseDefault = false;
            e.Reminders.Overrides = new List<EventReminder>();
            e.Reminders.Overrides.Add(eventReminder);

            // Recurrence:
            var recur = "RRULE:FREQ=DAILY;COUNT=20;INTERVAL=1;WKST=SU";

            e.Recurrence = new List<string>();
            e.Recurrence.Add(recur);
            e.RecurringEventId = "12345";
            e.OriginalStartTime = start;

            AddEvent(e);
        }
        /// <summary>
        /// Checks if a event is between the correctly setted dates
        /// </summary>
        /// <param name="e">event to check</param>
        /// <returns>True if the event is between correct dates</returns>
        private bool IsBetweenDateTime(EventDateTime e)
        {
            if ((e.Flags & 1) == 1)
            {
                DateTime today = DateTime.Today;
                return today >= e.start.Date && today <= e.end.Date;
            }

            return true;
        }
        public Event eventFromCalendarItem(CalendarItem item)
        {
            var e = new Event();
            var startTime = new EventDateTime();
            startTime.DateTime = item.StartTime;
            var endTime = new EventDateTime();
            endTime.DateTime = item.EndTime;

            e.Summary = item.Subject;
            e.Start = startTime;
            e.End = endTime;
            e.Location = item.Location;
            e.Transparency = item.Busy ? "opaque" : "transparent";

            return e;
        }
Esempio n. 53
0
 private static EventDateTime ConvertToEventDateTime(DateTime? dateTime, bool isFullDateEvent)
 {
     EventDateTime eventDateTime = new EventDateTime();
     if (isFullDateEvent)
     {
         DateTime date = dateTime ?? DateTime.Now;
         eventDateTime.Date = date.ToString(DATE_FORMAT);
     }
     else
     {
         eventDateTime.DateTime = dateTime;
     }
     eventDateTime.TimeZone = "Europe/London";
     return eventDateTime;
 }