2012年9月17日 星期一

Create additional registry keys with DSL Tools Setup Projects



I was trying to solve the Custom Tool property issue with .actiw files in ActiveWriter, as suggested by Bogdan Pietroiu months ago, and spent a clear hour trying to figure how to inject my own registry keys into WiX setup project of DSL Tools. I modified the .vstemplate for .actiw files to include the following:

...
<CustomParameters>
  <CustomParameter Name="$itemproperties$" Value="CustomTool" />
  <CustomParameter Name="$CustomTool$" Value="ActiveWriterCodeGenerator" />
</CustomParameters>
...

and thought that the file, when added to the project, will have Custom Tool property already set. I was appearently wrong (documentation says it should work).

Bogdan's suggestion was to have a key named after the file extension under Generators\{Language}, and I manually confirmed that it works great. So, how to automate the process of adding this reg key through the setup? WiX Toolkit documentation shows the way, so I copied Registry.wxs to have my own key registered.
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2003/01/wi'>
  <Fragment Id="CustomToolFragment">
    <FeatureRef Id="DefaultFeature">
      <ComponentRef Id="_ActiveWriterCTReg" />
    </FeatureRef>
    <DirectoryRef Id="TARGETDIR">
      <Component Id="_ActiveWriterCTReg" Guid="{some GUID}">
        <Registry Root='HKLM' Key='Software\Microsoft\VisualStudio\8.0\Generators\{164b10b9-b200-11d0-8c61-00a0c91e29d5}\.actiw' Id='{some GUID}' Type='string'Value='ActiveWriterCodeGenerator' />
        <Registry Root='HKLM' Key='Software\Microsoft\VisualStudio\8.0\Generators\{fae04ec1-301f-11d3-bf4b-00c04f79efbc}\.actiw' Id='{some GUID}' Type='string'Value='ActiveWriterCodeGenerator' />
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>

<Registry> elements define the key to be added, as you may have guessed. Anyway, although I changed the build action on the .wxs and although it seems that Candle and Light picked up the file, the installer didn't add the registry key. So? Orca to the rescue. You should check Component and Registry tables in .msi file to check if your key slipped in, and Orca shows them quite detailed. In my case, though, it shows the absence of my additions.

Long story (not so) short, it seems that I should examine Registry.tt as the first step, but didn't. To include your ComponentRef in DefaultFeature, you should have your Fragment as FragmentRef in Main.wxs . So, you should add each of your custom fragment in the list defined incustomFragmentIds in InstallerDefinitions.dslsetup as shown below:

<installerDefinitionxmlns="http://schemas.microsoft.com/VisualStudio/2005/DslTools/InstallerDefinitionModel"
  ...
  customFragmentIds="CustomToolFragment">

I hope this info helps someone.

2012年9月7日 星期五

新的Lenovo鍵盤

實在不想批評, 但是新的Lenovo T430 島式鍵盤, 實在不好用, 或許是不習慣.
少了許多按鍵就算了(少了 PrtScr, ScrLk, Pause), 反正也少用, 就算了
ps: 前一頁, 下一頁也沒了

請同事幫忙查到
Pause ==> Fn + P
Break ==> Fn + B
ScrLk ==> Fn + C
SysRq(PrtSc) ==> Fn + S 

可是我常用的滑鼠右鍵(就是App鍵)的位置, 竟然被 PrtSc取代了!!
快瘋了, 原本的工作可以不用滑鼠只靠鍵盤加快捷鍵就能完成, 現在要拖著滑鼠, 才能用右鍵功能!!

找了兩天, 使用了 日本人 Hirofuml 寫的 RemapKey (包在Win2003的resource kit內), 用 右鍵的Alt鍵替代App鍵(因為它找不到PrtSc鍵).
用了一天還是不習慣, 因為Alt也太常用到了, 左右手都會用到Alt, 實在不能沒有它們.
到這裡, 整個工作速度慢的像烏X(tortoise), 還有專案要完成呀!

還是再找, 終於讓我找到 ShaprKeys 我用的是3.5版.

將 Special: PrtSc(E0_37) 指定到 Special; Application(E0_5D) 就把滑鼠右鍵找回來了! 

趕快工作吧 ,沒有藉口了.  

2012年8月25日 星期六

NHibernate Query Generator的問題

