コード例 #1
0
ファイル: Calendar.cs プロジェクト: salih18200/orcs
        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);
        }
コード例 #2
0
ファイル: GoogleTest.aspx.cs プロジェクト: pank1982/mydoc
    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);
    }
コード例 #3
0
        public void TestConvertGoogleEventStatus()
        {
            EventEntry googleAppsEvent = new EventEntry("title", "description", "location");
            MeetingStatus status = MeetingStatus.Confirmed;

            // Event w/o explicit status should be treated as busy, since this is how the data
            // comes from the free busy projection
            status = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status);
            Assert.AreEqual(status, MeetingStatus.Confirmed);

            // Confirmed event should be converted to confirmed.
            googleAppsEvent.Status = EventEntry.EventStatus.CONFIRMED;
            status = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status);
            Assert.AreEqual(status, MeetingStatus.Confirmed);

            // Cancelled event should be converted to cancelled.
            googleAppsEvent.Status = EventEntry.EventStatus.CANCELED;
            status = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status);
            Assert.AreEqual(status, MeetingStatus.Cancelled);

            // Tentative event should be converted to tentative.
            googleAppsEvent.Status = EventEntry.EventStatus.TENTATIVE;
            status = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status);
            Assert.AreEqual(status, MeetingStatus.Tentative);

            // Bogus event should be converted to confirmed.
            googleAppsEvent.Status = new EventEntry.EventStatus();
            googleAppsEvent.Status.Value = "Abrakadabra";
            status = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status);
            Assert.AreEqual(status, MeetingStatus.Confirmed);
        }
コード例 #4
0
ファイル: Calendar.cs プロジェクト: nhannd/Xian
        /// <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);
        }
コード例 #5
0
ファイル: GoogleTest.aspx.cs プロジェクト: pank1982/mydoc
    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);
    }
コード例 #6
0
 public CalendarEvent(GoogleCalendarCredentials credentials, EventEntry entry)
 {
     Invitees = new List<CalendarEventInvitee>();
     Reminders = new List<CalendarEventReminder>();
     _credentials = credentials;
     _setContstructor(entry);
 }
コード例 #7
0
 public bool Insert(Task task)
 {
     EventEntry eventEntry = new EventEntry
                             {
                                 Title = {Text = task.Head},
                                 Content = {Content = task.Description,},
                                 Locations = {new Where("", "", task.Location)},
                                 Times = {new When(task.StartDate, task.StopDate)},
                             };
     Log.InfoFormat("Inserting new entry to google : [{0}]", task.ToString());
     CalendarService service = new CalendarService("googleCalendarInsert");
     service.setUserCredentials(task.AccountInfo.Username, task.AccountInfo.Password);
     Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
     ErrorMessage = String.Empty;
     try
     {
         EventEntry createdEntry = service.Insert(postUri, eventEntry);
         return createdEntry != null;
     }
     catch (Exception exception)
     {
         Log.ErrorFormat(exception.Message);
         Log.ErrorFormat(exception.ToString());
         ErrorMessage = exception.Message;
     }
     return false;
 }
コード例 #8
0
    protected bool nastanotPostoi()
    {
        bool postoi = false;

        Google.GData.Calendar.EventEntry novNastan = (Google.GData.Calendar.EventEntry)Session["novNastan"];
        string                 calendarId          = ddlKalendari.SelectedItem.Value;
        EventQuery             evQuery             = new EventQuery();
        GAuthSubRequestFactory authFactory         = new GAuthSubRequestFactory("cl", "FEITPortal");

        authFactory.Token = (string)Session["sessionToken"];
        myCalendarService.RequestFactory = authFactory;
        evQuery.Uri = new Uri("http://www.google.com/calendar/feeds/" + calendarId + "/private/full");
        Google.GData.Calendar.EventFeed evFeed = myCalendarService.Query(evQuery) as Google.GData.Calendar.EventFeed;

        if (evFeed != null)
        {
            foreach (Google.GData.Calendar.EventEntry en in evFeed.Entries)
            {
                string[] newEventId = novNastan.Content.Content.Split(':');
                string[] eventId    = en.Content.Content.Split(':');
                int      novLength  = newEventId.Length;
                int      starLength = eventId.Length;
                if (eventId[starLength - 1] == newEventId[novLength - 1])
                {
                    postoi = true;
                    break;
                }
            }
        }
        return(postoi);
    }
