SHOWcode

2020年1月19日 星期日

長時間裝載的ASP.NET頁面 在客戶端瀏覽器中顯示進度




对于加载时间比较长的ASP.NET页面,我们可以在客户端浏览器中显示进度条来显示页面正在装载。下面就是具体的实现过程:

新建项目,名字为WebPortal,在项目类型中选择Visual C#项目或者Visual Basic项目都可;
在模板类型中选择ASP.NET Web应用程序;
位置里输入:http://localhost/WebPortal;
添加新项:名字为ShowProgress的Web窗体。
在您的Web窗体ShowProgress.aspx上添加任何其他的Web服务器控件。
在ShowProgress.aspx上单击右键,点“查看代码”,在最上面输入:
Visual C# .NET代码
using System.Threading;

Visual Basic .NET代码
Imports System.Threading

在Page_Load事件里输入: Visual C# .NET代码
Response.Write("<div id='mydiv' >");
Response.Write("_");
Response.Write("</div>");
Response.Write("<script>mydiv.innerText = '';</script>");
Response.Write("<script language=javascript>;");
Response.Write("var dots = 0;var dotmax = 10;function ShowWait()");
Response.Write("{var output; output = '正在装载页面';dots++;if(dots>=dotmax)dots=1;");
Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText =  output;}");
Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ");
Response.Write("window.setInterval('ShowWait()',1000);}");
Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';");
Response.Write("window.clearInterval();}");
Response.Write("StartShowWait();</script>");
Response.Flush();
Thread.Sleep(10000);

Visual Basic .NET代码
Response.Write("<div id='mydiv' >")
Response.Write("_")
Response.Write("</div>")
Response.Write("<script>mydiv.innerText = '';</script>")
Response.Write("<script language=javascript>;")
Response.Write("var dots = 0;var dotmax = 10;function ShowWait()")
Response.Write("{var output; output = '正在装载页面';dots++;if(dots>=dotmax)dots=1;")
Response.Write("for(var x = 0;x < dots;x++){output += '·';}mydiv.innerText =  output;}")
Response.Write("function StartShowWait(){mydiv.style.visibility = 'visible'; ")
Response.Write("window.setInterval('ShowWait()',1000);}")
Response.Write("function HideWait(){mydiv.style.visibility='hidden';")
Response.Write("window.clearInterval();}")
Response.Write("StartShowWait();</script>")
Response.Flush()
Thread.Sleep(10000)

在ShowProgress.aspx窗体的html的中输入:
<script>
HideWait();
</script>



資料來源:https://blog.csdn.net/luyifeiniu/article/details/45230

2020年1月17日 星期五

Angular 8降级到Angular 7

Angular 8降级到Angular 7

npm   --nodjs

ng --version
npm uninstall -g @angular/cli
npm cache clean --force

npm install -g @angular/cli@7.3.9
ng --version

-- 創建Angular
 ng new ClientApp

2019年5月26日 星期日

pyQt5 button 事件(紀錄)



def setupUi(self, Form):
    Form.setObjectName("Form")
    Form.resize(489, 400)
    self.bt_file01 = QtWidgets.QPushButton(Form)
    self.bt_file01.setGeometry(QtCore.QRect(100, 140, 91, 51))
    self.bt_file01.setObjectName("bt_file01")
    self.bt_file01.clicked.connect(self.hello)




def hello(self):
    self.lb_title.setText("hello 我被觸發了")


2019年3月10日 星期日

C#.net Page_Load 前得知所按的BUTTON


C#.net Page_Load 前得知所按的BUTTON

參考:https://dotblogs.com.tw/jeff377/2008/03/17/1725

  protected void Page_Init(object sender, EventArgs e)
    {
        string strs1 = "";
        foreach (string str in Request.Form)
        {
            String ssss = str;
            Control c = Page.FindControl(str);
            if (c is Button)
            {
                Button imageb = (Button)c;
                strs1 += imageb.ID;
            }
        }
        string strs2 = strs1;

        if (strs1 == "Button1") {

            int xxx = int.Parse(Session["count"].ToString().Trim());
            int add_xxx = xxx + 1;
            Session["count"] = add_xxx.ToString().Trim();

            //Label3.Text = (int.Parse(Label3.Text.ToString().Trim()) + 1).ToString().Trim();
            Label3.Text = Session["count"].ToString().Trim();
        }

    }

