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
標籤
  • setnumber
  • IIS
  • NPOI 弱點
  • CK
  • 字串
  • -3849
  • CS21211211
  • SU
  • svn
  • db
  • shop
  • 移
  • json
  • jquery
  • C
  • Doug
  • list order
  • 100
  • 848
  • orm
  • en
  • chrome
  • aspjpeg
  • [u2]
  • [t]
  • Clipboard
  • Linq
  • LINE
  • InvalidOpe
  • 88
  • 860
  • 8
  • 766
  • 60
  • .net
  • 試
  • 隱碼
  • 欄位
  • 刪除
  • trigger
  • sw
  • sql
  • 66
  • 36
  • 60.5CtEp
  • iif
  • resize
  • GUI
  • max
  • server
搜尋 Language 結果:
關於 PostgreSQL
-- 自動更新某個欄位

CREATE OR REPLACE FUNCTION before_market_update ()
RETURNS TRIGGER AS 
$$
BEGIN
    NEW.LMDT = LocalTimeStamp;
    RETURN NEW;
END;
$$
LANGUAGE 'plpgsql';

CREATE TRIGGER updt_market
  BEFORE UPDATE
  ON "Market"
  FOR EACH ROW
  EXECUTE PROCEDURE before_market_update();
More...
Bike, 2022/8/12 下午 09:25:57
PostgreSQL 的 monitor trigger
--建立 table (要記得改 XXX)
CREATE TABLE IF NOT EXISTS public.table_monitor
(
    table_name text COLLATE pg_catalog."default" NOT NULL,
    update_at timestamp without time zone NOT NULL DEFAULT now(),
    update_count bigint NOT NULL DEFAULT 0,
    CONSTRAINT table_monitor_pkey PRIMARY KEY (table_name)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.table_monitor
    OWNER to XXX;

-- 這一段只要執行一次
CREATE OR REPLACE FUNCTION public.table_monitor_trigger_fnc()
    RETURNS trigger
    LANGUAGE 'plpgsql'
    COST 100
    VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
     Update public.table_monitor Set update_count = update_count + 1, update_at = now()  Where table_name = TG_TABLE_NAME; 
RETURN NEW;
END;
$BODY$;

ALTER FUNCTION public.table_monitor_trigger_fnc()
    OWNER TO XXX;

-- 對於被監控的 table, 要執行以下的指令,記得 monitor_table_name 要改為 table 的名字(要符合大小寫)
INSERT INTO public.table_monitor (table_name, update_at, update_count) VALUES ('monitor_table_name', '2000-01-01', 0) ON CONFLICT DO NOTHING;

CREATE OR REPLACE TRIGGER table_monitor_trigger
    AFTER INSERT OR DELETE OR UPDATE 
    ON monitor_table_name
    FOR EACH STATEMENT
    EXECUTE FUNCTION public.table_monitor_trigger_fnc();

監控用的程式碼:
public static void UpdateTableCache()
{
    //標記自已是正在執行的 Thread. 讓舊的 Thread 在執行完畢之後, 應該會自動結束. 以防舊的 Thread 執行超過 10 秒.
    CurrentThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

    try
    {
        //確認自已是正在執行的 Thread, 重覆執行. (另一個 Thread 插入執行)
        while (CurrentThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
        {
            LastUpdateDate = DateTime.Now;

            foreach (var dbId in CachedDbs)
            {
                var sql = @"select * from table_monitor";

                var dt = Su.PgSql.DtFromSql(sql, dbId);

                foreach (DataRow row in dt.Rows)
                {
                    string changeId = row["update_count"].DBNullToDefault();
                    string CacheKey = TableCacheKey(dbId, row["table_name"].DBNullToDefault());
                    ObjectCache cache = MemoryCache.Default;

                    string OldValue = (string)cache[CacheKey];

                    if (OldValue == null)
                    {
                        cache.Set(CacheKey, changeId, DateTime.MaxValue);
                    }
                    else
                    {
                        if (changeId != OldValue)
                        {
                            cache.Remove(CacheKey);
                            cache.Set(CacheKey, changeId, DateTime.MaxValue);
                        }
                    }
                }
            }

            //每兩秒檢查一次
            System.Threading.Thread.Sleep(2000);
        }
    }
    catch (Exception)
    {
        //依經驗, 只要 DB 能通, 這裡幾乎不會有問題, 所以這裡暫時不處理, 未來有問題時可以考慮寫入文字檔比較好.
    }
}
More...
Bike, 2022/7/20 上午 10:05:39
bootstrap-formhelpers intlTelInput 套件注意的問題
A下拉霸
 <div class="col-md-6">
                                        <label for="contact:fromlan">Source Language <span class="red">*</span></label>
                                        <div class="bfh-selectbox" data-name="From_Language_Id" id="FromLanItemParent">
                                            <!--FromLanItem S-->
                                            <div data-value="{Id}"><img src="assets/images/_smarty/flags/{Image}" alt="{Abbreviation}"> {LanguageName}</div>
                                            <!--FromLanItem E-->
                                        </div>
                                    </div>

自動生成的下拉霸
1 name 要用 data-name=""來設定
2 完全沒有選擇的時候可能會回傳空值

套件來源
http://bootstrapformhelpers.com/select/

B電話號碼
<label for="contact_department">Your Phone Number </label>
                                        <div>
                                            <input id="phone" name="phone" type="tel">

                                        </div>
                                        <div style="display:none">
                                            <input id="PhoneCountry" name="PhoneCountry" type="">
                                        </div>


                                        <script src="/assets/build/js/intlTelInput.js"></script>
                                        <script>
                                            var input = document.querySelector("#phone");
                                            var iti1 = window.intlTelInput(input, {
                                                // allowDropdown: false,
                                                // autoHideDialCode: false,
                                                // autoPlaceholder: "off",
                                                // dropdownContainer: document.body,
                                                // excludeCountries: ["us"],
                                                // formatOnDisplay: false,
                                                // geoIpLookup: function(callback) {
                                                //   $.get("http://ipinfo.io", function() {}, "jsonp").always(function(resp) {
                                                //     var countryCode = (resp && resp.country) ? resp.country : "";
                                                //     callback(countryCode);
                                                //   });
                                                // },
                                                // hiddenInput: "full_number",
                                                // initialCountry: "auto",
                                                // localizedCountries: { 'de': 'Deutschland' },
                                                // nationalMode: false,
                                                // onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
                                                placeholderNumberType: "MOBILE",
                                                // preferredCountries: ['cn', 'jp'],
                                                separateDialCode: true,
                                                utilsScript: "/assets/build/js/utils.js",
                                            });
                                            input.addEventListener("countrychange", function () {
                                                $('#PhoneCountry').val(JSON.stringify(iti1.getSelectedCountryData()))
                                                // do something with iti.getSelectedCountryData()
                                            });
                                        </script>

需要用另一個欄位來記錄電話號碼的國家資料 

套件的來源
https://github.com/jackocnr/intl-tel-input
 
More...
sean, 2019/3/6 上午 10:41:03
網站同時使用 C# 與 VB.net
由於早期網站都是VB.net寫的,若是直接換成 C#,就會耗費很多時間在轉換程式上
因此 ASP.NET 特別可以在同一網站同時寫 vb 跟 C#,方式是在 web.config compilation 加上設定
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
     <codeSubDirectories>
        <add directoryName="VB_Code"/>
        <add directoryName="CS_Code"/>
     </codeSubDirectories>
    </compilation>

也就是 VB.NET 的 code 就放到 ~\APP_Code\VB_Code 目錄
C# 的 code 就放到 ~\APP_Code\CS_Code 目錄
這樣做有兩點要注意
1.  Namespace 的命名,最好不要互相衝突, 要能夠區分出來
2.  VB_Code 與 CS_Code 放的位置有很大的影響, 因為牽涉到 compiler的先後順序,因為 VB_Code 在 CS_Code 在前面,所以 CS_Code可以叫用 VB_Code下的程式,但是 VB_Code 卻不能叫用 CS_Code 的程式,如果希望 VB_Code可以叫用 CS_Code的程式,就把設定換過來
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
     <codeSubDirectories>
        <add directoryName="CS_Code"/>
<add directoryName="VB_Code"/>
     </codeSubDirectories>
    </compilation>

缺點就是反過來 CS_Code不能使用 VB_Code的程式

基本上,若是舊的程式碼都在VB_Code 那就把 VB_Code 放到前面
More...
darren, 2017/5/10 下午 02:21:54
css 存取字型檔無法跨網站
當A網站的 css 去下載另一B網站的字型檔 (.ttf, .woff .. 等)
語法
@font-face { src: url('.....woff')
此時瀏覽器會使用 XHR 方存取字型檔案  因此會產生跨站問題 (CORS)
https://developer.mozilla.org/zh-TW/docs/HTTP/Access_control_CORS
所以無法下載字型檔

解決方法:
B網域網站要加上 http header,允許A網站存取
語法
Access-Control-Allow-Origin: http://foo.example
當然,http://foo.example 可以改成 * (星號)  表示所有站台都可以存取
More...
darren, 2015/10/23 下午 06:33:46
Global 網站使用 CultureInfo 物件
製作 Global 網站時,由於User來自世界各地
而各地對於時間格式以及貨幣,數字顯示方式都有所不同
這時就需要 .NET Globalization -> CultureInfo 來處理這個問題
CultureInfo 是基於 Language Code 來的
而 user 的 Language Code 基本上瀏覽器會放在 Request Header 送到Server
(ex. Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4)

        Dim d As Date = Now
        Dim n As Decimal = 86400.99
        Dim Cultures() As String = {"zh-TW", "pt-BR", "pt-PT", "en-US", "en-GB", "fr-FR", "de-DE", "es-ES", "ja-JP", "zh-CN", "ko-KR", "en-IN"}
        For i As Integer = 0 To Cultures.GetUpperBound(0)
            Dim c As New Globalization.CultureInfo(Cultures(i))
            Response.Write(Cultures(i) & "<br/>" & d.ToString("D", c) & " <br/>" & d.ToString("d", c) & "<br/>" & n.ToString("C", c))
            Response.Write("<hr/>")
        Next


結果如下:

zh-TW
2013年12月25日
2013/12/25
NT$86,400.99

pt-BR
quarta-feira, 25 de dezembro de 2013
25/12/2013
R$ 86.400,99

pt-PT
quarta-feira, 25 de Dezembro de 2013
25-12-2013
86.400,99 €

en-US
Wednesday, December 25, 2013
12/25/2013
$86,400.99

en-GB
25 December 2013
25/12/2013
£86,400.99

fr-FR
mercredi 25 décembre 2013
25/12/2013
86 400,99 €

de-DE
Mittwoch, 25. Dezember 2013
25.12.2013
86.400,99 €

es-ES
miércoles, 25 de diciembre de 2013
25/12/2013
86.400,99 €

ja-JP
2013年12月25日
2013/12/25
¥86,401

zh-CN
2013年12月25日
2013/12/25
¥86,400.99

ko-KR
2013년 12월 25일 수요일
2013-12-25
₩86,401

en-IN
25 December 2013
25-12-2013
₹ 86,400.99
More...
darren, 2013/12/26 下午 04:04:39
onkeypress 和 keyCode 在 Firefox 的問題
在 firefox 抓不到 window.event,所以要用以下的 function 來處理 keyCode:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title> new document </title>
  <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <script language="javascript">
  function myKeyPress(evt){
    evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
    var key = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
    if(evt.ctrlKey && (key == 13 || key == 10)){
      alert("send");//同时按下了Ctrl和回车键
      
    }
  }
</script>
</head>


<body onkeypress="myKeyPress(event)"> 
</body>
</html>



參考: http://www.felix021.com/blog/read.php?1171
More...
Bike, 2013/12/6 下午 02:13:09
compilerVersion Error

提供者選項中 'compilerVersion' 屬性的值必須是 'v4.0' 以上 (如果要針對 4.0 版以後的 .NET Framework 編譯)。若要針對 3.5 (含) 以後版本的 .NET Framework 編譯這個 Web 應用程式,請從 Web.config 檔案的 <compilation> 項目移除 'targetFramework' 屬性。


<system.codedom>
    <compilers>
     <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="WarnAsError" value="false"/>
     </compiler>
     <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="OptionInfer" value="true"/>
        <providerOption name="WarnAsError" value="false"/>
     </compiler>
    </compilers>
</system.codedom>


相關專案: 光寶
More...
Reiko, 2013/5/10 上午 10:14:22
MRTG 監控系統設定
查了監控 snmp 的套件,還是 mrtg 最簡單,做個紀錄一下

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
先安裝 windows server snmp 服務,啟動​並進行設定

可參考:http://blog.faq-book.com/?p=1799
設定 public 的地方需輸入,會與 mrtg 的設定有關

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
安裝 ActivePerl,並下載解壓 mrtg 到任意目錄
官網:http://mrtg.cs.pu.edu.tw/download.en.html

這裏以 c:\mrtg 為例

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
設定 c:\mrtg\bin\127.0.0.1.cfg, 並執行 c:\mrtg\bin\perl mrtg 127.0.0.1.cfg 可跑一次
會產生 html&圖 到 WorkDir: 下,再設成 iis web 即可

c:\mrtg\bin\127.0.0.1.cfg 範例
#設為背景服務
RunAsDaemon: no

#統計間隔(預設5分鐘 Interval:5)
Interval:5

#網頁訊息中文顯示
Language: big5

#瀏覽器重新讀取間隔(預設Refresh:300秒)
Refresh:300
WorkDir: c:\inetpub\wwwroot\mrtg
EnableIPv6: no

########################################################
# 127.0.0.1 CPU Loading
########################################################
Target[127.0.0.1-cpu]: .1.3.6.1.2.1.25.3.3.1.2.1&.1.3.6.1.2.1.25.3.3.1.2.2:public@127.0.0.1
Title[127.0.0.1-cpu]: CPU Loading
PageTop[127.0.0.1-cpu]: </code><h1>CPU Loading - 127.0.0.1</h1>
Colours[127.0.0.1-cpu]: R#ff4f27,Y#FFFF00,,R#ff4f27,Y#FFFF00
MaxBytes[127.0.0.1-cpu]: 100
Options[127.0.0.1-cpu]: gauge, nopercent, growright
Directory[127.0.0.1-cpu]: 127.0.0.1
YLegend[127.0.0.1-cpu]: CPU loading (%)
ShortLegend[127.0.0.1-cpu]: %
Legend1[127.0.0.1-cpu]: CPU1 負載
Legend2[127.0.0.1-cpu]: CPU2 負載
LegendI[127.0.0.1-cpu]: CPU1 負載
LegendO[127.0.0.1-cpu]: CPU2 負載


[127.0.0.1-cpu] 為產生檔名
Directory[127.0.0.1-cpu]: 127.0.0.1 會建立 127.0.0.1 的目錄來放 html&圖

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
建立 bat 排程每五分跑一次即可

mrtg.bat
perl mrtg 192.168.0.10.cfg
perl mrtg 192.168.0.20.cfg

rem 幫你建立 index.html
perl indexmaker --output c:\inetpub\wwwroot\mrtg\index.html 192.168.0.10.cfg 192.168.0.20.cfg


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
較麻煩的是 Target 的設定,為 snmp 的節點值,跟效能監視器裏的項目有點像

查到的較有用的
CPU Loading
Target[127.0.0.1-cpu]: .1.3.6.1.2.1.25.3.3.1.2.1&.1.3.6.1.2.1.25.3.3.1.2.2:public@127.0.0.1
其中 .1.3.6.1.2.1.25.3.3.1.2 固定,.1 .2 隨不同機器的 cpu 數 .3 .4 都有可能

Current Connections
Target[192.168.0.10-webusers]: .1.3.6.1.4.1.311.1.7.3.1.13.0&.1.3.6.1.4.1.311.1.7.3.1.14.0:public@127.0.0.1

Network Usage
Target[192.168.0.10-network]: \Realtek\ PCIe\ GBE\ Family\ Controller:public@127.0.0.1
這裏都會跟網卡名綁,通常用執行
perl cfgmaker --global "WorkDir: c:\inetpub\wwwroot\mrtg" --ifref=descr --ifdesc=descr public@127.0.0.1 --output network.cfg
它會幫你跑一遍路的節點,再挑出來用即可

Cpu 溫度找不到內建通用的,要安裝第三方套件,開其它篇寫

查到最完整的第三方提供 snmp 統整節點,但要錢,免費版節點很少,也沒有溫度

http://www.snmp-informant.com/
http://www.snmp-informant.com/products/std/snmp-informant-std-tree.htm 免費版節點

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
結果圖








 
More...
Jerry, 2013/4/13 下午 03:18:47
~ Uwinfo ~