2013年12月22日 星期日

FortiGate SslvpnClient4 command line

FortiSSLVPNclient.exe command line parameters

Usage: FortiSSLVPNclient <subcommand> [options] [args]

Available subcommands:
    connect        - Start a connection
    disconnect    - Disconnect from your session

To start a connection, enter the follwoing command:
    FortiSSLVPNclient  connect    [-s <connection settings name>]
                [-h <sslvpn server>[:<port>]]
                [-u <sslvpn username>[:<password>]]
                [-c <certificate subject>[:<issuer>]]

To disconnect from your session, enter the following command:
    FortiSSLVPNclient.exe disconnect

2013年12月19日 星期四

IE9 report viewer 無法切換下頁瀏覽

使用VS2012 MVC 4, 利用IFRAME 內嵌aspx頁面做RDLC報表瀏覽。
在IE10、FIREFOX、CHROME的環境都很OK。
在IE9 讀取報表時很正常,但如果點選下一頁就會出現JAVASCRIPT的錯誤

網頁錯誤詳細資料

使用者代理程式: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
時間戳記: Sun, 3 Nov 2013 09:34:40 UTC

訊息: 不正確的引數。
行: 3955
字元: 13
程式碼: 0
URI: https://xxxx/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=11.0.3366.16&Name=ViewerScript


訊息: 不正確的引數。
行: 3955
字元: 13
程式碼: 0
URI: https://xxxx/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=11.0.3366.16&Name=ViewerScript


訊息: 不正確的引數。
行: 3955
字元: 13
程式碼: 0
URI: https://xxxx/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=11.0.3366.16&Name=ViewerScript


看來是一直不斷的LOOP這個不正確的引數錯誤。


自已測了幾天找不出原因..
後來同事只是在aspx頁面中,在FORM TAG外再加了BODY TAG,問題就解決了。...(無言)

以下aspx頁面的內容,原本沒有BODY TAG

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
    Inherits="Web.Areas.Reports.
Test" %>

<%@ Register Src="~/ReportControl.ascx" TagName="ReportControl" TagPrefix="uc1" %>

<script src="../../../Scripts/jquery-1.9.1.js"></script>
<body>
<form id="form1" runat="server">
    <uc1:ReportControl runat="server" ID="RDL" />
</form>   
</body>





2013年12月16日 星期一

鹿耳門天后宮之匆匆

趁著來台南探望同學之餘,回台北前跑來鹿耳門的天后宮拜拜,也不知為什麼,就是想來看看,我自己也覺得爲啥要大老遠跑來感到不解,也說不出個原因,就是要來一趟比較安心^_^。
下了車,請司機等我一下,跑進去和前中後三大殿的媽祖及神明們講了一些心裡的願望,希望自己50歲以前可以安心回台東定居,保佑現在的公司順利接案結案,認識的人也能平安健康。
匆匆的來匆匆的去,希望她們都有聽到我說的話。期待10年後可以來還願啊,😄。

這次帶著爸爸一路南下,來看親戚及同學,同學生了第二個baby還要奮鬥個好幾年了,親戚則是準備要退休打算過著悠哉悠哉含飴弄孫的生活。
我則是抽空出來放風一下,抒發一下這幾個月的壓力,哈哈!如果再有時間,真該再到其他地方繞繞。

爸爸都70歲了,昨天坐高鐵南下時,在售票機買錯了票,當時有compliant了一下老爸(我脾氣真的也很差),也不太可能要求每個人都懂自己要什麼,所以很希望自己都是一個人,這樣問題就能精準掌控,也不用太在乎別人的感覺(這個真得很難)目前一個人讓我挺快樂的。

拉拉雜雜寫一堆,希望大家一切都順利囉!

2013年11月17日 星期日

excel 找含*的資料

EXCEL欄位中想要找含有*的儲存格
看來很簡單,但怎麼找都回傳所有的儲存格

看了這篇說明才知道*是指萬用查詢
秘訣   如果要尋找工作表資料中的星號、問號與波狀符號 (~),可以在 [尋找目標] 方塊中輸入波狀符號做為尋找目標的前置字元。例如,若要尋找包含 "?" 的資料,可以輸入~?做為搜尋準則。

尋找含*的儲存格,請CTRL+F,輸入關鍵字 ~*


 

2013年11月1日 星期五

windwos 8 drag and drop

windows 8真的很討厭....
原本檔案 都可以用drag and drop的方式開啟
例如在檔案總管目錄下查看目錄檔案,想要用drag and drop 打開一個沒有副檔名定義開啟程式的檔案,以前都直接將檔案拖到文字編輯器就開啟來了。

在window 8預設就無法這樣做.即使設定了控制台下使用者帳戶下的使用者帳戶控制為不要通知,仍然無法drag and drop。

windows 8 UAC限制的更加嚴格,表面上讓你關閉通知,但骨子里卻留了一手。

參考這篇文How to bring back Drag and Drop in Windows 8

