public CalendarEvent(GoogleCalendarCredentials credentials, AtomEntry entry)
 {
     Invitees = new List<CalendarEventInvitee>();
     Reminders = new List<CalendarEventReminder>();
     _credentials = credentials;
     _setContstructor((EventEntry)entry);
 }
Example #2
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a new, in memory atom entry</summary> 
        /// <returns>the new AtomEntry </returns>
        //////////////////////////////////////////////////////////////////////
        public static AtomEntry CreateAtomEntry(int iCount)
        {
            AtomEntry entry = new AtomEntry();
            // some unicode chars
            Char[] chars = new Char[] {
            '\u0023', // #
            '\u0025', // %
            '\u03a0', // Pi
            '\u03a3',  // Sigma
            '\u03d1', // beta
            '&',
            };

            AtomPerson author = new AtomPerson(AtomPersonType.Author);
            author.Name = "John Doe" + chars[0] + chars[1] + chars[2] + chars[3] + chars[4] + chars[5]; 
            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.Content.Type = "html"; 
            entry.Published = new DateTime(2001, 11, 20, 22, 30, 0);  
            entry.Title.Text = "This is a entry number: " + iCount;
            entry.Updated = DateTime.Now; 

    
            return entry;
        }
        private static void GetPageViews(AtomEntry Account)
        {
            string ProfileID = Account.Id.AbsoluteUri.Substring(47);
            DataFeedUrl = "https://www.google.com/analytics/feeds/data";

            DataQuery PageViewQuery = new DataQuery(DataFeedUrl)
            {
                Ids = ProfileID,
                Dimensions = "ga:date",
                Metrics = "ga:pageviews",
                Sort = "ga:date",
                GAStartDate = (DateTime.Now).AddDays(-7).ToString("yyyy-MM-dd"),
                GAEndDate = (DateTime.Now).ToString("yyyy-MM-dd")
            };

            DataFeed Results = Service.Query(PageViewQuery);

            foreach (AtomEntry Result in Results.Entries)
            {
                DataEntry Entry = (DataEntry)Result;

                Console.WriteLine(String.Format("{0}\t{1}",
                    Entry.Title.Text.Split('=')[1],
                    Entry.Metrics[0].Value));
            }
        }
Example #4
0
        public SpreadsheetsService GetSpreadsheetService()
        {
            if (_service == null)
            {
                DoAuth();

                // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
                SpreadsheetQuery query = new SpreadsheetQuery();
                query.Title = "Test Monkey";

                // Make a request to the API and get all spreadsheets.
                SpreadsheetFeed feed = null;
                try
                {
                    feed = _service.Query(query);
                }
                catch (Exception ex)
                {
                }

                // Iterate through all of the spreadsheets returned
                var spreadsheet = feed.Entries.Single();

                // Make a request to the API to fetch information about all
                // worksheets in the spreadsheet.
                var wsFeed = ((SpreadsheetEntry)spreadsheet).Worksheets;

                _toProcessSheet = ((WorksheetFeed)wsFeed).Entries.Single(x => x.Title.Text.Equals("To Process"));
                _processedSheet = ((WorksheetFeed)wsFeed).Entries.Single(x => x.Title.Text.Equals("Processed"));
                _everythingSheet = ((WorksheetFeed)wsFeed).Entries.Single(x => x.Title.Text.Equals("Everything"));
            }

            return _service;
        }
 private static void AddPostLabels(AtomEntry newPost, PostDetails genericPostDetails)
 {
     foreach (string postLabels in genericPostDetails.Labels)
     {
         newPost.Categories.Add(new AtomCategory(postLabels, "http://www.blogger.com/atom/ns#"));
     }
 }
