2023年10月2日 星期一

[筆記][TSQL]timestamp轉換

SELECT DATEDIFF(SECOND,'1970-01-01', GETUTCDATE()) AS 'UNIX TIMESTAMP';

SELECT DATEADD(s,unix_timestamp,'1970-01-01') as 時間

EX:
SELECT DATEADD(s,1694617261,'1970-01-01') as 時間

2023年8月31日 星期四

[筆記][Log4Net]property

  • %property{log4net:HostName}
  • property{IP}


參考:
https://logging.apache.org/log4net/log4net-1.2.12/release/sdk/log4net.Layout.PatternLayout.html

2023年8月22日 星期二

[筆記][Log4net]aspnet-request

  • <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%-5p %date{yyyy/MM/dd HH:mm:ss} %aspnet-request{HTTP_HOST}%aspnet-request{URL} %-20c{1} %-20M %m%n" />
        </layout>
  • %aspnet-request{key}:
    {slLang, slScreen, ASP.NET_SessionId, __RequestVerificationToken_L2l0aWNrZXQ1, .ASPXAUTH, LoginedUser_UserNo, ALL_HTTP, ALL_RAW, APPL_MD_PATH, APPL_PHYSICAL_PATH, AUTH_TYPE, AUTH_USER, AUTH_PASSWORD, LOGON_USER, REMOTE_USER, CERT_COOKIE, CERT_FLAGS, CERT_ISSUER, CERT_KEYSIZE, CERT_SECRETKEYSIZE, CERT_SERIALNUMBER, CERT_SERVER_ISSUER, CERT_SERVER_SUBJECT, CERT_SUBJECT, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, HTTPS, HTTPS_KEYSIZE, HTTPS_SECRETKEYSIZE, HTTPS_SERVER_ISSUER, HTTPS_SERVER_SUBJECT, INSTANCE_ID, INSTANCE_META_PATH, LOCAL_ADDR, PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, REMOTE_PORT, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PORT_SECURE, SERVER_PROTOCOL, SERVER_SOFTWARE, URL, HTTP_CACHE_CONTROL, HTTP_CONNECTION, HTTP_ACCEPT, HTTP_ACCEPT_ENCODING, HTTP_ACCEPT_LANGUAGE, HTTP_COOKIE, HTTP_HOST, HTTP_REFERER, HTTP_USER_AGENT, HTTP_SEC_CH_UA, HTTP_SEC_CH_UA_MOBILE, HTTP_SEC_CH_UA_PLATFORM, HTTP_UPGRADE_INSECURE_REQUESTS, HTTP_SEC_FETCH_SITE, HTTP_SEC_FETCH_MODE, HTTP_SEC_FETCH_USER, HTTP_SEC_FETCH_DEST}
  • 類似 Request.ServerVariables
  • 說明:
    Key 名稱 備註說明
    slLang 
    slScreen 
    ASP.NET_SessionId 
    __RequestVerificationToken_L2l0aWNrZXQ1 
    .ASPXAUTH 
    LoginedUser_UserNo 
    ALL_HTTP 
    ALL_RAW 
    APPL_MD_PATH 
    APPL_PHYSICAL_PATH 
    AUTH_TYPE 
    AUTH_USER 
    AUTH_PASSWORD 
    LOGON_USER 
    REMOTE_USER 
    CERT_COOKIE 
    CERT_FLAGS 
    CERT_ISSUER 
    CERT_KEYSIZE 
    CERT_SECRETKEYSIZE 
    CERT_SERIALNUMBER 
    CERT_SERVER_ISSUER 
    CERT_SERVER_SUBJECT 
    CERT_SUBJECT 
    CONTENT_LENGTH 
    CONTENT_TYPE 
    GATEWAY_INTERFACE 
    HTTPS 
    HTTPS_KEYSIZE 
    HTTPS_SECRETKEYSIZE 
    HTTPS_SERVER_ISSUER 
    HTTPS_SERVER_SUBJECT 
    INSTANCE_ID 
    INSTANCE_META_PATH 
    LOCAL_ADDR 
    PATH_INFO 
    PATH_TRANSLATED 
    QUERY_STRING 
    REMOTE_ADDR使用者IP ClientIP
    REMOTE_HOST 
    REMOTE_PORT 
    REQUEST_METHOD 
    SCRIPT_NAME 
    SERVER_NAME 
    SERVER_PORT 
    SERVER_PORT_SECURE 
    SERVER_PROTOCOL 
    SERVER_SOFTWARE 
    URL網站:index.html
    子網站:/sub/index.html
    不含querystring
    HTTP_CACHE_CONTROL 
    HTTP_CONNECTION 
    HTTP_ACCEPT 
    HTTP_ACCEPT_ENCODING 
    HTTP_ACCEPT_LANGUAGE 
    HTTP_COOKIE 
    HTTP_HOSTex:web.acb.com
    若是子網站也是抓到此路徑
    HTTP_REFERER 
    HTTP_USER_AGENT 
    HTTP_SEC_CH_UA 
    HTTP_SEC_CH_UA_MOBILE 
    HTTP_SEC_CH_UA_PLATFORM 
    HTTP_UPGRADE_INSECURE_REQUESTS 
    HTTP_SEC_FETCH_SITE 
    HTTP_SEC_FETCH_MODE 
    HTTP_SEC_FETCH_USER 
    HTTP_SEC_FETCH_DEST 

  • 參考:
    https://logging.apache.org/log4net/log4net-1.2.12/release/sdk/log4net.Layout.PatternLayout.html

2023年6月19日 星期一

[筆記][MVC]JSON長度限制(maxJsonLength)

  • 關鍵字:
    • maxJsonLength

  • 原寫法:
    return Json(result, JsonRequestBehavior.AllowGet);

  • 解法一:
    var serializer = new JavaScriptSerializer();
    serializer.MaxJsonLength = Int32.MaxValue;
    var result = new ContentResult{
    Content = serializer.Serialize(uList),
    ContentType = "application/json"
    };
    return result;           
  • 解法二:
    var result =GetJson();
    return new JsonResult() {
     Data = result ,
    MaxJsonLength = int.MaxValue,
     JsonRequestBehavior = JsonRequestBehavior.AllowGet
    };



參考之前文章:
  1. [筆記]使用 JSON JavaScriptSerializer 序列化或還原序列化期間發生錯誤,字串的長度超過在 maxJsonLength 屬性上設定的值。

2023年5月31日 星期三

[筆記]發送訊息至Teams頻道(webhook連接器)

  •  參考:
  • 作法:
    • 建立Webhook連接器。
    • 程式呼叫weebhook發送訊息。
    • 簡易:
      • {"text":"message"}
      • {"text":"message","title":"this is title."}
    • 進階:
      • {"text":"message","title":"this is title."
          "sections": [
            {
              "activityTitle": "Section標題",
              "activitySubtitle": "Section次標題",
              "activityText": "Section內文"
            }]"
         }
      • {"text":"message","title":"this is title."
          "sections": [
            {
              "activityTitle": "Section標題",
              "activitySubtitle": "Section次標題",
              "activityText": "Section內文"
            }
          ,{
              "title": "很像表格的title",
              "facts": [
                {
                  "name": "欄位名",
                  "value": "內文"
                },...
            ]"
         }
      • potentialAction ...etc