如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本-創(chuàng)新互聯(lián)

如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本?相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。

成都創(chuàng)新互聯(lián)客戶idc服務(wù)中心,提供成都移動(dòng)機(jī)房托管、成都服務(wù)器、成都主機(jī)托管、成都雙線服務(wù)器等業(yè)務(wù)的一站式服務(wù)。通過(guò)各地的服務(wù)中心,我們向成都用戶提供優(yōu)質(zhì)廉價(jià)的產(chǎn)品以及開(kāi)放、透明、穩(wěn)定、高性價(jià)比的服務(wù),資深網(wǎng)絡(luò)工程師在機(jī)房提供7*24小時(shí)標(biāo)準(zhǔn)級(jí)技術(shù)保障。

舉個(gè)簡(jiǎn)單的應(yīng)用場(chǎng)景,開(kāi)發(fā)一個(gè)小的API系統(tǒng),支持 XML、JSON輸出。區(qū)別是 基礎(chǔ)版(dev/dev.asp)只支持 Access,VIP版本(dev/vip.asp)支持 Access + SQL Server。這樣VIP版本就需要在現(xiàn)在的基礎(chǔ)上 增加 sqlserver的支持,增加額外的 配置項(xiàng)。開(kāi)發(fā)過(guò)程只需要 按正常開(kāi)發(fā)即可。

如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本

開(kāi)發(fā)完畢后,通過(guò) one.asp 打包成 index.asp 和 vip.asp 兩個(gè)版本,整套程序都是一個(gè)獨(dú)立的文件。

如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本

下圖演示了 解析過(guò)程:

如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本

完整的測(cè)試代碼 可以 訪問(wèn):oneasp.rar 下載

核心代碼 如下:

' ====================================================
' 類(lèi)名:One
' 作者:mqycn
' 博客:http://www.miaoqiyuan.cn
' 源碼:http://www.miaoqiyuan.cn/p/one-php
' 說(shuō)明:多項(xiàng)目 函數(shù)庫(kù)、類(lèi)庫(kù) 統(tǒng)一為一個(gè)版本的方法
' ====================================================
Class OneAsp
  Private FSO
  Private Root
   
  Private Sub Class_Initialize()
    Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  End Sub
   
  Private Sub Class_Terminate()
    Set FSO = Nothing
  End Sub
   
  Public Function Run(ByVal sourceFile, ByVal saveFile)
    Run = "<hr><b>Input:</b>" & sourceFile & "<br><b>Result:</b>" & Save(saveFile, Include(sourceFile))
  End Function
   
   
  Public Function Include(ByVal path)
    Dim tmpPath, tmpItem, arrPath, index
    tmpPath = ""
    arrPath = Split(path, "/")
    For index = 0 To UBound(arrPath) - 1
      tmpItem = arrPath(index)
      tmpPath = tmpPath & tmpItem & "/"
    Next
    Include = Parse(tmpPath, arrPath(UBound(arrPath)))
  End Function
   
  Private Function Parse(ByVal root, ByVal fileName)
    Call SetRoot(root)
    Dim html
    html = OpenRead(fileName)
     
    Dim preg, pregResult
    Set preg = New Regexp
    preg.pattern = "<!--#include file=""([^""]*)""-->"
    preg.global = True
    preg.ignorecase = True
     
    Dim htmlInclude
    Set pregResult = preg.execute(html)
    For Each htmlInclude In pregResult
      html = Replace(html, htmlInclude, Include(root & htmlInclude.submatches(0)))
    Next
     
    Parse = "<% '" & root & fileName & " Start %" & ">" & vbCrLf & html & vbCrLf & "<%  '" & root & fileName & " End %" & ">" & vbCrLf
  End Function
   
  Private Function SetRoot(ByVal rootPath)
    If Right(rootPath, 1) <> "/" Then rootPath = rootPath & "/"
    Root = rootPath
  End Function
   
  Private Function RealPath(ByVal path)
    RealPath = Server.Mappath(Root & path)
  End Function
   
  Private Function OpenRead(ByVal path)
    Dim txtFile
    Set txtFile = FSO.OpenTextFile(RealPath(path))
    OpenRead = txtFile.ReadAll()
    txtFile.close
    On Error GoTo 0
  End Function
   
  Public Function Save(ByVal path, ByVal body)
    Dim txtFile
    Set txtFile = FSO.CreateTextFile(Server.Mappath(path))
    txtFile.write body
    txtFile.close
    Set txtFile = Nothing
    Save = path
  End Function
   
End Class

標(biāo)題名稱:如何統(tǒng)一one.asp多項(xiàng)目、函數(shù)庫(kù)、類(lèi)庫(kù)的版本-創(chuàng)新互聯(lián)
文章源于:http://bm7419.com/article42/gishc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄云服務(wù)器、面包屑導(dǎo)航自適應(yīng)網(wǎng)站、微信小程序、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)