saqibpitafi / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Problem deleting recurring event instance that occurs after 7pm #242

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create a weekly recurring event on April 3rd from 7pm to 9pm with no 
end date using the gdata calendar api's

2. Delete an single occurance from this recurring event in november 2009 
using the gdata api's. 

What is the expected output? What do you see instead?

The single occurance should be deleted from the google calendar. Instead, 
the following error is returned: 

"g:originalEvent [2009-12-12 00:00:00] does NOT correspond to an instance 
of the recurring event." 

or 

"g:originalEvent [2009-11-28 00:00:00] does NOT correspond to an instance 
of the recurring event"

Occurances that occur prior to november 2009 are deleted proplery without 
any errors. Also, recurring events that were originally created as allday 
events and/or switched to non-allday events work properly. It is only the 
case where a non-allday recurring event is created that this issue appears 
to occur. 

Please use labels and text to provide additional information.

Original issue reported on code.google.com by dlevins...@gmail.com on 21 Apr 2009 at 11:11

GoogleCodeExporter commented 9 years ago
The same thing happens to me no matter when the event is created, no matter the 
duration, or calendar on 
which it is created. It only happens with 7 pm events. 

Original comment by rabinowi...@gmail.com on 21 Apr 2009 at 11:18

GoogleCodeExporter commented 9 years ago
Can you post the code you are using for this to make it easier for me to repro 
this? 

Original comment by fman...@gmail.com on 23 Apr 2009 at 4:06

GoogleCodeExporter commented 9 years ago

Original comment by fman...@gmail.com on 23 Apr 2009 at 4:07

GoogleCodeExporter commented 9 years ago
// Get a weekly recurring event on April 3rd from 7pm 
// to 9pm with no  end date using the gdata calendar api's
EventEntry originalEntry = CalendarService.Get(url);

// Delete instance of the recurrence pattern 
exEventItem = new EventEntry();
exEventItem.OriginalEvent = new OriginalEvent();
exEventItem.OriginalEvent.OriginalStartTime = new When();
exEventItem.OriginalEvent.OriginalStartTime.AllDay = false;
exEventItem.OriginalEvent.OriginalStartTime.StartTime = new DateTime(2009, 11, 
11, 
19, 0, 0);
exEventItem.OriginalEvent.OriginalStartTime.EndTime = new DateTime(2009, 11, 
11, 21, 
0, 0);
exEventItem.OriginalEvent.Href = originalEntry.SelfUri.ToString();
exEventItem.OriginalEvent.IdOriginal = entry.Id

exEventItem.Delete()

Original comment by dlevins...@gmail.com on 30 Apr 2009 at 12:43

GoogleCodeExporter commented 9 years ago
Is anyone looking into/reviewing this issue? Is this an actual defect?  Was 
anyone 
able to confirm this issue. I can make this issue happen consistently. 

Original comment by dlevins...@gmail.com on 21 May 2009 at 12:03

GoogleCodeExporter commented 9 years ago
Sorry, i was sick for a while. Looking at your code and the behaviour, this 
looks like a service issue, the calendar 
is just not allowing you to delete instances that far in the future. Report 
this issue here:

http://code.google.com/p/gdata-issues/

and link this bug to it, so that they know i investigate this already. 

I will resolve this as a non issue, as i do not see the .NET client code doing 
anything wrong. 

Original comment by fman...@gmail.com on 22 May 2009 at 1:31

GoogleCodeExporter commented 9 years ago
I tried above code but I get error "No Service object set"

then I changed my code and include following line
exEventItem.Service = MasterEvent.Service;

After this I get following error
"Can not update a read-only entry"

After Googling around try to find the solution , I implemented following code
EventEntry exEventItem = new EventEntry();

exEventItem.OriginalEvent = new OriginalEvent();

exEventItem.OriginalEvent.OriginalStartTime = new When();

exEventItem.OriginalEvent.OriginalStartTime.StartTime = Date of occurrence

exEventItem.OriginalEvent.Href = EventEntry.SelfUri.ToString();

exEventItem.OriginalEvent.IdOriginal = ID; // This is a EventId of the Master 
Event

exEventItem.Status = EventEntry.EventStatus.CANCELED;

