国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

SQL Server靜態頁面導出技術3

2024-08-31 00:50:18
字體:
來源:轉載
供稿:網友
本段文章節選自鐵道出版社新出的《用BackOffice建立Intranet/Extranet應用》一書(現已在海淀圖書城有售)。本書詳盡地講述了如何使用微軟BackOffice系列產品來組建Intranet/Extranet應用。通過它您將掌握NT的安裝和設置、使用IIS建立Web站點、通過ILS建立網絡會議系統、用Exchange建立企業的郵件和協作系統、用SQL Server建立Web數據庫應用、用PRoxy Server建立同Internet安全可靠的連接、用Media Server建立網絡電視臺/廣播站、用Chart server建立功能強大的聊天室、用Site Server建立個性化的郵件列表和分析網站的訪問情況、用Commerce Server建立B2B或B2C的電子商務網站。此外本書還對網絡的安全性進行了討論,從而指導您建立一個更為健壯和安全的網絡應用。閱讀本書之后,您將發現實現豐富多彩的網絡應用原來這樣簡單……
絕對原創,歡迎轉載。但請務必保留以上文字。


靜態頁面導出實例分析:
    下面討論如何使用靜態頁面導出技術來實現我們在前面要求的各種功能。
    首先,我們來看看要導出的頁面文件的結構:
    所有導出的頁面都將被放在一個目錄名為當日期的目錄下。其中有兩個非導出文件index.htm和show.htm文件。其作用同cbbinput目錄中的default.htm和show.htm文件相類似。都是為了滿足使頁面能夠正常顯示的需要。之所以使用index.htm而不用default.htm為文件名,是因為大多數ISP提供的主頁空間的目錄省缺文件的名字都是index.htm。
    當日的各個版面則導出為一個名為list.htm的文件。每個版面的文章題目列表則分別按順序導出為1~n(n為當日的版面總數)個頁面文件。其文件名也為1.htm~n.htm。當日所刊載的各個文章則以其id為文件名分別進行導出。在list.htm文件中,包含到各個版面頁面文件的超鏈接。在各個版面的頁面文件中,又包含到各個文章頁面文件的超連接。
    在出版報的主頁上,還應該有一個用來顯示日期的頁面文件。每個日期的超鏈接都將與其頁面文件所在的目錄中的index.htm文件相對應。點擊日期后,將彈出一個新的瀏覽器窗口。其中顯示的是相應日期的報紙內容。
    此外,還應當將此日各篇文章的配圖文件也拷貝到此目錄之下。
    我們為此建立一個任務,它會在每天下午的六點執行,將當天報紙的內容導出為靜態的HTML頁面文件。此任務的代碼如下(可以在本書配套光盤的SQLServer目錄的子目錄test下找到此段代碼的文件,其文件名為webout.sql。它使用的模板文件也可以在此目錄下找到):
use test
go
declare
    @riqi  varchar(20),
    @filepath  varchar(255),
    @listfile  varchar(255),
    @command varchar(255)