コード例 #9
0
ファイル: insert.cs プロジェクト: mintwans/cpsc483
        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;
        }
コード例 #10
0
 private IList<Attendee> GetAppointmentAttendees(EventEntry eventEntry)
 {
     return eventEntry.Participants.Where(p => p.Email != _googleUsername)
                                   .Select(participant => new Attendee
                                                              {
                                                                  Email = participant.Email
                                                              }).ToList();
 }
コード例 #11
0
        /// <summary>
        /// Adds a reminder to a calendar event.
        /// </summary>
        /// <param name="entry">The event to update.</param>
        /// <param name="numMinutes">Reminder time, in minutes.</param>
        /// <returns>The updated EventEntry object.</returns>
        static EventEntry AddReminder(EventEntry entry, int numMinutes)
        {
            Reminder reminder = new Reminder();
            reminder.Minutes = numMinutes;
            entry.Reminder = reminder;

            return (EventEntry)entry.Update();
        }
コード例 #12
0
        public GoogleCalendarItem(EventEntry entry)
        {
            _entry = entry;

            Start = _entry.Times[0].StartTime;
            End = _entry.Times[0].EndTime;
            Title = _entry.Title.Text;
            IsPrivateItem = _entry.EventVisibility != EventEntry.Visibility.PUBLIC && _entry.EventVisibility !=EventEntry.Visibility.DEFAULT;
            Location = _entry.Locations[0].ValueString;
        }
コード例 #13
0
        /// <summary>
        /// Adds an extended property to a calendar event.
        /// </summary>
        /// <param name="entry">The event to update.</param>
        /// <returns>The updated EventEntry object.</returns>
        static EventEntry AddExtendedProperty(EventEntry entry)
        {
            ExtendedProperty property = new ExtendedProperty();
            property.Name = "http://www.example.com/schemas/2005#mycal.id";
            property.Value = "1234";

            entry.ExtensionElements.Add(property);

            return (EventEntry)entry.Update();
        }
コード例 #14
0
 private Appointment GetAppointmentFromEventEntry(EventEntry entry)
 {
     return new Appointment
                {
                    EventId = entry.EventId,
                    Description = entry.Title.Text,
                    StartingAt = entry.Times[0].StartTime,
                    EndingAt = entry.Times[0].EndTime,
                    Attendees = GetAppointmentAttendees(entry)
                };
 }
コード例 #15
0
ファイル: GoogleTest.aspx.cs プロジェクト: pank1982/mydoc
    private void GetEvents()
    {
        CalendarService oCalendarService = GAuthenticate();
        //Uri oCalendarUri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full");

        //Search for Event
        EventQuery oEventQuery = new EventQuery();

        oEventQuery.Uri = new Uri("https://www.google.com/calendar/feeds/[email protected]/private/full");
        //oEventQuery.Query = "Query String";
        oEventQuery.ExtraParameters = "orderby=starttime&sortorder=ascending";
        oEventQuery.StartTime       = DateTime.Now;
        oEventQuery.EndTime         = DateTime.Now.AddDays(50);
        //oEventQuery.SingleEvents = true;

        Google.GData.Calendar.EventFeed oEventFeed = oCalendarService.Query(oEventQuery);
        string    dt    = "";
        DataTable table = new DataTable();

        table.Columns.Add(new DataColumn("EventTitle"));
        table.Columns.Add(new DataColumn("EventSummary"));
        table.Columns.Add(new DataColumn("EventStartDate"));
        table.Columns.Add(new DataColumn("EventEndDate"));
        table.Columns.Add(new DataColumn("EventStatus"));
        table.Columns.Add(new DataColumn("EventId"));
        table.Columns.Add(new DataColumn("EventLocation"));
        table.Columns.Add(new DataColumn("EventUId"));

        foreach (var entry in oEventFeed.Entries)
        {
            Google.GData.Calendar.EventEntry eventEntry = entry as Google.GData.Calendar.EventEntry;
            if (eventEntry != null)
            {
                if (eventEntry.Times.Count != 0)
                {
                    DataRow dr = table.NewRow();
                    dr["EventUId"]       = eventEntry.Uid.Value;
                    dr["EventId"]        = eventEntry.EventId.ToString();
                    dr["EventTitle"]     = eventEntry.Title.Text;
                    dr["EventSummary"]   = eventEntry.Summary.Text;
                    dr["EventStartDate"] = eventEntry.Times[0].StartTime.ToString("dd/MM/yyyy");
                    dr["EventEndDate"]   = eventEntry.Times[0].EndTime.ToString("dd/MM/yyyy");
                    dr["EventStatus"]    = eventEntry.Status.Value.ToString();
                    dr["EventLocation"]  = Convert.ToString(eventEntry.Locations[0].ValueString);
                    table.Rows.Add(dr);
                    //dt = dt + eventEntry.Title.Text + "<br/>";
                }
            }
        }
        //eventsLabel.Text = dt;
        gvCal.DataSource = table;
        gvCal.DataBind();
    }