Example #6
0
        public void AddHome(Home home)
        {
            var service = CreateService();
            var entry = new AtomEntry();
            entry.Title.Text = "Home Zope House";
            entry.Content.Type = "application/vnd.google-earth.kml+xml";
            XmlDocument doc = new XmlDocument();
            string placeMark = string.Format(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
                   <name>HomeZope Home</name>
                   <description/>
                   <Point>
                     <coordinates>{0},{1},0.0</coordinates>
                   </Point>
                 </Placemark>", home.Longitude, home.Latitude);
            doc.LoadXml(placeMark);
            entry.Content.ExtensionElements.Add(new XmlExtension(doc.DocumentElement));

            var insertedEntry = service.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);
            home.GoogleFeatureId = insertedEntry.Id.Uri.ToString();

            //var m = new MemoryStream();
            //insertedEntry.SaveToXml(m);
            //m.Position = 0;
            //var xml = new StreamReader(m).ReadToEnd();
        }
Example #7
0
 private AsyncSendData(AsyncDataHandler handler, Uri uriToUse, AtomEntry entry, AtomFeed feed,
     SendOrPostCallback callback, object userData, bool parseFeed)
     : base(uriToUse, null, userData, callback, parseFeed) {
     this.DataHandler = handler;
     this.entry = entry;
     this.Feed = feed;
 }
        public void Index()
        {
            var g = new Service("local", "application");//, "ABQIAAAACPMbozlNv9AIzNvsWUm6vhSvnLMDprvOSMH9Qt_oH5Ww7FTw1hRHT7gTSie1yM34rowNwVfw424XPA");

            Assert.Fail("Need to put password here");
            g.setUserCredentials("*****@*****.**", "zzz");
            var entry = new AtomEntry();
            entry.Content.ExtensionFactories.Add(new MapsExtension());
            entry.Title.Text = "test";
               entry.Content.Type = "application/vnd.google-earth.kml+xml";
               XmlDocument doc = new XmlDocument();
            doc.LoadXml(@"<Placemark xmlns='http://www.opengis.net/kml/2.2'>
                   <name>Faulkner's Birthplace</name>
                   <description/>
                   <Point>
                     <coordinates>-89.520753,34.360902,0.0</coordinates>
                   </Point>
                 </Placemark>");
            entry.Content.ExtensionElements.Add(new XmlExtension((XmlNode)doc.DocumentElement));
                 //    doc.LoadXml(@"@"<m:Placemark>
                 //  <m:name>Faulkner's Birthplace</m:name>
                 //  <m:description/>
                 //  <m:Point>
                 //    <m:coordinates>-89.520753,34.360902,0.0</m:coordinates>
                 //  </m:Point>
                 //</m:Placemark>";

            //entry.Content.Content = ;
            //entry.AddExtension(new MapsExtension());
            var m = new MemoryStream();
            //var mapStuff = entry.Content.CreateExtension("PlaceMark", "http://www.opengis.net/kml/2.2");

               // entry.Update();
            try
            {
                entry.SaveToXml(m);
            }
            catch (Exception e)
            {
                var s = e.ToString();
                throw;
            }
            m.Position = 0;
            var mm = new StreamReader(m).ReadToEnd();
             var q = g.Insert(new Uri("http://maps.google.com/maps/feeds/features/208433541473729117510/0004779109f86bbabd62d/full"), entry);

            var p = g.Query(new Uri("http://maps.google.com/maps/feeds/maps/default/full"));

            var z = new StreamReader(p).ReadToEnd();

            //// Arrange
            //HomeController controller = new HomeController();

            //// Act
            //ViewResult result = controller.Index() as ViewResult;

            //// Assert
            //ViewDataDictionary viewData = result.ViewData;
            //Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
        }
 /// <summary>constructor for the feedParser events</summary> 
 /// <param name="feed">the feed to use </param>
 /// <param name="entry">the feedentry to use </param> 
 public FeedParserEventArgs(AtomFeed feed, AtomEntry entry) {
     this.feedEntry = entry;
     this.feed = feed;
     if (feed == null && entry == null) {
         this.done = true;
     }
 }
Example #10
0
        /** Creates a new blog entry and sends it to the specified Uri */
        static AtomEntry PostNewEntry(Service service, Uri blogPostUri)
        {
            Console.WriteLine("\nPublishing a blog post");
            AtomEntry createdEntry = null;
            if (blogPostUri != null)
            {
                // construct the new entry
                AtomEntry newPost = new AtomEntry();
                newPost.Title.Text = "Marriage!";
                newPost.Content = new AtomContent();
                newPost.Content.Content = "<div xmlns='http://www.w3.org/1999/xhtml'>" +
                    "<p>Mr. Darcy has <em>proposed marriage</em> to me!</p>" +
                    "<p>He is the last man on earth I would ever desire to marry.</p>" +
                    "<p>Whatever shall I do?</p>" +
                    "</div>";
                newPost.Content.Type = "xhtml";
                newPost.Authors.Add(new AtomPerson());
                newPost.Authors[0].Name = "Elizabeth Bennet";
                newPost.Authors[0].Email = "*****@*****.**";

                createdEntry = service.Insert(blogPostUri, newPost);
                if (createdEntry != null)
                {
                    Console.WriteLine("  New blog post created with title: " + createdEntry.Title.Text);
                }
            }
            return createdEntry;
        }
Example #11
0
        public static AtomEntryCollection GetSheetNames(SpreadsheetsService zSpreadsheetService, AtomEntry zSheetEntry)
        {
            var link = zSheetEntry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

            var wsquery = new WorksheetQuery(link.HRef.ToString());
            var wsfeed = zSpreadsheetService.Query(wsquery);
            return wsfeed.Entries;
        }
 public void UpdatedTest()
 {
     AtomEntry target = new AtomEntry(); 
     DateTime expected = DateTime.Now; 
     DateTime actual;
     target.Updated = expected;
     actual = target.Updated;
     Assert.AreEqual(expected, actual);
 }
Example #13
0
        /// <summary>
        /// constructor. takes the async data blob
        /// </summary>
        /// <param name="data">async data to constructor</param>
        internal AsyncOperationCompletedEventArgs(AsyncData data)
            : base(data.Exception, false, data.UserData) {
            feedObject = data.Feed;
            stream = data.DataStream;

            IAsyncEntryData entryData = data as IAsyncEntryData;
            if (entryData != null) {
                entryObject = entryData.Entry;
            }
        }
		public static Profile FromAtomEntry(AtomEntry entry)
		{
			Profile profile = new Profile();
			profile.ID = entry.Content.Content;
			profile.Name = entry.Title.Text;
			profile.Authors = new List<Author>();
			foreach (AtomPerson person in entry.Authors)
			{
				profile.Authors.Add(Author.FromAtomPerson(person));
			}

			return profile;
		}
Example #15
0
        public void PublishNewEntry(BlogDescriptor blogDescriptor, String title, String content)
        {
            if (blogDescriptor == null)
                throw new ArgumentNullException("blogDescriptor");
            if (String.IsNullOrEmpty(blogDescriptor.Username))
                throw new ArgumentException("blogDescriptor.Username cannot be null or an empty string.");

            var entry = new gClient.AtomEntry();
            entry.Content.Content = content;
            entry.Content.Type = "html";
            entry.Title.Text = title;

            var service = new gClient.Service("blogger", GoogleSucks.GetApplicationName());
            service.Credentials = new gClient.GDataCredentials(blogDescriptor.Username, blogDescriptor.Password);
            service.Insert(new Uri(GetFeedUri(blogDescriptor)), entry);
        }
		public static Notice FromAtomEntry(AtomEntry entry)
		{
			Notice notice = new Notice();
			notice.DatePublished = entry.Published;
			notice.DateUpdated = entry.Updated;
			notice.Id = entry.Id.Uri.Content;
			notice.ContentType = entry.Content.Type;
			notice.Content = entry.Content.Content;
			notice.Subject = entry.Title.Text;
			IExtensionElementFactory factory = entry.FindExtension("ContinuityOfCareRecord", "urn:astm-org:CCR");
			if (factory != null)
			{
				XmlExtension extension = factory as XmlExtension;
				XmlSerializer serializer = new XmlSerializer(typeof(ContinuityOfCareRecord));
				XmlTextReader reader = new XmlTextReader(new StringReader(extension.Node.OuterXml));
				notice.CareRecord = serializer.Deserialize(reader) as ContinuityOfCareRecord;
			}
			return notice;
		}
Example #17
0
        public void PublishNewEntry(BlogDescriptor blogDescriptor, String title, String content)
        {
            if (blogDescriptor == null)
            {
                throw new ArgumentNullException("blogDescriptor");
            }
            if (String.IsNullOrEmpty(blogDescriptor.Username))
            {
                throw new ArgumentException("blogDescriptor.Username cannot be null or an empty string.");
            }

            var entry = new gClient.AtomEntry();

            entry.Content.Content = content;
            entry.Content.Type    = "html";
            entry.Title.Text      = title;

            var service = new gClient.Service("blogger", GoogleSucks.GetApplicationName());

            service.Credentials = new gClient.GDataCredentials(blogDescriptor.Username, blogDescriptor.Password);
            service.Insert(new Uri(GetFeedUri(blogDescriptor)), entry);
        }
Example #18
0
        /// <summary>eventhandler - called for event extension element
        /// </summary>
        /// <param name="sender">the object which send the event</param>
        /// <param name="e">FeedParserEventArguments, holds the feedEntry</param>
        /// <returns> </returns>
        protected void OnNewExtensionsElement(object sender, ExtensionElementEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            AtomFeedParser parser = sender as AtomFeedParser;

            if (e.Base.XmlName == AtomParserNameTable.XmlAtomEntryElement)
            {
                // the base is the Entry of the feed, let's call our parsing on the Entry
                AtomEntry entry = e.Base as AtomEntry;
                if (entry != null)
                {
                    entry.Parse(e, parser);
                }
            }
            else
            {
                HandleExtensionElements(e, parser);
            }
        }
Example #19
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>helper method to create a new, decoupled entry based on a feedEntry</summary>
        /// <param name="entryToImport">the entry from a feed that you want to put somewhere else</param>
        /// <returns> the new entry ready to be inserted</returns>
        //////////////////////////////////////////////////////////////////////
        public static AtomEntry ImportFromFeed(AtomEntry entryToImport)
        {
            Tracing.Assert(entryToImport != null, "entryToImport should not be null");
            if (entryToImport == null)
            {
                throw new ArgumentNullException("entryToImport");
            }
            AtomEntry entry = null;

            entry = (AtomEntry)Activator.CreateInstance(entryToImport.GetType());
            entry.CopyEntry(entryToImport);

            entry.Id = null;

            // if the source is empty, set the source to the old feed

            if (entry.Source == null)
            {
                entry.Source = entryToImport.Feed;
            }
            Tracing.TraceInfo("Imported entry: " + entryToImport.Title.Text + " to: " + entry.Title.Text);
            return(entry);
        }
Example #20
0
        /// <summary>public WebResponse Insert(Uri insertUri, Stream entryStream, ICredentials credentials)</summary>
        /// <param name="feed">the feed this entry should be inserted into</param>
        /// <param name="entry">the entry to be inserted</param>
        /// <returns> the inserted entry</returns>
        AtomEntry IService.Insert(AtomFeed feed, AtomEntry entry)
        {
            Tracing.Assert(feed != null, "feed should not be null");
            if (feed == null)
            {
                throw new ArgumentNullException("feed");
            }

            Tracing.Assert(entry != null, "entry should not be null");
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (feed.ReadOnly)
            {
                throw new GDataRequestException("Can not update a read-only feed");
            }

            Tracing.TraceMsg("Post URI is: " + feed.Post);
            Uri target = new Uri(feed.Post);

            return(Insert(target, entry));
        }
Example #21
0
        static public 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);
            }
        }
        /// <summary>
        /// parses the current position in the xml reader and fills 
        /// the provided GDataEntryBatch property on the entry object 
        /// </summary>
        /// <param name="reader">the xmlreader positioned at a batch element</param>
        /// <param name="entry">the atomentry object to fill in</param>
        protected void ParseBatch(XmlReader reader, AtomEntry entry) {
            if (reader == null) {
                throw new ArgumentNullException("reader");
            }
            if (entry == null) {
                throw new ArgumentNullException("entry");
            }

            if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace)) {
                object elementName = reader.LocalName;

                if (entry.BatchData == null) {
                    entry.BatchData = new GDataBatchEntryData();
                }

                GDataBatchEntryData batch = entry.BatchData;

                if (elementName.Equals(this.nameTable.BatchId)) {
                    batch.Id = Utilities.DecodedValue(reader.ReadString());
                } else if (elementName.Equals(this.nameTable.BatchOperation)) {
                    batch.Type = ParseOperationType(reader);
                } else if (elementName.Equals(this.nameTable.BatchStatus)) {
                    batch.Status = GDataBatchStatus.ParseBatchStatus(reader, this);
                } else if (elementName.Equals(this.nameTable.BatchInterrupt)) {
                    batch.Interrupt = GDataBatchInterrupt.ParseBatchInterrupt(reader, this);
                } else {
                    Tracing.TraceInfo("got an unknown batch element: " + elementName.ToString());
                    // default extension parsing
                    ParseExtensionElements(reader, entry);
                }
            }
        }
