Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Parses an xml node to create a Who object.</summary>
        /// <param name="node">the xml parses node, can be NULL</param>
        /// <param name="parser">the xml parser to use if we need to dive deeper</param>
        /// <returns>the created IExtensionElement object</returns>
        //////////////////////////////////////////////////////////////////////
        public override IExtensionElementFactory CreateInstance(XmlNode node, AtomFeedParser parser)
        {
            IExtensionElementFactory ele = base.CreateInstance(node, parser);

            OriginalEvent ev = ele as OriginalEvent;

            if (ev != null)
            {
                if (ev.IdOriginal == null)
                {
                    throw new ArgumentException("g:originalEvent/@id is required.");
                }

                if (ev.OriginalStartTime == null)
                {
                    throw new ArgumentException("g:when inside g:originalEvent is required.");
                }
            }

            return(ev);
        }
Exemplo n.º 2
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;
            }
        }
Exemplo n.º 3
0
        // end of accessor public TimeZone TimeZone


        //////////////////////////////////////////////////////////////////////
        /// <summary>searches through the evententries to 
        /// find the original event</summary> 
        /// <param name="original">The original event to find</param>
        /// <returns> </returns>
        //////////////////////////////////////////////////////////////////////
        public EventEntry FindEvent(OriginalEvent original) 
        {
            // first try the internal cache

            foreach (EventEntry entry  in this.Entries )
            {
                if (entry.SelfUri.ToString() == original.Href)
                {
                    return entry; 
                }
            }

            // did not find it in the cache. Need to call the server to get it. 
            CalendarService calService = this.Service as CalendarService; 

            if (calService != null)
            {
                EventQuery query = new EventQuery(original.Href);
                EventFeed newFeed =  (EventFeed) calService.Query(query); 

                if (newFeed != null && newFeed.Entries != null)
                {
                    Tracing.Assert(newFeed.Entries.Count == 1, "There should be just one entry returned"); 
                    return newFeed.Entries[0] as EventEntry;  
                }
            }
            return null; 
        }