问题描述
除了每周一次和每月一次的情况外,每种情况都适用ical附件(.ics).我正在尝试为一个工作日中的一个创建每周定期报表,并为每个月的最后一个星期二/第二个星期二创建一个每月定期报表.当我打开.ics文件时,它显示操作失败".
The ical attachment (.ics) works for every case except recurring weekly and once in a month cases. I'm trying to create a weekly recurrence for one of the weekday and also a monthly recurrence for last Tuesday/2nd Tuesday of every month. When I open the .ics file, it says "The operation failed".
每周:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Weekly, 1);
rrule.ByDay.Add(new WeekDay(DayOfWeek.Monday));
rrule.Until = end;
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
每月:
evnt.Start = new CalDateTime(start);
evnt.End = new CalDateTime(new DateTime(evnt.Start.Year, evnt.Start.Month, evnt.Start.Day, end.Hour, end.Minute, end.Second));
rrule = new RecurrencePattern(FrequencyType.Monthly,1);
rrule.Until = end;
rrule.ByDay.Add(new WeekDay(DayOfWeek.Sunday,FrequencyOccurrence.FifthToLast));
evnt.RecurrenceRules = new List<RecurrencePattern> { rrule };
请让我知道我在做错什么.
Please let me know what I'm doing wrong.
推荐答案
借助从@matis和@anmari获得的线索,我找到了根本原因.
With the cues I got from @matis and @anmari I figured the root cause.
当您创建具有特定工作日的定期约会时,开始日期和结束日期都应与同一工作日匹配.这是每个月的第二个星期三发生的工作样本.
When you create a recurring appointment with a specific weekday, both start and end date should match the same weekday. Here is a working sample occurring on 2nd Wednesday of every month.
BEGIN:VCALENDAR
METHOD:PUBLISH
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 4.0//EN
VERSION:2.0
BEGIN:VEVENT
ATTENDEE;CN="Last, First":mailto:[email protected]
CREATED:20200415T164742
DESCRIPTION: Cal Description
DTEND;TZID=Eastern Standard Time:20200513T110000
DTSTAMP:20200415T204742Z
DTSTART;TZID=Eastern Standard Time:20200513T103000
LOCATION:Meeting location
ORGANIZER;CN="user, Admin";SENT-BY="mailto:[email protected]":
RRULE:FREQ=MONTHLY;COUNT=13;BYDAY=2WE
SEQUENCE:0
SUMMARY:Title
UID:1913d514-696e-4237-bc3c-c1d073eacced
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:Reminder
TRIGGER:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR
这篇关于ICAL.NET重复元素:从开始日期到结束日期的每个星期二(每周),每个第二个,最后一个星期一(每月)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!