Example #23
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchDelete()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchDelete");

            FeedQuery query = new FeedQuery();
            Service service = new GBaseService(this.ApplicationName, this.gBaseKey);


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

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);

                Tracing.TraceMsg("Queried");

                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI"); 


                AtomFeed batchFeed = new AtomFeed(new Uri(this.gBaseURI), service);

                // set the default operation. 
                batchFeed.BatchData = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.delete; 

                Tracing.TraceMsg("Pouet ?");

                int i = 1; 
                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    AtomEntry batchEntry = new AtomEntry(); 
                    batchEntry.Id = entry.Id; 

                    batchEntry.BatchData = new GDataBatchEntryData();
                    batchEntry.BatchData.Id = i.ToString(); 
                    batchEntry.BatchData.Type = GDataBatchOperationType.delete; 

                    batchFeed.Entries.Add(batchEntry); 
                    i++; 
                }
                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));
                foreach (AtomEntry resultEntry in resultFeed.Entries )
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 200, "Status code should be 200, is:" + data.Status.Code);
                }
            }
        }
Example #24
0
        /////////////////////////////////////////////////////////////////////////////


       //////////////////////////////////////////////////////////////////////
       /// <summary>compares two atomEntrys to see if they are identical objects</summary> 
       /// <param name="theOne">the first AtomEntry </param>
       /// <param name="theOther">the other AtomEntry to compare with </param> 
       /// <returns>true if equal </returns>
       //////////////////////////////////////////////////////////////////////
       public static bool IsEntryIdentical(AtomEntry theOne, AtomEntry theOther)
       {
           Tracing.TraceMsg("Entering IsEntryIdentical"); 

           if (theOne == null || theOther == null)
           {
               return theOne == theOther; 
           }

           Tracing.TraceMsg("Comparing AuthorCollection"); 
           if (ObjectModelHelper.IsPersonCollectionIdentical(theOne.Authors, theOther.Authors)==false)
           {
               return false;
           }
           Tracing.TraceMsg("Comparing ContributorCollection"); 
           if (ObjectModelHelper.IsPersonCollectionIdentical(theOne.Contributors, theOther.Contributors)==false)
           {
               return false;
           }
           Tracing.TraceMsg("Comparing CategoryCollection"); 
           if (ObjectModelHelper.IsCategoryCollectionIdentical(theOne.Categories, theOther.Categories)==false)
           {
               return false;
           }
           Tracing.TraceMsg("Comparing LinkCollection"); 
           if (ObjectModelHelper.IsLinkCollectionIdentical(theOne.Links, theOther.Links)==false)
           {
               return false;
           }

           Tracing.TraceMsg("Comparing Content"); 
           if (ObjectModelHelper.IsContentIdentical(theOne.Content, theOther.Content)==false)
           {
               return false;
           }

           Tracing.TraceMsg("Comparing Source"); 
           if (ObjectModelHelper.IsSourceIdentical(theOne.Source, theOther.Source)==false)
           {
               return false;
           }

           Tracing.TraceMsg("Comparing Summary"); 
           if (ObjectModelHelper.IsTextConstructIdentical(theOne.Summary, theOther.Summary)==false)
           {
               return false;
           }

           Tracing.TraceMsg("Comparing Title"); 
           if (ObjectModelHelper.IsTextConstructIdentical(theOne.Title, theOther.Title)==false)
           {
               return false;
           }
           Tracing.TraceMsg("Comparing Rights"); 
           if (ObjectModelHelper.IsTextConstructIdentical(theOne.Rights, theOther.Rights)==false)
           {
               return false;
           }

           Tracing.TraceMsg("Comparing BaseLink"); 
           if (ObjectModelHelper.IsBaseLinkIdentical(theOne.Id, theOther.Id)==false)
           {
               return false;
           }
           /*
           if (System.DateTime.Compare(theOne.Published, theOther.Published) != 0)
           {
               return false;
           }
           if (System.DateTime.Compare(theOne.Updated,theOther.Updated) != 0)
           {
               return false;
           }
           */

           Tracing.TraceMsg("Exiting IsEntryIdentical"); 


           return true;
       }
Example #25
0
 static bool findLootWorkSheet(AtomEntry e)
 {
     return e.Title.Text.Equals("RainOfFearLoot", StringComparison.InvariantCultureIgnoreCase);
 }
Example #26
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>overloaded to make it easier to fire the event</summary> 
        /// <param name="newEntry">the new AtomEntry to fire </param>
        //////////////////////////////////////////////////////////////////////
        protected void OnNewAtomEntry(AtomEntry newEntry)
        {
            FeedParserEventArgs args = new FeedParserEventArgs(null, newEntry);
            this.OnNewAtomEntry(args);

        }
Example #27
0
        /// <summary>takes the updated entry returned and sets the properties to this object</summary> 
        /// <param name="updatedEntry"> </param>
        protected void CopyEntry(AtomEntry updatedEntry) {
            Tracing.Assert(updatedEntry != null, "updatedEntry should not be null");
            if (updatedEntry == null) {
                throw new ArgumentNullException("updatedEntry");
            }

            this.title = updatedEntry.Title;
            this.authors = updatedEntry.Authors;
            this.id = updatedEntry.Id;
            this.links = updatedEntry.Links;
            this.lastUpdateDate = updatedEntry.Updated;
            this.publicationDate = updatedEntry.Published;
            this.authors = updatedEntry.Authors;
            this.rights = updatedEntry.Rights;
            this.categories = updatedEntry.Categories;
            this.summary = updatedEntry.Summary;
            this.content = updatedEntry.Content;
            this.source = updatedEntry.Source;

            this.ExtensionElements.Clear();

            foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements) {
                this.ExtensionElements.Add(extension);
            }
        }