コード例 #16
0
 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);
 }
コード例 #17
0
ファイル: GCal.cs プロジェクト: nanariya/TriciaBot
        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);
        }
コード例 #18
0
        private static Event MapToEvent(EventEntry entry)
        {
            if (entry == null)
                return null;

            var time = entry.Times.FirstOrDefault();

            return new Event
            {
                Id = entry.EventId,
                Title = entry.Title.Text,
                Content = entry.Content.Content,
                StartTime = time == null ? null : (DateTime?)time.StartTime,
                EndTime = time == null ? null : (DateTime?)time.StartTime
            };
        }
コード例 #19
0
ファイル: TasksForm.cs プロジェクト: kos89/kos89repository
        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);
                }
            }
        }
コード例 #20
0
        //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();
            }
        }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
    protected void btnDodadi_Click(object sender, EventArgs e)
    {
        if (!nastanotPostoi())
        {
            novNastan = (Google.GData.Calendar.EventEntry)Session["novNastan"];
            string calendarId = ddlKalendari.SelectedItem.Value;
            GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cl", "FEITPortal");
            authFactory.Token = (string)Session["sessionToken"];
            myCalendarService.RequestFactory = authFactory;

            Uri       postUri       = new Uri("http://www.google.com/calendar/feeds/" + calendarId + "/private/full");
            AtomEntry insertedEntry = myCalendarService.Insert(postUri, novNastan);
            lblUspesno.Text = "Настанот беше успешно креиран!";
            mwGoogleEvent.ActiveViewIndex = 2;
        }
        else
        {
            btnNazad.Visible = true;
            lblGreska.Text   = "Настанот веќе постои во избраниот календар. Избришете го или обидете друг календар";
            mwGoogleEvent.ActiveViewIndex = 3;
        }
    }
コード例 #23
0
ファイル: GoogleService.cs プロジェクト: b9502032/MySite
        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 "";
            }
        }
コード例 #24
0
        public EventEntry UpdateOrCreateEvent(Event @event)
        {
            EnsureAuthentication();

            if (string.IsNullOrEmpty(@event.Id))
            {
                var eventEntry = new EventEntry(@event.Title);
                eventEntry.Content.Content = @event.Content;
                SetEventEntryTime(@event, eventEntry);

                return _calendarService.Insert(_calendarUri, eventEntry);
            }
            else
            {
                var eventEntry = GetEventEntryById(@event.Id);
                eventEntry.Content.Content = @event.Content;
                eventEntry.Title.Text = @event.Title;
                SetEventEntryTime(@event, eventEntry);

                return _calendarService.Update(eventEntry);
            }
        }
コード例 #25
0
ファイル: Calendar.cs プロジェクト: czoper/GTrello
        internal void AddEvents(Dictionary<string, Card> dictionary)
        {
            if (dictionary.Keys.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair<string, Card> trelloCard in dictionary)
            {
                EventEntry entry = new EventEntry();

                entry.Title.Text = trelloCard.Value.Name;
                entry.Content.Content = string.Format("{0} [{1}]", trelloCard.Value.Desc, trelloCard.Value.FullName);
                entry.Locations.Add(new Where() { ValueString = "Trello" });
                entry.Times.Add(new When(trelloCard.Value.DueDate.Value, trelloCard.Value.DueDate.Value.AddMinutes(5)));
                Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");

                EventEntry insertedEntry = service.Insert(postUri, entry);
                entries.Add(insertedEntry.Id.AbsoluteUri, entry);

                AddMapping(trelloCard.Key, insertedEntry.Id.AbsoluteUri);
            }
        }
