不能减少事件的序列号 [英] Cannot Decrease the Sequence Number of an Event

查看:122
本文介绍了不能减少事件的序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

起初,我认为以下错误是日期/时间问题,但经过进一步检查,似乎与设置标题有关> CalendarEvent :

  [14-05-08 16:47:26:183 EDT] CalendarEvent .setTitle([HOLD:TES 101-01,Test,10  -  Test Training(1 of 1)])[0.067 seconds] 
[14-05-08 16:47:26:189 EDT]执行失败:服务错误:CalendarApp:无法减少事件的序号(第374行,保存更改文件)[总运行时间为1.245秒]

和脚本的第374行如下:

  eventToUpdate.setTitle(title); 

变量很好 - eventToUpdate (when记录)是 CalendarEvent 对象,所以 setTitle(title)应该可以正常工作。 title 变量包含一个字符串,如执行脚本中的错误所示。



最近开始发生这种情况,没有对代码进行任何更改。我创建了一些函数来测试标题更改,事实证明,只有当事件的时间发生更改时才会发生此错误,而如果时间为,则仅发生错误 在标题改变之前改变了。如果之后改变了标题,那么不会有错误。请参阅以下代码:

  function eventTitleChangeTest(){
var calStart = new Date(Thu May 08 17: 00:00 GMT-04:00 2014);
var calEnd = new Date(Thu May 08 18:00:00 GMT-04:00 2014);
var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];

var event = calendar.createEvent(Temporary Title,calStart,calEnd);
var eventID = event.getId();
Logger.log(event.getTitle());
changeTitleById(eventID);
changeTitleByTime(calStart,calEnd);
}

function changeTitleById(id){
var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
var event = calendar.getEventSeriesById(id);
event.setTitle(基于ID的标题更改);
Logger.log(event.getTitle());
}

function changeTitleByTime(start,end){
var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
var events = calendar.getEvents(start,end);
var eventToChange = events [0];
//下面一行是问题(它在标题更改之前)
eventToChange.setTime(new Date(Wed May 07 17:00:00 GMT-04:00 2014),new日期(2014年5月17日17:00:00 GMT-04:00 2014));
eventToChange.setTitle(基于时间的标题更改);
//但如果我改变标题后的时间,它的工作没有问题。但为什么?
//eventToChange.setTime(新日期(2014年5月17日17:00:00 GMT-04:00 2014),新日期(2014年5月17日17:00:00 GMT-04:00 ));
Logger.log(eventToChange.getTitle());
}

function deleteEvent(id){
var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
calendar.getEventSeriesById(id).deleteEventSeries();
}

所以问题是:为什么改变日期/时间a CalendarEvent 在更改标题之前导致此错误?



随后,是否是一个错误?

序列号,请参阅
http://tools.ietf.org/ html / rfc5545#section-3.8.7.4


您应该始终使用当前序列号修改事件的最新版本。在这种情况下,我假设在每个设置者之后立即将更改传播到服务器。这意味着您可以尝试在第一次修改后重新获取eventToChange,然后再进行下一次修改。


At first I thought the following error was a date/time problem, but upon further inspection it seems to be related to setting the title of a CalendarEvent:

[14-05-08 16:47:26:183 EDT] CalendarEvent.setTitle([HOLD: TES 101-01, Test, 10 -- Test Training (1 of 1)]) [0.067 seconds]
[14-05-08 16:47:26:189 EDT] Execution failed: Service error: CalendarApp: Cannot decrease the sequence number of an event (line 374, file "Save Changes") [1.245 seconds total runtime]

and line 374 of the script is the following:

eventToUpdate.setTitle(title);

The variables are fine - eventToUpdate (when logged) is a CalendarEvent object, so setTitle(title) should work fine. The title variable contains a string, as shown in the error from the Execution Transcript.

This started happening recently, without any changes to the code. I created a few functions to test title-changes, and it turns out that the error only occurs when the time of the event is also changed, and only if the time is changed before the title is changed. If the time is changed after the title is changed, there is no error. See the following code:

function eventTitleChangeTest() {
  var calStart = new Date("Thu May 08 17:00:00 GMT-04:00 2014");
  var calEnd = new Date("Thu May 08 18:00:00 GMT-04:00 2014");
  var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];

  var event = calendar.createEvent("Temporary Title", calStart, calEnd);
  var eventID = event.getId();
  Logger.log(event.getTitle());
  changeTitleById(eventID);
  changeTitleByTime(calStart, calEnd);
}

function changeTitleById(id) {
  var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
  var event = calendar.getEventSeriesById(id);
  event.setTitle("ID-based Title Change");
  Logger.log(event.getTitle());
}

function changeTitleByTime(start, end) {
  var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
  var events = calendar.getEvents(start, end);
  var eventToChange = events[0];
  // The line below is the problem (it comes before the title change)
  eventToChange.setTime(new Date("Wed May 07 17:00:00 GMT-04:00 2014"), new Date("Wed May 07 17:00:00 GMT-04:00 2014"));
  eventToChange.setTitle("Time-based Title Change");
  // But if I change the time AFTER the title, it works without a problem. But why?
  //eventToChange.setTime(new Date("Wed May 07 17:00:00 GMT-04:00 2014"), new Date("Wed May 07 17:00:00 GMT-04:00 2014"));
  Logger.log(eventToChange.getTitle());
}

function deleteEvent(id) {
  var calendar = CalendarApp.getOwnedCalendarsByName(getLibraryProperty('LRCalName'))[0];
  calendar.getEventSeriesById(id).deleteEventSeries();
}

So the question is: Why does changing the date/time of a CalendarEvent before changing the title cause this error?

And subsequently, is this a bug?

解决方案

Sequence number must be non-decreasing and some changes increase the sequence number, see http://tools.ietf.org/html/rfc5545#section-3.8.7.4

You should always modify the most recent version of the event with the current sequence number. In this case I assume the changes are immediately propagated to the server after each setter. That means you could try to re-fetch "eventToChange" after the first modification before you do the next one.

这篇关于不能减少事件的序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