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
標籤
  • -5815
  • CheckBoxLi
  • 14
  • net
  • 1
  • unt ORDER
  • a
  • js UNION A
  • line ORDER
  • server
  • 10
  • CS
  • ip[t]
  • [u2]
  • cache
  • aHR0cDovL3
  • pg ORDER B
  • FVDAMrQl
  • ad
  • [t]
  • button
  • .
  • 5275
  • 934
  • sql script
  • drag
  • ajax order
  • 8CRLF-Head
  • C
  • httpRuntim
  • 橫
  • PG
  • HTML5
  • 0KeeTeam|e
  • 262
  • ?
  • 許蓋功
  • 角色
  • list
  • 上傳檔案太大
  • div2121121
  • en
  • output ord
  • NrhnyO3Z
  • inline
  • SQL
  • IP
  • GUI ORDER
  • Config ORD
  • iis
頁數 2 / 5 上一頁 下一頁
搜尋 PG 結果:
UW DB物件 GetAllDataFromBaseTableWithCache 會嚴重影響效能
UW -> DB 物件產生器會產生兩個function
GetAllDataFromBaseTableWithCache(string OrderFields = "_Default", bool IsCopy = true )
以及
Get物件名稱FromCachedDT(string Key)
-----------------------------------------------------------
設計上是希望將所有資料Cache在記憶體,然後前端直接抓出資料,不須到資料庫抓資料
理論上網頁速度應該比較佳,實際上卻發現是效能殺手

原因在於 GetAllDataFromBaseTableWithCache 是抓出整個table的資料放到 Cache
然後又做了一件事,當有人要資料時,會把整個 DataTable 做 Copy() 再 return
也就是說,當DataTable有數千筆資料列時
每叫用一次 "Get物件名稱FromCachedDT(string Key)" 就會把數千筆資料整個複製一次
再從複製出來的DataTable Select 出一列 return
------------------------------------------------------------
解決方法:
Get物件名稱FromCachedDT(string Key)  --> 改成一筆一筆資料做 Cache,這樣 Copy() 只會Copy一筆
實測上,原本頁面要跑1.8秒,調整後可以 0.4 秒就完成
-----------------------------------------------------------
結論:
PG產生器就把 GetAllDataFromBaseTableWithCache 拿掉吧
More...
darren, 2018/5/21 下午 03:17:00
LINE Pay介接
LINE Pay款流程: 
reserve Page(紅科) 發送 reserve API => 取得 payment URL => 轉址到 payment URL => LINE Pay 檢查USER狀態 => 轉回confirm page(紅科), 發送 confirm API => DOWN.

付款需要程式: 
reserve API, confirm API:

send request JSON and read return JSON:
C#: 
using System.Net;
using System.IO;

public partial class TEST : System.Web.UI.Page
{
    DB.OrderMain oOrderObj = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Setting request header
        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("__APIRootURL__");
        httpWebRequest.ContentType = "application/json; charset=UTF-8";
        httpWebRequest.Method = "POST";
        httpWebRequest.Headers.Add("X-LINE-ChannelId", DB.SysConfig.LINEPay.ChannelId);
        httpWebRequest.Headers.Add("X-LINE-ChannelSecret", DB.SysConfig.LINEPay.SecretKey);

        //加入參數
        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {
            string requestJSON = "{\"productName\": \"" + DB.SysConfig.SYSTEM_NAME + "\"," +
                                "\"productImageUrl\": \"" + DB.SysConfig.URL_Shopping + "images/Logo.jpg\"," +
                                "\"amount\": " + oOrderObj.TotalAmount() + "," +
                                "\"currency\": \"TWD\"," +
                                "\"orderId\": \"" + oOrderObj.DisplayOrderId + "\"," +
                                "\"confirmUrl\": \"" + DB.SysConfig.URL_Shopping + "Handler/LinePay/GotoComfirm.aspx?Id=" + oOrderObj.Id + "\"," +
                                "\"cancelUrl\": \"" + DB.SysConfig.URL_Shopping + "Shopping/OrderComplete.aspx?Id=" + oOrderObj.Id + "\"," +
                                "\"capture\": \"true\"," +
                                "\"confirmUrlType\": \"CLIENT\"}";

            streamWriter.Write(requestJSON);
            streamWriter.Flush();
            streamWriter.Close();
        }

        //取得回覆資訊
        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
        //解讀回覆資訊
        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            var responseJSON = streamReader.ReadToEnd();
            //將 JSON 轉為物件
            GN.LinePay.reserveRes.ReturnJSON oReturnObj = (GN.LinePay.reserveRes.ReturnJSON)Newtonsoft.Json.JsonConvert.DeserializeObject(responseJSON, typeof(GN.LinePay.reserveRes.ReturnJSON));

