2011年2月20日 星期日

asp.net menu 和 flash

在aspx上放了一個falsh object , 瀏覽時卻發現原本的sitemap menu下拉時, 卻被蓋在falsh下,
一直都把焦點放在z-index的修改上
看到 Tsung's Blog ...哈哈, 我也恍然大悟了. 感謝他

主要是在flash object加入一個設定

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"
        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
        <param name="MOVIE" value="../Yoshinoya/BrandSingleSeason.swf">
        <param name="PLAY" value="true">
        <param name="LOOP" value="true">
        <param name="WMODE" value="transparent">
        <param name="QUALITY" value="high">
        <embed src="BrandSingleSeason.swf" width="100%" height="100%" play="true" loop="true"
            wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
    </embed>
    </object>

另外,由Tsung's Blog延伸找到的範例也有詳細的說明 Z-Index and Flash.


後來,又查得JQuery提供一個swf plugin的套件,使用這個插件就無menu被蓋住的問題了.
所以後來參考範例網站後,就改用這個方式 ,程式碼也很簡潔

    <script type="text/javascript" src="../Scripts/jquery.swfobject.1-1-1.min.js"></script>     
    <script type="text/javascript">
        function displayFlash(type) {
            $('#myFlash').flash({ swf: type, height: '100%', width: '100%' });
        }
    </script> 
    <div id="myFlash" >
    </div>

進階的使用方法可參考

jQuery SWFObject Plugin

2011年2月9日 星期三

取用BugNet的HtmlEditor Provider

在BugNet Issue維護中,Descriptioncomment是使用html編輯器的方式讓我們可以輸入html格式的文字,我覺得挺好用的.

在BugNet的source code查看這段的做法,發現是利用provider的方式做的,先把相關的srouce code 抽出來,試著放入自已專案用的程式碼中

1.下載最新的BugNet souce code, 目前版本是0.8.276.0, 解壓縮後,複製以下目錄
 \BugNET-0.8.276-Source\src\Library\Providers\HtmlEditorProviders 

2.建立一個新方案,把 \BugNET-0.8.276-Source\src\Library\Providers\HtmlEditorProviders\下的四個專案都加入, 如果有需要,可以修改一下專案的Assembly Name及相關的namespace,不然build出來的dll名稱會是BugNet開頭的dll

3.build 完後,分別將專案內的dll複製出來,add reference 到自已的website 專案中,
同時也複製 以下目錄檔案及檔案

 a. \BugNET-0.8.276-Source\src\BugNET_WAP\Providers\HtmlEditorProviders
 b. \BugNET-0.8.276-Source\src\BugNET_WAP\UserControls\HtmlEditor.ascxHtmlEditor.ascx.cs、HtmlEditor.ascx.designer.cs

3.開啟自已website專案的web.config檔, 加入以下

 <configSections>
<section name="HtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.HtmlEditorConfiguration, BugNET.Providers.HtmlEditorProviders" requirePermission="false" allowDefinition="MachineToApplication" />
 </configSections>


<HtmlEditorProvider defaultProvider="CkHtmlEditorProvider">
    <providers>
      <add name="TextboxHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.TextboxHtmlEditorProvider, BugNET.Providers.TextboxHtmlEditorProvider" Height="250" Width="100%" />
      <add name="FckHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.FckHtmlEditorProvider, BugNET.Providers.FckHtmlEditorProvider" Height="250" Width="100%" ToolbarSet="Default" Skin="Silver" providerPath="~\Providers\HtmlEditorProviders\fckeditor\" />
      <add name="CkHtmlEditorProvider" type="BugNET.Providers.HtmlEditorProviders.CkHtmlEditorProvider, BugNET.Providers.CkHtmlEditorProvider" Height="250" Width="100%" Toolbar="Basic" providerPath="~\Providers\HtmlEditorProviders\CKEditor\" />
    </providers>
  </HtmlEditorProvider>


<pages enableSessionState="true" theme="Default">
      <controls>
          <add tagPrefix="bn" tagName="HtmlEditor" src="~/UserControls/HtmlEditor.ascx" />
 </controls>
    </pages>


以上紅字部份是依自已的需求做更改的

