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
標籤
  • a
  • 80
  • Kil3rDz98H
  • 250
  • post
  • ti
  • window.ope
  • svn
  • -3085
  • user_login
  • @@s2efe
  • 20
  • 4450
  • mod
  • ad
  • 60.5CtEp
  • data
  • 版本
  • datatable
  • editor
  • ARR
  • [U2]
  • batchpatch
  • sql man
  • 8 UNION AL
  • prop
  • en
  • 28
  • dotnet
  • image
  • CS
  • vslerp
  • 44
  • html
  • 憑證匯出
  • 8
  • sp_
  • 396
  • find
  • 6763
  • [t],
  • git
  • 9485
  • message
  • max
  • EnuM
  • 0
  • json.net
  • 行號
  • 50
頁數 6 / 6 上一頁
搜尋 list 結果:
程式技巧: 以字串陣列來取代拼字串
最近看到一些 javascript 範例 覺得這樣不錯的
就是用 array push, join 方式來拼字串

    var Data = [{"key": "key5", "value": "value5"}, {"key": "key4", "value": "value4"}, {"key": "key3", "value": "value3"}];
    var html = [];
    html.push('<select name="test">');
    for (var i = 0; i < Data.length; i++) {
        html.push('<option value="' + Data[i]["key"] + '">',
            Data[i]["value"],
            "</option>");
    }
    html.push('</select>');
    return html.join('');


同樣的方式 .net 也可以這樣做

        List<string> listOfString = new List<string>();
        for (int i = 0; i < 10; i++)
        {
            listOfString.Add(i.ToString());
        }
        string strResult = string.Join(", ", listOfString.ToArray());


用這種方式也省的判別最後一筆要不要加上分隔符號
More...
darren, 2012/10/17 下午 04:09:20
IIS7 的設定匯出及匯入 -- 使用 APPCMD
使用 APPCMD

所在位置: cd %windir%\system32\inetsrv

匯出整個網站設定: appcmd list site "SiteName" /config /xml > D:\IISSetting\SiteName.xml

匯入整個網站設定: appcmd.exe add site /in < D:\IISSetting\SiteName.xml

在執行匯入的動作之前,要先檢查一下 .XML 裡面的 ID, 是否和現有的網站衝突,一般會有兩個地方。 

有時在 XML 裡面會多一個 ftpServer 的區塊,要記得刪掉,另外 Application Pool 要記得,建立可以使用以下指令。

export
appcmd list apppool 116foto /config /xml >D:\IISSetting\app_116foto.xml
import
appcmd add apppool /name:116foto /in <D:\IISSetting\app_116foto.xml
More...
Bike, 2012/8/8 下午 11:32:33
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
Squid Proxy 設定
Squid Proxy 相關處理

主站
http://www.squid-cache.org/

Windows 版本
http://squid.acmeconsulting.it/

解壓縮至 c:\squid

指令
\sbin\squid.exe
squid -?
squid -z d:\squid\var\cache 暫存目錄設定
squid -i 加入服務
squid -n Squid -k reconfigure 設定檔更新可重置,重啟服務也可以

設定檔
\etc\squid.conf
建議co個用過的來抄

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
將某一檔案更新做法
C:\squid\bin>squidclient -h localhost -p 80 -m PURGE http://bserver.img.photosharp.com.tw/Image/Advert/360x120_v1_260x87s120.jpg

若不行需設定 squid.conf
參考 http://help.getbusi.com/kb/getbusi-alert-advance/removing-individual-objects-from-squid-cache
acl manager proto cache_object 後加入一行 acl Purge method PURGE
http_access allow manager localhost 後加入一行 http_access allow localhost Purge
http_access deny manager 後加入一行 http_access deny Purge

設定檔重置
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Web & Squid 共存(不同 IP 共用80Port)

如 192.168.0.203(Web), 192.168.0.201(Squid)
IIS 的網站需指定(192.168.0.203)

squid.conf 設定檔需修改 IP 位置
http_port 192.168.0.201:80 transparent

改變 IIS 監聽 IP 的範圍
=-=-=-= Windows Server 2003 =-=-=-=
Windows Server 2003 CD\Support\Tools\Support.msi 安裝後
C:\Program Files\Support Tools 下有程式 httpcfg
httpcfg delete iplisten -i 0.0.0.0
httpcfg set iplisten -i 192.168.0.203
=-=-=-= Windows Server 2008 =-=-=-=
netsh 進入指令模式
netsh>http
netsh http>add iplisten ipaddress=192.168.0.203:80 (會取代 0.0.0.0)

重啟指令
net stop http /y
net start w3svc查看指令

netstat -an
tcp 0.0.0.0:80 需沒有
tcp 192.168.0.203:80 需有

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\ListenOnlyList
會列出開機時會載入的 httpcfg set iplisten,若 ip 有設錯 iis 可能會出現 "指定的網路名稱格式不正確"
 

More...
Jerry, 2012/6/8 下午 12:46:09
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
IIS7網站備份&還原(只能從IIS7備份還原到IIS7)

cmd
cd C:\Windows\System32\inetsrv

※備份 backup.bat
*備份應用程式集區
appcmd list apppool HCI /config /xml >D:\IISSetting\appHCI.xml
*備份Site
appcmd list site HCI /config /xml >D:\IISSetting\HCI.xml

※還原 restore.bat
*備份應用程式集區
appcmd add apppool /name:HCI /in <D:\IISSetting\appHCI.xml
*備份site
appcmd add site /name:HCI /in <D:\IISSetting\HCI.xml

註1.HCI=>site name
註2.打開site的xml, 調整Id的值(不可與還原主機的IIS上已有ID重複)

More...
Reiko, 2012/4/12 下午 12:14:58
|< 123456 >|
頁數 6 / 6 上一頁
~ Uwinfo ~