GData schema extension describing a period of time.
Inheritance: IExtensionElement, IExtensionElementFactory
Beispiel #1
0
        public void googlecalendarSMSreminder(string sendstring)
        {
            CalendarService service = new CalendarService("exampleCo-exampleApp-1");
            service.setUserCredentials(UserName.Text, Password.Text);

            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = sendstring;
            entry.Content.Content = "Nadpis Test SMS.";
            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "Test sms";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
            entry.Times.Add(eventTime);

            //Add SMS Reminder
            Reminder fiftyMinReminder = new Reminder();
            fiftyMinReminder.Minutes = 1;
            fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
            entry.Reminders.Add(fiftyMinReminder);

            Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }
Beispiel #2
0
    private void CreateNewEvent()
    {
        //Set Event Entry
        Google.GData.Calendar.EventEntry oEventEntry = new Google.GData.Calendar.EventEntry();
        oEventEntry.Title.Text = "Test Calendar Entry From .Net for testing";
        oEventEntry.Content.Content = "Hurrah!!! I posted my second Google calendar event through .Net";

        //Set Event Location
        Where oEventLocation = new Where();
        oEventLocation.ValueString = "Mumbai";
        oEventEntry.Locations.Add(oEventLocation);

        //Set Event Time
        When oEventTime = new When(new DateTime(2012, 8, 05, 9, 0, 0), new DateTime(2012, 8, 05, 9, 0, 0).AddHours(1));
        oEventEntry.Times.Add(oEventTime);

        //Set Additional Properties
        ExtendedProperty oExtendedProperty = new ExtendedProperty();
        oExtendedProperty.Name = "SynchronizationID";
        oExtendedProperty.Value = Guid.NewGuid().ToString();
        oEventEntry.ExtensionElements.Add(oExtendedProperty);

        CalendarService oCalendarService = GAuthenticate();
        Uri oCalendarUri = new Uri("http://www.google.com/calendar/feeds/[email protected]/private/full");

        //Prevents This Error
        //{"The remote server returned an error: (417) Expectation failed."}
        System.Net.ServicePointManager.Expect100Continue = false;

        //Save Event
        oCalendarService.Insert(oCalendarUri, oEventEntry);
    }
 public void TestConvertEventsToFreeBusy()
 {
     ExchangeUser user = new ExchangeUser();
     EventEntry googleAppsEvent = new EventEntry("title", "description", "location");
     DateTimeRange coveredRange = new DateTimeRange(DateTime.MaxValue, DateTime.MinValue);
     List<DateTimeRange> busyTimes = new List<DateTimeRange>();
     List<DateTimeRange> tentativeTimes = new List<DateTimeRange>();
     DateTime startDate = new DateTime(2007, 07, 1, 10, 0, 0, DateTimeKind.Utc);
     DateTime endDate = new DateTime(2007, 07, 1, 11, 0, 0, DateTimeKind.Utc);
     When when = new When(startDate, endDate);
     Uri uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full");
     EventFeed googleAppsFeed = new EventFeed(uri, null);
     AtomEntryCollection entries = new AtomEntryCollection(googleAppsFeed);
 }