4.建立一個測試網頁testHtmlEditor.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="testHtmlEditor.aspx.cs" Inherits="Issues.testHtmlEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    test
  <bn:HtmlEditor id="EditCommentHtmlEditor" Height="200" runat="server" />       
</asp:Content>

執行後就可以看到html editor元件了.

BugNet預設的html editor toolbar是使用"Basic", 這個定義你可在
\BugNET-0.8.276-Source\src\BugNET_WAP\Providers\HtmlEditorProviders\CKEditor\config.js 自行修改,以下是原本的定義
config.toolbar_Basic =
[   
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],   
    '/',
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
    ['BidiLtr', 'BidiRtl' ],
    ['Link','Unlink','Anchor'],
    ['Image','Table','HorizontalRule'],
    '/',
    ['Styles','Format','Font','FontSize'],
    ['TextColor','BGColor'],
    ['Maximize', 'ShowBlocks','-','About']
];


BugNet中還有不少可學習的點,沒什麼想法的人可以玩看看

2011年1月13日 星期四

sp_MSforeachdb and sp_MsForEachTable

看到MSSQLTips 上這篇文章,

Making a more reliable and flexible sp_MSforeachdb

測試了一下發現挺實用,可以自由發揮

--instance中所有DB
exec sys.sp_MSforeachdb 'select ''?'' ' 


--instance中所有DB空間使用狀況
exec sys.sp_MSforeachdb'use ?; exec sp_spaceused'


--instance中所有DB訊息
exec master.sys.sp_MSforeachdb'use ?; exec sp_helpdb ? '

--目前DB中所有table訊息(含資料結構)
exec sys.sp_MsForEachTable 'sp_help ''?'' '


--目前DB中所有table筆數
exec sys.sp_MsForEachTable 'select ''?'', count(*) from ? '


其中傳入的變數 ?是否要當字串或欄位或物件,就依平常我們直接select 時的想法去想就可以明白了
要當字串,則前後加單引號, 要當物件則直接使用? 或[?] 都可以

2011年1月11日 星期二

DSOFramer @ windows 2008 R2 64bit

作業系統即將升級到Windows 2008 R2 + SQL 2005 64 bit + Office 2007 ,所以做了測試

網站上需要產生Excel檔,然後開啟做線上檢視

使用DSOFramer ActiveX元件是最方便的檢視元件


產生Excel是用Excel Application的方式實做,測試後發生太多奇奇怪怪的問題,大都是和Excel開檔的權限有關。
大家都覺得測的很煩了,所以請同事改用NPOI的方式重新撰寫這一段產生Excel套表的程式碼。

ps.使用NPOI時,若是office 2003則需要上到SP2以上,不然有時會無法在DSOFramer上開檔

完成後,終於可以順利產生Excel檔了,但用DSOFramer OpenWebDoc (open url doc)時,出現了這個錯誤訊息
The associated COM server does not support ActiveX Document embedding.

爬了文後,有人說在open時,要給定第三個參數 "Word.Document"

像這樣   open "http://test/xls/test.xls" , true, "Word.Document"

試了一下,結果改出現這個錯誤訊息
程序呼叫或引數不正確

然後開啟來的竟是word 的檔案轉換程式?

最後參考這篇文章,把參數改成 "Excel.Sheet"

Visual C++ ActiveX Control for hosting Office documents in Visual Basic or HTML


像這樣  open "http://test/xls/test.xls" , true, "Excel.Sheet"

然後就可以正常顯示了。LUCKY。。。

原來這是office 的program id表列如下,

 Excel Spreadsheet     "Excel.Sheet"    
  Excel Chart     "Excel.Chart"       
  PowerPoint Presentation   "PowerPoint.Show"  
  Project Database    "MSProject.Project" 
  Visio Drawing    "Visio.Drawing"   
  Word Document    "Word.Document"  

2010年12月13日 星期一

String or Binary data would be truncated

今天匯入EXCEL檔資料時,出現這個錯誤

String or Binary data would be truncated 

字串或二進位資料會被截斷

看來是某個欄位太長轉入TABLE時被截掉了,

但到底是哪個欄位?

只好採用刪去法來測試,

