www.gusucode.com > 艺术签名文章资讯网源代码 > 艺术签名文章资讯网源代码/624/adminhtry/admin_softset.asp

    <!--#include file="setup.asp"-->
<!--#include file="check.asp"-->
<%
Server.ScriptTimeout = 99999
Admin_header
'=====================================================================
' 软件名称:新云网站管理系统
' 当前版本:NewAsp Content Management System Version 3.0
' 文件名称:admin_articleset.asp
' 更新日期:2007-05-29
' 官方网站:新云网络(www.newasp.net) QQ:94022511
'=====================================================================
' Copyright 2003-2007 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
Dim Action,maxcount,autoform,showtext
If CInt(ChannelID) = 0 Then ChannelID = 2
maxcount=Newasp.ChkNumeric(Request.Form("maxcount"))
autoform=Newasp.ChkNumeric(Request.Form("autoform"))
showtext=Newasp.ChkNumeric(Request.Form("showtext"))
If maxcount<500 Then maxcount=500
If maxcount>50000 Then maxcount=500

Dim isxmltext,xmlfilename,xmlFilePath,m_xmlFilePath,xmlFilePrefix,xmlFileExt
Dim Channel_Setting,InstallDir_ChannelDir
InstallDir_ChannelDir = Trim(Newasp.InstallDir & Newasp.ChannelDir)
Channel_Setting = Split(Newasp.Channel_Setting & "|||||||||||||||", "|||")
xmlFilePrefix = Trim(Channel_Setting(10))
xmlFileExt = Trim(Channel_Setting(11))
m_xmlFilePath = Trim(Channel_Setting(12))
If Len(m_xmlFilePath) > 2 And InStr(m_xmlFilePath, ":") > 0 Then
	xmlFilePath = m_xmlFilePath &"\"
Else
	xmlFilePath = Server.MapPath(InstallDir_ChannelDir & m_xmlFilePath) & "\"
