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 (20)
  • 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)
最新回應
  • 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
標籤
  • 4027
  • groupby
  • IDENTITY
  • 現網站在大流量卡住時
  • 憑証
  • m0wjbho4
  • git
  • vb.net
  • 82
  • 0KeeTeam|e
  • npoi
  • for
  • 移至定義
  • aspx[t]
  • ef
  • ubuntu
  • sa
  • 寬度
  • SQL2008
  • url2121121
  • message
  • win
  • asp
  • timeout212
  • 826
  • HTTP 錯èª
  • 58
  • iframe
  • CCE-44186-
  • 網址
  • 空格
  • fortinet
  • vpn
  • 排程
  • MSkvKiovQU
  • CS
  • 搜尋
  • ddd
  • 站內
  • minvalue[t
  • dbcontext
  • C
  • -5809
  • .
  • GRANT
  • who
  • ctcn
  • UW.JSON.Wr
  • 1
  • CK,
搜尋 timeout 結果:
dotnet ef dbcontext scaffold
錯誤訊息:
dotnet : 因為找不到指定的命令或檔案,所以無法執行。
位於 線路:1 字元:1
+ dotnet ef dbcontext scaffold "Host=xxxxxxxxxxxxx;CommandTimeout=500 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (因為找不到指定的命令或檔案,所以無法執行。:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
可能的原因包括:
  * 內建 dotnet 命令拼寫錯誤。
  * 您預計要執行 .NET 程式,但不存在 dotnet-ef。
  * 您預計要執行全域工具,但在 PATH 上找不到此名稱且開頭為 dotnet 的可執行檔。
 
解決方法:
重新安裝套件,安裝指令:dotnet tool install --global dotnet-ef


 

參考:
dotnet ef 找不到指定的命令
 
More...
Reiko, 2023/2/13 下午 04:36:03
奇怪的 alert 問題.. 用 setTimeout 來解決.
以下的程式碼, 直接 alert(this.errorMessages); 會造成 chrome 卡住..
使用  setTimeout 延後 alert 可以解決這個問題. 但必需延後足夠的時間. 已知 200 ms 依然會卡住.

    errorMessages: "",

    failProcess: function (ret) {
        console.log("failProcess start: " + new Date().getSeconds() + "." + new Date().getMilliseconds());
        var json = ret.responseJSON;
        if (json && json.invalidatedPayloads) {
            var errors = json.invalidatedPayloads.filter(function F(x) {
                return x.messages.length > 0
            });

            console.log("bdfore add class: " + new Date().getSeconds() + "." + new Date().getMilliseconds());

            errors.map(function (x) {
                return $("[name='" + x.name + "']").addClass("error");
            });

            console.log("after add class: " + new Date().getSeconds() + "." + new Date().getMilliseconds());

            errorMessages = errors.map(function (x) {
                    return x.messages.join('\r\n');
            }).join('\r\n');

            console.log("afger build errorMessages: " + new Date().getSeconds() + "." + new Date().getMilliseconds());
            console.log(errorMessages);

            //alert(this.errorMessages);

            window.setTimeout(api.alertError, 500);

            console.log("after alert: " + new Date().getSeconds() + "." + new Date().getMilliseconds());
        }

        console.log("failProcess end: " + new Date().getSeconds() + "." + new Date().getMilliseconds());
    },
More...
Bike, 2021/9/29 下午 08:45:07
比較程式碼
以前年輕不懂事, 寫了一些很遜的程式碼, 例如:

舊的程式碼:

        public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 0)
        {
            SqlDataAdapter DA = new SqlDataAdapter(Sql, GetDBC(DBC));

            DataTable DT = new DataTable();
            try
            {
                DA = new SqlDataAdapter(Sql, DBC);
                if (timeout > 0)
                {
                    DA.SelectCommand.CommandTimeout = timeout;
                }

                DA.Fill(DT);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
                DA.Dispose();
            }

            return DT;
        }