Beispiel #4
0
        public void WriteSchedule(String title, String description, String location,  List<String> guestEmail, DateTime startTime, DateTime endTime)
        {
            EventEntry entry = new EventEntry(title, description, location);
            When eventTime = new When(startTime, endTime);
            entry.Times.Add(eventTime);
            guestEmail.ForEach((mail) =>
            {
                Who guest = new Who();
                guest.Email = mail;
                guest.Rel = description;
                entry.Participants.Add(guest);
            });

            Uri url = new Uri("https://www.google.com/calendar/feeds/" + this._gmailID + "/private/full");
            AtomEntry result = _gCal.Insert(url, entry);
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Service service = new Service("cl", "companyName-appName-1");
            service.setUserCredentials("*****@*****.**", "jWH>45bY1");
            EventEntry entry = new EventEntry();
            DataSet ds = new DataSet();
            When eventTimes = new When();
            AtomEntry insertedEntry;

            SqlConnection cn = new SqlConnection();
            try
            {
                cn = DBDevite.DBOpen();

                SqlDataAdapter da = new SqlDataAdapter("SELECT u.Users as userw, c.Name as client, t.Date as date, t.TimeStart as start, t.TimeEnd as endw, t.About as about, t.TaskStatus " +
                                                       "FROM tasks t " +
                                                       "LEFT JOIN users u ON t.userID = u.ID " +
                                                       "LEFT JOIN clients c ON t.clientID = c.ID " +
                                                       "WHERE t.TaskStatus = 'true'", cn);
                SqlCommandBuilder cb = new SqlCommandBuilder(da);
                da.Fill(ds);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DBDevite.DBClose(cn);
            }

            Uri postUri = new Uri("http://www.google.com/calendar/feeds/[email protected]/private/full");
            //запись в EventEntry
            foreach(DataTable thisTable in ds.Tables)
            {
                foreach(DataRow row in thisTable.Rows)
                {
                    entry.Title.Text = row["client"].ToString() + "  " + row["userw"].ToString();
                    entry.Content.Content = row["about"].ToString();

                    eventTimes.StartTime = Convert.ToDateTime(Convert.ToDateTime(row["date"].ToString()).ToString("dd-MM-yyyy") + " " + row["start"].ToString().Trim() + ":00");
                    eventTimes.EndTime = Convert.ToDateTime(Convert.ToDateTime(row["date"].ToString()).ToString("dd-MM-yyyy") + " " + row["endw"].ToString().Trim() + ":00");
                    entry.Times.Add(eventTimes);
                    insertedEntry = service.Insert(postUri, entry);
                }
            }
        }
        //add an event to google calendar
        public static void addEvent(Appointment appt)
        {
            if (authenticated == true) {

                Dictionary<int, string> insertedId = new Dictionary<int, string>();

                //create new thread for add event
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += delegate(object s, DoWorkEventArgs args) {
                    try {
                        //add event to Google Calendar
                        EventEntry entry = new EventEntry();

                        // Set the title and content of the entry.
                        entry.Title.Text = appt.Subject;
                        entry.Content.Content = appt.Note;

                        // Set a location for the event.
                        Where eventLocation = new Where();
                        eventLocation.ValueString = appt.Location;
                        entry.Locations.Add(eventLocation);

                        When eventTime = new When(appt.StartDate, appt.EndDate);
                        entry.Times.Add(eventTime);

                        lock (threadLock) {
                            EventEntry insertedEntry = service.Insert(postUri, entry);
                            eventIDs.Add(appt.AppointmentId, insertedEntry.EventId);
                            insertedId.Add(appt.AppointmentId, insertedEntry.EventId);
                        }
                    }
                    catch (Exception e) {
                        Util.logError("Google Calendar Error: " + e.Message);
                    }
                };

                bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) {
                    foreach (int apptId in insertedId.Keys) {
                        Database.modifyDatabase("UPDATE Event SET GoogleEventID = '" + insertedId[apptId] + "' WHERE EventID = '" + apptId + "';");
                    }
                };

                //start the thread
                bw.RunWorkerAsync();
            }
        }
        public static void export(string email, string password, List<LeadTask> tasks)
        {
            CalendarService myService = new CalendarService("exportToGCalendar");
            myService.setUserCredentials(email, password);

            foreach (LeadTask task in tasks) {
                EventEntry entry = new EventEntry();

                // Set the title and content of the entry.
                entry.Title.Text = task.text;
                entry.Content.Content = task.details;

                When eventTime = new When((DateTime)task.start_date, (DateTime)task.end_date);
                entry.Times.Add(eventTime);

                Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");

                // Send the request and receive the response:
                Google.GData.Client.AtomEntry insertedEntry = myService.Insert(postUri, entry);
            }
        }
Beispiel #8
0
        public  async Task<string> Insert(Guid userId, string title, string content, DateTime start, DateTime end)
        {
            try
            {
                //同步到Google日历
                var item = _iSysUserService.GetById(userId);

                if (string.IsNullOrEmpty(item.GoogleUserName) || string.IsNullOrEmpty(item.GooglePassword)) return "";

                var myService = new CalendarService(item.GoogleUserName);
                myService.setUserCredentials(item.GoogleUserName, item.GooglePassword);

                // Set the title and content of the entry.
                var entry = new EventEntry
                {
                    Title = { Text = "云集 " + title },
                    Content = { Content = content }
                };

                //计划时间
                var eventTime = new When(start, end);

                //判断是否为全天计划
                if (start.Date != end.Date)
                    eventTime.AllDay = true;

                entry.Times.Add(eventTime);

                var postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");

                // Send the request and receive the response:
                var eventEntry = myService.Insert(postUri, entry);
                return eventEntry.EventId;
            }
            catch
            {
                return "";
            }
        }
        public void send(string info)
        {
            EventEntry entry = new EventEntry();
            entry.Title.Text = "iPhone4 开卖状况改变";
            entry.Content.Content = info;

            Where eventLocation = new Where();
            eventLocation.ValueString = "Apple Store";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(2), DateTime.Now.AddMinutes(30));
            entry.Times.Add(eventTime);

            Reminder reminder = new Reminder();
            reminder.Minutes = 1;
            reminder.Method = Reminder.ReminderMethod.all;

            entry.Reminders.Add(reminder);

            Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");

            AtomEntry insertedEntry = svc.Insert(postUri, entry);
        }
        /// <summary>
        /// Creates a google calendar event
        /// </summary>
        public void CreateEvent(CalendarEvent cEvent)
        {
            EventEntry entry = new EventEntry();

            entry.Title.Text = cEvent.Subject;
            entry.Content.Content = cEvent.Body;

            ExtendedProperty property = new ExtendedProperty();
            property.Name = syncExtendedParameterName;
            property.Value = cEvent.Id;
            entry.ExtensionElements.Add(property);

            Where eventLocation = new Where();
            eventLocation.ValueString = cEvent.Location;
            entry.Locations.Add(eventLocation);

            When eventTime = new When(cEvent.StartDate, cEvent.EndDate);
            entry.Times.Add(eventTime);

            Uri postUri = new Uri(string.Format(calendarUrl, this.calendarId));

            AtomEntry insertedEntry = this.calService.Insert(postUri, entry);
        }
        private void CreateReminder(CalendarService calendarService, String reminderText, DateTime reminderTime)
        {
            EventEntry newEvent = new EventEntry();
            newEvent.Title.Text = reminderText;
            newEvent.Content.Content = reminderText + " (Reminder added by RemGen from " + Environment.MachineName + " by " + Environment.UserName + " " + Environment.UserDomainName + ")";

            //Where eventLocation = new Where();
            //eventLocation.ValueString = "Test event location 2";
            //newEvent.Locations.Add(eventLocation);

            When eventTime = new When(reminderTime, reminderTime);
            newEvent.Times.Add(eventTime);

            Reminder reminder = new Reminder();
            reminder.Method = Reminder.ReminderMethod.sms;
            reminder.AbsoluteTime = reminderTime;

            newEvent.Reminders.Add(reminder);

            Uri postUri = new Uri(calendarApiUri);
            try
            {
                AtomEntry insertedEntry = calendarService.Insert(postUri, newEvent);
                MessageBox.Show("Reminder added successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to create event" + Environment.NewLine + Environment.NewLine + ex.ToString(), "RemGen");
            }
        }