在regedit中,找到 HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > Policies > System 
EnableLUA設為0


然後重開機。

windows 8真的很討厭....,
T400 改為使用整合顯示卡後,當的機率變小,但還是會當...而且當掉的時機點竟然都是在長時間不用的情況下??
當掉後,必須把電池先拔掉再插回去才開得了機????

機器的電源管理都是設不休眠...不關閉顯示器...除了設定10分鐘變暗之外....

真不知道他在當什麼.....



2013年10月21日 星期一

SQLCLR FormsAuthentication.HashPasswordForStoringInConfigFile

人客給了一個EXCEL,要批次先建好系統使用者
但因預設密碼為使用者帳戶,每個人都不同,我又想直接透過SQLServer openrowset 方式讀取excel檔然後直接轉入。

首選當然是建一個CLR Funciton 直接在tsql 使用,但CLR不支援System.Web,所以FormsAuthentication.HashPasswordForStoringInConfigFile 就沒法使用了。

找到可行的解決方法,改寫成CLR Funciton ,記錄一下 ,粉方便~~~

What will give me the same result as FormsAuthentication hashing for a non web application?


public static string SHA1(this string stringToHash)
{
    // SHA1 is 160bit
    SHA1 sha = new SHA1Managed();
    byte[] hash = sha.ComputeHash(Encoding.ASCII.GetBytes(stringToHash));

    StringBuilder stringBuilder = new StringBuilder();
    foreach (byte b in hash)
    {
     stringBuilder.AppendFormat("{0:x2}", b);
    }
    return stringBuilder.ToString().ToUpper(); // HashPasswordForStoringInConfigFile uses uppercase hex
}
 
 

2013年10月20日 星期日

OPENROWSET導致SQL Server服務關閉

Windows 8 + SQL 2012 (11.0.3128)

症頭是使用OPENROWSET導致SQL Server服務關閉。
 select * 
  from OPENROWSET('Microsoft.ACE.OLEDB.12.0',
  'Excel 12.0;HDR=YES;IMEX=1;Database=c:\temp\ImportUsers.xlsx',
  'select * from [Users$]')  


查看事件檢視器,就這麼簡短的一行字
SQL Server (MSSQLSERVER) 服務意外地終止。已經發生 1 次。

另外還有項看不懂的Application Error
失敗的應用程式名稱: sqlservr.exe,版本: 2011.110.3128.0,時間戳記: 0x50deadad
失敗的模組名稱: ntdll.dll,版本: 6.2.9200.16579,時間戳記: 0x51637f77
例外狀況代碼: 0xc0000374
錯誤位移: 0x00000000000ebd59
失敗的處理程序識別碼: 0x61c
失敗的應用程式開始時間: 0x01cecd9d9186c411
失敗的應用程式路徑: C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn\sqlservr.exe
失敗的模組路徑: C:\Windows\SYSTEM32\ntdll.dll
報告識別碼: af519ed8-3991-11e3-be9a-0c6076872559
失敗的套件完整名稱:
失敗的套件相關應用程式識別碼:




 同一個EXCEL檔轉成ImportUsers.xls使用SQL 2005讀取,卻沒有問題
 select * 
  from OPENROWSET('Microsoft.Jet.OLEDB.4.0',
  'Excel 8.0;HDR=YES;IMEX=1;Database=c:\temp\ImportOrgnUsers.xls',
  'select * from [Users$]')   


 找到這篇文章,解藥如下

EXEC master.dbo.sp_MSset_oledb_prop 
N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1  

EXEC master.dbo.sp_MSset_oledb_prop

 N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters',1

試了一下,執行 AllowInProcess即可解決。

順便查了一下何謂 AllowInProcess  Anish Shenoy說到

AllowInProcess=0 (default)
Running the process outside the SQL Server Process:

Allowing the provider to run outside the SQL Server Process helps to protect the SQL Server process from errors in the provider, as when the provider runs outside the SQL Server process Updates or inserts involving column data types like (varchar(max), nvarchar(max), varbinary(max), text, ntext, or image) are not allowed.


AllowInProcess=1
Running the process inside the SQL Server Process:
By setting this option in the SQL Server providers, we will be able to handle the data types like (varchar(max), nvarchar(max), varbinary(max), text, ntext, or image) including long columns, image and text data.

In case of excel data we can see that when we import an excel data into the database tables without having predefined datatypes, by default the datatypes of some of the columns may be assigned to nvarchar(max) or ntext etc, so if we do net set the Allow Inprocess it will throw error.
 
這讓我順便抱怨一下,在SQL2012使用 撰寫SQL 指令 Import /Export資料時,在資料表對映無法解析到正確的資料類型 ,datatype 202 是什麼東西啊。



剛好也了解到原來這算是是一個BUG嗎?

nvarcahr 和varchar在SP1取消支援,改成了[DT_WSTR]和[DT_STR],把SSIS的定義套用在SSMS,真是很奇怪。

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

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