<%@ Page CodeFileBaseClass="IlgharCMS.Lib.AdminPageBase" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>批量生成</title>
<script language="c#" runat="server">
protected string Condition()
{
	StringBuilder condition = new StringBuilder();
	condition.Append(Alias.Channel.TemplatePath + " IS NOT NULL");
	condition.Append(" AND " + Alias.Channel.Generate + "=true");
	if (Request.QueryString["Type"] == "Channel" || Request.QueryString["Type"] == "Object")
		condition.Append(" AND " + Alias.Channel.InnerID + "=" + Request.QueryString["ChannelID"]);
	
	return condition.ToString();
}

protected string GetNamespace(object record, bool isChannel)
{
	if (isChannel)
	{
		return Manager.Channels.Select(Alias.Channel.ID + "='" + ((DataRow)record)[Alias.Channel.ID] + "'")[0][Alias.Module.Namespace].ToString();
	}
	else
	{
		if (!Guid.Equals(((DataRow)record)[Alias.Channel.ExtraInstance.BindingChannelID], Guid.Empty))
			return Manager.Channels.Select(Alias.Channel.ID + "='" + ((DataRow)record)[Alias.Channel.ExtraInstance.BindingChannelID] + "'")[0][Alias.Module.Namespace].ToString();
		else if (!Guid.Equals(((DataRow)record)[Alias.Channel.ExtraInstance.BindingInstanceID], Guid.Empty))
			return Manager.Channels.Select(Alias.Instance.ID + "='" + ((DataRow)record)[Alias.Channel.ExtraInstance.BindingInstanceID] + "'")[0][Alias.Module.Namespace].ToString();
		else
			return "";
	}
}
</script>
<script type="text/javascript">
var _page = "generate_do";
var _webPath = "<%=WebPath%>";
var _interval = parseInt("<%=Site[GenerateInterval]%>");
var _type = "<%=Request.QueryString["Type"]%>";
var _objectHeader = "<%=Request.QueryString["Object"]%>";
var _mark;
var _object;
var _pathInChannel, _pathInChannelBackup;
var _caller = new Array();
var _records = null;
var _recordIndex;
var _recordPageNumber;
var _pageSize = 20;
var _pages = null;
var _pageIndex = 0;
var _pageNumber = -1;
var _pageCount = -1;
var _channelIndex = 0;
var _channels = new Array();
<ilghar:List Object="Channel" Condition="Condition()">
	<ilghar:Record>
		_channels[_channels.length] = new Object();
		_channels[_channels.length - 1].Namespace = "<%=GetNamespace(Record, true)%>";
		_channels[_channels.length - 1].InstanceID = "<%=InstanceID%>";
		_channels[_channels.length - 1].Lang = "<%=Lang%>";
		_channels[_channels.length - 1].Path = "<%=Path%>";
		_channels[_channels.length - 1].TemplatePath = "<%=TemplatePath%>";
		_channels[_channels.length - 1].Extension = "<%=Extension%>";
	</ilghar:Record>
</ilghar:List>
var _extraInstances = new Array();
<ilghar:List Object="Channel.ExtraInstance">
	<ilghar:Record>
		_extraInstances[_extraInstances.length] = new Object();
		_extraInstances[_extraInstances.length - 1].ChannelID = "<%=ChannelID%>";
		_extraInstances[_extraInstances.length - 1].BindingInstanceID = "<%=BindingInstanceID%>";
		_extraInstances[_extraInstances.length - 1].BindingChannelID = "<%=BindingChannelID%>";
		_extraInstances[_extraInstances.length - 1].Mark = "<%=Mark%>";
		_extraInstances[_extraInstances.length - 1].Namespace = "<%=GetNamespace(Record, false)%>";
	</ilghar:Record>
</ilghar:List>
var _modules = new Array();
<ilghar:List ID="List" Object="Module">
	<ilghar:Record>
		_modules[_modules.length] = new Object();
		_modules[_modules.length - 1].Namespace = "<%=Namespace%>";
		_modules[_modules.length - 1].Name = "<%=Name%>";
	</ilghar:Record>
</ilghar:List>
var _lang_nothing = "没有可生成项目！";
var _lang_pages = "获取模板页面失败！";
var _lang_generating = "正在生成：";
var _lang_generate_fail = "生成失败！";
var _lang_generate_success = "生成成功！";
var _lang_generate_complete = "生成完毕！";
var _lang_sleep = "休息{Interval}秒钟";
</script>
</head>
<body>
<script type="text/javascript" src="<%=CommonPath%>jquery/core.js"></script>
<ilghar:List Object="Module" Source="List">
	<ilghar:Record>
		<script type="text/javascript" src="<%=Manager.GetModulePath(null)%><%=Namespace%>/alias.js"></script>
	</ilghar:Record>
</ilghar:List>
<script type="text/javascript" src="<%=CommonPath%>xmldom.js"></script>
<script type="text/javascript" src="<%=JsPath%>global.js"></script>
<script type="text/javascript" src="<%=JsPath%>system.js"></script>
</body>
</html>