Beispiel #12
0
		private EventEntry FillKalenderEntry (EventEntry KalenderEntry, DataRow KalenderRow)
			{

			KalenderEntry.Title.Text = KalenderRow ["Titel"].ToString ();
			KalenderEntry.Content.Content = CreateFullBeschreibung (KalenderRow);

			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["ID"].ToString (), "WPMediaID"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["KontaktPerson"].ToString (), "WPMediaKontaktPerson"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["Veranstalter"].ToString (), "WPMediaVeranstalter"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["Typ"].ToString (), "WPMediaTyp"));
			KalenderEntry.ExtensionElements.Add (new ExtendedProperty (KalenderRow ["ZielGruppe"].ToString (), "WPMediaZielGruppe"));

			Where EntryLocation;
			if (KalenderEntry.Locations.Count > 0)
				EntryLocation = KalenderEntry.Locations [0];
			else
				{
				EntryLocation = new Where ();
				KalenderEntry.Locations.Add (EntryLocation);
				}
			EntryLocation.ValueString = KalenderRow ["VeranstaltungsOrt"].ToString ();
			EntryLocation.Label = KalenderRow ["VeranstaltungsOrt"].ToString ();

			When EntryTiming;
			if (KalenderEntry.Times.Count > 0)
				{
				EntryTiming = KalenderEntry.Times [0];
				EntryTiming.StartTime = Convert.ToDateTime (KalenderRow ["Von"]);
				EntryTiming.EndTime = Convert.ToDateTime (KalenderRow ["Bis"]);
				}
			else
				{
				EntryTiming = new When (Convert.ToDateTime (KalenderRow ["Von"]), Convert.ToDateTime (KalenderRow ["Bis"]));
				KalenderEntry.Times.Add (EntryTiming);
				}

			return KalenderEntry;
			}
        public void TestConvertEventToFreeBusy()
        {
            ExchangeUser user = new ExchangeUser();
            EventEntry googleAppsEvent = new EventEntry("title", "description", "location");
            DateTimeRange coveredRange = new DateTimeRange(DateTime.MaxValue, DateTime.MinValue);
            List<DateTimeRange> busyTimes = new List<DateTimeRange>();
            List<DateTimeRange> tentativeTimes = new List<DateTimeRange>();
            DateTime startDate = new DateTime(2007, 07, 1, 10, 0, 0, DateTimeKind.Utc);
            DateTime endDate = new DateTime(2007, 07, 1, 11, 0, 0, DateTimeKind.Utc);
            When when = new When(startDate, endDate);

            user.Email = "*****@*****.**";

            // Event w/o valid times set should be ignored.
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, DateTime.MaxValue);
            Assert.AreEqual(coveredRange.End, DateTime.MinValue);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 0);

            googleAppsEvent.Times.Add(when);

            // Event w/o explicit status should be treated as busy, since this is how the data
            // comes from the free busy projection
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 1);
            Assert.AreEqual(busyTimes[0].Start, startDate);
            Assert.AreEqual(busyTimes[0].End, endDate);
            busyTimes.Clear();

            // Confirmed event w/o attendees should be treated as busy.
            googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 1);
            Assert.AreEqual(busyTimes[0].Start, startDate);
            Assert.AreEqual(busyTimes[0].End, endDate);
            busyTimes.Clear();

            // Cancelled event should be treated as free.
            googleAppsEvent.Status = EventEntry.EventStatus.CANCELED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);

            // Tentative event w/o attendees should be treated as tentative.
            googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();

            Who john = new Who();
            googleAppsEvent.Participants.Add(john);

            john.Attendee_Status = new Who.AttendeeStatus();
            john.Email = user.Email;
            googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED;

            // Busy event with attendee tentative should be treated as tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();


            // Busy event with attendee invited should be treated as tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();

            // Busy event with attendee accepted should be treated as busy.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 1);
            Assert.AreEqual(busyTimes[0].Start, startDate);
            Assert.AreEqual(busyTimes[0].End, endDate);
            busyTimes.Clear();

            // Busy event with attendee declined should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);

            googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE;

            // Tentative event with attendee tentative should be treated as tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();


            // Tentative event with attendee invited should be treated as tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();

            // Tentative event with attendee accepted should be treated as tentative.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(busyTimes.Count, 0);
            Assert.AreEqual(tentativeTimes.Count, 1);
            Assert.AreEqual(tentativeTimes[0].Start, startDate);
            Assert.AreEqual(tentativeTimes[0].End, endDate);
            tentativeTimes.Clear();

            // Tentative event with attendee declined should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);

            googleAppsEvent.Status = EventEntry.EventStatus.CANCELED;

            // Cancelled event with attendee tentative should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_TENTATIVE;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);


            // Cancelled event with attendee invited should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_INVITED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);

            // Cancelled event with attendee accepted should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_ACCEPTED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);

            // Cancelled event with attendee declined should be treated as free.
            john.Attendee_Status.Value = Who.AttendeeStatus.EVENT_DECLINED;
            CallConvertEventToFreeBusy(user,
                                       googleAppsEvent,
                                       coveredRange,
                                       busyTimes,
                                       tentativeTimes);
            Assert.AreEqual(coveredRange.Start, startDate);
            Assert.AreEqual(coveredRange.End, endDate);
            Assert.AreEqual(tentativeTimes.Count, 0);
            Assert.AreEqual(busyTimes.Count, 0);
        }