要了解 NHibernate Query Generator(NHQG) 一定要到這個網站 http://ayende.com/blog
NHQG目前是已經停止開發了, 但是你可以在 https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/deprecated/NHibernate.Query.Generator 取得舊的Source.
一開始我是用Ryan Cromwell 的方法, 但是會找不到NHQG, 我的方法如下:
echo Off
rem set path=%path%;c:\tools\svn-win32-1.4.4\bin
rem C:\Program Files\CollabNet\Subversion Client\svn.exe
echo get Trunk (Non-Recursive)…
svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk trunk -q -N
echo done
echo get Art…
svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/Art trunk/Art -q
echo done
echo get SharedLibs…
svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/SharedLibs trunk/SharedLibs -q
echo done
echo get NHQG…
rem jk, modify
rem svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/NHibernate.Query.Generator trunk/NHibernate.Query.Generator -q
svn co https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/deprecated/NHibernate.Query.Generator
echo done
echo build NHQG…
pushd .
cd trunk\NHibernate.Query.Generator
rem jk, modify
rem %windir%\Microsoft.NET\Framework64\v2.0.50727\msbuild.exe default.build 
%windir%\Microsoft.NET\Framework\v2.0.50727\msbuild.exe default.build 
echo done
echo build Installer
cd NHibernate.Query.Generator.Setup
%windir%\Microsoft.NET\Framework\v2.0.50727\msbuild.exe Setup.wixproj 
echo done
popd
PAUSE
上述batch主要是載Rhino-Tools,但我們主要是看NHQG. so, 載完後NHQG有三個專案:
NHibernate.Query.Generator, NHibernate.Query.Generator.Model, NHibernate.Query.Generator.Tests,
但是經過Build後, Test專案會有一個錯誤, Test專案是用 Model.dll 參考來產生hbm.xml檔, 所以 dll內有一個CS沒有按照 urn:nhibernate-mapping-2.2 的規範, 就會出錯.
System.Xml.Schema.XmlSchemaValidationException: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'property' in namespace 'urn:nhibernate-mapping-2.2'. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.
原因是WierdClass.cs 的 MesajIst 類別沒有 Id ?
我的解決方式, 是把它註解 ?! Test專案也不去測 MesajIst ?!
還沒仔細研究, 先測試過吧.

2012年8月3日 星期五

Eclipse+SysdeoTomcatPlugin

要記錄一件很X的事件, 花了我一天, 剛好一天!
  因為要追 directjngine 的問題,  去載了它1.0的source. 因為看到它的eclipse專案匯入後用到.tomcatplugin, 所以就想說要去載Sysdeo的Plugin來試試看.之前知道這個PlugIn, 只知道它可以啟動tomcat; 看了http://www.eclipsetotale.com/tomcatPlugin.html 的說明, 看到 DevLoader 好像不錯(說明), 因為它可以直接從Eclipse啟動tomcat, 並動態載入class及jar, 按照它的說明,
1.Eclipse安裝了Plugin.
2.設定的tomcat.
3.將eclipse下dropins/com.sysdeo.eclipse.tomcat_3.3.0(我的載3.3.0版)的DevLoader.zip解壓到tomcat/common/classes裡面.(jk, 發現了嗎?紅字的部份)
4.將tomcat啟動(當然是用plugin的方式啟動)
結果, 還沒有作第3步時的錯誤: java.lang.ClassNotFoundException: org.apache.catalina.loader.DevLoader
變成
java.lang.NoClassDefFoundError: org/apache/catalina/loader/WebappLoader

接下來就是花了一天的時間作白工.

專案Properties內Tomcat的DevLoader Classpoath的Active DevLoader要啟動(打勾)
不是專案reloaderable=true的問題.
不是DevLoader.java的問題,我甚到還重新compile了DevLoader.
(DevLoader 繼承自 WebappLoader )
不是Tomcat版本的問題, 雖然網路上說它只支援到Tomcat5.x

是我解錯誤位置了, 應該要將DevLoader.zip 解到  [tomcat]\server\classes
重新啟動tomcat後, 看到console內有 
...

[DevLoader] Starting DevLoader
[DevLoader] projectdir=C:\Users\xxx\Documents\JavaProjects\xxx\WebContent
[DevLoader] added file:/C:/Users....

...
就是成功了.

大概是新手才會碰到的問題, 但是還是記錄一下, 免得再浪費一天.

如果是Tomcat6, 請將DevLoader 包成jar檔, 放在Tomcat6\lib下

2012年7月19日 星期四

用DBCA建database後

DBCA重建資料庫後, 一切都後順利, 但是重新開機後, 同事反應, 出現
ORA-12505, TNS: listener does no currently know of SID given in connect descriptor
ORA-12514: TNS: 監聽器目前不知道連線描述區中要求的服務
Why ? 已經有下dbstart了, lsnrctl 也有 start了, 為何還會出現錯誤.
解決方法如下:
每次Oracle開機,
$> sqlplus / as sysdba
SQL> startup;
即可, 但是每次都要下, 很麻煩; 另一個方法, 修改 oratab

vi /etc/oratab
將
orcl:/oracle/u01/app/oracle/product/10.2.0/db_1:N
改為
orcl:/oracle/u01/app/oracle/product/10.2.0/db_1:Y

下次dbstart 就會自動啟動了.

2012年7月12日 星期四

