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
標籤
  • inertSQL
  • iis
  • TLS1
  • web test
  • 98
  • http 錯èª
  • AD
  • separatedi
  • DB
  • 鎖定
  • 檔案
  • vs
  • Server Err
  • 出單機
  • window
  • [t]
  • async
  • 220
  • bugzilla
  • load
  • 1021211211
  • 70
  • 中文
  • Line
  • face
  • C
  • 288
  • ddd
  • Chrome
  • mod
  • Su
  • div
  • [U2]
  • GDI
  • 7853
  • 0 ORDER BY
  • for xml
  • 8308
  • 排名
  • 92
  • mod[t]
  • backup
  • JSON
  • en
  • 1z5JIPhd
  • server
  • Nanoha
  • IndexOf
  • s3
  • net
頁數 9 / 9 上一頁
搜尋 LINE 結果:
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
查看資料庫最耗時的Sql Command
從網路找到改良的,直接查不用開Sql Profiler

加入可指定資料庫的改良
SELECT TOP 100 execution_count, total_worker_time, last_worker_time, max_worker_time, min_worker_time, CONVERT(INT, att.value) AS dbid, DB_NAME(CONVERT(INT, att.value)) as dbname ,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text)ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) as statement_text
FROM sys.dm_exec_query_stats as qs 
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
CROSS APPLY sys.dm_exec_plan_attributes(qs.plan_handle) att
WHERE att.attribute='dbid' and DB_NAME(CONVERT(INT, att.value)) = 'P9'
ORDER BY execution_count DESC 


以執行次數排序,可檢查爆量的Sql
Where statement_start_offset =0 測起來可以篩掉系統的Query,如:AspNet_SqlCache
SELECT TOP 10 execution_count, total_worker_time, last_worker_time, max_worker_time, min_worker_time, SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text)ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) as statement_text
FROM sys.dm_exec_query_stats as qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
WHERE statement_start_offset = 0
ORDER BY execution_count DESC  


以總執行時間排序,檢查寫耗時的Sql
SELECT TOP 10 total_worker_time, last_worker_time, max_worker_time, min_worker_time, SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,((CASE statement_end_offset WHEN -1 THEN DATALENGTH(st.text)ELSE qs.statement_end_offset END - qs.statement_start_offset)/2) + 1) as statement_text
FROM sys.dm_exec_query_stats as qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as st
ORDER BY max_worker_time DESC


結果如下


 
More...
Jerry, 2012/6/8 下午 12:50:24
inline 物件的 margin-top 會被略過
<a href='#' style="background-color:#cccccc; color=black; padding: 3px; margin:6px 6px 6px 6px;">AA</a>
<a href='#' style="background-color:#cccccc; color=black; padding: 3px; margin:6px 6px 6px 6px;">BB</a>
--> 其中因為 a 是 inline 物件, margin 的 Top 會被略過


若是想要保持兩個 Link在同一行, 又要有上方的 margin, 可以在外面再包一個 div
<div style="margin-top:6px;">
<a href='#' style="background-color:#cccccc; color=black; padding: 3px; margin:6px 6px 6px 6px;">AA</a>
<a href='#' style="background-color:#cccccc; color=black; padding: 3px; margin:6px 6px 6px 6px;">BB</a>
</div>
More...
Bike, 2012/5/20 上午 09:18:10
CSS 寬度的繼承問題 --> 讓 div 的寬度隨內文變化, 不要和父容器相同
有個困擾很久的老問題:
<div id="divContent" style="border:1px solid black">ABCDE</div>
--> 寬divContent 的度隨內文變化

<div style="width:1000px"><div id="divContent" style="border:1px solid black">ABCDE</div></div>
--> divContent 的寬度會和父容器相同


原來 display 為 block 的物件的寬度都會和父容器相同, 把 display Mode 改為 inline 即可.

<div style="width:1000px"><div id="divContent" style="border:1px solid black; display:inline">ABCDE</div></div>
--> divContent 的寬度會和父容器相同


但 inline 的物件後方可能會跟了些不讓跟的東西, 所以可能要加個 <br> 比較好.
More...
Bike, 2012/5/19 上午 06:39:23
VB 轉 C# 問題整理
之前將部分UW網站VB程式碼轉到C#,
我是用此工具轉
http://www.developerfusion.com/tools/convert/vb-to-csharp/
轉換後,放到visual studio還是有很多毛毛蟲
整理一些問題, 希望能減少轉換上的困難
 
1. Imports --> using (using 只能用namespace)
   System.Web.HttpContext 是不能放在using, 因為他是類別, 不是 namspace
   所以 Current.Session 要調整成 HttpContext.Current.Session
 
