我们知道有些报表因为运算的速度实在的太慢,所以我们会让一个页面先计算,缓存在一个地方,然后让客户去读缓存因为速度实在是太慢了,就希望能在计算的中体现现在正在运算哪个模块,我第一才想到的是通过一个页面一个模块,然后一个一个的跳转过去,这样 在界面上就可以看到现在执行的情况,可能这个能达到要求,现在我把他稍微的改造,用一个页面完成,这样程序也好控制点
一、先在web.config中设置配置
一、先在web.config中设置配置
<httpHandlers>
<add verb="POST,GET" path="report/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
<add verb="POST,GET" path="report/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
注意别我忘记在Global.asax中添加
protected void Application_Start(Object sender, EventArgs e)
{
Ajax.Utility.HandlerPath = "report";
}
二、就是做程序了,其实和原来的程序一点也不用改,只要添加就行了,和有个开发经理说的一样,增加有的情况下不是改,是扩充,加什么呢?
private void Page_Load(object sender, System.EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(report.WebForm1));
}
{
Ajax.Utility.RegisterTypeForAjax(typeof(report.WebForm1));
}
先注册类
[Ajax.AjaxMethod]
public string aaaaa()
{
DataSet result = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = this.BuildQuerycommand("xxxxxxxx", "1");
cmd.CommandTimeout = 1000;
da.SelectCommand = cmd;
da.Fill(result);
return "aaaaa";
}
[Ajax.AjaxMethod]
public string bbbbb()
{
DataSet result = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = this.BuildQuerycommand("xxxxxxxx", "1");
public string aaaaa()
{
DataSet result = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = this.BuildQuerycommand("xxxxxxxx", "1");
cmd.CommandTimeout = 1000;
da.SelectCommand = cmd;
da.Fill(result);
return "aaaaa";
}
[Ajax.AjaxMethod]
public string bbbbb()
{
DataSet result = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = this.BuildQuerycommand("xxxxxxxx", "1");
然后把以前写的方法统统考过来,再在头上写[Ajax.AjaxMethod]这样就行了,后台就ok了,主要还要看前台,
<script language="javascript">
function callback_testa(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.bbbbb(callback_testb);
}
function callback_testb(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.ccccc(callback_testc);
}
function callback_testc(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.ddddd(callback_testd);
}
function callback_testd(res)
{
window.document.Form1.all("ss").value+=res.value;
}
function test1()
{
WebForm1.aaaaa(callback_testa);
}
window.onbeforeunload = function()
{
window.event.returnValue = false;
}
</script>
function callback_testa(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.bbbbb(callback_testb);
}
function callback_testb(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.ccccc(callback_testc);
}
function callback_testc(res)
{
window.document.Form1.all("ss").value+=res.value;
WebForm1.ddddd(callback_testd);
}
function callback_testd(res)
{
window.document.Form1.all("ss").value+=res.value;
}
function test1()
{
WebForm1.aaaaa(callback_testa);
}
window.onbeforeunload = function()
{
window.event.returnValue = false;
}
</script>
这个主要是完成前台的显示,注意调用的方法就是使用你注册的类名.你的方法名就行了
这样效果就出来了
没多大的改,编程的样子,实现的效果多了大的改变,虽然实质没改,但在大环境确实有不少的改变啊