TS-209掛了,重新安裝IPKG


我的TS-209 竟然掛了, 找了新的硬碟重新安裝, 步驟如下:
使用 QFinder 進行系統安裝, 這段很簡單就不多說了(請上官網找到最新的img檔)

OS裝完後, 再來就是ipkg了, 主要參考自網頁官網論壇

作了一個big-disk的目錄(請先檢查你的目錄是 HDA_DATA or MD0_DATA,自己替換)
mkdir -p /share/HDA_DATA/big-disk/opt
mkdir /share/HDA_DATA/big-disk/ipkglib
cd /; ln -sf /share/HDA_DATA/big-disk/ipkglib /usr/lib/ipkg
rm -rf /opt
cd /; ln -sf /share/HDA_DATA/big-disk/opt /opt

cd /share/HDA_DATA/big-disk

取得ipk
wget http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/unstable/ipkg-opt_0.99.163-10_arm.ipk

tar -xOvzf ipkg-opt_*_arm.ipk ./data.tar.gz | tar -C / -xzvf -

vi /opt/etc/ipkg.conf

加入這行
src mssii http://ipkg.nslu2-linux.org/feeds/optware/cs05q3armel/cross/stable

進行ipkg更新
/opt/bin/ipkg update
應該會看到 Successfully terminated.
就是安裝成功了.

測試ipkg 安裝軟體, 安裝mc(一個好用的文字界面檔案總管, 另人懷念的DOS時代)
步驟如下:
cd /share/HDA_DATA/big-disk
/opt/bin/ipkg update
/opt/bin/ipkg install slang
/opt/bin/ipkg install mc --tmp-dir=/share/HDA_DATA/

/opt/bin/mc


每次開機重新ln
mount /dev/mtdblock5 -t ext2 /tmp/config
cd /tmp/config
vi autorun.sh
加入
rm -rf /opt
ln -sf /share/HDA_DATA/big-disk/opt /opt
結束
chmod 755 autorun.sh
cd /
umount /dev/mtdblock5

重開機(#reboot)

我還加了PATH路徑
方便呼叫ipkg
mkdir /mnt/config
mount -t ext2 /dev/mtdblock5 /mnt/config
cd /mnt/config
vi autorun.sh
在尾端加入
echo "export PATH=/opt/bin:$PATH" >> /etc/profile

cd /
umount /mnt/config

如果移除ipkg
rm -rf /usr/lib/ipkg
rm -rf /share/HDA_DATA/big-disk
rm -rf /opt

另外, 使用ipkg安裝SVN
請確定 /opt ln 到 /share/HDA_DATA/big-disk/opt
指令: ln -sf /share/HDA_DATA/big-disk/opt /opt

ipkg install svn

安裝完成後, 要讓SVN開機自動執行
mount /dev/mtdblock5 -t ext2 /tmp/config
cd /tmp/config
echo "/opt/bin/svnserve -d --listen-port=3690" >> autorun.sh
cd /
umount /dev/mtdblock5
最後的結果, 擷圖請參考

noyta: http://www.kenming.idv.tw/a_u_qnap_ts_209_pro_ac_em_subversion_ser
網頁上的指令有錯誤(少了一個'-'), 請照上面指令執行即可.



Oracle 的character set

請一位到職不到一年的同事安裝 OracleDB, 我後悔了, 半年後還在收拾....
因為字元集的錯誤, 匯入了原本 dmp 檔, 不僅匯入過程錯誤, 也造成了 database 內出現了亂碼的 table , 連要刪除tablespace 都刪不掉(constraint索引, 限制條件的相依 ), 更不用說刪除table...最後忍痛把整個database刪除, 重新用DBCA建database, 過程的記錄如下, 如果有相同需求的人, 歡迎一起討論.

查看目前的字集設定
方法1)
SQL>SELECT parameter, value FROM v$nls_parameters WHERE parameter LIKE '%CHARACTERSET';


方法2)
SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;


有很多方法可以看編碼, google 一下就有了, 就不多說了.




我的想法是先把編碼改好, 再匯入dmp檔, 看有沒有得救.


所以主要是NLS_CHARACTERSET的值, 我要改成ZHT16MSWIN950, 語法如下:


#sqlplus / as sysdba
進入splplus 後

shutdown immediate;
startup mount;


alter database open;
alter database character set internal_use ZHT16MSWIN950;


shutdown immediate;
startup;

done;完成了.
再用上面的語法檢查一次.

PS: 其實在client有一個方法, 可以不用動到Server端, 但是你必須要每個client都是設定環境變數, 不是很理想.

但是如上面提到, 我的OracleDB還是一樣, 無法刪除亂碼的table, 所以後來還是整個database刪除, 再重建, OracleDB重建資料庫很麻煩, 我最後還是用UI界面處理, 下一篇再Post上來了.