End If
xmlFilePath = Replace(xmlFilePath, "\\", "\")
If Len(xmlFileExt) < 3 Then xmlFileExt = ".xml"
If Left(xmlFileExt,1) <> "." Then xmlFileExt = "." & xmlFileExt

If Not ChkAdmin("9999") Then
	Server.Transfer("showerr.asp")
	Response.End
End If

Action = LCase(Request("action"))
Select Case Trim(Action)
Case "toxml"
	Call DataToXml
Case "todata"
	Call XmlToData
Case Else
	Call showmain
End Select
If FoundErr = True Then
	ReturnError(ErrMsg)
End If

Admin_footer
SaveLogInfo(AdminName)
CloseConn

Sub showmain()
%>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder">
<tr>
	<th colspan="2"><%=Newasp.ChannelName%> - 数据库/XML相互转换</th>
</tr>
<tr>
	<td class="TableRow2" colspan="2"><fieldset style="border : 1px dotted #ccc;text-align : left;line-height:22px;">
		<legend>
		<b>数据转换操作说明</b>
		</legend>
		<ol style="margin:0px 10px;list-style-position: inside;">
			<li>在此你可以进行XML和数据库之间的相互转换</li>
			<li><span class="style2">数据库转换XML</span>,将数据库中的软件简介转换成XML文件存储,这样可以节省数据库空间,让数据库的运行效率更高。</li>
			<li><span class="style2">XML转换数据库</span>,将XML文件中的内容保存到数据库中。</li>
			<li>你可以在频道设置中指定保存XML文件的路径,同时创建保存XML文件的目录。</li>
			<li>注意:进行数据转换时非常占用服务器资源,请尽量用默认设置进行转换;<span class="style1">操作前请备份数据库</span>。</li>
		</ol>
	</fieldset></td>
</tr>
<form method="post" action="?action=toxml">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>"/>
<tr>
	<td width="25%" class="TableRow1" align="right"><u>数据库转换XML</u>:</td>
	<td width="75%" class="TableRow1"><input type="submit" name="submit1" value="开始进行 XML 转换" /></td>
</tr>
</form>
<form method="post" action="?action=todata">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>"/>
<tr>
	<td class="TableRow2" align="right"><u>XML转换数据库</u>:</td>
	<td class="TableRow2"><input type="submit" name="submit2" value="开始进行数据库转换" /></td>
</tr>
</form>
</table>
<%
End Sub

Sub PlanbarCodes()
	Response.Write "	<div id=""planmain"">" & vbCrLf
	Response.Write "		<div id=""planbartext1"">进度</div>" & vbCrLf
	Response.Write "		<div class=""planbar""><div id=""planbar1""></div></div>" & vbCrLf
	Response.Write "		<div id=""planbartext3"">0%</div>" & vbCrLf
	Response.Write "	</div>" & vbCrLf
	Response.Write "	<div class=""plantext"" id=""planbartext2""></div>" & vbCrLf
End Sub

Sub DataToXml()
%>
<script type="text/javascript" language="javascript">
function planwidth(iwidth){
	if (iwidth>100){
	iwidth=100;
	}
	var obj = document.getElementById("planbartext3");
	obj.innerHTML=iwidth+'%';
	iwidth=iwidth * 5
	var obj = document.getElementById("planbar1");
	obj.style.width=iwidth+'px';
};
function plantext(text){
var obj = document.getElementById("planbartext2");
obj.innerHTML=text;
}
</script>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder">
<tr>
	<th><%=Newasp.ChannelName%> - 数据库转换到XML</th>
</tr>
<form name="newasp_form" method="post">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>"/>
<input type="hidden" name="act" value="yes"/>
<tr>
	<td class="TableRow1">每次转换最多 <input type="text" name="maxcount" value="<%=maxcount%>" size="5"> 条数据  
	<input name="newasp_submit" id="newasp_submit" type="submit" value="开 始">&nbsp;&nbsp;
	<input type="checkbox" name="autoform" value="1"<%If autoform=1 Then Response.Write " checked"%>> 自动转换&nbsp;&nbsp;
	<input type="checkbox" name="showtext" value="1"<%If showtext=1 Then Response.Write " checked"%>> 显示转换信息</td>
</tr>
</form>
<tr>
	<td class="TableRow2">
	<div id="planmain">
		<div id="planbartext1">进度</div>
		<div class="planbar"><div id="planbar1"></div></div>
		<div id="planbartext3">0%</div>
	</div>
	<div class="plantext" id="planbartext2"></div>
	</td>
</tr>
<tr>
	<td class="TableRow1" align="center"><input type="button" name="Submit4" onclick="javascript:location.href='?ChannelID=<%=ChannelID%>'" value="返回上一页" class="Button"></td>
</tr>
</table>
<%
	If Request.Form("maxcount")<>"" Then
		Call DatabaseToXml()
	End If
End Sub

Sub XmlToData()
%>
<script type="text/javascript" language="javascript">
function planwidth(iwidth){
	if (iwidth>100){
	iwidth=100;
	}
	var obj = document.getElementById("planbartext3");
	obj.innerHTML=iwidth+'%';
	iwidth=iwidth * 5
	var obj = document.getElementById("planbar1");
	obj.style.width=iwidth+'px';
};
function plantext(text){
var obj = document.getElementById("planbartext2");
obj.innerHTML=text;
}
</script>
<table border="0" align="center" cellpadding="3" cellspacing="1" class="TableBorder">
<tr>
	<th colspan="2"><%=Newasp.ChannelName%> - XML转换到数据库</th>
</tr>
<form name="newasp_form" method="post">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>"/>
<input type="hidden" name="act" value="yes"/>
<tr>
	<td class="TableRow1">每次转换最多 <input type="text" name="maxcount" value="<%=maxcount%>" size="5"> 条数据  
	<input name="newasp_submit" id="newasp_submit" type="submit" value="开 始">&nbsp;&nbsp;
	<input type="checkbox" name="autoform" value="1"<%If autoform=1 Then Response.Write " checked"%>> 自动转换&nbsp;&nbsp;
	<input type="checkbox" name="showtext" value="1"<%If showtext=1 Then Response.Write " checked"%>> 显示转换信息</td>
</tr>
</form>
<tr>
	<td class="TableRow2">
	<div id="planmain">
		<div id="planbartext1">进度</div>
		<div class="planbar"><div id="planbar1"></div></div>
		<div id="planbartext3">0%</div>
	</div>
	<div class="plantext" id="planbartext2"></div>
	</td>
</tr>
<tr>
	<td class="TableRow1" align="center"><input type="button" name="Submit4" onclick="javascript:location.href='?ChannelID=<%=ChannelID%>'" value="返回上一页" class="Button"></td>
</tr>
</table>
<%
	If Request.Form("maxcount")<>"" Then
		Call XmlToDatabase()
	End If
End Sub

Sub DatabaseToXml()
	If Request.form("act")<>"yes" Then Exit Sub
	Newasp.CreatPathEx(xmlFilePath)
	Response.Flush
	Response.Write "<script>document.getElementById('newasp_submit').disabled=true;document.getElementById('newasp_submit').value='继 续';plantext('正在进行数据转换,请耐心等待,中途不要离开本页面。');</script>" & vbCrLf
	Response.Flush
	
	Dim sid,cid,strText,i,n,m_strXmlPath
	Dim Articlelist,Node,Nodes,TextContent

	Set Rs = Newasp.Execute("SELECT TOP " & maxcount & " softid,ChannelID,softname,[content],isxmltext,xmlfilename FROM NC_SoftList WHERE ChannelID=" & ChannelID & " And isxmltext=0 And isAccept<>0 ORDER BY SoftTime DESC,softid DESC")
	If Rs.EOF Then
		Response.Write "<script language=""javascript"" type=""text/javascript"">plantext('XML数据转换完成');</script>" & vbCrLf
		Response.Flush
	Else
		SQL=Rs.GetRows(-1)
		Set Articlelist=Newasp.ArrayToxml(SQL,Rs,"softinfo","xml")
		maxcount=UBound(SQL,2)+1
		n = maxcount \ 100
		i = 0
		SQL=Empty
		If Not Articlelist Is Nothing Then
			For Each Node in Articlelist.documentElement.SelectNodes("softinfo")
				If Not Response.IsClientConnected Then Response.End
				sid=Node.selectSingleNode("@softid").text
				cid=Node.selectSingleNode("@channelid").text
				TextContent=Node.selectSingleNode("@content").text
				isxmltext=Newasp.ChkNumeric(Node.selectSingleNode("@isxmltext").text)
				xmlfilename=Node.selectSingleNode("@xmlfilename").text & ""
				If showtext=1 Then
					Response.Write "<script>plantext('正在转换第"&i+1&"条数据');</script>" & vbCrLf
					Response.Flush
				End If
				Set Nodes=Node.cloneNode(True)
				'--移除多余的节点
				Nodes.attributes.removeNamedItem("isxmltext")
				Nodes.attributes.removeNamedItem("xmlfilename")
				If Len(xmlfilename) < 5 Then
					'--如果数据库中XML文件名不存在创建新文件名
					xmlfilename = Newasp.CreateFileName(xmlFileExt,xmlFilePrefix,sid)
					Newasp.Execute ("UPDATE NC_SoftList SET xmlfilename='" & Replace(xmlfilename, "'", "") & "' WHERE softid="&sid)
				End If
				m_strXmlPath = xmlFilePath & xmlfilename
				'--保存XML文档
				If Newasp.SaveXMLDocument(m_strXmlPath,"<xml>" & Nodes.xml & "</xml>") Then
					'--保存XML文档成功后更新数据库
					Newasp.Execute ("UPDATE NC_SoftList SET [content]='0',isxmltext=1 WHERE softid="&sid)
				End If
				Set Nodes=Nothing
				If n > 0 Then 
					If (i+1) mod n = 0 Or (i+1)= maxcount Then
						Response.Write "<script>planwidth("&Int(((i+1)/ maxcount )*100)&");</script>" & vbCrLf
						Response.Flush
					End If
				Else
					If (i+1)= maxcount Then
						Response.Write "<script>planwidth("&Int(((i+1)/ maxcount )*100)&");</script>" & vbCrLf
						Response.Flush
					End If
				End If
				i = i + 1
			Next
		End If
		Set Articlelist=Nothing
		Response.Write "<script>document.getElementById('newasp_submit').disabled=false;</script>" & vbCrLf
		Response.Flush
		If autoform=1 Then
			Response.Write "<script>setTimeout('document.newasp_form.submit();',1000);</script>" & vbCrLf
			Response.Flush
		End If
	End If
	Set Rs = Nothing
	
End Sub

Sub XmlToDatabase()
	If Request.form("act")<>"yes" Then Exit Sub
	Response.Flush
	Response.Write "<script>document.getElementById('newasp_submit').disabled=true;document.getElementById('newasp_submit').value='继 续';plantext('正在进行数据转换,请耐心等待,中途不要离开本页面。');</script>" & vbCrLf
	Response.Flush
	
	Dim sid,cid,strText,i,n
	Dim TextContent,m_strXmlPath

	Set Rs = Newasp.Execute("SELECT TOP " & maxcount & " softid,ChannelID,isxmltext,xmlfilename FROM NC_SoftList WHERE ChannelID=" & ChannelID & " And isxmltext=1 And isAccept<>0 ORDER BY SoftTime DESC,softid DESC")
	If Rs.EOF Then
		Response.Write "<script language=""javascript"" type=""text/javascript"">plantext('XML数据转换完成');</script>" & vbCrLf
		Response.Flush
	Else
		SQL=Rs.GetRows(-1)
		maxcount=UBound(SQL,2)+1
		n = maxcount \ 100
		For i=0 To maxcount-1
			If Not Response.IsClientConnected Then Response.End
			sid=SQL(0,i)
			cid=SQL(1,i)
			xmlfilename=SQL(3,i) & ""
			If showtext=1 Then
				Response.Write "<script>plantext('正在转换第"&i+1&"条数据');</script>" & vbCrLf
				Response.Flush
			End If
			If Len(xmlfilename) < 5 Then
				'--如果数据库中XML文件名不存在创建新文件名
				xmlfilename = Newasp.CreateFileName(xmlFileExt,xmlFilePrefix,sid)
				Newasp.Execute ("UPDATE NC_SoftList SET xmlfilename='" & Replace(xmlfilename, "'", "") & "' WHERE softid="&sid)
			Else
				m_strXmlPath = xmlFilePath & xmlfilename
				TextContent = Newasp.ReadXMLDocument(m_strXmlPath,"softinfo/@content")
				If Len(TextContent) > 0 Then
					Newasp.Execute ("UPDATE NC_SoftList SET [content]='" & Newasp.CheckStr(TextContent) & "',isxmltext=0 WHERE softid="&sid)
					Newasp.FileDelete(m_strXmlPath)
				End If
			End If
			
			If n > 0 Then 
				If (i+1) mod n = 0 Or (i+1)= maxcount Then
					Response.Write "<script>planwidth("&Int(((i+1)/ maxcount )*100)&");</script>" & vbCrLf
					Response.Flush
				End If
			Else
				If (i+1)= maxcount Then
					Response.Write "<script>planwidth("&Int(((i+1)/ maxcount )*100)&");</script>" & vbCrLf
					Response.Flush
				End If
			End If
		Next
		Response.Write "<script>document.getElementById('newasp_submit').disabled=false;</script>" & vbCrLf
		Response.Flush
		If autoform=1 Then
			Response.Write "<script>setTimeout('document.newasp_form.submit();',1000);</script>" & vbCrLf
			Response.Flush
		End If
	End If
	Set Rs = Nothing
End Sub

%>