コード例 #26
0
ファイル: Create.cs プロジェクト: prafullat/gminder
        private void HandleAddButton(object sender, EventArgs e)
        {
            var calendar = calendarList.SelectedItem as Calendar;
            if (calendar == null)
                return;

            var newEntry = new EventEntry();
            newEntry.QuickAdd = true;
            newEntry.Content.Content = newEventNameTextBox.Text;

            try
            {
                calendar.Create(newEntry);
                Close();
            }
            catch (Exception ex)
            {
                Logging.LogException(true, ex,
                    "Error adding event.",
                    "You may not have permission to edit the selected calendar."
                );
            }
        }
コード例 #27
0
ファイル: Google日历助手.cs プロジェクト: manasheep/Core3
        public EventEntry 创建活动(string 标题, string 说明, string 地点, DateTime 开始时间, DateTime 结束时间, Reminder.ReminderMethod 提醒方式, TimeSpan 提前提醒时间)
        {
            if (提醒方式 != Reminder.ReminderMethod.none && 提前提醒时间.TotalMinutes < 1) throw new Exception("提前提醒时间不得小于1分钟,因为低于分钟的单位将被忽略");

            var q = new EventEntry(标题, 说明, 地点);
            q.Times.Add(new When(开始时间, 结束时间));
            q.Reminder = new Reminder { Minutes = 提前提醒时间.Minutes, Days = 提前提醒时间.Days, Hours = 提前提醒时间.Hours, Method = Reminder.ReminderMethod.all };

            if (操作日历名称 == null)
            {
                return 日历服务.Insert(new Uri(访问网址), q) as EventEntry;
            }
            else
            {
                var query = new CalendarQuery(访问网址);
                CalendarEntry c = null;
                foreach (CalendarEntry f in 日历服务.Query(query).Entries)
                {
                    if (f.Title.Text == 操作日历名称) c = f;
                }
                return 日历服务.Insert(new Uri(c.Content.AbsoluteUri), q) as EventEntry;
            }
        }
コード例 #28
0
        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);
        }
コード例 #30
0
        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);
        }
        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);
        }
コード例 #32
0
ファイル: objectmodelhelper.cs プロジェクト: mintwans/cpsc483
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <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;
        }
コード例 #33
0
        /// <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;
        }