原來有個欄位table開varchar(20), 但EXCEL中却超出了長度.

記得以前也曾遇到這個問題,但每次都忘了是到底怎麼回事.

下次應該要先檢查EXCEL中的資料

記錄一下免得又忘了.

2010年12月9日 星期四

BugNet使用二個月的心得

自從10月初開始使用BugNet以來, 我和同事也用這套opensource的工具快2個月了.
大家可以說是愈用愈上癮,因為用這套來做為系統維護的Q&A時,大家將維護過程中遇到的問題及解決過程及個人心得感想全部都一股腦的輸入上去. 害我只得時時提醒大家不要寫一些個人情感抒發文在Comments或Time Tracking上.
同時大家也希望以後公司自己改寫的QA系統可以加上一個個人情感抒發的欄位,讓大家吐一下口水.

用到目前為止,我覺得最好的功能是custom fileds的設定,讓專案維護很有彈性.
再來就是RoadMap的呈現, 哪些還在進行中的問題或已經結案的問題都可以很一目了然

當然,也有一些很煩的地方, 例如有些ISSUS欄位真想要有預設值, 同事抱怨要"打很多字咧"...
還有可以一登入就看到屬於自已的而且跨所有PROJECTS的OPEN ISSUE有哪些嗎? 這也是不錯的建議...
結果今天上BugNet的官網上看, BugNet已有更新版2010/12/05 version 0.8.270.0,而且把這個功能加上去了. 可以參考完整的功能說明


最後,DB的設計我也覺得很清楚,可以很方便讓我寫自已要的報表查詢. 利用pivot 語法,將自訂欄位做一個整合呈現.

這二個月操作上使用很多,但source code就沒看那麼深入,因為偶覺得有點小複雜咧.

等空閒時間多了再來好好細細研究.

http 方式連結 analysis server SQL2008 R2

環境是SQL2008 R2 64 bits, 要建立OLAP HTTP連線
設定方式請參考阿兜仔所寫的文章

Configuring HTTP Access to SQL Server 2008 Analysis Services on Microsoft Windows Server 2008

設定後,在SSMS 2008R2 用http://myserver/olap64/msmdpump.dll 的方式連結到AS Server上.

結果出現這個錯誤訊息...

Cannot connect to http://myserver/olap64/msmdpump.dll.

The connection either timed out or was lost. (Microsoft.AnalysisServices.AdomdClient)

遠端伺服器傳回一個錯誤: (405) 不允許的方法。 (System)


再試著在Excel 2010, 以http連線到AS , 結果出現另一個訊息..

the http server returned the following error: method not allow


反覆檢視文章,檢查了半天, 看來設定沒問題....
(IIS 7的介面真的令人很不習慣,一個設定要找老半天,還要中翻英一下才...)


最後,忙了半天,在教學文章末的討論中找到答案,
由Andy T. 網友所回覆..在iis applicationpool (應用程式集區), 進階設定,將啟用32位元應用程式設成False就好了...

以下是這位Andy阿兜仔說的....

I wanted to add in a comment on 64-bit vs. 32-bit.  I am running Vista Business on a 64-bit machine.  I kept getting "405.0 - Method not allowed" errors when trying the http URL to the msmdpump.dll.  The error seemed as though it was not accepting the POST method, but in fact the issue was that my OLAP application pool should not be enabled for 32-bit applications.  If you go to the advanced settings on the OLAP application pool, the 2nd setting from the very top is, "Enable 32-Bit Applications" and it must be set to "False" since I am running on a 64-bit machine.
- Andy

開啟SSMS, 用http連線.....然後, 就成功了.....
Browse Cube ....冇問題啦
Process ............也冇問題啦

ps.同事說,他使用SQL 2008 64 bits + SP2, 在SSMS中以http方式連結AS SERVER,結果process時, 整個當掉. 目前無解...

VS CODE離線安裝套件方式-續

去年 vscode離線安裝 powershell nupkg 今年在一台無外網的 windwos 2025上安裝時遇到了powershell版本一直讀取到了5.1的版本,鬼打牆了一下午,在VM還原重測測了好幾回,應該是可行了。 將下載到的免安裝powershell 解壓縮到...