新的程式碼:
        public static DataTable DTFromSQL(string Sql, string DBC = null, Int32 timeout = 30)
        {
            using (var DA = new SqlDataAdapter(Sql, GetDBC(DBC)))
            {
                //不可為 null
                DataTable DT = new DataTable();

                DA.SelectCommand.CommandTimeout = timeout;

                DA.Fill(DT);

                return DT;
            }
        }


可以參考:
https://dotblogs.com.tw/yc421206/archive/2012/01/03/64154.aspx
 
More...
Bike, 2018/4/4 上午 07:56:39
throttle & debounce
又發現新說法

我們在 front-end 做 scroll event的監聽的時候很常會過度的觸發要執行的事情,因此導致效能不太佳,
我們需要的是固定頻率執行某個function , 這個原來叫 throttle

另外一種狀況像是autocomplete,不需要每一個keyup 都去ajax 去backend 抓資料回來,所以我們過去,
設一個變數去記住setTimeout 回傳回來的數字,如果下一次的keyup 發生在預設的時間內就去把 setTimeout清掉。
原來這種做法,有一個稱呼叫 debounce

不過jQuery 沒有內建這兩個function。這樣在複雜的 js 中增加易讀性。
More...
瞇瞇, 2015/4/6 下午 08:19:47
ThreadStart 未處理 Exception 造成網站Crash
最近把 shopunt 網站重啟的Log加上,發現網站有兩次時無預警的重啟
但是沒有exception log, 於是去看系統的 Event log, 發現出現以下的錯誤

應用程式: w3wp.exe
Framework 版本: v4.0.30319
描述: 處理序已終止,因為有未處理的例外狀況。
例外狀況資訊: System.Exception
堆疊:
於 UW.SQL.DTFromSQL(System.String, System.String)
於 UW.SQL.DTFromSQL(System.String, System.Data.SqlClient.SqlConnection ByRef, Boolean)
於 SHOPUNT.DB.Product.RebuildNotStopProducDT()
於 System.Threading.ExecutionContext.runTryCode(System.Object)
於 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
於 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
於 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
於 System.Threading.ThreadHelper.ThreadStart()

---------------------------------------------------------------------------------------------------------------------------------------

失敗的應用程式名稱: w3wp.exe,版本: 7.5.7601.17514,時間戳記: 0x4ce7afa2
失敗的模組名稱: KERNELBASE.dll,版本: 6.1.7601.18229,時間戳記: 0x51fb1677
例外狀況碼: 0xe0434352
錯誤位移: 0x000000000000940d
失敗的處理程序識別碼: 0x57c4
失敗的應用程式開始時間: 0x01d012faf33398f8
失敗的應用程式路徑: c:\windows\system32\inetsrv\w3wp.exe
失敗的模組路徑: C:\Windows\system32\KERNELBASE.dll
報告識別碼: 90ad2f4d-7f89-11e4-8ad2-e41f13b7d81e


原因是另開 Thread 以非同步取得非停售產品的資料時 產生 sql timeout,這時網站就整個 Crash 
約兩分鐘後才重新啟動,我想雙11網站一直Crash應該跟這個有關

改善方式:
1. RebuildNotStopProducDT 要 Try Catch 不要丟 exception 直接寄 mail 就好
2. 資料庫取得 "非停售產品" 有點沒有效率,不忙時至少要跑 4 秒,資料庫一忙就會Timeout,所以應該要把確定下架且不會販售的產品設定為停售 (Is_StopSell = 'Y'),這樣至少少了2000件產品的查詢,可以秒殺


另外 .NET 4.0 有新的物件叫做 Task 可以用來處理非同步程式,也可以處理 exception 狀況,有時間的話再來改看看
 
More...
darren, 2014/12/13 下午 05:44:05
小心設定連線字串中的Connect Timeout
今天網站升到 .Net Framework 4.0 時,突然有幾個頁面一執行就會load不停,並且造成 w3wp.exe 的CPU飆高。

經查詢之後發現,問題發生在執行SQL時;會load不停的頁面所呼叫的連線字串中,都將屬性Connection Timeout=0

,因此將Connection Timeout=0拿掉就好了。

<add key="xxxxxx" value="server={server};database={DB};uid={uid};pwd={pwd};Max Pool Size={size};Connection Timeout=0"/>

http://msdn.microsoft.com/zh-cn/library/system.data.oracleclient.oracleconnection.connectiontimeout(v=vs.110).aspx

所以在設定連線字串時,應避免將Connection Timeout設成0,否則會無限期的等待連接。


p.s. 很神奇的事是,在 .Net Framework 2.0 是正常的,但升成 4.0 後才會load不停,不知道為什麼。
More...
candice, 2014/11/5 下午 06:56:48
SQL 搜尋時發生的奇怪現象與解決方法

半夜被老闆 Line,跟我說網頁發生錯誤,他無法看統計報表,會出現作業逾時的錯誤 我查了一下網頁程式,發現是這筆SQL指令跑太久
 Select Id, (IsNull(Total, 0) - IsNull(CouponDiscount, 0) + IsNull(CouponAdd, 0)) as Total, Buyer_Email, EN_Packing_List_Status, EN_Order_Source, En_Stock_Status, Create_Date
From V_Order_main With(Nolock)
Where Id in (select Order_Id from Ad_Trace With(NoLock) where (Parameter_Id = 14278))
AND Create_Date >= '2014/10/3' And Create_Date < '2014/10/12'

--> 跑了50秒~ 1分鐘

 Select Id, (IsNull(Total, 0) - IsNull(CouponDiscount, 0) + IsNull(CouponAdd, 0)) as Total, Buyer_Email, EN_Packing_List_Status, EN_Order_Source, En_Stock_Status, Create_Date
From V_Order_main With(Nolock)
Where Id in (select Order_Id from Ad_Trace With(NoLock) where (Parameter_Id = 14278))

--> 拿掉日期限制 > 秒殺,  結果跑出 47 筆資料

跑一下執行計畫 原來子查詢的 Ad_Trace 沒有建立Index造成


加上 Index 之後,再跑第一支SQL --> 秒殺

奇怪的地方:
明明訂單日期欄位(Create_Date) 跟 Ad_Trace 沒有多大關係,但是加上日期限制之後,居然會引發 Ad_Trace 搜尋過久的現象
他好像是先依照訂單日期找出所有訂單,然後再從子查詢 Ad_Trace 裡面搜尋有無符合的條件訂單
而不是先跑子查詢找出 Ad_Trace 所有的 Order_Id,再去找符合 Create_Date 的訂單

SQL內部運作的機制真是有點讓人想不透,幸好有評估計畫可以看出問題在哪裡
這讓我想起以前學SQL時的一句話 => 盡量用Join來取代子查詢
使用子查詢真的是效能殺手啊

------繼續補充--------------------------------------

上面的SQL在雙11活動後,由於當日訂單過多,一樣造成SQL timeout 的現象,研判還是子查詢造成的問題
Select Id, (IsNull(Total, 0) - IsNull(CouponDiscount, 0) + IsNull(CouponAdd, 0)) as Total, Buyer_Email, EN_Packing_List_Status, EN_Order_Source, En_Stock_Status, Create_Date
From V_Order_main With(Nolock)
Where Id in (select Order_Id from Ad_Trace With(NoLock) where (Parameter_Id = 14720))
And Create_Date > '2014-11-10' And Create_Date < '2014-11-11'

--> 跑了51秒

所以先將子查詢拿出來跑出一串字串 
865828,865890,865901,865903,865928,865955,865990,865993,866005,866035.....
(共1452筆)
再把他拼入sql跑   --> 7秒

 
More...
darren, 2014/10/11 上午 09:58:18
在 window load 之後使用 setTimeout 可以加速網頁的例子
下面的圖片可以注意 GetStopSellProducts.aspx 的執行位置。

原來的做法,在 window.load 時就執行一段 longcode,window.load 的時間約在 736 ms: 
$(window).load(function () {
    UpdateQty();
});




用 setTimeout 去呼叫 UpdateQty 大概可以省下 200 ms,只要 507 ms 就可以完成 window.load,如下圖。
$(window).load(function () {
    window.setTimeout("UpdateQty();", 100);    
});

 
 
