我已经使用asp.net webforms和vb.net成功地将FullCalendar v1.4.2与sql server连接。我想更新到v1.5.3,但原来的集成代码已经不起作用了,我不知道如何修复它。
其次,我想帮助添加拖放功能,以便从asp.net中更新拖放数据库,但我不确定从哪里开始。
我在1.4.2版本中使用的代码如下:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('#calendar').fullCalendar({
header: {
left: 'prev, next today',
center: 'title',
right: 'month, basicWeek, basicDay'
},
events: "Calendar.asmx/EventList"
});
});
</script>
Imports System
Imports System.Data
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Web.UI.Page
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Calendar
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function EventList(ByVal startDate As String, ByVal endDate As String) As String
' List to hold events
Dim events As List(Of CalendarDTO) = New List(Of CalendarDTO)()
Dim WebConfigConnection As String = ConfigurationManager.ConnectionStrings("FresheyeTimeTrackerConnectionString").ConnectionString
Dim query As String = "SELECT * FROM CORE_PROJECT"
Dim conn As New SqlConnection(WebConfigConnection)
Dim cmd As New SqlCommand(query, conn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds)
'If startDate > ToUnixTimespan(DateTime.Now) Then
'GoTo x
'End If
Dim starting As DateTime = FromUnixTimespan(startDate)
' Loop through events to be added
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
If String.IsNullOrEmpty(ds.Tables(0).Rows(i)("ProjectDeliveryDate").ToString()) Then
Else
' Create a new event and start to populate
Dim value As CalendarDTO = New CalendarDTO()
' Date is required to be in a unix format
value.StartDate = ToUnixTimespan(DateTime.Parse(ds.Tables(0).Rows(i)("ProjectAddedDate").ToString))
value.id = ds.Tables(0).Rows(i)("ProjectID").ToString()
value.title = ds.Tables(0).Rows(i)("ProjectTitle").ToString()
value.EndDate = ToUnixTimespan(DateTime.Parse(ds.Tables(0).Rows(i)("ProjectDeliveryDate").ToString))
events.Add(value)
End If
Next
' Serialize the return value so it can be decoded in java.
x:
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
Return js.Serialize(events)
End Function
Private Function ToUnixTimespan(ByVal d As DateTime) As Int64
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 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
End Class
我也在为此而挣扎。。。看起来我们从类似的地方借用了代码。。。
在上面的代码中,您似乎没有将startDate和endDate转换回start和end。你是在FullCalendar.js中这样做的吗?
基本上,除了在返回事件之前,我做了一个替换,以便发送回的字符串包含start和end,而不是startDate和EndDate之外,我的内容与您的内容基本相同。
我的代码在Chrome中似乎可以正常工作,但在IE中不行。
关于更新Db。。。我正在查看上发布的几个答案
FullCalendar,如何允许用户编辑/删除事件并将其从数据库中删除?