CalendarService.Insert(new 
Uri(http://www.google.com/calendar/feeds/default/private/full), exEventItem);

but I now am getting following error

The remote server returned an error: (403) Forbidden.

Execution of request failed: 
http://www.google.com/calendar/feeds/default/private/full

   at Google.GData.Client.GDataRequest.Execute()
   at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
   at Google.GData.Client.GDataGAuthRequest.Execute()
   at Google.GData.Client.Service.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
   at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
   at Google.GData.Client.Service.Insert[TEntry](Uri feedUri, TEntry entry)

Please help me solve this issue, as this is very critical for our project.

Original comment by tonydu...@gmail.com on 28 Dec 2010 at 10:44

GoogleCodeExporter commented 9 years ago
Hello Tony,

Can you print the body of the exception returned by the server? From my tests, 
it seems that "exEventItem" does not correspond to an occurrence of the 
recurring event.
If this is the case, can you give us the value of "Date of occurrence" and 
check if this is not due to daylight saving time.

Also, I would advise you to use "HTTPS" instead of "HTTP" when using any of 
Google Service API.

Best,
Alain 

Original comment by ala...@google.com on 29 Dec 2010 at 10:01

GoogleCodeExporter commented 9 years ago
Thank you Alain for the reply.

How do I print the body of the exception returned by the server? All I get is a 
C# exception which I have already mentioned.

I wonder if my approch is right. In other blog post 
(http://www.google.com/support/forum/p/apps-apis/thread?tid=73a2189e62e7ea08&hl=
en) am63 suggested that I should use RecurrenceExcption in order to delete 
single instance of recurring event.

Can one of you guys direct me to a sample code that works?

Thanks and I greatly appriciate your help.

Original comment by tonydu...@gmail.com on 29 Dec 2010 at 4:16

GoogleCodeExporter commented 9 years ago
I'm sorry, I don't have a MS Windows environment but by looking at the source 
code, I guess you can do something like this: 
Console.WriteLine(exception.ResponseString);

The way I created recurrence exception in Java was as follow:
[CODE]
    String eventID = "aj9i23l498p8d695183b9aco78";
    CalendarService service = new CalendarService("alainv-test-1.0");
    service.setUserCredentials(<USERNAME>, <PASSWORD>);

    CalendarEventEntry newEntry = new CalendarEventEntry();

    newEntry.setStatus(EventStatus.CANCELED);

    When originalEventTime = new When();
    DateTime startTime = DateTime.parseDateTime(<START-TIME OF THE EXCEPTION>);
    originalEventTime.setStartTime(startTime);

    OriginalEvent originalEvent = new OriginalEvent();
    originalEvent.setOriginalId(eventID);
    originalEvent.setOriginalStartTime(originalEventTime);

    // Set the Original Event
    newEntry.setOriginalEvent(originalEvent);

    service.insert(new URL("https://www.google.com/calendar/feeds/default/private/full"), newEntry);
[/CODE]

As you can see, it is very similar to the way you did it in C#. I also had a 
"403 Forbidden" error and it was due to the "startTime" not properly set:

g:originalEvent [<START-TIME>] does NOT correspond to an instance of the 
recurring event.

I hope this help!

Best,
Alain

Original comment by ala...@google.com on 29 Dec 2010 at 4:32

GoogleCodeExporter commented 9 years ago
Yes Alain you are right I was not setting the start time correctly. I fix the 
problem by converting the date to localTime. But now I am having different 
problem, here is the problem,
1.  I created weekly recurring event starting from 12/29/2010 10:11 am
2.  I delete single occurrence dated 01/05/2011 10:11am, works fine
3.  I delete single occurrence dated 01/12/2011 10:11am, works fine
4.  When I dele single occurrence dated 01/19/2011 10:11am, the dates from 
01/05/2011 shifted to previous date. And time is also changed from 10:11am to 
5:11pm
 Now my calendar event looks like
12/29/2010 5:11pm
01/04/2011 5:11pm
01/11/2011 5:11pm
01/18/2011 5:11 pm
01/25/2011 5:11 pm

I am attaching a jpeg image of my calendar view
Also here is the final code
        internal void DeleteOccurences(DateTime deleteDate, EventEntry masterEvent)
        {

            DateTime masterEventStartTime = masterEvent.Times[0].StartTime;

            DateTime calculatedDeleteDate = new DateTime(deleteDate.Year, deleteDate.Month, deleteDate.Day, masterEventStartTime.Hour, masterEventStartTime.Minute, masterEventStartTime.Second);

            //Delete instance of the recurrence pattern 

            EventEntry exEventItem = new EventEntry();
            exEventItem.OriginalEvent = new OriginalEvent();
            exEventItem.OriginalEvent.OriginalStartTime = new When();
            exEventItem.OriginalEvent.OriginalStartTime.StartTime = calculatedDeleteDate.ToLocalTime();
            exEventItem.OriginalEvent.Href = masterEvent.SelfUri.ToString();
            exEventItem.OriginalEvent.IdOriginal = masterEvent.EventId;
            exEventItem.Status = EventEntry.EventStatus.CANCELED;

            try
            {
                CalendarService.Insert(new Uri("https://www.google.com/calendar/feeds/{0}/private/full"), exEventItem);
            }
            catch { } // occurrence not found

        }

Original comment by tonydu...@gmail.com on 29 Dec 2010 at 6:13

Attachments:

GoogleCodeExporter commented 9 years ago
Oh, I found the problem. It was in my code. I was assigning localtime in one 
location and universal time on other while reading the entry from Google.
Thanks Alain for your support and help. The above code is now working like a 
charm.

Original comment by tonydu...@gmail.com on 29 Dec 2010 at 7:56

GoogleCodeExporter commented 9 years ago

Original comment by ccherub...@google.com on 30 Dec 2010 at 10:15