Example #28
0
 public AsyncDeleteData(AtomEntry entry, bool permanentDelete, object userData, SendOrPostCallback callback)
     : base(null, userData, callback) {
     _entry = entry;
     _permanentDelete = permanentDelete;
 }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>overloaded to make it easier to fire the event</summary>
        /// <param name="newEntry">the new AtomEntry to fire </param>
        //////////////////////////////////////////////////////////////////////
        protected void OnNewAtomEntry(AtomEntry newEntry)
        {
            FeedParserEventArgs args = new FeedParserEventArgs(null, newEntry);

            this.OnNewAtomEntry(args);
        }
Example #30
0
 /// <summary>deletes an Atom entry object</summary>
 /// <param name="entry"> </param>
 public void Delete(AtomEntry entry)
 {
     Delete(entry, false);
 }
Example #31
0
 /// <summary>Inserts an AtomBase entry against a Uri</summary>
 /// <param name="feedUri">the uri for the feed this object should be posted against</param>
 /// <param name="baseEntry">the entry to be inserted</param>
 /// <param name="type">the type of request to create</param>
 /// <returns> the response as a stream</returns>
 public Stream EntrySend(Uri feedUri, AtomEntry baseEntry, GDataRequestType type)
 {
     return(this.EntrySend(feedUri, baseEntry, type, null));
 }
