码迷,mamicode.com
首页 > 数据库 > 详细

ESQL之刷新模块配置

时间:2015-02-08 09:04:56      阅读:377      评论:0      收藏:0      [点我收藏+]

标签:database   数据库   管理   配置   web开发   

修改database.xml文件后只需在网页中执行<esql module=模块名 act=refresh />,修改的参数立即生效

例:

<html>
<title>刷新数据模块配置参数</title>
<chtml>
<esql module=help act=refresh />
</chtml>
</html>
轻开B2C电子商务网站数据模块管理实例

数据模块配置文件base/database.xml

<?xml version="1.0" encoding="GBK"?>
<Database DbUrl="jdbc:mysql://localhost/" Password="htok" UserName="root" age="200" DriverName="com.mysql.jdbc.Driver" Name="htok_baby" Unicode="UTF-8" frequency="100" max="32" min="1" pause="1" taskFrequency="1" timesUsed="30" trace="false" weName="家纺数据库"></Database>
显示模块的网页文件hlep/db_info/show.html
初始化配置文件

<bag id=pPage><we name=m1>@{pPage:m}/database.xml</we><we name=t>@{pPage:m}/tables.xml</we></bag>
<we>@{@{pPage:m1}:db}</we><we>@{@{pPage:t}:t}</we>
显示基本配置信息
<table border=1 style="border-collapse:collapse;font-size:12px" width=98% align=center bordercolor=#8bb2e9 cellpadding="3">
	<tr><td colspan=2 align=center><b>基本配置参数</b></td></tr>
	<tr><th width=18%>数据库名称</th><td>@{@{pPage:m1}:Name}</td></tr>
	<tr><th>数据库标题</th><td>@{@{pPage:m1}:weName}</td></tr>
	<tr><th>数据库驱动</th><td>@{@{pPage:m1}:DriverName}</td></tr>
	<tr><th>链接地址</th><td>@{@{pPage:m1}:DbUrl}</td></tr>
	<tr><th>用户名</th><td>@{@{pPage:m1}:UserName}</td></tr>
	<tr><th>密 码</th><td>********</td></tr>
	<tr><td colspan=2 align=center><b>执行 SQL 语句</b></td></tr>
	<form action="@{sys:face}help/db_info/sql.html?m=@{pPage:m}" method=post id=sql>
	<input type=hidden name=tabName>
	<tr><th>SQL语句</th><td><textarea name="sqlStr" rows="6" cols="72"></textarea></td></tr>
	<tr><th>操 作</th><td><INPUT name=act type=radio onclick="showNew(1);" checked value=query>查询<INPUT name=act type=radio value=edit onclick="showNew(0);">修改  <chtml><if x="@{sys:canDo}"><a href="javascript:doSql();void(0);" x=true>[执行]</a></if></chtml><div id=addnew><input type=CheckBox name=new value=1>同时生成表配置 位置:<select name=sort><chtml><for end="@{@{pPage:t}:getLength}" ><option>@{for:getSuffix}</option></for></chtml><option selected>@{@{pPage:t}:getLength}</option></select></div></td></tr></form>
</table>
显示高级配置信息
<table border=1 style="border-collapse:collapse;font-size:12px;display:none" width=98% align=center bordercolor=#8bb2e9 cellpadding="3" id=HighTab>
	<tr><td colspan=2 align=center><b>连接池配置参数</b></td></tr>
	<tr><th width=18%>基本连接数</th><td>@{@{pPage:m1}:min}  (缺省为2)</td></tr>
	<tr><th>最大连接数</th><td>@{@{pPage:m1}:max}  (缺省为5)</td></tr>
	<tr><th>连接能使用的次数</th><td>@{@{pPage:m1}:timesUsed}  (缺省为3次)</td></tr>
	<tr><th>连接能等待的时间</th><td>@{@{pPage:m1}:age}  (缺省为120秒)</td></tr>
	<tr><th>连接池的刷新周期</th><td>@{@{pPage:m1}:frequency}  (缺省为60秒)</td></tr>
	<tr><th>连续几次连不上数据库后暂停连接池</th><td>@{@{pPage:m1}:pause}  (缺省为5次)</td></tr>
	<tr><th>控制台输出有关连接池的提示</th><td>@{@{pPage:m1}:trace}  (缺省为false,即不输出)</td></tr>