Beispiel #14
0
        public void googlecalendarSMSreminder(string sendstring)
        {
            CalendarService service = new CalendarService("exampleCo-exampleApp-1");
            service.setUserCredentials("*****@*****.**", "joneson55");

            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = sendstring;
            entry.Content.Content = "Lockerz Login Page Check.";
            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "Lockerz Login";
            entry.Locations.Add(eventLocation);

            When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
            entry.Times.Add(eventTime);

            if (checkBox1.Checked == true)  //Reminder ON/OFF
            {
                //Add SMS Reminder
                Reminder fiftyMinReminder = new Reminder();
                fiftyMinReminder.Minutes = 1;
                fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
                entry.Reminders.Add(fiftyMinReminder);
            }
            else
            {
            }

            Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");

            // Send the request and receive the response:
            AtomEntry insertedEntry = service.Insert(postUri, entry);
        }
Beispiel #15
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>tests the original event </summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarOriginalEventTest()
        {
            Tracing.TraceMsg("Entering CalendarOriginalEventTest");

            FeedQuery query = new FeedQuery();

            CalendarService service = new CalendarService(this.ApplicationName);

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory) this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultCalendarUri);

                EventFeed calFeed = service.Query(query) as EventFeed;

                string recur  = 
                    "DTSTART;TZID=America/Los_Angeles:20060314T060000\n" +
                    "DURATION:PT3600S\n" + 
                    "RRULE:FREQ=DAILY;UNTIL=20060321T220000Z\n" +
                    "BEGIN:VTIMEZONE\n" + 
                    "TZID:America/Los_Angeles\n" +
                    "X-LIC-LOCATION:America/Los_Angeles\n" +
                    "BEGIN:STANDARD\n" +
                    "TZOFFSETFROM:-0700\n" +
                    "TZOFFSETTO:-0800\n" +
                    "TZNAME:PST\n" +
                    "DTSTART:19671029T020000\n" +
                    "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n" +
                    "END:STANDARD\n" +
                    "BEGIN:DAYLIGHT\n" +
                    "TZOFFSETFROM:-0800\n" +
                    "TZOFFSETTO:-0700\n" +
                    "TZNAME:PDT\n" +
                    "DTSTART:19870405T020000\n" +
                    "RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU\n" +
                    "END:DAYLIGHT\n" +
                    "END:VTIMEZONE\n"; 

                EventEntry entry  =  ObjectModelHelper.CreateEventEntry(1); 
                entry.Title.Text = "New recurring event" + Guid.NewGuid().ToString();  

                // get rid of the when entry
                entry.Times.Clear(); 

                entry.Recurrence = new Recurrence();
                entry.Recurrence.Value = recur; 

                EventEntry recEntry = calFeed.Insert(entry) as EventEntry;

                entry = ObjectModelHelper.CreateEventEntry(1); 
                entry.Title.Text = "whateverfancy"; 

                OriginalEvent originalEvent = new OriginalEvent();
                When start = new When();
                start.StartTime = new DateTime(2006, 03, 14, 15, 0,0); 
                originalEvent.OriginalStartTime = start;
                originalEvent.Href = recEntry.SelfUri.ToString();
                originalEvent.IdOriginal = recEntry.EventId;
                entry.OriginalEvent = originalEvent;
                entry.Times.Add(new When(new DateTime(2006, 03, 14, 9,0,0),
                                         new DateTime(2006, 03, 14, 10,0,0)));
                calFeed.Insert(entry);

                service.Credentials = null; 
                factory.MethodOverride = false;
            }
        }
