UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (21)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
  • API串接 (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • SQL
  • code
  • postmessag
  • 現網站在大流量卡住時
  • aHR0cDovL3
  • aHR0cHM6Ly
  • 9367-9367
  • 92
  • db
  • rewrite
  • asp
  • css
  • thread
  • xml2121121
  • a
  • 遠端桌面服務
  • 無法新增重複的集合元
  • Image
  • vb
  • 背景圖
  • mirro
  • 上傳檔案
  • CK
  • 98
  • win ORDER
  • 26
  • -6734
  • @@Yk5Fc
  • 大榮
  • c
  • 隱碼
  • ip
  • idictionar
  • 1
  • load
  • JSON
  • Button
  • cast order
  • 122,
  • https:www.
  • tls1.0
  • IndexOf
  • 跳出
  • 漢光
  • ClientIP
  • 14
  • LINE
  • 408
  • jq
  • pG2rL0AN
頁數 1 / 56 下一頁
在 Postgres 中不要使用 "Not In"
select id from shopline_customer where id not in (select id from shopline_customer_ext)
以上 SQL 跑不完.

SELECT c.id
FROM shopline_customer c
WHERE NOT EXISTS (
    SELECT 1
    FROM shopline_customer_ext e
    WHERE e.id = c.id
);

以上 SQL 只要 0.3 秒.

GPT 的解釋: (ps, id 是 primary key, 非 null)
🚨 一、為什麼會慢:NOT IN 的效能陷阱
NOT IN 會觸發「反半連接(anti-join)」掃描
PostgreSQL 必須逐筆比對左邊的每個 id
並檢查右邊的 id 是否不在其中
若右邊子查詢結果中出現任何 NULL,NOT IN 的邏輯會「不確定」,導致全表掃描與回退
即使 id 是主鍵(有索引),PostgreSQL 通常仍會展開為 Nested Loop Anti Join 或 Hash Anti Join,
當 shopline_customer 和 shopline_customer_ext 都是大表(例如數十萬筆),
時間就會暴漲。
⚠️ NOT IN + NULL 問題:
即使 id 欄位宣告為 NOT NULL,也可能因外層的隱含條件造成額外檢查負擔。
PostgreSQL 會多執行一次 Anti-Join NULL Filter,浪費時間。
More...
Bike, 2025/10/29 上午 10:24:11
IIS的29小時重啟機制
其實這是老問題了,就是IIS每過29小時會重啟 App Pool 機制
這個機制目的是讓主機可以回收記憶體以增進網站效能,過程是smooth的
當此回收機制開始時,新的request會由新的程序跑,舊的request仍會把他跑完(理論上,但太久的程式還是會自動停)

這樣的機制,最明顯的是會造成 inProc 的 session or cache 資料消失
造成程式上的錯誤,或是user的資料消失
另外,這個29小時回收機制,不會因為程式更新,網站重啟,而重新計算

原本以為這機制影響不大,但最近因為電商後台程式有個排程跑太久剛好被回收機制中斷
然後自己假日在外無法即時處理問題,造成電商客戶在等著把問題解決
想說還是把這個 29小時魔咒 處理一下
在某個特定無排程時間,執行重啟網站
 
More...
darren, 2025/9/1 上午 10:30:33
HCT 新竹物流串接
這是使用新竹物流的範例程式  來源是UNT後台Web專案
* 新竹物流取得配號API必須先在專案加入WEB服務參考 (此專案命名是HctService)
* 取得配號是使用 HctService.Service1SoapClient -> TransData_Json() 來取得
  回傳資料因為有 面單(出貨標籤) 圖檔的Hex字串,所以回應訊息很大,建議一次僅處理兩筆出貨單
* 本範例程式有處理Hex字串轉圖檔程式

* 取得貨況的功能。是另一組專用API -> https://www.hct.com.tw/phone/searchGoods_Main_Xml.ashx
  * POST參數是xml再加密為base64字串
  * Response是base64字串,需解密為xml
  * 本程式範例有相關的使用與加解密功能 參考 GetDeliveryStatus
More...
darren, 2025/8/20 下午 02:40:19
流量異常原因查找
由實體機追查哪一台 VM 的流量最大

# 抓取第一次數據
$before = Get-Counter -Counter @(
    '\Hyper-V Virtual Network Adapter(*)\Bytes Sent/sec',
    '\Hyper-V Virtual Network Adapter(*)\Bytes Received/sec'
)

# 等待 10 秒
Start-Sleep -Seconds 10

# 抓取第二次數據
$after = Get-Counter -Counter @(
    '\Hyper-V Virtual Network Adapter(*)\Bytes Sent/sec',
    '\Hyper-V Virtual Network Adapter(*)\Bytes Received/sec'
)

# 分析並計算平均每秒流量
$results = @()

for ($i = 0; $i -lt $before.CounterSamples.Count; $i++) {
    $instance = $before.CounterSamples[$i].InstanceName

    $sentIndex = $i
    $recvIndex = $i + $before.CounterSamples.Count / 2

    $sentBefore = $before.CounterSamples[$sentIndex].CookedValue
    $sentAfter = $after.CounterSamples[$sentIndex].CookedValue

    $recvBefore = $before.CounterSamples[$recvIndex].CookedValue
    $recvAfter = $after.CounterSamples[$recvIndex].CookedValue

    $sentPerSec = ($sentAfter - $sentBefore) / 10
    $recvPerSec = ($recvAfter - $recvBefore) / 10

    $results += [PSCustomObject]@{
        AdapterName   = $instance
        SentPerSec    = [math]::Round($sentPerSec, 2)
        ReceivedPerSec = [math]::Round($recvPerSec, 2)
        TotalPerSec   = [math]::Round($sentPerSec + $recvPerSec, 2)
    }
}

# 顯示結果,依照總流量排序
$results | Sort-Object TotalPerSec -Descending | Format-Table -AutoSize



用 performance monitor 監查看各VM的流量(找不到)
Get-Counter '\Hyper-V Virtual Network Adapter(*)\Bytes Total/sec'

在 VM 上追查哪個網站流量最大
用 performance monitor 監查看各網站的流量
Web Service: Bytes Sent/sec
 
More...
Bike, 2025/8/4 上午 11:11:06
PrintDocument 另存成 PDF
如果列印主機是 windows server 主機,通常會有 "Microsoft Print to PDF" 名稱的印表機
那使用 Print Document 物件另存成 PDF code 如下
pd.PrinterSettings.PrinterName = "Microsoft Print to PDF";
pd.PrinterSettings.PrintToFile = true;
pd.PrinterSettings.PrintFileName = @"C:\TEMP\XPS\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf";
More...
darren, 2025/5/12 下午 04:36:12
AWS SES 建立 SNS 通知
在 powershell 執行以下的指令


# List of SES identities
$identities = @(
    "wztech.com.tw",
    "s3.com.tw",
    "jdcard.com.tw",
    "mskcable.com",
    "uwinfo.com.tw",
    "bike.idv.tw",
    "richwave.com.tw",
    "ctcn.com.tw",
    "jcard.com.tw",
    "bike@bike.idv.tw",
    "ee@ier.org.tw"
)

foreach ($identity in $identities) {
    # Convert identity to a valid topic name by replacing '@' and '.' with '_'
    $safeIdentity = $identity -replace "@", "_" -replace "\.", "_"
    $topicName = "SES_NOTIFY_$safeIdentity"
    $endpoint = "https://working.uwinfo.com.tw/aws/api/sns/receive?topic=$topicName"

    # Validate topic name format
    if ($topicName -notmatch '^[a-zA-Z0-9_\-\$]+$') {
        Write-Host "❌ Invalid topic name: $topicName"
        continue
    }

    # 1. Create SNS topic
    $topicArn = aws sns create-topic `
        --name $topicName `
        --query 'TopicArn' `
        --output text

    Write-Host "✔ Created topic: $topicArn"

    # 2. Subscribe webhook
    aws sns subscribe `
        --topic-arn $topicArn `
        --protocol https `
        --notification-endpoint $endpoint

    Write-Host "✔ Subscribed webhook: $endpoint"

    # 3. Link SES notifications
    foreach ($type in @("Delivery", "Bounce", "Complaint")) {
        aws ses set-identity-notification-topic `
            --identity $identity `
            --notification-type $type `
            --sns-topic $topicArn
        Write-Host "✔ $type linked to $topicName"
    }

    Write-Host "✅ Setup complete for $identity\n"
}

Write-Host "🎉 All identities processed."



收到的 log 會放在這裡: E:\WebBackup\195\ASP.NET Project\working\Data\Log\sns

 
 
More...
Bike, 2025/4/16 上午 10:40:39
AWS SES 建立 SNS 通知
在 powershell 執行以下的指令

# List of SES identities
$identities = @(
    "wztech.com.tw",
    "s3.com.tw",
    "jdcard.com.tw",
    "mskcable.com",
    "uwinfo.com.tw",
    "bike.idv.tw",
    "richwave.com.tw",
    "ctcn.com.tw",
    "jcard.com.tw",
    "bike@bike.idv.tw",
    "ee@ier.org.tw"
)

foreach ($identity in $identities) {
    # Convert identity to a valid topic name by replacing '@' and '.' with '_'
    $safeIdentity = $identity -replace "@", "_" -replace "\.", "_"
    $topicName = "SES_NOTIFY_$safeIdentity"
    $endpoint = "https://working.uwinfo.com.tw/aws/api/sns/receive?topic=$topicName"

    # Validate topic name format
    if ($topicName -notmatch '^[a-zA-Z0-9_\-\$]+$') {
        Write-Host "❌ Invalid topic name: $topicName"
        continue
    }

    # 1. Create SNS topic
    $topicArn = aws sns create-topic `
        --name $topicName `
        --query 'TopicArn' `
        --output text

    Write-Host "✔ Created topic: $topicArn"

    # 2. Subscribe webhook
    aws sns subscribe `
        --topic-arn $topicArn `
        --protocol https `
        --notification-endpoint $endpoint

    Write-Host "✔ Subscribed webhook: $endpoint"

    # 3. Link SES notifications
    foreach ($type in @("Delivery", "Bounce", "Complaint")) {
        aws ses set-identity-notification-topic `
            --identity $identity `
            --notification-type $type `
            --sns-topic $topicArn
        Write-Host "✔ $type linked to $topicName"
    }

    Write-Host "✅ Setup complete for $identity\n"
}

Write-Host "🎉 All identities processed."

--

收到的 log 會放在這裡: E:\WebBackup\195\ASP.NET Project\working\Data\Log\sns

 
 
More...
Bike, 2025/4/16 上午 10:40:31
mysql 使用 EF model 要注意的地方
近日處理我們公司某個使用 my sql 的專案,已經被雷的幾次,紀錄一下

1.  使用 EF Scaffolding 指令去更新 Model ,有些欄位原本是明確型別 變成 可null型別
     也就是本來是 datetime 變成 datetime?, int 變成 int?
     看起來是一些 view 的欄位會有這些狀況,這時就要去 git revert ,避免build專案又一堆錯誤
2.  使用 IQueryable 語法處理時間要小心,不要在裡面計算時間。
     
DateTime shouldBeGiveCoinDateTime = DateTime.Now.AddDays(-14);
return dbContext.ViewOrderForCoinCronJob.AsNoTracking().Where(x =>
    x.CompletedAt <= shouldBeGiveCoinDateTime
    && x.CreatedAt >= DateTime.Now.AddYears(-1) // -> 這裡轉換mysql指令會出錯
    && x.DeletedAt == null
    && x.CoinAmount > 0
    && x.Status == (byte)ORDER_STATUS.COMPLETED
    && dbContext.PackingMain.Any(y => y.OrderId == x.Id)
    && x.IsGiveCoin != 0
    && !dbContext.CoinLog.Any(y =>
        y.OrderId == x.Id
        && y.StrKey.Contains(COIN_LOG.STRING_KEY_PREFIX.ORDER_ACCUMULATION)
    )
).ToList();

要把時間計算先算出來,再帶入式子
DateTime shouldBeGiveCoinDateTime = DateTime.Now.AddDays(-14);
DateTime createDateStartAt = DateTime.Now.AddYears(-1); // -> 先算出日期
return dbContext.ViewOrderForCoinCronJob.AsNoTracking().Where(x =>
    x.CompletedAt <= shouldBeGiveCoinDateTime
    && x.CreatedAt >= createDateStartAt // -> 帶入算好的日期
    && x.DeletedAt == null
    && x.CoinAmount > 0
    && x.Status == (byte)ORDER_STATUS.COMPLETED
    && dbContext.PackingMain.Any(y => y.OrderId == x.Id)
    && x.IsGiveCoin != 0
    && !dbContext.CoinLog.Any(y =>
        y.OrderId == x.Id
        && y.StrKey.Contains(COIN_LOG.STRING_KEY_PREFIX.ORDER_ACCUMULATION)
    )
).ToList();


 
More...
darren, 2025/3/10 下午 05:43:38
Line 登入,出現 "由於無法取得官方帳號的資訊,因此無法新增好友。" 錯誤訊息。
Line 登入時,若是指定了 bot_prompt=aggressive ,但沒有在 Login Channel 指定相對應的 Official Account ,就會看到 "由於無法取得官方帳號的資訊,因此無法新增好友。" 的錯誤訊息,如下圖:



此時要去 Line Login Channel 的 Add friend option 中,指定 Linked LINE Official Account,如下圖:

可參考: https://developers.line.biz/en/docs/line-login/link-a-bot/#link-a-line-official-account




 
More...
Bike, 2025/2/25 上午 08:09:03
IP v4 Country 取得IP所屬國家
其實是 2024/10 取得的IP country 檔案
相關檔案以及程式碼放在附件
More...
darren, 2025/1/23 上午 09:40:06
|< 12345678910… >|
頁數 1 / 56 下一頁
~ Uwinfo ~