代码之家  ›  专栏  ›  技术社区  ›  Umar.H

FullCalender.io与经典ASP

  •  1
  • Umar.H  · 技术社区  · 6 年前

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

    我想将full calendar.io集成到我公司的本地内联网中,为我的门店经理(大约800人)显示假期,以便区域经理能够了解发生的事情和时间。

    现在,我的想法是使用Python和完整日历建立一个简单的连接,只从dB-static读取事件。

    然而,我公司的本地Web服务器没有安装Python,公司认为在其上安装任何东西都有风险,因为Web服务器是安全的 古老的

    哦,也没有php,我们唯一能做的就是

    所以我一直在玩弄从我的MSSQLServer用asp classic构建基本的html页面。我已经能够创建从我的数据库中提取的动态页面(这是在一个安全的内部网上)

    请注意,我在一家相当大的公司工作,任何更改都需要非常长的时间,并且陷入政治泥潭,因此我不会在Web服务器上安装Python/php或任何东西。

    我有一个ms sql表,如下所示:

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

    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);
          }
        });
    
      });
    

    对不起,这篇文章太长了,我认为直白比含蓄好!另外,请温柔一点,直到昨天晚上我才知道什么是asp经典,我是一个新手。

    1 回复  |  直到 6 年前
        1
  •  4
  •   Adam    6 年前

    听起来您需要使用经典asp生成JSON代码。有一些JSON类可用于经典ASP( see here

    试试这样的。。。

    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
    
    %>
    

    JSON class 由@lankymart链接:

    <!--#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
    
    %>
    

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