logo       

Re: Efficiently Deleteng All Events in a Calendar: msg#00280

org.google.api.calendar

Subject: Re: Efficiently Deleteng All Events in a Calendar



Jenyphur wrote:

>
> Can you post your code so I can see if we are doing things the same
> way? Thanks.
>

My code is very standard and as follows. One important point is that I
found it possible to make use of the ".NextChunk()" method; doing so
always returned a result that was incompatible with the query.Uri
property, so resulting in a run-time abort. In the end I just read all
the events in one go.

John

Precis of code:

string calendarURI = "myUrl";
string userName = "xxxxx@xxxxxxxxxxxxxx";
string passWord = "mypassword";

EventQuery query = new EventQuery();
CalendarService service = new
CalendarService(ApplicationName);

if (userName != null)
{
service.setUserCredentials(userName, passWord);
}

query.Uri = new Uri(calendarURI);
query.NumberToRetrieve=999;

EventFeed calFeed = service.Query(query);

DeleteEvents (calFeed, query, service);

private void DeleteEvents (EventFeed calFeed,
EventQuery query,
CalendarService service){
int i=0;
while (calFeed != null && calFeed.Entries.Count > 0)
{
foreach (EventEntry entry in calFeed.Entries){
i++;
Response.Write (i.ToString() + " Deleting: " + entry.Title.Text +
"<br />");
entry.Delete();
}
calFeed = null;
}
}




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise