2010年1月31日 星期日

Peopleware 書摘

加班就像衝刺:跑馬拉松要為最後百米保留體力是有道理的,一開始就拔腿狂奔只會浪費時間。經常強迫部屬衝刺的經理人,只會失去部屬的尊重。最優秀的員工早就看穿一切,當經理人吼著要在四月份完工時,他們懂得三緘其口,等著看好戲,只要有機會,就開始補償性的打混摸魚,到頭來每週真正在工作的還是四十小時。

《Peopleware 腦力密集產業的人才管理之道》第三章  P.37

2010年1月22日 星期五

在 Window 2000 之下執行 Delphi 2010 的應用程式

  1. 複製 Delphi 2010 的 *.BPL 檔案至 WINNT\System32
  2. 複製 MIDAS.DLL 至 WINNT\System32
  3. 安裝 MDAC 2.8
  4. 安裝 Windows Installer 3.1
  5. 安裝 SQL Server native Client

2010年1月18日 星期一

使用 SQL Server 開啟 DBF 檔案

dBase 的 DBF 檔,可以使用 Jet 4.0 開啟
所以可以在 SQL Server 的管理工具中這樣下:(假設你的 DBF 檔是 C:\DBF\ABC.DBF)

SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0', 'Data Source=C:\DBF;Extended Properties=dBase III;')...ABC

ABC 前面的三個點不可以省略,因為是 server_name.database_name.schema_name.table_name 四部份名稱中間省略了 database_name 和 schame_name 之後留下的三個點

如果SQL 2005/2008 出現
SQL Server 已封鎖元件 'Ad Hoc Distributed Queries' 的 STATEMENT 'OpenRowset/OpenDatasource' 之存取
這樣的錯誤訊息,請先到
SQL Server 介面區組態 >> 功能的介面區組態 >> 特定遠端查詢
去開啟 啟用 OPENROWSET 與 OPENDATASOURCE 支援之後,就可以執行了

2010年1月8日 星期五

X64 系統 BDE merge module 安裝方法

由於 x64 系統已經無法執行 16 bit 的程式,使得原先的 BDE 安裝程式已經無法使用了,解決方法就是重包一個(至少是 x32 的)安裝程式。

重包 BDE 安裝程式,需要 BDE merge module。可以於此處下載:http://support.installshield.com/kb/view.asp?articleid=Q104962

2009年10月30日 星期五

取得物件的私有欄位、呼叫已經綁定在物件上的事件

要 using System.Reflection、System.ComponentModel、System.Text 三個命名空間
public string ListFields(Type type)
{
  StringBuilder sb = new StringBuilder();
  FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic);
  sb.Append(@"<table border='1' cellpadding='3' cellspacing='0'><tr><th>Field Name</th>
              <th>Type</th><th>Static</th></tr>");
  foreach (FieldInfo fInfo in fieldInfos)
  {
    sb.AppendFormat("<tr><td>{0:s}</td><td>{1:s}</td><td>{2:s}</td></tr>",
      fInfo.Name, fInfo.FieldType.FullName, fInfo.IsStatic ? "Yes" : "No");
  }
  sb.Append("</table>");
  return sb.ToString();
}
這樣就可以把 type 裡面定義的私有欄位,用 Table 的方式顯示出來
如果私有欄位定義在 base class 中,則傳入 obj.GetType().BaseType
執行範例一: 
System.Web.UI.WebControls.FormView() FormView1 = new System.Web.UI.WebControls.FormView();
ListFields(FormView1.GetType());
Field Name Type Static
EventPageIndexChanged System.Object Yes
EventPageIndexChanging System.Object Yes
EventItemCommand System.Object Yes
EventItemCreated System.Object Yes
EventItemDeleted System.Object Yes
EventItemDeleting System.Object Yes
EventItemInserting System.Object Yes
EventItemInserted System.Object Yes
EventItemUpdating System.Object Yes
EventItemUpdated System.Object Yes
EventModeChanged System.Object Yes
EventModeChanging System.Object Yes
執行範例二: 
System.Web.UI.WebControls.DropDownList DopDownList1 = new System.Web.UI.WebControls.DropDownList();
ListFields(DropDownList1.GetType());
Field Name Type Static

??怎麼沒有東西??
那麼改用 ListFields(dropDownList1.GetType().BaseType) 試看看
Field Name Type Static
EventSelectedIndexChanged System.Object Yes
EventTextChanged System.Object Yes
果然有了!
拿到這些私有欄位的名稱有什麼用?各位發覺到了嗎,這些私有欄位都是以 Event 開頭的,也就是說這些是用來儲存 Delegate 的私有變數
接下來,就可以利用以下的程式,來呼叫「已經綁定在物件上的事件處理函式」
public void InvokeEvent(object obj, Type type, string eventName, EventArgs e)
{  
  PropertyInfo propertyInfo = (type.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic));
  EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(obj, null);
  FieldInfo fieldInfo = type.GetField(eventName, BindingFlags.Static | BindingFlags.NonPublic);
  Delegate[] dels = eventHandlerList[fieldInfo.GetValue(null)].GetInvocationList();
  foreach (Delegate d in dels)
  {  
    d.Method.Invoke(d.Target, new object[] { obj, e });
  }
}
呼叫範例:
InvokeEvent(DropDownList1, DropDownList1.GetType().BaseType, "EventSelectedIndexChanged", e);

2009年6月17日 星期三

UpdatePanel 與 ValidationSummary 合併使用的注意事項

  1. Validator 以及由 Validator 驗證的控制項必須放在同一個 UpdatePanel 中
  2. ValidationSummary 也必須放在 UpdatePanel 中,可以跟 1 的不同

2009年4月17日 星期五

網路收音機 Ver0.61 更新事項

Ver 0.61 更新事項

  1. 因 HiChannel 修改了網路廣播的收聽方式,故作此更新
  2. 頻道下拉清單字體改小,以便更完整的顯示頻道名稱

WebRadio.xml 中修改的項目有:
  1. <URL ID="hinet"> 標籤的 URL 部份
  2. <CHANNEL> 標籤中,是由 HiChannel 提供服務的 SUBID 部份