国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語(yǔ)言|JavaScript|易語(yǔ)言|vb.net|

服務(wù)器之家 - 編程語(yǔ)言 - ASP.NET教程 - asp.net線程批量導(dǎo)入數(shù)據(jù)時(shí)通過(guò)ajax獲取執(zhí)行狀態(tài)

asp.net線程批量導(dǎo)入數(shù)據(jù)時(shí)通過(guò)ajax獲取執(zhí)行狀態(tài)

2020-04-15 13:16LI小白 ASP.NET教程

asp.net線程批量導(dǎo)入數(shù)據(jù)是大家日常工作中常遇到的一個(gè)要求,但批量添加時(shí)間一般較長(zhǎng),如果能返回執(zhí)行的狀態(tài)就好,那么下面這篇文章主要給大家介紹了asp.net線程批量導(dǎo)入數(shù)據(jù)時(shí)通過(guò)ajax獲取執(zhí)行狀態(tài)的方法,有需要的朋友可以參

前言

最近因?yàn)楣ぷ髦杏龅揭粋€(gè)需求,需要做了一個(gè)批量導(dǎo)入功能,但長(zhǎng)時(shí)間運(yùn)行沒(méi)個(gè)反饋狀態(tài),很容易讓人看了心急,產(chǎn)生各種臆想!為了解決心里障礙,寫(xiě)了這么個(gè)功能。

通過(guò)線程執(zhí)行導(dǎo)入,并把正在執(zhí)行的狀態(tài)存入session,既共享執(zhí)行狀態(tài),通過(guò)ajax調(diào)用session里的執(zhí)行狀態(tài),從而實(shí)現(xiàn)反饋導(dǎo)入狀態(tài)的功能!