set @riqi=left(convert(varchar(40),getdate(),20),10)
set @filepath='d:/webout/'+@riqi+'/'
set @command='md '+@filepath
execute master.dbo.Xp_cmdshell @command
set @command='md '+@filepath+'images'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/files/*.* d:/webout/'+@riqi+'/'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/files/images/*.* d:/webout/'+@riqi+'/images/'
execute master.dbo.Xp_cmdshell @command
set @command ='copy d:/test/'+@riqi+'/*.* d:/webout/'+@riqi+'/'
execute master.dbo.Xp_cmdshell @command
set @listfile=@filepath+'list.htm'
execute sp_makewebtask
@outputfile=@listfile,
@query='select distinct banmian
from gaojian
where kanwu=''出版報'' and datepart(yy,riqi)=datepart(yy,getdate()) and datepart(dy,riqi)=datepart(dy,getdate())',
@templatefile='d:/test/list.tml',
@codepage=936

declare
@lists int,
@banmian varchar(64),
    @filename varchar(64),
    @search varchar(2000)
set @lists=0
declare point cursor for
select distinct banmian
from gaojian
where kanwu='出版報' and datepart(yy,riqi)=datepart(yy,getdate()) and datepart(dy,riqi)=datepart(dy,getdate())
for read only

open point
fetch point into
  @banmian
while (@@fetch_status=0)
begin
set @lists=@lists+1
set @filename=@filepath+convert(varchar(64),@lists)+'.htm'
set @search='SELECT id,timu,laiyuan
FROM gaojian
WHERE datepart(yy,riqi)=datepart(yy,convert(datetime,'''+@riqi+'''))
and datepart(dy,riqi)=datepart(dy,convert(datetime,'''+@riqi+'''))'+
'and banmian ='''+@banmian+'''and kanwu=''出版報''order by timu'
execute sp_makewebtask
@outputfile=@filename,
@query=@search,
@templatefile='d:/test/list2.tml',
@codepage=936
fetch point into
@banmian
end
close point
deallocate point

declare @gaojianid int
declare point2 cursor for
select gaojian.id
from gaojian
where kanwu='出版報' and datepart(yy,riqi)=datepart(yy,getdate()) and
datepart(dy,riqi)=datepart(dy,getdate())
for read only

open point2
fetch point2 into
  @gaojianid
while (@@fetch_status=0)
begin
set @filename=@filepath+convert(varchar(64),@gaojianid)+'.htm'
set @search='SELECT timu,laiyuan,neirong,left(pics,10)+ STUFF(pics,1,21,''''),yuanwen
FROM gaojian
WHERE id='+convert(varchar(64),@gaojianid)
execute sp_makewebtask
@outputfile=@filename,
@query=@search,
@templatefile='d:/test/outfile.tml',
@codepage=936
fetch point2 into
@gaojianid
end
close point2
deallocate point2

declare
@dy int,
    @date varchar(20),
    @yue varchar(2),
    @yue2 varchar(2),
    @ri int,
    @xingqi int,
    @year int,
    @outchar varchar(1600),
    @tt int

create table ##daylist
    (out varchar(1600))

set @yue2='00'
set @tt=0

declare point3 cursor for
SELECT distinct
dy=datepart(dy,riqi),date=left(convert(varchar(40),riqi,20),10),
yue=convert(varchar(2),datepart(mm,riqi)),ri=datepart(dd,riqi),xingqi=datepart(dw,riqi),year=datepart(yy,riqi)
FROM gaojian
where kanwu = '出版報'
order by year,dy
for read only

open point3
fetch point3 into
        @dy,@date,@yue,@ri,@xingqi,@year
while (@@fetch_status=0)
begin
if @yue<>@yue2
begin
set @tt=0
if @yue2=0
   insert into ##daylist
values('<TABLE BORDER="BORDER" ALIGN="CENTER"><th><tr><h2>'+convert(varchar(4),@year)+
'年'+@yue+'月份</h2></tr></th><tr><td>星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>')
else
   insert into ##daylist
values('</tr></table><TABLE BORDER="BORDER" ALIGN="CENTER"><th><tr><h2>'+
convert(varchar(4),@year)+'年'+@yue+'月份</h2></tr></th><tr><td>星期日</td><td>星期一</td><td>星期二</td><td>星期三</td><td>星期四</td><td>星期五</td><td>星期六</td></tr>')
end
if @tt<>0
   if @xingqi < 7
      set @outchar=@outchar+'<td><a href="'+@date+'/index.htm" TARGET="new">'+convert(varchar(2), @ri)+'</a></td>'
    else
      set @outchar=@outchar+'<td><a href="'+@date+'/index.htm" TARGET="new">'+convert(varchar(2), @ri)+'</a></td></tr><tr>'
else
      begin
      set @tt=1
      set @outchar=
      case
     when @xingqi=1 then ''
    when @xingqi=2 then '<td></td>'
    when @xingqi=3 then '<td></td><td></td>'
    when @xingqi=4 then '<td></td><td></td><td></td>'
    when @xingqi=5 then '<td></td><td></td><td></td><td></td>'
    when @xingqi=6 then '<td></td><td></td><td></td><td></td><td></td>'
    when @xingqi=7 then '<td></td><td></td><td></td><td></td><td></td><td></td>'
      end
    if @xingqi < 7
      set @outchar=@outchar+'<td><a href="'+@date+'/index.htm" TARGET="new">'+convert(varchar(2), @ri)+'</a></td>'
    else
      set @outchar=@outchar+'<td><a href="'+@date+'/index.htm" TARGET="new">'+convert(varchar(2), @ri)+'</a></td></tr><tr>'
     end

insert into ##daylist values(@outchar)

set @yue2=@yue
set @outchar=''

fetch point3 into
        @dy,@date,@yue,@ri,@xingqi,@year
end
close point3
deallocate point3

execute sp_makewebtask
@outputfile='d:/test/daylist.htm',
@query='select * from ##daylist',
@templatefile='d:/test/rili.tml',
@codepage=936
drop table ##daylist
    首先請讀者通讀上面的代碼,以便對它有一個大概的了解。下面我們將對代碼進行逐段的分析和講解:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 故城县| 开封县| 崇礼县| 吉隆县| 中江县| 双城市| 四川省| 武功县| 阜平县| 延边| 蒙阴县| 芒康县| 阿勒泰市| 洮南市| 宁波市| 溧阳市| 东台市| 门源| 光山县| 大港区| 洛川县| 亳州市| 霍城县| 西盟| 龙游县| 天镇县| 营口市| 交口县| 隆尧县| 武邑县| 仪陇县| 永州市| 新蔡县| 大同县| 江安县| 墨脱县| 香格里拉县| 柳河县| 岚皋县| 保靖县| 昌邑市|