I have an app that first deletes events on a shared resource calendar, and 
then publishes new events to the same calendar.  Yesterday the app worked 
fine.  Today, i get an IOException error 'Unable to write data to the 
transport connection: An established connection was aborted by the software 
in your host machine.'  at the Publish feed line.  I made no changes to the 
code.  I am doing the delete and the publish via the batch procedures.  I 
am using domain admin credentials.  The calendar is there and the Uri has 
not changed.  Here is my code (sans credentials):

static void DeleteEvents()
        {
            //Create connection to gerenuk google calendar
            CalendarService myService = new CalendarService("appname");
            myService.setUserCredentials(userName, userPassword);
  
            // Get some events to operate on.
            EventQuery delquery = new EventQuery(feedUri);
            delquery.StartDate = DateTime.Today.AddMonths(-3);
            delquery.EndDate = DateTime.Today.AddMonths(3);
            delquery.NumberToRetrieve = 5000;
            EventFeed delfeed = myService.Query(delquery);

            // Add the entries to a new feed.
            AtomFeed delbatchFeed = new AtomFeed(delfeed);

            //Batch delete of existing gerenuk entries
            foreach (AtomEntry entry in delfeed.Entries)
            {
                
                entry.Id = new AtomId(entry.EditUri.ToString());
                entry.BatchData = new 
GDataBatchEntryData(GDataBatchOperationType.delete);

                delbatchFeed.Entries.Add(entry);
            }

            //Publish the feed back to the calendar
            EventFeed delbatchResultFeed = 
(EventFeed)myService.Batch(delbatchFeed, new Uri(delfeed.Batch));

            //check the return values of the batch operations to make sure 
they all worked.
            //the insert operation should return a 201 and the rest should 
return 200
            //Maybe create a log file?
            bool success = true;
            foreach (EventEntry entry in delbatchResultFeed.Entries)
            {
                if (entry.BatchData.Status.Code != 200 && 
entry.BatchData.Status.Code != 201)
                {
                    success = false;
                    Console.WriteLine("The Delete batch operation with ID " 
+
                        entry.BatchData.Id + " failed.");
                    
                }
            }

            if (success)
            {
                Console.WriteLine("All Delete batch operations 
successful!");
            }



        }

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to