コード例 #34
0
    // f-ja za zacuvuvanje, azuriranje na nastani za opredelen kalendar
    public static bool AddUpdateDeleteEvent(List <GoogleTokenModel> GoogleTokenModelList, List <GoogleCalendarAppointmentModel> GoogleCalendarAppointmentModelList, double TimeOffset)
    {
        bool result = false;

        foreach (GoogleTokenModel GoogleAppointmentOAuthDetailsObj in GoogleTokenModelList)
        {
            //Get the calendar service for a user to add/update/delete events
            CalendarService CalService = GetCalendarService(GoogleAppointmentOAuthDetailsObj);
            //get the calendar id for this user to add/update/delete events
            string CalendarID = GetCalendarID(CalService);

            EventEntry InsertedEntry = new EventEntry();

            if (GoogleCalendarAppointmentModelList != null && GoogleCalendarAppointmentModelList.Count > 0)
            {
                foreach (GoogleCalendarAppointmentModel GoogleCalendarAppointmentModelObj in GoogleCalendarAppointmentModelList)
                {
                    //to restrict the appointment for specific staff only
                    //Delete this appointment from google calendar
                    if (GoogleCalendarAppointmentModelObj.DeleteAppointment == true)
                    {
                        Google.GData.Calendar.EventEntry Entry = new Google.GData.Calendar.EventEntry();

                        ExtendedProperty oExtendedProperty = new ExtendedProperty();
                        oExtendedProperty.Name  = "EventID";
                        oExtendedProperty.Value = GoogleCalendarAppointmentModelObj.EventID;
                        //transport
                        //      ExtendedProperty oExtendedPropertyTransport = new ExtendedProperty();
                        //     oExtendedPropertyTransport.Name = "Transport";
                        ///      oExtendedPropertyTransport.Value = GoogleCalendarAppointmentModelObj.EventTransport;
                        //     // weather
                        //      ExtendedProperty oExtendedPropertyWeather = new ExtendedProperty();
                        //      oExtendedPropertyWeather.Name = "Weather";
                        //      oExtendedPropertyWeather.Value = GoogleCalendarAppointmentModelObj.Weather;


                        //search the calendar so to update or add appointment in it
                        string     ThisFeedUri = "http://www.google.com/calendar/feeds/" + CalendarID + "/private/full";
                        Uri        postUri     = new Uri(ThisFeedUri);
                        EventQuery Query       = new EventQuery(ThisFeedUri);

                        ///  "extq=[EventID:" + GoogleCalendarAppointmentModelObj.EventID + "]" + "[" + "Transport:" + GoogleCalendarAppointmentModelObj.EventTransport + "]" + "[" + "Weather:" + GoogleCalendarAppointmentModelObj.Weather + "]";

                        Query.ExtraParameters = "extq=[EventID:" + GoogleCalendarAppointmentModelObj.EventID + "]";
                        Query.Uri             = postUri;
                        Entry.ExtensionElements.Add(oExtendedProperty);
                        //     Entry.ExtensionElements.Add(oExtendedPropertyTransport);
                        //   Entry.ExtensionElements.Add(oExtendedPropertyWeather);
                        EventFeed calFeed = CalService.Query(Query);

                        //if search contains result then update
                        if (calFeed != null && calFeed.Entries.Count > 0)
                        {
                            foreach (EventEntry SearchedEntry in calFeed.Entries)
                            {
                                SearchedEntry.Delete();
                                result = true;
                                break;
                            }
                            //return null;
                        }
                    }
                    //Add if not found OR update if appointment already present on google calendar
                    else
                    {
                        Google.GData.Calendar.EventEntry Entry = new Google.GData.Calendar.EventEntry();

                        // Set the title and content of the entry.
                        Entry.Title.Text = GoogleCalendarAppointmentModelObj.EventTitle.ToString();

                        System.Text.StringBuilder EventDetails = new System.Text.StringBuilder();
                        EventDetails.Append(GoogleCalendarAppointmentModelObj.EventDetails);
                        Entry.Content.Content = EventDetails.ToString();


                        When EventTime = new When();
                        EventTime.StartTime = GoogleCalendarAppointmentModelObj.EventStartTime.AddMinutes(-TimeOffset);
                        EventTime.EndTime   = GoogleCalendarAppointmentModelObj.EventEndTime.AddMinutes(-TimeOffset);

                        Entry.Times.Add(EventTime);

                        Reminder remaindertiming1 = new Reminder();

                        if (GoogleCalendarAppointmentModelObj.Remainder1 != "")

                        {
                            string[] remainder1 = GoogleCalendarAppointmentModelObj.Remainder1.Split(' ');

                            int timingvalue = Convert.ToInt16(remainder1[1]);
                            if (remainder1[2].ToLower() == "minutes")
                            {
                                remaindertiming1.Minutes = timingvalue;
                            }
                            else if (remainder1[2].ToLower() == "hours")
                            {
                                remaindertiming1.Hours = timingvalue;
                            }
                            else if (remainder1[2].ToLower() == "days")
                            {
                                remaindertiming1.Days = timingvalue;
                            }

                            if (remainder1[0].ToLower() == "email")
                            {
                                remaindertiming1.Method = Reminder.ReminderMethod.email;
                            }
                            else
                            {
                                remaindertiming1.Method = Reminder.ReminderMethod.alert;
                            }
                            Entry.Reminders.Add(remaindertiming1);
                        }

                        //vtoriot remainder
                        Reminder remaindertiming2 = new Reminder();
                        if (GoogleCalendarAppointmentModelObj.Remainder2 != "")
                        {
                            string[] remainder2 = GoogleCalendarAppointmentModelObj.Remainder2.Split(' ');

                            int timingvalue = Convert.ToInt16(remainder2[1]);
                            if (remainder2[2].ToLower() == "minutes")
                            {
                                remaindertiming2.Minutes = timingvalue;
                            }
                            else if (remainder2[2].ToLower() == "hours")
                            {
                                remaindertiming2.Hours = timingvalue;
                            }
                            else if (remainder2[2].ToLower() == "days")
                            {
                                remaindertiming2.Days = timingvalue;
                            }

                            if (remainder2[0].ToLower() == "email")
                            {
                                remaindertiming2.Method = Reminder.ReminderMethod.email;
                            }
                            else
                            {
                                remaindertiming2.Method = Reminder.ReminderMethod.alert;
                            }
                            Entry.Reminders.Add(remaindertiming2);
                        }


                        // Set a location for the event.
                        Where eventLocation = new Where();
                        if (string.IsNullOrEmpty(GoogleCalendarAppointmentModelObj.EventLocation) == false)
                        {
                            eventLocation.ValueString = GoogleCalendarAppointmentModelObj.EventLocation;
                            Entry.Locations.Add(eventLocation);
                        }
                        //Add appointment ID to update/ delete the appointment afterwards
                        ExtendedProperty oExtendedProperty = new ExtendedProperty();
                        oExtendedProperty.Name  = "EventID";
                        oExtendedProperty.Value = GoogleCalendarAppointmentModelObj.EventID;
                        Entry.ExtensionElements.Add(oExtendedProperty);
                        //add transport extra property
                        ExtendedProperty transportExtendedProperty = new ExtendedProperty();
                        transportExtendedProperty.Name  = "Transport";
                        transportExtendedProperty.Value = GoogleCalendarAppointmentModelObj.EventTransport;
                        Entry.ExtensionElements.Add(transportExtendedProperty);

                        ExtendedProperty weatherExtendedProperty = new ExtendedProperty();
                        weatherExtendedProperty.Name  = "Weather";
                        weatherExtendedProperty.Value = GoogleCalendarAppointmentModelObj.Weather;
                        Entry.ExtensionElements.Add(weatherExtendedProperty);

                        //search the calendar so to update or add appointment in it
                        string     ThisFeedUri = "http://www.google.com/calendar/feeds/" + CalendarID + "/private/full";
                        Uri        postUri     = new Uri(ThisFeedUri);
                        EventQuery Query       = new EventQuery(ThisFeedUri);
                        Query.ExtraParameters = "extq=[EventID:" + GoogleCalendarAppointmentModelObj.EventID + "]";
                        Query.Uri             = postUri;
                        Entry.ExtensionElements.Add(oExtendedProperty);
                        EventFeed calFeed = CalService.Query(Query);

                        //if search contains result then update
                        if (calFeed != null && calFeed.Entries.Count > 0)
                        {
                            foreach (EventEntry SearchedEntry in calFeed.Entries)
                            {
                                SearchedEntry.Content = Entry.Content;
                                SearchedEntry.Title   = Entry.Title;
                                SearchedEntry.Times.RemoveAt(0);
                                SearchedEntry.Times.Add(EventTime);
                                SearchedEntry.Locations.RemoveAt(0);
                                SearchedEntry.Locations.Add(eventLocation);
                                SearchedEntry.Reminders.Add(remaindertiming1);
                                SearchedEntry.Reminders.Add(remaindertiming2);
                                SearchedEntry.ExtensionElements.Add(transportExtendedProperty);
                                SearchedEntry.ExtensionElements.Add(weatherExtendedProperty);

                                CalService.Update(SearchedEntry);
                                result = true;
                                break;
                            }
                        }
                        //otherwise add the entry
                        else
                        {
                            InsertedEntry = CalService.Insert(postUri, Entry);
                            result        = true;
                        }
                    }
                }
            }
        }
        return(result);
    }
コード例 #35
0
 /// <summary>
 /// Updates the title of an existing calendar event.
 /// </summary>
 /// <param name="entry">The event to update.</param>
 /// <param name="newTitle">The new title for this event.</param>
 /// <returns>The updated EventEntry object.</returns>
 static EventEntry UpdateTitle(EventEntry entry, String newTitle)
 {
     entry.Title.Text = newTitle;
     return (EventEntry)entry.Update();
 }