Beispiel #16
0
		public Dictionary<String, String> RunPublishWordUpCalendar(String CalendarTitle, String LastUpdate, 
			List<String> TerminTypeIDsToProcess, int GoogleIDIndex)
			{
			int UpdateCounter = 0;
			DataTable KalenderTable = CreateKalendarTable ();
			String TypeIDSelectClause = WordUp23.Basics.Instance.GetTypSelectPart (TerminTypeIDsToProcess);
			String SelectStatement = "Select * from Termine where " + TypeIDSelectClause + "Order by LastUpdateToken desc";
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
										"Before Select Statement \"" + SelectStatement + "\"");

			DataSet ToProcessCalendarDataSet =
				WordUpWCFAccess.GetCommonDataSet (SelectStatement);

			if (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count == 0)
				{
				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
						"Number of Termine-Entries to Process = 0");
				return new Dictionary<String, String> ();
				}
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
					"Number of Termine-Entries to Process = "
						+ Convert.ToString (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count));

			List<System.Guid> ListOfTerminTypenWithTypOrtNaming = WordUp23.Basics.Instance.GetTerminTypenWithTypOrtNaming ();
	
			WPMediaGoogleCalendarUpdate.DoUpdate GoogleUpdate = new DoUpdate ();
			GoogleUpdate.CalendarTitle = CalendarTitle;
			GoogleUpdate.MissingGoogleEventIDs.Clear ();

			bool AllRunsCorrect = true;
			int CountHasGoogleIDAndIsProcessedBefore = 0;

			foreach (DataRow IwTRow in ToProcessCalendarDataSet.Tables ["Termine"].Rows)
				{
				String EventEntryElementID = String.Empty;
				try
					{
					if (IwTRow ["ID"] == Convert.DBNull)
						{
						continue;
						}

					if ((IwTRow ["Von"] == Convert.DBNull)
						|| (IwTRow ["Bis"] == Convert.DBNull))
						continue;
		
					EventEntryElementID = IwTRow ["ID"].ToString ();
					String [] GoogleEventID = IwTRow ["GoogleEventID"].ToString ().Split (';');
					if (GoogleEventID.Length == 0)
						GoogleEventID = new String[] {"", ""};

					if (GoogleEventID.Length == 1)
						GoogleEventID = new String [] { GoogleEventID [0], "" };

					if (!String.IsNullOrEmpty (GoogleEventID [GoogleIDIndex]))
						CountHasGoogleIDAndIsProcessedBefore++;
					if (CountHasGoogleIDAndIsProcessedBefore > 20)
						break;

					EventEntry EventEntryElement = GoogleUpdate.GetEventEntry (EventEntryElementID, GoogleEventID [GoogleIDIndex]);
					if (EventEntryElement == null)
						{
						WMB.Basics.ReportErrorToEventViewer ("Beim Eintrag \"" + EventEntryElementID
							+ "\" mit der GoogleIDEventID \"" + GoogleEventID + "\"\r\n" + "kam es zu einem Fehler");
						continue;
						}
					if (EventEntryElement.EventId != GoogleEventID [GoogleIDIndex])		// do BackLink activities
						{
						GoogleEventID [GoogleIDIndex] = EventEntryElement.EventId;
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join (";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch (ModifyStatement);
						}
					EventEntryElement.Dirty = true;
					String OrteID = IwTRow ["OrteID"].ToString ();
					String Ortsbezeichnung = "Nicht definiert";
					if (String.IsNullOrEmpty (OrteID) == false)
						Ortsbezeichnung = WordUp23.Basics.Instance.Orte [OrteID] ["Bezeichnung"].ToString ()
							+ " " + WordUp23.Basics.Instance.Orte [OrteID] ["Beschreibung"].ToString ();
					if (ListOfTerminTypenWithTypOrtNaming.Contains ((System.Guid) IwTRow ["TermineTypID"]) == true)
						{
						EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}
					else
						{
						//if (String.IsNullOrEmpty (IwTRow ["NameID"].ToString ()) == false)
						//    EventEntryElement.Title.Text = IwTRow ["NameID"].ToString ();
						//else
							EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}

					if (IwTRow ["TermineTypID"].ToString () == "f61d9cb1-59a4-430b-ad67-ebdcc5df1d11")
						{
						EventEntryElement.IsDraft = true;
						}


					When EntryTiming;
					if (EventEntryElement.Times.Count > 0)
						{
						EntryTiming = EventEntryElement.Times [0];
						EntryTiming.StartTime = Convert.ToDateTime (IwTRow ["Von"]);
						EntryTiming.EndTime = Convert.ToDateTime (IwTRow ["Bis"]);
						}
					else
						{
						EntryTiming = new When (Convert.ToDateTime (IwTRow ["Von"]), Convert.ToDateTime (IwTRow ["Bis"]));
						EventEntryElement.Times.Add (EntryTiming);
						}

					Where EntryLocation;
					if (EventEntryElement.Locations.Count > 0)
						EntryLocation = EventEntryElement.Locations [0];
					else
						{
						EntryLocation = new Where ();
						EventEntryElement.Locations.Add (EntryLocation);
						}

					String TerminBeschreibung = FillTerminBeschreibung (IwTRow);
					String OrtsBeschreibung = FillLocation (IwTRow, EntryLocation);
					String PersonenBeschreibung = WordUp23.Basics.Instance.GetTypeParticipantText (IwTRow);

// da passiert es
					Google.GData.Extensions.ExtensionCollection<Who> Participants = new Google.GData.Extensions.ExtensionCollection<Who>();
//					PersonenBeschreibung = FillPersonen(IwTRow, EventEntryElement.Participants);
					PersonenBeschreibung = FillPersonen(IwTRow, Participants);

// da ist es passiert		
					String OrganisationsBeschreibung = FillOrganisationsBeschreibung (IwTRow);

					EventEntryElement.Content.Content = TerminBeschreibung + OrtsBeschreibung
						+ OrganisationsBeschreibung + PersonenBeschreibung;

					if (GoogleUpdate.SaveEventEntry (EventEntryElement, EventEntryElementID) == false)
						{
						WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						                                     "Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID +
						                                     "\" ist ein Fehler aufgetreten\r\n"
						                                     + EntryTiming.StartTime.ToString () + " - " + EntryTiming.EndTime.ToString ());
						GoogleEventID[GoogleIDIndex] = "";
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join(";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch(ModifyStatement);
						}
					//else
					//	{
					//	WMB.Basics.ReportInformationToEventViewer("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
					//		"Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID + "\" ist alles OK\r\n"
					//		+ EntryTiming.StartTime.ToString() + " - " + EntryTiming.EndTime.ToString());
					//	}
					continue;
					}

				catch (Exception Excp)
					{
					WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						"Beim Eintrag \"" + EventEntryElementID + "\" ist folgender Fehler aufgetreten:\r\n"
						+ Excp.ToString());
					AllRunsCorrect = false;
					
					}
				}

			if ((AllRunsCorrect == true)
				&& (CloseRequestedCall != null))
				{
				CloseRequestedCall (this, "SaveNextStartDataTime");
				}
			return GoogleUpdate.MissingGoogleEventIDs;
			}
