【发布时间】:2012-03-01 20:42:17
【问题描述】:
我已经使用 asp.net webforms 和 vb.net 成功地将 FullCalendar v1.4.2 与 sql server 连接起来。我想更新到 v1.5.3,但原来的集成代码不再有效,我看不到如何修复它。
其次,我想帮助我添加拖放功能,以便在从 asp.net 拖放时更新数据库,但我不知道从哪里开始。
适用于 v 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
【问题讨论】:
-
@Brian - 不是我,但我可以给出几个可能的原因: 散文中没有句子。代码格式化破坏了语法高亮。为 vb.net 特定问题标记了 c#。问题中包含一堆额外且不必要的代码。谢天谢地,我可以编辑修复大部分问题:)
-
我放置了一个 c# 标签,因为我想要 C# 或 VB 语言的解决方案?
标签: asp.net vb.net ado.net fullcalendar