2. index或是key, value類的東西要用中括號 []
   VB:Session("name") --> C#:Session["name"]
   Cache(""), Application(""), DataRow("") 也是一樣
   
3. 所有方法都要加上 ()
   例如 ToString --> ToString()
   例如 ToLower --> ToLower()
 
4. 不能隱含式的型別轉換, 要明確
   轉換型態可以有以下方法
   - 轉字串時, 直接後面加上 .ToString()
   - Convert 物件轉換
   - 變數名稱前面加上(Type), 例如 (HashTable)Session["htData"]
   - 以 as 方式轉換, 若要轉換的物件可能是null建議用此方法, 例如 
     System.Net.HttpWebRequest http = System.Net.WebRequest.Create(Url) as System.Net.HttpWebRequest;
     string strData = HttpContext.Current.Cache["CacheName"] as string;
     用 as 方法不會強制轉換, 用 (Type) 或 ToString() 一旦遇到 null 會發生Exception
 
5. 帶參數的 Property C#是不允許的, .Net 會自動產生 get_ function 取代
   VB: UW.WU.URL --> C#: UW.WU.get_URL();
 
6. partial 要放在 public 後面
 
7. aspx頁面C#的檔頭要設定AutoEventWireup="true"
     另外所有的 server control 的 On Event 所執行的function name (例如 Button 的 OnClick)  都要在 aspx 裡面設定
   (這部分會在後台程式發生,因為轉換後常忘了加)
   <asp:DropDownList ID="ddlName" runat="server" AutoPostBack="true" 
      OnSelectedIndexChanged="ddlName_SelectedIndexChanged"></asp:DropDownList>
   <asp:Button ID="btnAdd" runat="server" Text="新增" OnClick="btnAdd_Click" />
 
8. 因為字串相加也是 +, 一些特殊寫法要注意
   VB: (Url & "Page=" & EndPage + 1)    --> VB會先將整數加好後再字串相加
   c#: (Url + "Page=" + (EndPage + 1))  --> 由於C#會先將1轉為字串再把所有字串相加 , 所以要先用括號包起來先讓整數相加

9. vbCrLf -> "\r\n"
    vbTab ->  "\t"

10. VB function 轉換 
    Conversion.Fix -> Math.Floor
     Strings.Format(x, "###0.0") -> 用 x.ToString("N1");

11. EN 處理要多加注意,需額外加 (int) 才會顯示數值,很多 sql 指令這樣拼要小心
" where EN_產品性質 = " + SHOPUNT.EN.產品性質.非成品 ; -> where EN_產品性質 = 非成品   (會出錯)
" where EN_產品性質 = " + (int)SHOPUNT.EN.產品性質.非成品; -> where EN_產品性質 = 100

先整理這些 以後遇到再加上


 
More...
darren, 2012/5/17 上午 10:50:34
在列印前把列印的內容使用圖檔存備份
主要是使用 Printing.PreviewPrintController 的產生預覽圖片的功能來儲存列印內容, 再把圖片送到印表機, 以保証列印內容和儲存的圖檔是一致的. 值得一提的是, 在預覽時可以使用不同的印表機, 以便讓產生較小的圖檔, 否則有時會發生 GDI+ 的錯誤.

Sample 如下:

Imports System.Drawing.Printing