            if (oReturnObj.returnCode == "0000")
            {
                //成功
            }
            else
            {
                //失敗
                string ErrMsg = "Error Code: " + oReturnObj.returnCode + "\r\n" + oReturnObj.returnMessage;
            }
        }
    }
}


.vb
Imports System.Net
Imports System.IO

Partial Class TEST
    Inherits System.Web.UI.Page

    Dim oOrderObj As DB.OrderMain
    Private Sub Admin_TEST_Load(sender As Object, e As EventArgs) Handles Me.Load
        'Setting request header
        Dim httpWebRequest As HttpWebRequest = WebRequest.Create("__APIRootURL__")
        httpWebRequest.ContentType = "application/json; charset=UTF-8"
        httpWebRequest.Method = "POST"
        httpWebRequest.Headers.Add("X-LINE-ChannelId", DB.SysConfig.LINEPay.ChannelId)
        httpWebRequest.Headers.Add("X-LINE-ChannelSecret", DB.SysConfig.LINEPay.SecretKey)
        '加入參數
        Using streamWriter As New StreamWriter(httpWebRequest.GetRequestStream())
            Dim requestJSON As String = "{""productName"": """ + DB.SysConfig.SYSTEM_NAME + """," +
                                        """productImageUrl"": """ + DB.SysConfig.URL_Shopping + "images/Logo.jpg""," +
                                        """amount"": " + oOrderObj.TotalAmount() + "," +
                                        """currency"": ""TWD""," +
                                        """orderId"": """ + oOrderObj.DisplayOrderId + """," +
                                        """confirmUrl"": """ + DB.SysConfig.URL_Shopping + "Handler/LinePay/GotoComfirm.aspx?Id=" + oOrderObj.Id + """," +
                                        """cancelUrl"": """ + DB.SysConfig.URL_Shopping + "Shopping/OrderComplete.aspx?Id=" + oOrderObj.Id + """," +
                                        """capture"": ""true""," +
                                        """confirmUrlType"": ""CLIENT""}"

            streamWriter.Write(requestJSON)
            streamWriter.Flush()
            streamWriter.Close()
        End Using
        '取得回覆資訊
        Dim httpResponse As HttpWebResponse = httpWebRequest.GetResponse
        '解讀回覆資訊
        Using streamReader As New StreamReader(httpResponse.GetResponseStream())
            Dim responseJSON As String = streamReader.ReadToEnd()
            '將 JSON 轉為物件
            Dim oReturnObj As GN.LinePay.reserveRes.ReturnJSON = Newtonsoft.Json.JsonConvert.DeserializeObject(responseJSON, GetType(GN.LinePay.reserveRes.ReturnJSON))

            Dim ResMsg As String = ""
            If oReturnObj.returnCode = "0000" Then
                '成功

            Else
                '失敗
            End If
        End Using
    End Sub
End Class




工具網站:
JSON 轉物件 http://json2csharp.com/
C# to VB : http://converter.telerik.com/



#專案: 紅科
More...
Reiko, 2017/6/21 下午 07:22:58
簡單的 HTTP Relay By MVC.
客戶要求
1. 檔案只能放在 Firewall 內的後台用 Web server (Server A).
2. 使用者只能存取 DMZ 的 Web server (Server B).
3. Server B 只能用 HTTP 通過 Firewall 向 Server A 要資料.(i.e.  Server B 不能掛戴 Server A 的目錄成為虛擬目錄)

所以在 Server B 上面建立了一支程式用 HTTP 的方式讀取 Server A 的檔案再寫出去.

例如, http://ServerB/Upload/test.pdf 會讀取 http://ServerA/Upload/test.pdf 再送到 Client 端

namespace WWW.Controllers
{
    public class UploadController : Controller
    {
        // GET: Upload
        public void Index(string Filename)
        {
            //Create a stream for the file
            Stream stream = null;

            //This controls how many bytes to read at a time and send to the client
            int bytesToRead = 10000;

            // Buffer to read bytes in chunk size specified above
            byte[] buffer = new Byte[bytesToRead];

            string url = "http://admin-dev.nanya.bike.idv.tw/newnanyaback/Upload/" + Filename;

            // The number of bytes read
            try
            {
                //Create a WebRequest to get the file
                HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(url);

                //Create a response for this request
                HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();

                if (fileReq.ContentLength > 0)
                    fileResp.ContentLength = fileReq.ContentLength;

                //Get the Stream returned from the response
                stream = fileResp.GetResponseStream();

                // prepare the response to the client. resp is the client Response
                var resp = HttpContext.Response;

                if (Filename.ToLower().EndsWith(".png") ||
                    Filename.ToLower().EndsWith(".jpg") ||
                    Filename.ToLower().EndsWith(".jpeg") ||
                    Filename.ToLower().EndsWith(".gif")
                    )
                {
                    resp.ContentType = "image";
                }
                else
                {
                    //Indicate the type of data being sent
                    resp.ContentType = "application/octet-stream";

                    //Name the file
                    resp.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(Filename, Encoding.UTF8) + "\"");
                }

                resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());