Example #32
0
 /// <summary>
 /// internal Insert version to avoid recursion in the template versions
 /// </summary>
 /// <param name="feedUri"></param>
 /// <param name="newEntry"></param>
 /// <returns></returns>
 protected AtomEntry internalInsert(Uri feedUri, AtomEntry newEntry)
 {
     return(this.Insert(feedUri, newEntry, null));
 }
        public void DeleteAsync(AtomEntry entry, bool permanentDelete, Object userData)
        {
            AsyncDeleteData data = new AsyncDeleteData(entry, permanentDelete, userData, ProgressReportDelegate);

            AsyncStarter(data, AsyncDeleteWorker, userData);
        }
Example #34
0
 /// <summary>
 /// updates the entry asynchronous, you need to supply a valid and unique
 /// token. Events will be send to the async delegates you setup on the service
 /// object
 /// </summary>
 /// <param name="entry"></param>
 /// <param name="userData">a unique identifier to associate this request with</param>
 /// <returns></returns>
 public void UpdateAsync(AtomEntry entry, Object userData) {
     AsyncSendData data = new AsyncSendData(this, entry, this.ProgressReportDelegate, userData);
     WorkerSendEventHandler workerDelegate = new WorkerSendEventHandler(AsyncUpdateWorker);
     this.AsyncStarter(data, workerDelegate, userData);
 }