Beispiel #17
0
 /// <summary>standard typed Contains method </summary> 
 public bool Contains( When value )  
 {
     // If value is not of type AtomEntry, this will return false.
     return( List.Contains( value ) );
 }
        private void AddItem(CalendarItem calendarItem)
        {
            var entry = new EventEntry(calendarItem.Title);
            var w = new Where {ValueString = calendarItem.Location};
            var eventTime = new When(calendarItem.Start, calendarItem.End);
            entry.Times.Add(eventTime);
            entry.Locations.Add(w);
            entry.EventVisibility = calendarItem.IsPrivateItem ? EventEntry.Visibility.CONFIDENTIAL : EventEntry.Visibility.PUBLIC;
            CalendarService calendarService = Service;

            calendarService.Insert(new Uri(GOOGLE_CALENDAR_URI), entry);
        }
Beispiel #19
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static EventEntry CreateEventEntry(int iCount)
        {
            EventEntry entry = new EventEntry();
            // some unicode chars
            Char[] chars = new Char[] {
                                          '\u0023', // #
                                          '\u0025', // %
                                          '\u03a0', // Pi
                                          '\u03a3',  // Sigma
                                          '\u03d1', // beta
            };

            // if unicode needs to be disabled for testing, just uncomment this line
            // chars = new Char[] { 'a', 'b', 'c', 'd', 'e'}; 

    
    
            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3]; 
            author.Email = "*****@*****.**";
            entry.Authors.Add(author);
    
            AtomCategory cat = new AtomCategory();
    
            cat.Label = "Default";
            cat.Term = "Default" + chars[4] + " Term";
            entry.Categories.Add(cat);
    
            entry.Content.Content = "this is the default text entry";
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

            When newTime = new When();
            newTime.StartTime = DateTime.Today.AddDays(-3);
            newTime.EndTime = DateTime.Today.AddDays(1);
            entry.Times.Add(newTime);


            entry.Reminder = new Reminder();
            entry.Reminder.Minutes = DEFAULT_REMINDER_TIME; 

            Who someone = new Who();
            someone.ValueString = "*****@*****.**";
            Who.AttendeeStatus status = new Who.AttendeeStatus();
            status.Value = "event.accepted"; 
            someone.Attendee_Status = status;
            someone.Rel = "http://schemas.google.com/g/2005#event.organizer";

            entry.Participants.Add(someone);


            Where newPlace = new Where();
            newPlace.ValueString = "A really nice place";
            entry.Locations.Add(newPlace);
            newPlace = new Where();
            newPlace.ValueString = "Another really nice place";
            newPlace.Rel = Where.RelType.EVENT_ALTERNATE;
            entry.Locations.Add(newPlace);
            return entry;
        }
Beispiel #20
0
  /// <summary>standard typed add method </summary> 
  public int Add( When value )  
  {
      return base.Add(value);
 }
Beispiel #21
0
        private static EventEntry InsertEvent(EventFeed feed, String title, 
            String author, DateTime startTime, DateTime endTime, bool fAllDay,
            String place)
        {
            EventEntry entry = new EventEntry();

            entry.Title = new AtomTextConstruct(
                                AtomTextConstructElementType.Title, 
                                title);
            entry.Authors.Add(new AtomPerson(AtomPersonType.Author, author));
            entry.Published = DateTime.Now;
            entry.Updated = DateTime.Now;


            Where newPlace = new Where();
            newPlace.ValueString = place;
            entry.Locations.Add(newPlace);

            When newTime = new When();
            newTime.StartTime = startTime;
            newTime.EndTime = endTime;
            newTime.AllDay = fAllDay; 
            entry.Times.Add(newTime);

            return feed.Insert(entry) as EventEntry;
        }
Beispiel #22
0
        private Event mapEvent(EventEntry entry, When time)
        {
            Event eventEntry = new Event();

            eventEntry.title = entry.Title.Text;
            eventEntry.description = entry.Content.Content;

            eventEntry.date = time.StartTime;
            eventEntry.endDate = time.EndTime;
            eventEntry.allDayEvent = time.AllDay;
            if (eventEntry.allDayEvent && eventEntry.endDate.Equals(eventEntry.date.AddDays(1)))
                eventEntry.endDate = eventEntry.endDate.AddDays(-1);
            eventEntry.active = entry.Status.Equals(EventEntry.EventStatus.CONFIRMED);

            //eventEntry.id = entry.Id.ToString();

            return eventEntry;
        }
