FullCalender.io 与经典 ASP

FullCalender.io with classic ASP

对于这个问题,我深表歉意,但我能使用的编码语言极其有限 - 因此,您是我最后的支持堡垒。请看下面

我想将完整 calendar.io 集成到我公司的本地 Intranet 中,以显示我的商店经理(大约 800 个)的假期,以便区域经理可以了解发生的事情和时间。

我有一个资源管理系统,让他们,商店经理,预订假期,并在 Python(谢谢 selenium)

的一点帮助下每天被转储到我的本地服务器上

现在,我的想法是使用 Python 和完整日历设置一个简单的连接,以从我的 dB 中读取事件 - 仅静态。

但是,我公司的本地网络服务器没有安装 Python,公司认为在其上安装任何东西都是有风险的,因为网络服务器 非常 旧.

好的,很酷,第 2 步让我们使用包含的 php 文件来读取 json 并每天将 json 文件转储到那里,这不会那么困难使用 python 和 pandas 每天设置工作流程。

哦,也不php,我们唯一可以使用的是asp。不是 asp.net,asp-经典!

所以我一直在尝试用我的 ms-sql 服务器上的 asp-classic 构建基本的 html 页面。我已经能够创建从我的 dB 中提取的动态页面(这是在安全的内部网上)

请注意,我在一家相当大的公司工作,任何更改都需要很长时间并且陷入政治困境,所以我不会在网络服务器上安装 Python/php 或任何东西。

我有一个 ms-sql table 像这样:

ID : Varchar(255)
Event Start : datetime
Event End : datetime
Area : int

我想象使用类似下面的东西可以让我在 html 页面上生成我的事件:

Set gobjConn = Server.CreateObject("ADODB.Connection")
Set grs = Server.CreateObject("ADODB.Recordset")
gsConnect = "Driver={SQL Server};Server=Server;Database=mydb;uid=uid,pw=pw
gobjConn.Open gsConnect


    gsSQL = "SELECT ID,[Event Start], [Event End] FROM Events WHERE Area = '" & Area& "'"
Set grs = gobjConn.Execute(gsSQL)

区域编号是一个查询字符串,我将在我的代码中进一步声明。

从这里我不知道如何将其集成到 Jquery 完整日历中。

    $(document).ready(function() {

    $('#calendar').fullCalendar({
      header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay,listWeek'
      },
      defaultDate: '2019-01-12',
      editable: true,
      navLinks: true, // can click day/week names to navigate views
      eventLimit: true, // allow "more" link when too many events
      events: {
        url: 'read_my_sql_dB_here',
        error: function() {
          $('#script-warning').show();
        }
      },
      loading: function(bool) {
        $('#loading').toggle(bool);
      }
    });

  });

抱歉这么长post,我想明示比含蓄更好!也请保持温柔,直到昨天晚上我才知道 asp-classic 是(或现在)是什么,我是一个新手编码员。

听起来您需要使用 classic asp 生成 JSON 代码。有一些 JSON classes 可用于 classic ASP (see here),但 JSON 代码需要 FullCalender.io看起来很简单,只 response.write 它会比使用 class.

生成它更容易

尝试这样的事情...

events.asp:

<%

    Response.ContentType = "application/json"

    Dim gobjConn, grs, gsConnect, gsSQL, theData, r, Area

    ' if you're getting the area int from the querystring it's wise to
    ' check it's actually an int before inserting it into your SQL

    Area = request.QueryString("Area")

    if NOT isNumeric(Area) then
        Area = 1 ' set a default
        'response.End() ' or just use response.End() to stop the script
    else
        Area = int(Area)
    end if

    Set gobjConn = Server.CreateObject("ADODB.Connection")
    Set grs = Server.CreateObject("ADODB.Recordset")
    gsConnect = "Driver={SQL Server};Server=Server;Database=mydb;uid=uid,pw=pw"
    gobjConn.Open gsConnect

    gsSQL = "SELECT ID,[Event Start], [Event End] FROM Events WHERE Area = " & Area
    Set grs = gobjConn.Execute(gsSQL)

        if NOT grs.EOF then

            ' Use GetRows() to convert the recordset to to a 2D array

            theData = grs.getRows()

            ' start to build the JSON

            response.write "[" & VBcrlf

            for r = 0 to uBound(theData,2)

                ' loop through the events

                response.write "  {" & VBcrlf
                response.write "    ""id"": """ & theData(0,r) & """," & VBcrlf

                ' If you want to include a title you would need to escape the text:
                ' response.write "    ""title"": """ & JSONEncode(theData(3,r)) & """," & VBcrlf

                response.write "    ""start"": """ & theData(1,r) & """," & VBcrlf
                response.write "    ""end"": """ & theData(2,r) & """" & VBcrlf

                if r = uBound(theData,2) then
                    ' end of events, no comma
                    response.write "  }" & VBcrlf
                else
                    response.write "  }," & VBcrlf
                end if

            next

            response.write "]"

        else

            ' no events

        end if

    grs.close() : set grs = nothing ' close the recordset
    gobjConn.close() : set gobjConn = nothing ' close the connection


    ' Use this function to escape JSON text

    Function JSONEncode(ByVal val)
        val = Replace(val, "\", "\")
        val = Replace(val, """", "\""")
        val = Replace(val, Chr(8), "\b")
        val = Replace(val, Chr(12), "\f")
        val = Replace(val, Chr(10), "\n")
        val = Replace(val, Chr(13), "\r")
        val = Replace(val, Chr(9), "\t")
        JSONEncode = Trim(val)
    End Function

%>

使用@lankymart 链接的JSON class

<!--#include file = "jsonObject.class.asp" -->
<%

    Response.ContentType = "application/json"

    Dim gobjConn, grs, gsConnect, gsSQL, Area

    ' if you're getting the area int from the querystring it's wise to
    ' check it's actually an int before inserting it into your SQL

    Area = request.QueryString("Area")

    if NOT isNumeric(Area) then
        Area = 0 ' set a default
        'response.End() ' or just use response.End() to stop the script
    else
        Area = int(Area)
    end if

    Set gobjConn = Server.CreateObject("ADODB.Connection")
    Set grs = Server.CreateObject("ADODB.Recordset")
    gsConnect = "Driver={SQL Server};Server=Server;Database=mydb;uid=uid,pw=pw"
    gobjConn.Open gsConnect

    gsSQL = "SELECT ID,[Event Start], [Event End] FROM Events WHERE Area = " & Area
    Set grs = gobjConn.Execute(gsSQL)

        set JSON = New JSONarray

            JSON.LoadRecordset grs

            JSON.Write() 

        set JSON = nothing

    grs.close() : set grs = nothing ' close the recordset
    gobjConn.close() : set gobjConn = nothing ' close the connection

%>

在你的jQuery中:

  events: {
    url: 'events.asp',
    error: function() {
      $('#script-warning').show();
    }
  },