SHOWcode

2020年2月3日 星期一

Jquery 抓Json 資料



  <script src="js/jquery-3.3.1.min.js"></script>


    <script type="text/javascript">
        $(document).ready(function () {

            var jqxhr = $.getJSON("./data_json/Filter_json/j97hq-92dsm_n.json", function () {
                console.log("success");
            })

            //如果有這檔案會印出success

            //$.getJSON("./data_json/Resonator_json/tl8oh-63gm2.json", function (json) {
            //    alert("JSON Data: " + json.name);
            //});

            //讀出json屬性的值,name是KEY,根據自己KEY定義改
            //debugger;
            var info = document.querySelector('.info');
            var str = "";


            $.getJSON("./data_json/Filter_json/j97hq-92dsm_n.json", function (json_data) {

                // console.log(JSON.stringify(json));
                // debugger;
                var len = json_data.length; //資料比數

                if (len != 0) {
                    for (var i = 0; i < len; i++) {
                        // var content = '<tr>' + '<td>名稱:' + datastr[i].name + ' </td>' + '<td>value_a:' + datastr[i].value_a + ' </td>' + '<td>value_b:' + datastr[i].value_b + ' </td>' + '<td>value_c:' + datastr[i].value_c + ' </td>' + '<td>value_d:' + datastr[i].value_d + ' </td>' + '<td>value_e:' + datastr[i].value_e + ' </td>' + '</tr>';
                        var content = "";
                        if (json_data[i].value_url != 'Null') {
                            content = '<tr>' + '<td> <a href="./pdf/Datasheet/' + json_data[i].value_url + '" target="_blank"> ' + json_data[i].name + '<img src="./img/pdf-download.png" width="51px" height="35px"></a></td>' + '<td>' + json_data[i].value_a + ' </td>' + '<td>' + json_data[i].value_b + ' </td>' + '<td>' + json_data[i].value_c + ' </td>' + '<td>' + json_data[i].value_d + ' </td>' + '<td> </td>' + '</tr>';
                        } else {
                            content = '<tr>' + '<td>' + json_data[i].name + ' </td>' + '<td>' + json_data[i].value_a + ' </td>' + '<td>' + json_data[i].value_b + ' </td>' + '<td>' + json_data[i].value_c + ' </td>' + '<td>' + json_data[i].value_d + ' </td>' + '<td> </td>' + '</tr>';
                        }

                        //console.log(content);
                        str += content;
                    };
                } else {
                    var content = '<tr>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '<td>Null</td>' + '</tr>';
                    //console.log(content);
                    str += content;
                }

                info.innerHTML += str;
            });


            //將JSON印成字串



        });
    </script>

----Html-----

        <div class="table-responsive">
            <nobr>
                <table class="table">
                    <thead>
                        <tr>
                            <th scope="col">Part</th>
                            <th scope="col">Frequency</th>
                            <th scope="col">Bandwidth</th>
                            <th scope="col">Lid Symbol</th>
                            <th scope="col">Dimension</th>
                            <th scope="col">Automotive</th>

                        </tr>
                    </thead>
                    <tbody class="info">
                    </tbody>
                </table>
            </nobr>
        </div>

nginx服务无法停止(Windows)


nginx服务无法停止(Windows)


本文链接:https://blog.csdn.net/qq_36133698/article/details/88582539


本人一般停止nginx服务都是通过Windows自带的任务管理器来强制结束nginx进程实现的,如图
但是 这次我通过同样的方法来结束nginx服务,发现nginx的进程无法结束
首先我要确认了nginx服务还在运行,因为nginx是web服务器,正常启动的话,是可以访问它的网页的。例如:我们在浏览器中输入:127.0.0.1:8888(默认监听80端口,我这里修改了nginx.conf监听8888端口) 回车后,应该能看到一个欢迎页面(没有改默认网页的情况)。如果能够看到, 说明nginx启动正常。
然后我进入nginx根目录通过命令停止nginx服务,结果报错 如图
意思是nginx服务没有启动 所以nginx服务停止报错 这就很诡异啦 ngnix明明在偷偷运行 这里为啥会提示nginx没有运行呢。因为我的nginx监听的是8888端口 所以我就想 既然终端提示nginx服务停止了那8888端口就不会被监听,但是nginx的web页面可以访问 说明8888端口还在被监听 我只需要把监听8888端口的进程全部kill就可以停止nginx服务啦
cmd 输入命令 netstat -ano 如图 找到nginx监听端口的pid
通过cmd 命令tasklist|findstr "PID"  如图 找到监听8888端口的进程

确实发现有nginx服务在运行 通过cmd命令 taskkill /f /t /im nginx.exe 结束进程 结果如图
最后访问127.0.0.1:8888 失败 说明nginx服务被成功停止





















2020年1月30日 星期四

C#.Net json to datatable

using System.Data;
using System.Web.Script.Serialization;
using System.Collections;
using System.IO;


  String line = "";
        try
        {   // Open the text file using a stream reader.
            string filename = AppDomain.CurrentDomain.BaseDirectory;
            using (StreamReader sr = new StreamReader(filename + @"\data_json\Antenna_DR_json\q9qwy-nvsns.json"))
            {
                // Read the stream to a string, and write the string to the console.
                 line = sr.ReadToEnd();
               // Console.WriteLine(line);
            }
        }
        catch (IOException ex)
        {
        }

        DataTable json_data = JsonToDataTable(line);

    #region json To datatable
    public DataTable JsonToDataTable(string json)
    {
        DataTable dataTable = new DataTable();  //例項化
        DataTable result;
        try
        {
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
            javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大數值
            ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(json);
            if (arrayList.Count > 0)
            {
                foreach (Dictionary<string, object> dictionary in arrayList)
                {
                    if (dictionary.Keys.Count<string>() == 0)
                    {
                        result = dataTable;
                        return result;
                    }
                    if (dataTable.Columns.Count == 0)
                    {
                        foreach (string current in dictionary.Keys)
                        {
                            dataTable.Columns.Add(current, dictionary[current].GetType());
                        }
                    }
                    DataRow dataRow = dataTable.NewRow();
                    foreach (string current in dictionary.Keys)
                    {
                        dataRow[current] = dictionary[current];
                    }

                    dataTable.Rows.Add(dataRow); //迴圈新增行到DataTable中
                }
            }
        }
        catch
        {
        }
        result = dataTable;
        return result;
    }

    #endregion




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);

Jenkins-mail

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