C# 什么是为体育赛事服务的正确方式?
我试图允许用户使用将在线日历中的事件添加到设备上的日历中。这在iOS和桌面平台上似乎很好,但我在安卓设备上遇到了障碍。我遇到这样的信息: 有没有更好的方式来为这项活动服务,从而避免这种情况发生C# 什么是为体育赛事服务的正确方式?,c#,android,asp.net,asp.net-mvc,icalendar,C#,Android,Asp.net,Asp.net Mvc,Icalendar,我试图允许用户使用将在线日历中的事件添加到设备上的日历中。这在iOS和桌面平台上似乎很好,但我在安卓设备上遇到了障碍。我遇到这样的信息: 有没有更好的方式来为这项活动服务,从而避免这种情况发生 public ActionResult ICS(int id) { // Get event from Database var heEvent = HEEvent.GetEventDetails(id); // Create iCal object
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(" ", "_")));
}
你的错误,你不需要我告诉你,与我无关。这完全取决于你、你的手机和你的技术预算。买一张SD卡 关于服务Icalendar,您经常听到它们被称为feed,但是订阅Icalendar的客户端定期轮询日历url,每次都请求整个日历。为了避免大量不必要的处理,您需要以某种方式持久化日历,以便在不重新生成数千次相同日历的情况下传播更改。为此,我建议使用文件系统和HTTP缓存头。修改日历时,将其作为静态文件写入面向web的目录中。也许你已经这么做了。然后在您的Web服务器上设置合理的缓存头,然后离开