</table>
相关操作脚本代码
//折叠左边的窗口
var highShow = false;
function doShow()
{
	if(highShow)
	{
		showHigh.style.display = "block";
		hideHigh.style.display = "none";
		HighTab.style.display = "none";
		highShow = false;
	}
	else{
		showHigh.style.display = "none";
		hideHigh.style.display = "block";
		HighTab.style.display = "block";
		highShow = true;
	}
}
function doDel()
{
	if(!confirm('真的要删除吗?\r数据模块删除后,使用该模块的应用程序将不能正常工作!\r放弃删除请点[取消],确认删除请点[确定]')){return;}
	var str = '@{sys:face}help/db_info/del.chtml?m=@{pPage:m}';
		location.href= str;
}
function doSql()
{
	var sql = document.forms['sql'];
	if(sql['sqlStr'].value=="")
	{alert("SQL语句不能空!");sql['sqlStr'].focus();return;}
	if(!confirm('请认真检查SQL语句和操作的类型!\r修改请点[取消],执行请点[确定]')){sql['sqlStr'].focus();return;}
	var str = sql['sqlStr'].value.toLowerCase();
	var pos = str.indexOf('from');
	if(pos>0)
	{
		str = sql['sqlStr'].value.substring(pos+5);
		pos = str.indexOf(' ');
		if(pos>0) str = str.substring(0,pos);
		sql['tabName'].value = str;
	}
	sql.submit();
}
function showNew(i)
{
	if(i==1)
		addnew.style.display = "block";
	else{
		addnew.style.display = "none";
		var sql = document.forms['sql'];
		sql['new'].checked = false;
	}
}
效果
技术分享
编辑(help/db_info/edit.html)状态显示效果

技术分享

保存配置信息及刷新模块代码(help/db_info/save.chtml)

<html>
<chtml><Bag id=sys><we name=NodeID>a0</we></Bag><!-- 栏目节点 --></chtml>
<chtml file="base/ac/checkAcl.htm"/><!-- 引入权限检查文件 -->
<chtml>
<!-- 权限判断 -->
	<if x="@{sys:canDo}" else=1>
		<we x=true>
			<if x="@{cover:@{sys:modules}(@{pPage:m})}" else=1>
				<bag id=pPage x=true><we name=m1>@{pPage:m}/database.xml</we></bag>
				<we>
					<bag id=pPage><we name=m1>help/db_info/db.xml</we></bag>
					<we>@{@{pPage:m1}:db}</we>
					<Bag id="@{pPage:m1}" act=save>@{pPage:m}/tables.xml</Bag>
				</we>
			</if>
			<we>@{@{pPage:m1}:db}</we>
			<bag id='@{pPage:m1}'>
				<we name="Name">@{pPage:Name}</we>
				<we name="weName">@{pPage:weName}</we>
				<we name="DriverName">@{pPage:DriverName}</we>
				<we name="DbUrl">@{pPage:DbUrl}</we>
				<we name="UserName">@{pPage:UserName}</we>
				<we name="Password">@{pPage:Password}</we>
				<we name="min">@{pPage:min}</we>
				<we name="max">@{pPage:max}</we>
				<we name="timesUsed">@{pPage:timesUsed}</we>
				<we name="age">@{pPage:age}</we>
				<we name="frequency">@{pPage:frequency}</we>
				<we name="pause">@{pPage:pause}</we>
				<we name="trace">@{pPage:trace}</we>
			</bag>
			<Bag id="@{pPage:m1}" act=save>@{pPage:m}/database.xml</Bag>
			<if x="@{pPage:FileDB_extname}" else=1><we/><file value="@{pPage:FileDB}">@{pPage:Name}</file></if>
			<esql module="@{pPage:m}" act=refresh>更新参数</esql>
			<script>alert("操作成功!");</script>
		</we>
		<script>alert("您没有权限!");</script>
	</if>
</chtml>
<form id=reload target=lframe action="@{sys:face}help/dbs_menu.html"></form>
<script>
	location.href='@{sys:face}help/db_info/show.html?m=@{pPage:m}';
	document.forms['reload'].submit();
</script>
</html>
其中的

<esql module="@{pPage:m}" act=refresh>更新参数</esql>
即时刷新了刚才修改的模块参数,不必重新启动系统。
百闻不如一见,赶快打开轻开B2C电子商务网站并登录后台试试吧技术分享

轻开平台资源下载及说明

平台免费下载:http://download.csdn.net/detail/tx18/8381859

最新开发手册下载:http://download.csdn.net/detail/tx18/8411089

开发实例:轻开B2C电子商务网站,免费下载:http://download.csdn.net/detail/tx18/8318585

轻开平台会不定期升级为大家提供更多强大而Easy的功能,请留意最新的开发手册



ESQL之刷新模块配置

标签:database   数据库   管理   配置   web开发   

原文地址:http://blog.csdn.net/tx18/article/details/43634417

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!