Example #35
0
        /// <summary>helper method to create a new, decoupled entry based on a feedEntry</summary> 
        /// <param name="entryToImport">the entry from a feed that you want to put somewhere else</param>
        /// <returns> the new entry ready to be inserted</returns>
        public static AtomEntry ImportFromFeed(AtomEntry entryToImport) {
            Tracing.Assert(entryToImport != null, "entryToImport should not be null");
            if (entryToImport == null) {
                throw new ArgumentNullException("entryToImport");
            }

            AtomEntry entry = null;
            entry = (AtomEntry)Activator.CreateInstance(entryToImport.GetType());
            entry.CopyEntry(entryToImport);

            entry.Id = null;

            // if the source is empty, set the source to the old feed

            if (entry.Source == null) {
                entry.Source = entryToImport.Feed;
            }
            Tracing.TraceInfo("Imported entry: " + entryToImport.Title.Text + " to: " + entry.Title.Text);
            return entry;
        }
Example #36
0
 /// <summary>
 /// inserts the entry asynchronous, you need to supply a valid and unique
 /// token. Events will be send to the async delegates you setup on the service
 /// object
 /// </summary>
 /// <param name="feedUri">the target feed the entry get's inserted into</param>
 /// <param name="entry"></param>
 /// <param name="userData">a unique identifier to associate this request with</param>
 /// <returns></returns>
 public void InsertAsync(Uri feedUri, AtomEntry entry, Object userData) {
     AsyncSendData data = new AsyncSendData(this, feedUri, entry, this.ProgressReportDelegate, userData);
     WorkerSendEventHandler workerDelegate = new WorkerSendEventHandler(AsyncInsertWorker);
     this.AsyncStarter(data, workerDelegate, userData);
 }
 public AsyncDeleteData(AtomEntry entry, bool permanentDelete, object userData, SendOrPostCallback callback)
     : base(null, userData, callback)
 {
     _entry           = entry;
     _permanentDelete = permanentDelete;
 }
 public AsyncSendData(AsyncDataHandler handler, AtomEntry entry, SendOrPostCallback callback, object userData)
     : this(handler, null, entry, null, callback, userData, false)
 {
 }