2019年2月11日 星期一

MSSQL:使用SqlBulkCopy將資料批次寫入資料庫


MSSQL:使用SqlBulkCopy將資料批次寫入資料庫
原址:https://demo.tc/post/283
Oracle:https://blog.csdn.net/baidu_27474941/article/details/71709420

//一開始我們先產生一個DataTable來裝我們要寫入的資料
 DataTable dt = new DataTable();
 dt.Columns.Add("id", typeof(int));
 dt.Columns.Add("name", typeof(string));
 
 //因為SqlBulkCopy的猛就是大量的一次寫入,所以我們也來跑10萬筆吧
 int i;
 for (i = 0; i < 100000; i++)
 {
     DataRow dr = dt.NewRow();
     dr["name"] = i.ToString();
     dt.Rows.Add(dr);
 }
 
 //宣告連結字串
 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ASPNETDBConnectionString1"].ConnectionString);
 
 conn.Open();
 //宣告SqlBulkCopy
 using (SqlBulkCopy sqlBC = new SqlBulkCopy(conn))
         {
             //設定一個批次量寫入多少筆資料
             sqlBC.BatchSize = 1000;
             //設定逾時的秒數
             sqlBC.BulkCopyTimeout = 60;
 
             //設定 NotifyAfter 屬性,以便在每複製 10000 個資料列至資料表後,呼叫事件處理常式。
             sqlBC.NotifyAfter = 10000;
             sqlBC.SqlRowsCopied += new SqlRowsCopiedEventHandler(OnSqlRowsCopied);
 
             //設定要寫入的資料庫
             sqlBC.DestinationTableName = "dbo.Table1";
              
             //對應資料行
             sqlBC.ColumnMappings.Add("id", "id");
             sqlBC.ColumnMappings.Add("name", "name");
 
             //開始寫入
             sqlBC.WriteToServer(dt);
         }
         conn.Dispose();
 }
 void OnSqlRowsCopied(object sender, SqlRowsCopiedEventArgs e)
 {
     Response.Write("---<br/>");
 } 

2019年2月10日 星期日

將字串轉換成Html編碼 /解碼 字串

摘要:將字串轉換成Html編碼 /解碼 字串
System.Web.HttpUtility.HtmlEncode(txtBox.Text);
System.Web.HttpUtility.HtmlDecode(txtBox.Text);

2018年12月9日 星期日

C# ENTER 防呆

<form id="form1" runat="server" onkeypress="if (window.event.keyCode==13) return false;">
..
.
.
.
</form>

C# 正規 紀錄


public static bool isMatchNumber(string str)
    {
        return Regex.IsMatch(str, @"(^([0-9]*|\d*\d{1}?\d*)$)");
    }

2018年11月8日 星期四

C# ajax 範例


C#.net ajax 範例


  <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel2"  UpdateMode="Conditional" runat="server" >
    <ContentTemplate>
       <fieldset>
       <legend>UpdatePanel content</legend>
        <!-- Other content in the panel. -->
           <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
           <table style="width: 1024px" align="center" >
                    <tr>
                        <td>
                 <nobr>
                <table class="table table-bordered" id="maintable" rules="ALL" class="table" style="width: 100%; max-width: 1024px; border-color: black;" align="center">
                      <tr style=" display: none;">
                       <td style="width: 10%;"></td>
                        <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                        <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>
                         <td style="width: 10%;"></td>

                    </tr>
<asp:Label ID="Label2" runat="server" ></asp:Label>
                     </table>
                        </td>
                        </tr>

                    </table>

           <input type="checkbox" checked="checked" />
           <input id="ch" type="checkbox"  />
           <input type="checkbox" checked="checked" />
           <asp:TextBox ID="TextBox23" runat="server"></asp:TextBox>
           <asp:Button ID="Button2" runat="server" Text="Button"/>
           <iframe id="iframesun" runat="server" style="width:100%;height:944px"></iframe>
        </fieldset>
    </ContentTemplate>
</asp:UpdatePanel>

Jenkins-mail

參考:http://www.linuxea.com/1767.html 前置作業略過~有空再補 Mailer Plugin post { success { emailext ( subject: ...