                int length;
                do
                {
                    // Verify that the client is connected.
                    if (resp.IsClientConnected)
                    {
                        // Read data into the buffer.
                        length = stream.Read(buffer, 0, bytesToRead);

                        // and write it out to the response's output stream
                        resp.OutputStream.Write(buffer, 0, length);

                        // Flush the data
                        resp.Flush();

                        //Clear the buffer
                        buffer = new Byte[bytesToRead];
                    }
                    else
                    {
                        // cancel the download if client has disconnected
                        length = -1;
                    }
                } while (length > 0); //Repeat until no data is read
            }
            finally
            {
                if (stream != null)
                {
                    //Close the input stream
                    stream.Close();
                }
            }
        }
    }
}



但不是這樣就好了, 在 RouteConfig.cs 中要加上:
            routes.MapRoute(
                name: "Upload",
                url: "Upload/{filename}",
                defaults: new { controller = "Upload", action = "Index", filename = UrlParameter.Optional }
            );

此外在 Web.Config 中也要加上:

  <system.webServer>
    <handlers>
      <add name="UrlRoutingHandler_Upload"
           type="System.Web.Routing.UrlRoutingHandler, 
               System.Web, Version=4.0.0.0, 
               Culture=neutral, 
               PublicKeyToken=b03f5f7f11d50a3a"
           path="/Upload/*"
           verb="GET"/>
    </handlers>
  </system.webServer>

參考:
http://stackoverflow.com/questions/5596747/download-stream-file-from-url-asp-net

http://blog.darkthread.net/post-2014-12-05-mvc-routing-for-url-with-filename.aspx
More...
Bike, 2016/12/1 下午 09:34:30
IIS Server SSL 升級方式
20211102 補充一下 (下面網址可以下載工具調整 reg)
Nartac Software - IIS Crypto
--------------------------
網路上有一些工具可以看出網站SSL連線是不是安全  這是我測試的結果 (用 www.nalimay.com 測試)







看樣子主要是支援舊的 SSL 2.0 SSL 3.0 造成 F 等級,所以網路上搜尋一下
​發現IIS 要改 registry 資料(也就是把一些設定關掉 一些定打開) 然後重新開機才會升級  
請參考附件   升級後就好一點了  變 B ,換成另外一種警告  有空再看看如何解,








 
More...
darren, 2015/12/25 下午 03:51:01
SPDY and HTTP/2

對於網頁加速的問題,已經被廣泛的討論了
主要在於減少 request 數以及減低網路傳輸的時間
也因此發展出一些技巧或技術,例如 css sprite, 資料gzip 等
瀏覽器也把連線數限制從2條變成6條,以加快網頁顯示的速度
然而若要網頁能有本質上的提升,則是該把 HTTP 這個老通訊協定升級了
(目前是HTTP/1.1, 1999年)

由Google Chrome推廣的 SPDY 標準,已經改良並訂為 HTTP/2 的標準 (2015年初定案)
他的重點在於 (如果我理解得沒錯的話,歡迎指正)
1. http header 也可壓縮 (HTTP1.1 header 無法壓縮)
2. 一個 connection 可以傳輸多個Content (HTTP1.1 一個request 一個 content)
3. 可以 Server Push 資料
4. 可以向下相容 1.1
實測上,可以讓網頁載入速度提升約 30%

目前,大部分瀏覽器已經支援 HTTP/2 標準,然而 Server 端的步調就緩慢許多
微軟的 IIS 要到 10 才支援,目前只有 windows 10 才有
Windows Server則要明年 2016 才有支援
相反於微軟,其他非微軟的開發速度上就快多了 例如 Node.js

---------------------------------------------------------
測試上,可以用 Chrome 的開發模式 把 protocol 欄位勾選顯示



h2 就是 http/2
More...
darren, 2015/8/31 上午 11:09:11
UNT流量異常追蹤紀實
自從 8/1 起 shopunt 就呈現奇怪的現象