Beispiel #23
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Where  object.</summary> 
        /// <param name="node">the node to parse node</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created Where  object</returns>
        //////////////////////////////////////////////////////////////////////
        public IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            Tracing.TraceCall();
            When when = null;

            if (node != null)
            {
                object localname = node.LocalName;
                if (localname.Equals(this.XmlName) == false ||
                  node.NamespaceURI.Equals(this.XmlNameSpace) == false)
                {
                    return null;
                }
            }

            bool startTimeFlag = false, endTimeFlag = false;

            when = new When();
            if (node != null)
            {
                if (node.Attributes != null)
                {
                    String value = node.Attributes[GDataParserNameTable.XmlAttributeStartTime] != null ? 
                        node.Attributes[GDataParserNameTable.XmlAttributeStartTime].Value : null; 
                    if (value != null)
                    {
                        startTimeFlag = true;
                        when.startTime = DateTime.Parse(value);
                        when.AllDay = (value.IndexOf('T') == -1); 
                    }
                
                    value = node.Attributes[GDataParserNameTable.XmlAttributeEndTime] != null ? 
                        node.Attributes[GDataParserNameTable.XmlAttributeEndTime].Value : null; 
                
                    if (value != null)
                    {
                        endTimeFlag = true;
                        when.endTime = DateTime.Parse(value); 
                        when.AllDay = when.AllDay && (value.IndexOf('T') == -1); 
                    }
                
                    if (node.Attributes[GDataParserNameTable.XmlAttributeValueString] != null)
                    {
                        when.valueString = node.Attributes[GDataParserNameTable.XmlAttributeValueString].Value;
                    }
                }
                // single event, g:reminder is inside g:when
                if (node.HasChildNodes)
                {
                    XmlNode whenChildNode = node.FirstChild;
                    IExtensionElementFactory f = new Reminder() as IExtensionElementFactory;
                    while (whenChildNode != null && whenChildNode is XmlElement)
                    {
                        if (String.Compare(whenChildNode.NamespaceURI, f.XmlNameSpace, true, CultureInfo.InvariantCulture) == 0)
                        {
                            if (String.Compare(whenChildNode.LocalName, f.XmlName, true, CultureInfo.InvariantCulture) == 0)
                            {
                                Reminder r = f.CreateInstance(whenChildNode, null) as Reminder;
                                when.Reminders.Add(r);
                            }
                        }
                        whenChildNode = whenChildNode.NextSibling;
                    }
                }
            }
            
            if (!startTimeFlag)
            {
                throw new ClientFeedException("g:when/@startTime is required.");
            }

            if (endTimeFlag && when.startTime.CompareTo(when.endTime) > 0)
            {
                throw new ClientFeedException("g:when/@startTime must be less than or equal to g:when/@endTime.");
            }

            return when;
        }
Beispiel #24
0
        /// <summary>
        /// Add a local event to Google Calendar
        /// </summary>
        /// <param name="GGService">Google calendar service object</param>
        /// <param name="GGCalendar">GG calendar object</param>
        /// <param name="myGGItem">GGItem object to be added to GG calendar</param>
        /// <returns>Google event's ID</returns>
        private string AddGGEvent(CalendarService GGService, CalendarEntry GGCalendar, GGItem myGGItem)
        {
            // Create a event object
            EventEntry entry = new EventEntry();

            // Use description as event title (necessary)
            entry.Title.Text = myGGItem.GetDescription();
            // Use tag as event content (optional)
            entry.Content.Content = myGGItem.GetTag() + " | " + myGGItem.GetPath();

            // Set event start and end time
            if (myGGItem.GetEndDate().CompareTo(GGItem.DEFAULT_ENDDATE) != 0)
            {   // Specified endDate
                // Use endDate - 2hours as start time and endDate as end time
                When eventTime = new When(myGGItem.GetEndDate().AddHours(-2), myGGItem.GetEndDate());
                entry.Times.Add(eventTime);
            }
            else
            {   // Default endDate
                // Treat as tasks, set due date as 3 days later
                When eventTime = new When(DateTime.Today, DateTime.Today.AddDays(3));
                entry.Times.Add(eventTime);
            }

            // Log(entry.Updated.ToLongDateString());

            // Set email reminder: 15 minutes before end time
            Reminder GGReminder = new Reminder();
            GGReminder.Minutes = 15;
            GGReminder.Method = Reminder.ReminderMethod.email;
            entry.Reminders.Add(GGReminder);

            // Create the event on Google Calendar
            Uri postUri = new Uri("https://www.google.com/calendar/feeds/" + GGCalendar.Id.AbsoluteUri.Substring(63) + "/private/full");
            AtomEntry insertedEntry = GGService.Insert(postUri, entry);

            // Return the event's ID
            return insertedEntry.Id.AbsoluteUri;
        }
        /// <summary>
        /// Helper method to create either single-instance or recurring events.
        /// For simplicity, some values that might normally be passed as parameters
        /// (such as author name, email, etc.) are hard-coded.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        /// <param name="entryTitle">Title of the event to create.</param>
        /// <param name="recurData">Recurrence value for the event, or null for
        ///                         single-instance events.</param>
        /// <returns>The newly-created EventEntry on the calendar.</returns>
        static EventEntry CreateEvent(CalendarService service, String entryTitle,
                                     String recurData)
        {
            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = entryTitle;
            entry.Content.Content = "Meet for a quick lesson.";

            // Set a location for the event.
            Where eventLocation = new Where();
            eventLocation.ValueString = "South Tennis Courts";
            entry.Locations.Add(eventLocation);

            // If a recurrence was requested, add it.  Otherwise, set the
            // time (the current date and time) and duration (30 minutes)
            // of the event.
            if (recurData == null) {
                When eventTime = new When();
                eventTime.StartTime = DateTime.Now;
                eventTime.EndTime = eventTime.StartTime.AddMinutes(30);
                entry.Times.Add(eventTime);
            } else {
                Recurrence recurrence = new Recurrence();
                recurrence.Value = recurData;
                entry.Recurrence = recurrence;
            }

            // Send the request and receive the response:
            Uri postUri = new Uri(feedUri);
            AtomEntry insertedEntry = service.Insert(postUri, entry);

            return (EventEntry)insertedEntry;
        }
