Example #1
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create an ExtendedProperty object.</summary> 
        /// <param name="node">when node</param>
        /// <returns>the created ExtendedProperty object</returns>
        //////////////////////////////////////////////////////////////////////
        public static ExtendedProperty Parse(XmlNode node)
        {
            Tracing.TraceCall();
            ExtendedProperty prop = null;
            Tracing.Assert(node != null, "node should not be null");

            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            object localname = node.LocalName;

            if (localname.Equals(GDataParserNameTable.XmlExtendedPropertyElement))
            {
                prop = new ExtendedProperty();

                if (node.Attributes != null)
                {
                    prop.Value = node.Attributes[GDataParserNameTable.XmlValue] != null ? 
                         node.Attributes[GDataParserNameTable.XmlValue].Value : null; 
                    prop.Name = node.Attributes[AtomParserNameTable.XmlName]!= null ? 
                        node.Attributes[AtomParserNameTable.XmlName].Value : null; 
                }
            }
            return prop;
        }
Example #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);
    }
        /// <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();
        }
        /// <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);
        }
Example #5
0
        /////////////////////////////////////////////////////////////////////////////

        
        //////////////////////////////////////////////////////////////////////
        /// <summary>tests the extended property against the calendar</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarExtendedPropertyTest()
        {
            Tracing.TraceMsg("Entering CalendarExtendedPropertyTest");

            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);
                }

                service.RequestFactory = this.factory; 

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

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

                string guid = Guid.NewGuid().ToString(); 

                ExtendedProperty prop; 
                EventEntry entry;

                if (calFeed != null)
                {
                    entry = ObjectModelHelper.CreateEventEntry(1); 
                    entry.Title.Text = guid; 

                    prop = new ExtendedProperty(); 
                    prop.Name = "http://frank.schemas/2005#prop"; 
                    prop.Value = "Mantek"; 

                    entry.ExtensionElements.Add(prop); 

                    calFeed.Insert(entry); 
                }

                calFeed = service.Query(query) as EventFeed;
                prop = null;
                entry = null;

                if (calFeed != null && calFeed.Entries.Count > 0)
                {
                    entry = calFeed.Entries[0] as EventEntry;

                    Assert.AreEqual(entry.Title.Text, guid, "Expected the same entry");

                    foreach (Object o in entry.ExtensionElements )
                    {
                        ExtendedProperty p = o as ExtendedProperty; 
                        if (p != null)
                        {
                            Tracing.TraceMsg("Found one extended property"); 
                            Assert.AreEqual(p.Name, "http://frank.schemas/2005#prop", "Expected the same entry");
                            Assert.AreEqual(p.Value, "Mantek", "Expected the same entry");
                            prop = p; 
                        }
                    }
                }

                Assert.IsTrue(prop != null, "prop should not be null"); 

                // now delete the prop again
                // BUGBUG: currently you can not delete extended properties in the calendar
                /*
                if (entry != null)
                {
                    entry.ExtensionElements.Remove(prop);
                    prop = null;
                    EventEntry newEntry = entry.Update() as EventEntry; 
                    foreach (Object o in newEntry.ExtensionElements )
                    {
                        ExtendedProperty p = o as ExtendedProperty; 
                        if (p != null)
                        {
                            Tracing.TraceMsg("Found one extended property"); 
                            prop = p; 
                            break;
                        }
                    }
                    Assert.IsTrue(prop == null, "prop should be gone now");
                }
                */
                // get rid of the entry
                if (entry != null)
                    entry.Delete();
                
                service.Credentials = null; 

            }
        }
 public static void SetGoogleOutlookContactId(string syncProfile, Contact googleContact, string outlookContactId)
 {
     // check if exists
     bool found = false;
     foreach (Google.GData.Extensions.ExtendedProperty p in googleContact.ExtendedProperties)
     {
         if (p.Name == "gos:oid:" + syncProfile + "")
         {
             p.Value = outlookContactId;
             found = true;
             break;
         }
     }
     if (!found)
     {
         Google.GData.Extensions.ExtendedProperty prop = new ExtendedProperty(outlookContactId, "gos:oid:" + syncProfile + "");
         prop.Value = outlookContactId;
         googleContact.ExtendedProperties.Add(prop);
     }
 }
Example #7
0
        /////////////////////////////////////////////////////////////////////////////

        
        //////////////////////////////////////////////////////////////////////
        /// <summary>tests the extended property against the calendar</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarExtendedPropertyTest()
        {
            Tracing.TraceMsg("Entering CalendarExtendedPropertyTest");

            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 guid = Guid.NewGuid().ToString(); 

                ExtendedProperty prop; 


                if (calFeed != null)
                {
                    EventEntry entry = ObjectModelHelper.CreateEventEntry(1); 
                    entry.Title.Text = guid; 

                    prop = new ExtendedProperty(); 
                    prop.Name = "http://frank.schemas/2005#prop"; 
                    prop.Value = "Mantek"; 

                    entry.ExtensionElements.Add(prop); 

                    calFeed.Insert(entry); 
                }

                calFeed = service.Query(query) as EventFeed;

                prop = null;

                if (calFeed != null && calFeed.Entries.Count > 0)
                {
                    EventEntry entry = calFeed.Entries[0] as EventEntry;

                    Assert.AreEqual(entry.Title.Text, guid, "Expected the same entry");

                    foreach (Object o in entry.ExtensionElements )
                    {
                        ExtendedProperty p = o as ExtendedProperty; 
                        if (p != null)
                        {
                            Tracing.TraceMsg("Found one extended property"); 
                            Assert.AreEqual(p.Name, "http://frank.schemas/2005#prop", "Expected the same entry");
                            Assert.AreEqual(p.Value, "Mantek", "Expected the same entry");
                            prop = p; 
                        }
                    }
                }

                Assert.IsTrue(prop != null, "prop should not be null"); 

                service.Credentials = null; 

                factory.MethodOverride = false;
            }
        }