上代碼: 前端頁(yè)面

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>批量導(dǎo)入數(shù)據(jù)</title>
 <style type="text/css">
  .pop_body_con { width: 310px; position: fixed; top: 50%; left: 50%; margin-left: -150px; background: #eee; display:none; }
   .pop_body_con .pop_head { width: auto; padding: 10px 0; background: #fff; }
    .pop_body_con .pop_head a { display: block; color: #717274; font-size: 12px; text-decoration: none; text-align: center; }
  .pop_box { width: auto; overflow: hidden; padding: 45px 10px; }
   .pop_box .pop_text { float: left; }
    .pop_box .pop_text p { padding: 0; margin: 0; font-size: 12px; line-height: 18px; color: #717274;}
   .pop_box .progress_bar_con { float: left; width: 220px; position: relative; z-index: 2; }
    .pop_box .progress_bar_con p { margin: 0; padding: 0; font-size: 12px; color: #fff; line-height: 18px; width: 100%;
            text-align: center; position: absolute; left: 0; top: 0; z-index: 4; }
    .pop_box .progress_bar_con .progress_bar_start { width: 100%; height: 18px; background: #C4C0C0; }
    .pop_box .progress_bar_con .progress_bar_end { width: 16%; height: 18px; background: #2bd35d; position: absolute; left: 0; top: 0; z-index: 3; }
   .pop_box .progress_bar_con { float: left; }
  #loading-mask { width: 100%; height: 100%; position: fixed; top: 0px; left: 0px; z-index: 0; background-color: rgba(0, 0, 0, 0.34902); display: none; }
 </style>
 <script src="ajax-master/jquery.js"></script>
 <script>
  var MyInterval;
 
  $(function () {
   $("#startImport").click(function () {
    MyInterval = setInterval(getState, 1000);
   });
  });
  
  function getState() {
   $.ajax({
    url: "test.aspx",
    type: "Post",
    data: { action: "getSession" },
    success: function (msg) {
     if (msg != "null") {
      msg = eval('(' + msg + ')');
      if (msg.being == 100) {
       setProcessBar(1, 1);
       $(".pop_body_con").hide();
       $("#loading-mask").hide();
       clearInterval(MyInterval);
      }
      else {
       $(".pop_body_con").show();
       $("#loading-mask").show();
       setProcessBar(msg.being, msg.count)
      }
     }
    }
   });
  }
 
  function setProcessBar(exeFlag, exeMax) {
   $("#progressbar_text").html(parseInt(roundFun(exeFlag / exeMax, 2) * 100) + "%");
   $("#progressbar_bar").attr("style", "width:" + parseInt(roundFun(exeFlag / exeMax, 2) * 100) + "%;");
  }
 
  function roundFun(number, X) {
   X = (!X ? 2 : X);
   return Math.round(number * Math.pow(10, X)) / Math.pow(10, X);
  }
 </script>
</head>
<body style="background-color: #fff;">
 <input id="startImport" type="button" value="導(dǎo)入數(shù)據(jù)" />
 <div id="loading-mask" ></div>
 <div class="pop_body_con">
  <div class="pop_head">
   <a href="javascript:;">正在導(dǎo)入…請(qǐng)勿操作!</a>
  </div>
  <div class="pop_box">
   <div class="pop_text">
    <p>導(dǎo)入進(jìn)度:</p>
   </div>
   <div class="progress_bar_con">
    <p id="progressbar_text">0%</p>
    <div class="progress_bar_start"></div>
    <div class="progress_bar_end" id="progressbar_bar"></div>
   </div>
  </div>
 </div>
</body>
</html>

后臺(tái)頁(yè)面:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class test : System.Web.UI.Page
{
 protected void Page_Load(object sender, EventArgs e)
 {
  string action = Request.Form["action"];
  if (!string.IsNullOrEmpty(action))
  {
   Hashtable temp = tmethod();
   if (temp == null)
   {
    Thread trd = new Thread(new ParameterizedThreadStart(insertData));
    trd.Start(action);
   }
   else
   {
    if (temp["reCode"].ToString() == "100")
    {
     
     Session.Remove("process");
    }
   }
 
   JavaScriptSerializer ser = new JavaScriptSerializer();
   String jsonStr = ser.Serialize(temp);
   Response.Write(jsonStr);
   Response.End();
  }
 }
 
 
 public Hashtable tmethod()
 {
  return (Hashtable)Session["process"];
 }
 
 private void insertData(object obj)
 {
  string action = obj.ToString();
  int tCount = 100;
  for (int i = 0; i < tCount; i++)
  {
   Hashtable stateHash = setStateVal(0, i, tCount, action);
   Session["process"] = stateHash; //存入session,方便共享執(zhí)行狀態(tài)
   Thread.Sleep(500);
  }
  Session["process"] = setStateVal(100, tCount, tCount, action);
  Thread.CurrentThread.Abort();
 }
 
 private Hashtable setStateVal(int code, int beingV, int CountV, string action)
 {
  Hashtable stateHash = new Hashtable();
  stateHash["reCode"] = code; //返回狀態(tài)值
  stateHash["being"] = beingV;  //正在執(zhí)行值
  stateHash["count"] = CountV;  //總值
  stateHash["action"] = action;  //總值
  return stateHash;
 }
}

ok,共享完畢!

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問(wèn)大家可以留言交流。

原文鏈接:http://www.cnblogs.com/LittleBai/p/6179183.html

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 免费av片网站| 亚洲天堂一区 | 欧美一级片在线 | 精品九色 | 精精国产xxxx视频在线观看 | 精品在线一区二区 | 日韩福利视频导航 | 91精品一区二区三区久久久久久 | 精品黑人一区二区三区久久 | 久久国产精品无码网站 | 校园春色av | 一级全黄性色生活片 | 最好看的2019年中文在线观看 | 亚洲欧美另类久久久精品2019 | 青青久久久 | 国产老头老太作爱视频 | 日韩欧美网站 | 久久久久久亚洲 | 国产精品二区一区二区aⅴ污介绍 | 精品久久av | 亚洲国内精品 | 国产精品毛片久久久久久久 | 亚洲男人的天堂在线观看 | 澳门av| 欧美一级在线视频 | 国内精品视频 | 欧美另类国产 | 国外成人在线视频 | 日韩在线免费电影 | 欧美一区亚洲一区 | 久久大 | 国产精品99久久久久久www | 米奇777超碰欧美日韩亚洲 | 久久久成人动漫 | 伊人热久久婷婷 | 老丁头电影在线观看 | 久久精品亚洲精品 | 蜜臀久久精品99国产精品日本 | 久久精品一区二区三区四区 | 日韩精品一区不卡 | 欧美一区二区在线观看 |