More...
Bike, 2013/5/19 下午 05:32:36
Load 事件是發生在 window 上面,不是 Document。
有點白癡的問題,弄了半個小時。

           $(window).load(function () {
               window.setTimeout("FloatingBag.getFloatingBag();", 20);
           });

//           $(document).load(function () {
//               
//           })
More...
Bike, 2013/5/19 下午 02:33:07
global.asax 的事件
從 http://blog.ie-soft.de/post/2007/12/globalasax-events.aspx  抄來的. 留作參考

HttpApplication Events:

Application_AcquireRequestState
Occurs when ASP.NET acquires the current state (for example, session state) that is associated with the current request. 

Application_AuthenticateRequest
Occurs when a security module has established the identity of the user. 

Application_AuthorizeRequest
Occurs when a security module has verified user authorization. 

Application_BeginRequest
Occurs as the first event in the HTTP pipeline chain of execution when ASP.NET responds to a request. 

Application_Disposed
Adds an event handler to listen to the Disposed event on the application. 

Application_EndRequest
Occurs as the last event in the HTTP pipeline chain of execution when ASP.NET responds to a request. 

Application_Error
Occurs when an unhandled exception is thrown. 

Application_PostAcquireRequestState
Occurs when the request state (for example, session state) that is associated with the current request has been obtained. 

Application_PostAuthenticateRequest
Occurs when a security module has established the identity of the user. 

Application_PostAuthorizeRequest
Occurs when the user for the current request has been authorized. 

Application_PostMapRequestHandler
Occurs when ASP.NET has mapped the current request to the appropriate event handler. 

Application_PostReleaseRequestState
Occurs when ASP.NET has completed executing all request event handlers and the request state data has been stored. 

Application_PostRequestHandlerExecute
Occurs when the ASP.NET event handler (for example, a page or an XML Web service) finishes execution. 

Application_PostResolveRequestCache
Occurs when ASP.NET bypasses execution of the current event handler and allows a caching module to serve a request from the cache. 

Application_PostUpdateRequestCache
Occurs when ASP.NET completes updating caching modules and storing responses that are used to serve subsequent requests from the cache. 

Application_PreRequestHandlerExecute
Occurs just before ASP.NET begins executing an event handler (for example, a page or an XML Web service). 

Application_PreSendRequestContent
Occurs just before ASP.NET sends content to the client. 

Application_PreSendRequestHeaders
Occurs just before ASP.NET sends HTTP headers to the client. 

Application_ReleaseRequestState
Occurs after ASP.NET finishes executing all request event handlers. This event causes state modules to save the current state data. 

Application_ResolveRequestCache
Occurs when ASP.NET completes an authorization event to let the caching modules serve requests from the cache, bypassing execution of the event handler (for example, a page or an XML Web service). 

Application_UpdateRequestCache
Occurs when ASP.NET finishes executing an event handler in order to let caching modules store responses that will be used to serve subsequent requests from the cache. 

Application_Init
This method occurs after _start and is used for initializing code. 

Application_Start
As with traditional ASP, used to set up an application environment and only called when the application first starts.

Application_End
Again, like classic ASP, used to clean up variables and memory when an application ends.

Session Events:

Session_Start
As with classic ASP, this event is triggered when any new user accesses the web site.

Session_End
As with classic ASP, this event is triggered when a user's session times out or ends. Note this can be 20 mins (the default session timeout value) after the user actually leaves the site.

Profile Events:

Profile_MigrateAnonymous
Occurs when the anonymous user for a profile logs in.

Passport Events:

PassportAuthentication_OnAuthenticate
Raised during authentication. This is a Global.asax event that must be named PassportAuthentication_OnAuthenticate.
 

Possibly more events defined in other HttpModules like:

System.Web.Caching.OutputCacheModule
System.Web.SessionState.SessionStateModule
System.Web.Security.WindowsAuthentication
System.Web.Security.FormsAuthenticationModule
System.Web.Security.PassportAuthenticationModule
System.Web.Security.UrlAuthorizationModule
System.Web.Security.FileAuthorizationModule
System.Web.Profile.ProfileModule

More...
Bike, 2012/6/9 上午 08:55:08
~ Uwinfo ~