Beispiel #26
0
 /// <summary>standard typed remove method </summary> 
 public void Remove( When value )  
 {
     base.Remove(value);
 }
Beispiel #27
0
 /// <summary>standard typed indexOf method </summary> 
 public int IndexOf( When value )  
 {
     return( List.IndexOf( value ) );
 }
Beispiel #28
0
        /// <summary>
        /// Sets the contents of an entry from a row of the table.
        /// </summary>
        /// <param name='entry'>
        /// The EventEntry to modify
        /// </param>
        /// <param name='row'>
        /// The row number in which the data sits.
        /// </param>
        protected void CnvtRowToEntry(EventEntry entry, int row)
        {
            DateTime start;
            DateTime end;
            const int DateStartColumnIndex = 0;
            const int TimeStartColumnIndex = 1;
            const int TitleColumnIndex = 2;
            const int TimeEndColumnIndex = 3;
            const int PlaceColumnIndex = 4;
            string timeSeparator = CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator;
            string dateStart = "";
            string timeStart = "";
            string timeEnd = "";

            // Prepare time information
            entry.Times.Clear();
            entry.Locations.Clear();

            try {
                dateStart = ( (string) this.grdEventsList.Rows[ row ].Cells[ DateStartColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErStartDateMissing ) );
            }

            try {
                timeStart = ( (string) this.grdEventsList.Rows[ row ].Cells[ TimeStartColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErStartDateMissing ) );
            }

            try {
                timeEnd = ( (string) this.grdEventsList.Rows[ row ].Cells[ TimeEndColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                timeEnd = timeStart;
            }

            // Prepare times
            timeEnd = timeEnd.Trim();
            timeStart = timeStart.Trim();

            if ( timeStart.ToLower().EndsWith( GCalFramework.EtqHourMark ) ) {
                timeStart = timeStart.Substring( 0, timeStart.Length -1 ) + timeSeparator + "00";
            }

            if ( timeEnd.ToLower().EndsWith( GCalFramework.EtqHourMark ) ) {
                timeEnd = timeEnd.Substring( 0, timeEnd.Length -1 ) + timeSeparator + "00";
            }

            // Set start/end date/time
            timeEnd = dateStart + ' ' + timeEnd;
            dateStart = dateStart + ' ' + timeStart;

            try {
                start = DateTime.Parse( dateStart, CultureInfo.CurrentCulture.DateTimeFormat  );
            } catch(FormatException exc) {
                throw new FormatException( StringsL18n.Get( StringsL18n.StringId.ErParsingStartTime )
                    + ": " + exc.Message );
            }

            try {
                end = DateTime.Parse( timeEnd, CultureInfo.CurrentCulture.DateTimeFormat  );
            } catch(FormatException)
            {
                // Adapt the end time by one hour from the start
                end = start.AddHours( 1 );
            }

            // Set times
            if ( start == end ) {
                end = start.AddHours( 1 );
            }

            var eventTime = new When( start, end );
            entry.Times.Add( eventTime );

            // Set title
            try {
                entry.Title.Text = ( (string) this.grdEventsList.Rows[ row ].Cells[ TitleColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            if ( entry.Title.Text.Trim().Length == 0 ) {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            // Set place
            string strPlace = null;
            try {
                strPlace = ( (string) this.grdEventsList.Rows[ row ].Cells[ PlaceColumnIndex ].Value ).Trim();
            } catch(Exception)
            {
                strPlace = GCalFramework.EtqNotAvailable;
            }

            if ( strPlace.Trim().Length == 0 ) {
                entry.Title.Text = GCalFramework.EtqNotAvailable;
            }

            var eventLocation = new Where();
            eventLocation.ValueString = strPlace;
            entry.Locations.Add( eventLocation );

            // Set alarm
            Reminder reminder = new Reminder();
            reminder.Minutes = 30;
            reminder.Method = Reminder.ReminderMethod.all;
            entry.Reminder = reminder;

            return;
        }
Beispiel #29
0
        /// <summary>
        /// Adds a new event to the calendar using the specified information.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public CalendarEvent AddEvent(string title, string description, DateTime? start, DateTime? end)
        {
            EventEntry entry = new EventEntry();

            // Set the title and content of the entry.
            entry.Title.Text = title;
            entry.Content.Content = description;

            if (start != null || end != null)
            {
                When eventTime = new When();
                if(start != null)
                    eventTime.StartTime = (DateTime)start;

                if(end != null)
                    eventTime.EndTime = (DateTime)end;

                entry.Times.Add(eventTime);
            }

            // Send the request and receive the response:
            entry = _service.Insert(new Uri(CALENDAR_URI), entry) as EventEntry;

            return new CalendarEvent(entry);
        }
Beispiel #30
0
 /// <summary>standard typed insert method </summary> 
 public void Insert( int index, When value )  
 {
     base.Insert(index, value);
 }