基本上是每日半夜12點流量暴增 (peak 到 80mb),然後逐漸下降,到了 5~6點又慢慢爬升,直到 10 點以後就驟降

基本上,網站沒有掛掉,沒有太多Exception,LB兩台server的流量很平均,Server Diff 查也沒有過多的Session
可以排除被攻擊的可能性

為了找問題,只好從 IIS Log著手......
1. 首先,查詢12點有甚麼網頁或網址異常多點擊數,並且比較 11 點與 12點兩者差異,結果都沒有任何異常
    卻意外發現有家廣告合作廠商半夜會來抓產品圖,只是這個流量不大,發生點也不是在12點整,不是兇手
2. 起先因為 IIS log 沒有設定 sc-bytes 這個屬性,只有 time-taken 屬性,發現有些圖片 load 的特別久,但還是無法確定問題,所以想說把 sc-bytes 加到 IIS log 再來觀察
3. 加了 sc-bytes 之後的 IIS log,才發現驚人的事實,有幾張圖片竟然高達好幾MB,最大張是放在周年慶的 landing 圖片,竟高達 7.8MB



光1小時,一張圖片吃掉 8.6GB 的量,換算平均值約 13 mb/sec , OMG!
趕緊請設計把圖片換掉

只是這樣,還是有一個奇怪現象,為何半夜12點流量暴增,早上 10 點流量驟減?


這是禍首最大張圖片的點擊數統計(時間是GMT,16是半夜12點, 15是晚上11點),
就跟流量圖一樣,00~10 點擊數很高,其他時間很低
下面是這張圖片所屬頁面的點擊數統計 (/tch/fixpage.aspx?id=689)



從圖片點擊數看來,我以為是 ISP 某種 transparent proxy cache 發揮作用 (半夜 00~10點關閉 所以流量增加),
但是看到 fixpage.aspx 的點擊數也是一樣的狀況,我就不知道該怎麼解釋了??
ISP transparent proxy 也會處理 *.aspx ?? 

還是回歸到最基本的原因,網站的廣告曝光量是 00~10點最高??

 
More...
darren, 2015/8/9 上午 11:00:45
IE11無法套用CKEditor
慧守CKEditor編輯器版本更新(目前版本IE11無法使用),更新至4.4.7後,大部份IE11皆正常,但有台電腦無法正常運作。
該電腦:




原套用方法:
<textarea style="width:675px; height:60px" name="Description" id="Description">#Description#</textarea>
                                            <script type="text/javascript">
                                                CKEDITOR.replace('Description');
                                            </script>


更改為下面方法即可:
​
<textarea style="width:675px; height:60px" name="Description" id="Description">#Description#</textarea>
                                            <script type="text/javascript">
                                                $('#Description').ckeditor();
                                            </script>
More...
Reiko, 2015/6/30 下午 05:13:01
黑貓 EGS 安裝注意
這是 Shopunt 安裝新機器時發生的問題,把他記一下

安裝 黑貓 EGS SERVICE,只要把另一台server C:\EGS 整個目錄 copy 過來
然後跑 C:\EGS\EGS_SETUP.exe  就會跳出 Ezcat Gateway System 視窗
然後只要 "啟動EGS系統" --> windows 服務 就會出現 Ezcat Gateway System Service

這個服務會建立 web service 並監聽 8800 port
http://localhost:8800/egs?cmd=......   就可以存取資料

但要注意的是,由於整個目錄複製過來,會將 sqllite 資料也一併複製過來,這樣會產生一個問題
就是黑貓的配送單號會重複產生,所以新server一定要做一件事

就是 停止EGS服務 -> (系統維護) -> 備份EGS資料 -> 存檔
然後再 還原EGS資料 -> 找出剛剛備份檔  -> (系統資訊) -> 啟動EGS服務
若是看到托運單號是 100 整數  應該就是 reset成功






 
More...
darren, 2015/6/15 下午 04:36:19
SQL 資料庫還原: 叢集硬碟注意事項。
叢集磁碟5的R碟為新增硬碟,記得要在"其他資源"的內容相依性補進去,不然會在還原的時候找不到新的叢集硬碟。
More...
frank, 2015/6/2 下午 07:18:36
HTTP Error 500.21 - PageHandlerFactory-Integrated



通常發生在新電腦安裝後​或是安裝 .NET 4.0 之後
第一次跑網站出現這樣的錯誤

執行下面cmd 就可以解決
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

 
More...
darren, 2015/4/2 下午 02:07:54
|< 12345 >|
頁數 2 / 5 上一頁 下一頁
~ Uwinfo ~