我正在尝试允许用户使用DDay.iCal将在线日历中的活动添加到设备上的日历中。这似乎在iOS和桌面平台上运行良好,但我遇到了Android设备的问题。我遇到这个消息:
有没有更好的方法来发挥这一事件,以防止这种情况发生?
public ActionResult ICS(int id)
{
// Get event from Database
var heEvent = HEEvent.GetEventDetails(id);
// Create iCal object
var iCal = new iCalendar();
iCal.Method = "PUBLISH";
// Create iCal Event
var icalEvent = iCal.Create<DDay.iCal.Event>();
icalEvent.Summary = heEvent.Name;
icalEvent.Start = new iCalDateTime(heEvent.TimeBegin.Year, heEvent.TimeBegin.Month, heEvent.TimeBegin.Day, heEvent.TimeBegin.Hour, heEvent.TimeBegin.Minute, 00);
TimeSpan calculatedEventDuration = heEvent.DateEnd.Subtract(heEvent.TimeBegin);
if (calculatedEventDuration.Hours > 1) { icalEvent.Duration = calculatedEventDuration; }
else { icalEvent.Duration = TimeSpan.FromHours(1); } // default to 1 hour if event time is less
icalEvent.Location = heEvent.Location;
// Create a serialization context and serializer factory.
// These will be used to build the serializer for our object.
ISerializationContext ctx = new SerializationContext();
ISerializerFactory factory = new DDay.iCal.Serialization.iCalendar.SerializerFactory();
// Get a serializer for our object
IStringSerializer serializer = factory.Build(iCal.GetType(), ctx) as IStringSerializer;
string output = serializer.SerializeToString(iCal);
var contentType = "text/calendar";
var bytes = Encoding.UTF8.GetBytes(output);
return File(bytes, contentType, String.Format(@"{0}.ics", heEvent.Name.Replace(" ", "_")));
}
答案 0 :(得分:-1)
你的错误,你不需要我告诉你,与Ical无关。它完全在您,您的手机和技术预算之间。 (购买SD卡!)
关于服务Icalendars,您经常听到他们称为Feed,但是客户定期订阅Icalendar轮询日历网址,每次请求整个日历。为了避免大量不必要的处理,您需要以某种方式保留日历,以便更改传播而无需重新生成相同的日历数千次。为此,我建议使用文件系统并充分利用HTTP缓存头。修改日历后,将其作为静态文件写入面向Web的目录中。也许你已经这样做了。然后在您的网络服务器上设置合理的缓存标题,然后离开。