Namespace X
    Partial Public Class PrintSomething
        Dim PD As PrintDocument

        Dim ppc As New Printing.PreviewPrintController()

        Dim TotalPage As Int32 = 0

        ''' <summary>
        ''' 第幾次列印, 用來控制寫出的圖檔
        ''' </summary>
        ''' <remarks></remarks>
        Dim PrintCount As Int32 = 1

        Dim PageCount As Int32 = 1

            :
            :
            :
      
        Sub New(ByVal oPM As DB.PackingListMain, ByVal dtDetail As DataTable, dtUsedCoupon As DataTable)
            '初始化資料
            :
            :
            :
        End Sub

        Sub InitPrintDocument()
            '在這裡設定 PrintDocument 的紙張, 印表機, 邊界, 橫印或直印

            PD = New PrintDocument

            :
            :
            :

        End Sub

        Sub print()
            InitPrintDocument()

            PD.PrintController = ppc

           
            ' 第一次先把列印結果存在 Printing.PreviewPrintController 中
            AddHandler PD.PrintPage, AddressOf GeneratePreview

            '再來儲存圖片
            AddHandler PD.EndPrint, AddressOf SaveImage

            PD.Print()
        End Sub


        Dim ppi() As Printing.PreviewPageInfo
        Dim PrintPage As Int32 = 0

        Sub SaveImage(ByVal sender As Object, ByVal ev As PrintEventArgs)

            PrintDebug("Save Image Start, " & Now.ToString("yyyy-MM-dd HH:mm:ss.fff"))

            '把圖檔存起來
            Dim TF As String = Now.ToString("yyyyMMddHHmmss") ' DB.SysConfig.Path.LocalDataRoot
            Dim PathLocal As String = "C:\PrintLog\" & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"
            Dim PathPackingListSheetImage As String = DB.SysConfig.PackingListSheetImage & TF.Substring(0, 4) & "-" & TF.Substring(4, 2) & "\"

            System.IO.Directory.CreateDirectory(PathLocal)
            System.IO.Directory.CreateDirectory(PathPackingListSheetImage)

            Dim LatestImages As String = ""
            ppi = ppc.GetPreviewPageInfo()

            For x As Integer = 0 To ppi.Length - 1
                Dim Filename As String = TF & "_" & Me.oPM.Id & "_" & x & ".png"

                ppi(x).Image.Save(PathLocal & Filename, System.Drawing.Imaging.ImageFormat.Png)
            Next


            '把圖檔印出來
            For x As Integer = 0 To ppi.Length - 1
  '建立新的 PrintDocument
                InitPrintDocument()

                If CST.WebConfig.Server_NAME = "測試主機" Then
                    UW.WU.DebugWriteLine("PrinterName: " & Me.PD.PrinterSettings.PrinterName)
                    UW.WU.DebugWriteLine("PaperSize: " & PD.DefaultPageSettings.PaperSize.PaperName)

                    PD.DocumentName = "PackingList"
                    PD.PrinterSettings.PrintFileName = "C:\PDF\PackingList" & Now.ToString("yyyyMMddHHmmss") & "_" & PrintPage & ".prn"
                    PD.PrinterSettings.PrintToFile = True

                    'PD.PrinterSettings.
                End If

                '很奇怪, 這裡不會分頁, 所以要一張一張印   
                AddHandler PD.PrintPage, AddressOf pd_PrintPage2
                PD.Print()


               PrintPage += 1

            Next
        End Sub

        Private Sub pd_PrintPage2(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
            '很奇怪, 這裡不會分頁, 所以要一張一張印           
            ev.Graphics.DrawImage(ppi(PrintPage).Image, 0, 0)
            ev.HasMorePages = False
        End Sub


        Private Sub GeneratePreview(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
            ' 列印內容
        End Sub

        End Class
    End Class

End Namespace

More...
Bike, 2012/5/3 下午 04:00:38
Select with XLock
在 Select 指令後, 依據結果做一些工作, 即使有 Transaction, 但還是有可能發生一致性的問題:

Ex:

        Dim Conn As SqlConnection = UW.SQL.GetOpenedConnection
        Dim Tran As SqlTransaction = Conn.BeginTransaction

        Try
            Dim C As Int32 = UW.SQL.GetSingleValue("Select Counter From TableA Where Id = 1", Tran)
            C = C + 1
            UW.SQL.executeSQL("Update TableA Set Counter = " & C & " Where  Id = 1", Tran)
            Tran.Commit()
        Catch ex As Exception
            Tran.Rollback()
            UW.WU.DebugWriteLine(ex.ToString, True, True)

        Finally
            If Conn.State <> ConnectionState.Closed Then
                Conn.Close()
            End If

        End Try


以上的程式由兩個 Session 同時執行時, 並不能保証 Counter 會被加 2

若是要保証兩個 Session 都會把 Counter 加一(總共加 2), 要把以下這一行

Dim C As Int32 = UW.SQL.GetSingleValue("Select Counter From TableA Where Id = 1", Tran)

改為

Dim C As Int32 = UW.SQL.GetSingleValue("Select Counter From TableA With(XLock) Where Id = 1", Tran)
More...
Bike, 2012/5/3 下午 03:02:16
建立索引時加入其它非建值欄位
語法:


USE AdventureWorks;
GO
CREATE INDEX IX_Address_PostalCode      
ON Person.Address (PostalCode)      
INCLUDE (AddressLine1, AddressLine2, City, StateProvinceID);


在建立索引時, 可以加入非鍵值欄位, 可以加速讀取速度, 避開索引大小限制, 可惜 SQL 2008 沒有 UI 介面可以使用, 但 SQL 2012 好像就有 UI 可以用了.

參考資料:  Create Indexes with Included Columns http://msdn.microsoft.com/en-us/library/ms190806.aspx
More...
Bike, 2012/5/3 下午 02:53:46
|< 123456789 >|
頁數 9 / 9 上一頁
~ Uwinfo ~