Ich verwende das FullCalendar jQuery-Plugin von arshaw auf ASP.NET 4. Alles ist in Ordnung, die Ereignisse werden abgerufen, aber sie werden nicht im Kalender angezeigt. Ich bin sicher, dass sie abgeholt werden, FireBug zeigt die Antwort wie diese:
{"d":[{"__type":"CalendarioEvento","title":"Samara Dos Santos
Freitas","start":1304441400,"color":null},
{"__type":"CalendarioEvento","title":"Apae","start":1304443800,"color":null},
{"__type":"CalendarioEvento","title":"Apae","start":1304447400,"color":null},
{"__type":"CalendarioEvento","title":"Samara Dos Santos
Freitas","start":1304449800,"color":null}]}
Ich habe auch versucht, eine Ereignisse Array manuell Serialisierung, aber es funktioniert nicht.
Die Funktion $.ajax() in fullcalendar.js:
$.ajax($.extend({}, ajaxDefaults, source, {
type: "POST",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(events) {
events = events || [];
var res = applyAll(success, this, arguments);
if ($.isArray(res)) {
events = res;
}
callback(events);
},
error: function() {
applyAll(error, this, arguments);
callback();
},
complete: function() {
applyAll(complete, this, arguments);
popLoading();
}
}));
Hier ist mein VB-Code, um die Ereignisse aus der Datenbank zu fecth und geben Sie sie an das Plugin:
Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManager
Imports Newtonsoft.Json
<System.Web.Script.Services.ScriptService()> _
Partial Class _Default
Inherits System.Web.UI.Page
Private Shared Function ToUnixTimespan(ByVal d As DateTime) As Long
Dim time As New TimeSpan()
time = d.ToUniversalTime().Subtract(New DateTime(1970, 1, 1, 0, 0, 0))
Return CType(Math.Truncate(time.TotalSeconds), Int64)
End Function
Private Shared Function FromUnixTimespan(ByVal s As String) As DateTime
Dim time As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
Return time.AddSeconds(s)
End Function
<WebMethod()> _
Public Shared Function ListarEventos(ByVal starte As String, ByVal ende As String) As List(Of CalendarioEvento)
Dim conexaoSql As New SqlConnection(ConnectionStrings("praeConnectionString").ConnectionString)
Dim comandoSql As SqlCommand = New SqlCommand("spListarEventosCalendario", conexaoSql)
comandoSql.CommandType = CommandType.StoredProcedure
comandoSql.Parameters.AddWithValue("@bitPendentes", 0)
comandoSql.Parameters.AddWithValue("@agendamentos", "188,135")
comandoSql.Parameters.AddWithValue("@start", FromUnixTimespan(starte))
comandoSql.Parameters.AddWithValue("@end", FromUnixTimespan(ende))
comandoSql.Parameters.AddWithValue("@veiculo", "M01")
Dim eventos As List(Of CalendarioEvento) = New List(Of CalendarioEvento)
Try
conexaoSql.Open()
Dim sdrEventos As SqlDataReader = comandoSql.ExecuteReader
While sdrEventos.Read
Dim evento As New CalendarioEvento
evento.title = StrConv(sdrEventos("vchNome").ToString, VbStrConv.ProperCase)
evento.start = ToUnixTimespan(Convert.ToDateTime(sdrEventos("vchData") + " " + sdrEventos("vchHora")))
eventos.Add(evento)
End While
Catch ex As Exception
Finally
conexaoSql.Close()
End Try
comandoSql.Parameters("@bitPendentes").Value = 1
Try
conexaoSql.Open()
Dim sdrEventos As SqlDataReader = comandoSql.ExecuteReader
While sdrEventos.Read
Dim evento As New CalendarioEvento
evento.title = StrConv(sdrEventos("vchNome").ToString, VbStrConv.ProperCase)
evento.start = ToUnixTimespan(Convert.ToDateTime(sdrEventos("vchData") + " " + sdrEventos("vchHora")))
evento.color = "#6AB0D8"
eventos.Add(evento)
End While
Catch ex As Exception
Finally
conexaoSql.Close()
End Try
Return eventos
End Function
Klasse beenden
Hat jemand eine Lösung?
Herzlichen Dank.