Ext.Net 1.x_Ext.Net.TaskManager模拟进度条

Ext.Net
专注与Ext.Net 控件用法,分享优秀JS库。
厦门德仔

一直很想做一个登陆时候的进度条 上图先:

 

   <ext:Button ID="btnlogin" runat="Server" Text="登陆"  Icon="Accept" OnDirectClick="Login_Click" >
            </ext:Button>
             
    <ext:TaskManager ID="TaskManager1" runat="server">
        <Tasks>
            <ext:Task 
                TaskID="Task1"
                Interval="1000" 
                AutoRun="false">
                <DirectEvents>
                    <Update OnEvent="RefreshProgress" />
                </DirectEvents>                    
            </ext:Task>
        </Tasks>
    </ext:TaskManager>

 protected void Login_Click(object sender, DirectEventArgs e)
    {
        Model._Login _lg = new Model._Login();
        _lg.UserCode = this.txtusername.Text.Trim();
        _lg.Password = this.txtpassword.Text.Trim();
        BLL.Login lg = new BLL.Login();
        if (lg.UserLogin(_lg))
        {


            X.Msg.Show(new MessageBoxConfig
            {
                Title = "请等待",
                Message = "正在加载项",
                ProgressText = "初始化中...",
                Width = 300,
                Progress = true,
                Closable = false,
                AnimEl = this.btnlogin.ClientID
            });

            this.StartLongAction();
        }
        else 
        {
            X.Msg.Alert("警告", "账号或密码有误").Show();

        }

    }
    private void StartLongAction()
    {
        this.Session["Task1"] = 0;
        ThreadPool.QueueUserWorkItem(LongAction);

        this.TaskManager1.StartTask("Task1");
    }


    private void LongAction(object state)
    {
        for (int i = 0; i < 100; i++)
        {
            Thread.Sleep(100);
            this.Session["Task1"] = i + 1;
        }
        this.Session.Remove("Task1");
    }


    protected void RefreshProgress(object sender, DirectEventArgs e)
    {
        object progress = this.Session["Task1"];
        if (progress != null)
        {
            X.Msg.UpdateProgress(((int)progress) / 100f, string.Format(" {0} % {1}", progress.ToString(), 100));
        }
        else
        {
            this.TaskManager1.StopTask("Task1");
            X.MessageBox.Hide();
            //this.ResourceManager1.AddScript("Ext.Msg.notify('Done', 'Your items were loaded!');");
            Response.Redirect("Default.aspx");
        }
    }

Ext.Net1.7 后台操作页面超时 并 实现进度条的问题

10-01
![](https://img-ask.csdn.net/upload/201510/01/1443698718_356785.png) 需要达到如图样式 protected void Page_Load(object sender, EventArgs e) { } private static string TableName; //要修改的表名 [DirectMethod(Timeout = 900000)] protected void btnOK_DirectClick(object sender, Ext.Net.DirectEventArgs e) { UpHouse(); } [DirectMethod(Timeout=900000)] public void UpHouse() { try { TableName = this.txtTable.Text.Trim(); DataTable dt = GetDataReader("select distinct HouseCode from " + TableName + " order by HouseCode"); //获取非重复的数据 foreach (DataRow dr in dt.Rows) { string HouseCode = dr["HouseCode"].ToString(); string strSql = "select Id,HouseCode,HouseNo from " + TableName + " where HouseCode = '" + HouseCode + "' order by HouseCode"; DataTable dtr = GetDataReader(strSql); for (int i = 0; i < dtr.Rows.Count; i++) { string HouseCode_new = dtr.Rows[i]["HouseCode"].ToString().Trim(); string HouseNo = dtr.Rows[i]["HouseNo"].ToString().Trim(); string HouseId = dtr.Rows[i]["Id"].ToString().Trim(); if (HouseCode_new != HouseNo) { string UdSql = "Update " + TableName + " set HouseNo = '" + HouseCode_new + "' where Id = " + HouseId; UpdateDataReader(UdSql); break; } } } X.Msg.Alert("提示", "修改成功!").Show(); } catch (Exception e) { X.Msg.Alert("提示", "修改失败!" + e.Message).Show(); } } #region 数据处理 public static string strConn = "Data source=localhost;database=HH;user id=sa;pwd=sa;"; public static DataTable GetDataReader(string strSql) { using (SqlConnection connection = new SqlConnection(strConn)) { DataTable dt = new DataTable(); try { SqlDataAdapter command = new SqlDataAdapter(strSql, strConn); connection.Open(); command.Fill(dt); } catch (Exception ex) { connection.Close(); throw new Exception(ex.Message); } finally { connection.Close(); } return dt; } } public static int UpdateDataReader(string strSql) { using (SqlConnection connection = new SqlConnection(strConn)) { DataSet ds = new DataSet(); try { SqlCommand command = new SqlCommand(strSql, connection); connection.Open(); if (command.ExecuteNonQuery() > 0) { return 1; } else { return 0; } } catch (Exception ex) { connection.Close(); throw new Exception(ex.Message); } finally { connection.Close(); } } } #endregion } }
©️2020 CSDN 皮肤主题: 鲸 设计师: meimeiellie 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值