SHOWcode

2020年2月11日 星期二

Trigger UPDATE,INSERT,DELETE



資料更改時同時寫入另一個表


SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TRIGGER [ TRIGGER名稱 ]   ON [ 主TABLE] AFTER UPDATE,INSERT,DELETE


AS 
BEGIN
IF EXISTS (SELECT 1 FROM inserted) AND EXISTS (SELECT 1 FROM deleted)
BEGIN
INSERT INTO  [ 寫入的TABLE] SELECT 'UPDATE',* FROM inserted
END

ELSE IF EXISTS (SELECT 1 FROM inserted) AND NOT EXISTS (SELECT 1 FROM deleted)
INSERT INTO [ 寫入的TABLE] SELECT 'INSERT',* FROM inserted

ELSE IF NOT EXISTS (SELECT 1 FROM inserted) AND EXISTS (SELECT 1 FROM deleted) 
INSERT INTO [ 寫入的TABLE]   SELECT 'DELETE',* FROM deleted



END
USE [dbMES] GO /****** Object: Trigger [dbo].[tb_recordslog_Modify] Script Date: 2020/4/30 上午 09:00:44 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: <KIRA> -- Create date: <20160727> -- Description: <Device setting> -- ============================================= ALTER TRIGGER [dbo].[tb_recordslog_Modify] on [dbo].[tb_recordslog] AFTER INSERT AS BEGIN --表格異動資料時會產生暫存的inserted和deleted兩個表格 --兩個表格格式資訊皆與原表格相同 --inserted紀錄insert資料、update後資料 --deleted紀錄delete資料、update前資料 --依據異動方式將異動資料新增到記錄檔 --inserted和deleted皆有資料表示為-UPDATE --inserted有資料deleted無資料表示為-INSERT IF EXISTS (select 1 from inserted) and Not EXISTS (select 1 from deleted) insert into tb_recordslog_1 select DID,DIP,SID,DVALUE,SYSTIME from inserted END



2020年2月3日 星期一

json 多table 分類 抓法

json 多table 分類 抓法



---Json--

{
"first":[
{"name":"張三","sex":"男"},
{"name":"李四","sex":"男"},
{"name":"王武","sex":"男"},
{"name":"李梅","sex":"女"}
],
"first01":[
{"name":"張3","sex":"男"},
{"name":"李4","sex":"男"},
{"name":"王5","sex":"男"},
{"name":"李6","sex":"女"}
]
}


----Jscript ----

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


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

            var jqxhr = $.getJSON("./data_json/data/data.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/data/data.json", function (json_data) {

//var len = json_data.first.length; //first表資料比數
                var len = json_data.first01.length; //first01表資料比數

                if (len != 0) {
                    for (var i = 0; i < len; i++) {
                        //var content = '<tr>' + '<td>' + json_data.first[i].name + ' </td>' + '<td>' + json_data.first[i].sex + '</tr>';
                        var content = '<tr>' + '<td>' + json_data.first01[i].name + ' </td>' + '<td>' + json_data.first01[i].sex + '</tr>';
                        //console.log(content);
                        str += content;
                    };
                } else {
                    var content = '<tr>' + '<td>Null</td>' + '<td>Null</td>'  + '</tr>';
                    //console.log(content);
                    str += content;
                }

                info.innerHTML += str;
            });


            //將JSON印成字串



        });
    </script>

----------------Html-------

  <table class="table">
                    <thead>
                        <tr>
                            <th scope="col">Classification</th>
                            <th scope="col"> Part No.</th> 
                        </tr>
                    </thead>
                    <tbody class="info">
                    </tbody> 
                </table>





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

    }

Jenkins-mail

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