Example #39
0
 static bool findArmorTypesWorkSheet(AtomEntry e)
 {
     return e.Title.Text.Equals("Constants", StringComparison.InvariantCultureIgnoreCase);
 }
Example #40
0
 public void DeleteAsync(AtomEntry entry, bool permanentDelete, Object userData) {
     AsyncDeleteData data = new AsyncDeleteData(entry, permanentDelete, userData, ProgressReportDelegate);
     AsyncStarter(data, AsyncDeleteWorker, userData);
 }
 public void EntryTest()
 {
     FeedParserEventArgs target = new FeedParserEventArgs(); // TODO: Initialize to an appropriate value
     AtomEntry expected = new AtomEntry();
     AtomEntry actual;
     target.Entry = expected;
     actual = target.Entry;
     Assert.AreEqual(expected, actual);
 }
Example #42
0
 public AsyncSendData(AsyncDataHandler handler, AtomEntry entry, SendOrPostCallback callback, object userData)
     : this(handler, null, entry, null, callback, userData, false) {
 }
        /// <summary>reads one of the feed entries at a time</summary>
        /// <param name="reader"> XmlReader positioned at the entry element</param>
        /// <returns> notifies user using event mechanism</returns>
        public void ParseEntry(XmlReader reader)
        {
            Tracing.Assert(reader != null, "reader should not be null");
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            object localname = reader.LocalName;

            Tracing.TraceCall("Parsing atom entry");
            if (localname.Equals(this.nameTable.Entry) == false)
            {
                throw new ClientFeedException("trying to parse an atom entry, but reader is not at the right spot");
            }

            AtomEntry entry = OnCreateNewEntry();

            ParseBasicAttributes(reader, entry);

            // remember the depth of entry
            int depth = -1;

            while (NextChildElement(reader, ref depth))
            {
                localname = reader.LocalName;

                if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom))
                {
                    if (localname.Equals(this.nameTable.Id))
                    {
                        entry.Id = entry.CreateAtomSubElement(reader, this) as AtomId;
                        ParseBaseLink(reader, entry.Id);
                    }
                    else if (localname.Equals(this.nameTable.Link))
                    {
                        entry.Links.Add(ParseLink(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Updated))
                    {
                        entry.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Published))
                    {
                        entry.Published = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture);
                    }
                    else if (localname.Equals(this.nameTable.Author))
                    {
                        entry.Authors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Contributor))
                    {
                        entry.Contributors.Add(ParsePerson(reader, entry));
                    }
                    else if (localname.Equals(this.nameTable.Rights))
                    {
                        entry.Rights = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Category))
                    {
                        AtomCategory category = ParseCategory(reader, entry);
                        entry.Categories.Add(category);
                    }
                    else if (localname.Equals(this.nameTable.Summary))
                    {
                        entry.Summary = ParseTextConstruct(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Content))
                    {
                        entry.Content = ParseContent(reader, entry);
                    }
                    else if (localname.Equals(this.nameTable.Source))
                    {
                        entry.Source = entry.CreateAtomSubElement(reader, this) as AtomSource;
                        ParseSource(reader, entry.Source);
                    }
                    else if (localname.Equals(this.nameTable.Title))
                    {
                        entry.Title = ParseTextConstruct(reader, entry);
                    }
                    // all parse methods should leave the reader at the end of their element
                    reader.Read();
                }
                else if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
                {
                    // parse the google batch extensions if they are there
                    ParseBatch(reader, entry);
                }
                else
                {
                    // default extension parsing
                    ParseExtensionElements(reader, entry);
                }
            }
            OnNewAtomEntry(entry);

            return;
        }
Example #44
0
 /// <summary>WebResponse Update(Uri updateUri, Stream entryStream, ICredentials credentials)</summary>
 /// <param name="entry">the old entry to update</param>
 /// <returns> the new Entry, as returned from the server</returns>
 public AtomEntry Update(AtomEntry entry)
 {
     return(this.Update(entry, null));
 }