Jun 10, 2015

自製滷味, 滷汁 做法收集

萬用滷汁

1.草果1顆、花椒1錢、甘草1錢、桂皮1錢、八角1錢、小茴香1錢
2.蔥2支、辣椒2根、薑4片、米酒4大匙、醬油1杯、水4杯、冰糖4大匙
做法: 
1.將滷料1裝入棉布袋中,收口綁緊。
2.蔥拍扁後切大段;辣椒拍扁後切末。
3.取一深鍋,將所有材料煮滾,即為1份萬用滷汁

Ex.滷雞胗
材料:
雞肫10個、萬用滷汁1份
做法: 
1.雞肫用清水反覆清洗,去除多餘脂肪,入滾水汆燙,撈起瀝乾備用。
2.將滷汁煮滾,放入雞肫,以中小火滷約20分鐘,取出切片後盛盤。


牛肉專用滷汁  使用味道較為強烈的中藥辛香料去除牛肉的腥味。
1.丁香5分、山奈1錢、白荳蔻1錢、陳皮1錢、桂皮1錢、八角1錢、小茴香1錢、花椒1錢、甘草1錢
2.辣椒4根、薑8片、米酒半杯、壺底油3杯、水12杯、冰糖半杯
做法: 
1.將滷料1裝入棉布袋,收口綁緊。
2.辣椒拍扁後切小段。
3.取一深鍋,將所有材料放入煮滾,即為1份牛肉專用滷汁。

Ex. 滷牛腱做法: 
1.牛腱心汆燙,撈起瀝乾備用。
2.將牛肉專用滷汁煮滾,放入牛腱心,以中小火滷約1小時30分鐘,熄火後浸泡一夜,取出切薄片後盛盤。

小豆干專用滷汁
八角2粒、甘草3片、醬油半杯、沙拉油半杯、冰糖半杯、水半杯
做法:
1.將滷料1裝入棉布袋,收口綁緊備用。
2.取一深鍋,將所有材料煮滾,即為1份小豆乾專用滷汁。

Ex.滷豆干做法:
1.取適量小豆乾專用滷汁(可蓋過小豆乾即可),放入小豆乾一起煮滾,轉中火滷約15分鐘(不加鍋蓋),熄火後蓋上鍋蓋燜約3小時。
2.打開鍋蓋,續以中火滷約15分鐘,熄火後蓋上鍋蓋燜約3小時,再重複此動作一次至滷汁收乾即可。

鹽水滷汁
單純以鹽水滷製,最能吃到食物原味,稱為「白滷」。有別於使用到醬油的「醬滷」。
滷料:

1.陳皮2錢、桂皮2錢、八角2錢
2.蔥2支、薑4片、鹽3大匙、雞粉2大匙、米酒半杯、水10杯
做法:
1.將滷料1裝入棉布袋,收口綁緊備用。
2.蔥拍扁後切大段備用。
3.取一深鍋,將所有材料煮滾即為1份鹽水滷汁。

Ex.鹽水滷雞做法:
1.全雞處理乾淨後,雞身均勻抹上3大匙鹽、2大匙胡椒粉,醃約6小時備用。
2.將鹽水滷汁煮滾,放入雞隻,以中火滷約35~40分鐘,取出後切塊盛盤。
Tips:如果是鹽滷雞腿,只需要醃2小時、滷25分鐘。

清宮御膳滷汁

據說是清朝宮廷外傳的中藥滷汁配方,透過一夜浸泡,讓中藥材精華滲入蛋中。也可滷花枝。
滷料:

1.當歸1錢、杜仲1錢、桂枝1錢、八角1錢、花椒1錢、紅茶葉半杯-
2.鹽1大匙、醬油露1杯、高湯6杯a
做法:
1.將滷料1裝入棉布袋,收口綁緊備用。
2.取一深鍋,將所有材料煮滾,即為1份清宮御膳滷汁。

Ex.清宮茶葉蛋
材料:
雞蛋20個、清宮御膳滷汁適量
做法:
1.雞蛋放入冷水中,以小火煮滾,續煮5分鐘後撈出沖涼,以湯匙將蛋殼略敲出紋路備用。
2.取適量清宮御膳滷汁煮滾(蓋過雞蛋即可),放入雞蛋,以小火滷約1小時,熄火後浸泡一夜至入味。


萬巒豬腳滷汁

豬腳在汆燙後急速冷凍,可達到皮香肉Q。滷汁可以用來滷任何肉類。
滷料:
1.草果1顆、山奈1錢、陳皮1錢、桂皮1錢、甘草1錢、八角1錢、花椒1錢
2.蔥2支、薑4片、米酒半杯、壺底油(或蔭油)2杯、水8杯、冰糖半杯
做法:
1.將滷料1裝入棉布袋,收口綁緊備用。
2.蔥拍扁後切大段。
3.取一深鍋,將所有材料煮滾即為1份萬巒豬腳滷汁。

Ex. 萬巒豬腳
材料:
1.豬後腳1隻、萬巒豬腳滷汁1份
2.醬油膏4大匙、蒜泥1大匙、細砂糖1大匙}
做法:
1.豬腳放入滾水中汆燙,撈起泡入冰水至涼,再放入冷凍庫中急速冷凍約1小時,再取出備用。
2.將萬巒豬腳滷汁煮滾,放入豬腳,以中小火滷約1小時即成。可切片沾醬食用,將材料2拌勻即為沾醬。

Sep 3, 2014

Delete all files and subfolders under specify folder

-- delete all files and subfolders under specify folder.
FOR /D %%p IN ("D:\temp\*.*") DO rmdir "%%p" /s /q
del /q /f D:\temp\*

Oct 18, 2012

Oracle Performance Tunning Practice - INDEX RANGE SCAN with CPU high utilization

1. set autotrace on  and execute sql .
   Using index by "INDEX RANGE SCAN"
2. Through AWR report found the sql is top1 in  SQL ordered by CPU Time part.
3.  alter session set events '10046 trace name context forever, level 8';
    Execute sql again  and found  STAT line for the traced query contains 'cnt=xxx' problem.
4. Check table records found the value are skewed cause by program bug.
5. Remove abnormal data and  analyze index column .

  execute dbms_stats.gather_table_stats('xxx','xxxxxxx',method_opt=>'FOR COLUMNS xxx');
6. High CPU utilization was solved.
    

Sep 6, 2012

SQL Server Error: 5132 ,Error: 17207 when attach DB

SQL Server Error: 5132 , Error: 17207, Severity: 16
Loss SQL Server 2005 .LDF file , when try to attach MDF/NDF facing problem.
Step 0) Copy MDF/LDF to another location for backup purpose.
Step 1) Create DB with same DB/MDF/NDF/LDF Name
Step 2) Stop SQL Service
Step 3) Replace new DB MDF/NDF file with old MDF/NDF file
Step 4) Start SQL Server
Step 5) SQL Server 2005

ALTER DATABASE  YourDB SET EMERGENCY
go
select * from sysdatabases
go
ALTER DATABASE YourDB SET SINGLE_USER
go
DBCC CHECKDB(YourDB, REPAIR_ALLOW_DATA_LOSS)
go
ALTER DATABASE SFC SET MULTI_USER

CheckDB complained about the missing log then went and rebuilt the log 


#Remark - SQL Server 2000 update system tables
EXEC sp_configure 'allow updates'1
RECONFIGURE WITH OVERRIDE;
 
-- do some modification to system tables
 -- Ex.Put the DB in suspect mode:
 -- update sysdatabases set status = 32768 where name ='YourDB'
 
EXEC sp_configure 'allow updates'0
RECONFIGURE WITH OVERRIDE;

Aug 31, 2012

帶狀皰疹

水痘與帶狀皰疹同樣都是由同一病毒所引起。水痘是原發性感染,而帶狀皰疹是原來潛伏性感染的再活動。此病毒能夠逃避身體的免疫反應 , 即使在正常的宿主中。可能再出現在日後的生活中,特別是利用免疫力降低時出現 

1. 治療必須儘早開始, 我的經驗是看診時皮膚科醫生提到三天之內塗藥與吃藥治療最有效,超過此時間治療比較無效,就需等二到三星期內消失.

2. 帶狀皰疹是否會傳染?若對水痘無免疫力者,接觸帶狀皰疹可能會感染到水痘。而對已有水痘抵抗力者,則絲毫無損。也就是說帶狀皰疹會傳染,但只傳染給一些對水痘沒有免疫力者,而受感染者亦只是發水痘而已。 

3. 帶狀皰疹俗稱「皮蛇」,實因其發皰疹分佈情形成帶狀而與「皮蛇」相似而命名。看過以上帶狀皰疹的病因後,可見砍「皮蛇」能治療此病是無稽之談。

 4. 「蛇」環繞全身就沒命了嗎?帶狀皰疹大多只發生於身體單側,左邊或右邊,只有約二%~十%會超過範圍到另一側,甚至全身散佈,這樣情況大都是患者原來就有其它惡性疾病,或免疫不全,其死亡的機率當然較高。因此,「沒命」的原因是來自原有的疾病,而非被「蛇」纏死了。

Jul 13, 2012

讓身體內蠢蠢欲動的癌細胞多多睡覺

讓身體內蠢蠢欲動的癌細胞多多睡覺。 1. 咖哩的重要成份「薑黃」(抗癌成份是「薑黃素」) 2. 辣椒(抗癌成份是「辣椒素」) 3. 姜(抗癌成份是「薑油」) 4. 綠茶(抗癌成份是「兒茶素」) 5. 大豆(抗癌成份是「異黃酮」) 6. 蕃茄(抗癌成份是「茄紅素」) 7. 葡萄(抗癌成份是「白黎蘆醇」) 8. 大蒜(抗癌成份是「硫化物」) 9. 高麗菜(抗癌成份是「indole」) 10. 花椰菜(抗癌成份是「硫化物」)

May 24, 2012

sharepoint 2010 user name not updating after AD display name changed

sharepoint 2010 user name not updating after AD display name changed Try using following step to solve it.: 1. Open "Sharepoint 2010 Management Shell" 2. Set-SPUser -identity "[domain]\[useraccount]” -SyncFromAD -web http://sharepointwebsite

Jan 30, 2012

少林氣功

 本功法集強身及武術的高深鍛練法, 其特點是易練,不必什麼特別昂貴的設 備。人人可練,只要鍛練持之有恆必能見效。
   本功法包括氣功的動功,靜功,及武術特殊功練習法。

            『 第  一  編 』
        少林氣功的練習要領
   少林寺僧在一千多年的研練中纍積了豐富的經驗, 使少林氣功以靜中含動, 武中含氣,武與氣並用而區別於其它氣功流派。 少林氣功的基本法則或要領有 :" 一靜、二鬆、三細勻、四恆 "。
(一)   靜
   所謂「靜」, 即練氣功時思想要完全集中,在練功時要排除一切雜念,永保 思想集中,使大腦真正保持「靜」。 其法就是意守丹田,古人說「丹田即氣海 ,能消吞百疾。 」所以意守丹田是練氣功的妙訣和原則。拳諺曰: 「舌舐抵上 顎攝真氣,氣沉丹田填海池。 」即練氣功時,一是要舌舐上顎,二是要氣沉丹 田攝氣歸意,『以意領氣』,這樣才不致於使人體的內氣流散。 內經曰: 「氣 為血之帥,血為氣之母。 」總之,血為氣壯力,氣為血導航,對氣功來說更為 重要。 在本門功夫中,攝氣即聚氣,發氣即發勁,氣到力到,氣乃精也,氣乃 力也。 上述練氣功的方法,說易練難,最難處是在初練時難入靜境,思想難以 集中。 訓練的方法是以計數呼吸,即把一呼一吸定為一息,然後從一到十勤練 下去,思想就慢慢集中了。 古人說: 「靜從純思來。」思想一集中,心思皆純 靜。 丹田是氣功之本,是精氣之源,人體全身之血氣和精氣,都由丹田所集而
 發,所以凡練氣功者都必須悉知丹田的部位和意守丹田之法。
   丹田穴位於肚臍正中下方三寸,也叫關元穴。 在練功時,拳手需以意領氣, 調全身之氣沉聚在丹田, 也就是全神貫注,把意志集中在丹田部位,就是意守 丹田。 練意守丹田的時間最好是在早晨五至七點、上午九至十點,下午二至三 點, 晚上十點,初學者每次以十五至卅分鐘為宜,半年後以卅至六十分鐘為宜 ,早晨和晚上可適當再延長一些。 在技擊中,拳手可先以意領氣,使氣沉丹田 ,再以意領氣,使丹田之氣順意而疾發,並由丹田之氣所發動。 右動者,崩勁 疾達右; 左動者,崩勁疾達左; 上動者, 崩勁疾向上; 下動者,崩勁疾向下。
 全身百節齊動者崩勁如火山爆發, 疾注百節,勢如劈雷,快如出雷,出腿之急 根本無法防範。 在少林武功中,如動與崩(即內與外)同時發,則需密切配合 ,如此久練方見成效。 開始時可先練手,後練腳,再練全身。練久者力必大。 再逐步練掌分磚、指透牆、鐵拳功等,繼而練足功、腿功, 如帶鐵瓦、纏沙袋 等。
(二)鬆
   所謂鬆,就是練功時全身的肌肉、關節要放鬆。 拳譜曰: 「鬆者氣宜達,氣 足易聚存」。 「在技擊實戰中,為了對付對手攻來的各種攻勢,應隨時採用各 種方法還擊,這就需要調氣。 從上到下,或從下到上,這個調氣的過程叫換氣 。 換氣前需先鬆,如不鬆則難移難調。鬆應以靜為綱,且始終如一; 或坐或站 ,肌體必須保持自然,使肌肉放鬆,靜形如眠,思想集中。 另外,還應使氣與 力合, 腦與心合,心與意合,以意領氣,並必須將所目視之物映於腦,再由腦 所策,以意換氣而壯力。
   初學者也許不明了上述規律和奧秘所在。 因此,從最初的意識驅動到攻擊, 都保持著高度的緊張。 但這樣勢必會破壞自己的協調,使攻擊的力量下降,速 度減緩,而大大削弱技術的效果。

(三)細勻
   所謂「細勻」,是指練氣功時,要使呼吸深長而細勻。 而且呼則呼盡,吸則 吸滿, 不能忽而粗,忽而細,忽而長,忽而短,必須粗細均勻,長短相宜,切 記不能吸氣長、呼氣短,免得逆滯而影響全身精氣的調發。   在少林氣功中,有六種呼吸法,也就是氣功由淺到深的六個階段。
   第一個階段是: 自然呼吸。 即吸氣時要用鼻吸,上下牙齒微微相合,舌尖舐 住上牙床,隨著呼氣腹部凸起。 呼氣時,嘴要閉住,舌要舐上顎,隨著呼氣腹 部要收縮。練習的時間,每天最少練習半個小時。
   第二個階段是小周天呼吸法,也叫陰陽循環法。 所謂陰陽循環,按氣功的說 法, 人體前面屬陽,後面屬陰,小周天就是指氣在人體上身前後面循環周轉。 小周天的呼吸法是吸氣時腹部收縮, 呼氣時腹部凸起,所以又稱反式呼吸,應 在第一階段練習一個月以後再練此功。 呼吸用鼻,用意念引導氣循環於上體, 即以意領氣。 呼氣時想氣由頭頂經胸部下降到丹田。吸氣時意識到氣由丹田經 會陰尾閭、脊椎而上達頭頂,如果是站式,吸氣時腳趾要抓地, 這是為了使氣 上提。練習的時間為七十五天。
   第三階段叫大周天呼吸法, 就是把氣擴大到下身,因有前兩個階段的基礎, 已把氣練得深長了, 所以氣的循環可以擴大到全身,而且是口呼鼻吸,呼氣時 氣由頭頂經丹田,下沉到湧泉; 吸氣時,氣由湧泉上升至尾椎(閭), 而後達 於頭頂。此功如練半年,能健全神經係統,內氣十分可觀。
   第四階段叫調息, 即好象又回到自然呼吸,但要比第一階段呼吸深長得多。 目的是為了使內部器官得到平衡發展,不致於出偏,歷程是六十天。
   第五階段叫加強深呼吸法, 即呼吸時喉部要盡量張開,腹部的凸縮同第二和 第三階段,但要氣運全身,使內『『髒得到鍛煉,時間是三個月。
   第六階段叫內呼吸法。 就是呼吸時毫無聲息,連自己也聽不到,因此又稱「 真息」。 但其效果會使氣功的功夫更深,能隨時隨地應用於技擊。時間是十個 月。
(四)  恆
   所謂「恆」, 指練氣功貴在堅持,無論冬寒刺骨,還是暑熱似火,都要堅持 不懈,幾十年如一日。 練功應在三個時辰裡進行,即早晨練、中午練和披星練 。 並編成歌訣曰「晨練洩廢納新氣,午練順逆精氣蓄,夜深旋氣發精銳,彈指 穿木如插席。 」特別是披星練,由於此時萬物沉寂,故思純、心專,氣宜集, 銳散。

Apr 29, 2011

Sharepoint list items detail about Author,Editor , assignto with mutiple values , Duedate

c# , get sharepoint list item detail about Author,Editor , assignto with mutiple values , Duedate
// Add reference Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.Runtime
//
using Microsoft.SharePoint.Client;


ClientContext clientContext = new ClientContext("http://sharepointserver");
List list = clientContext.Web.Lists.GetByTitle("testlist");
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "";
ListItemCollection listItems = list.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
int i = 0;
foreach (ListItem listItem in listItems)
{
var SendToList = string.Empty;
var MailSubJect = string.Empty;
var MailBody = string.Empty;

DateTime dt = Convert.ToDateTime(Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd"));
DateTime today = Convert.ToDateTime(DateTime.Now.ToLocalTime().ToString("yyyy/MM/dd"));
if ((dt <= today) && (listItem["Status"].ToString().Equals("Finished") == false))
{
Console.WriteLine("Id: {0} Title: {1} Author : {2} Editor : {3}",
listItem.Id, listItem["Title"],
((FieldUserValue)(listItems[i]["Author"])).LookupValue,
((FieldUserValue)(listItems[i]["Editor"])).LookupValue
);
String StartDateStr = Convert.ToDateTime(listItem["StartDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String DueDateStr = Convert.ToDateTime(listItem["DueDate"]).ToLocalTime().ToString("yyyy/MM/dd");
String ModifiedStr = Convert.ToDateTime(listItem["Modified"]).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
double PercentComplete = Convert.ToDouble(listItem["PercentComplete"].ToString());
PercentComplete = PercentComplete * 100;
String PercentCompleteStr = PercentComplete.ToString();
var BodyStr = string.Empty;
if (listItem["Body"]!=null)
BodyStr = listItem["Body"].ToString();
var assigntolist = string.Empty;
Type t = listItems[i]["AssignedTo"].GetType();
if (t.IsArray)
{
foreach (FieldUserValue o in listItems[i]["AssignedTo"] as FieldUserValue[])
Console.WriteLine("AssignedTo: {0}", o.LookupValue);
}
}
i = i + 1;
}

C# send mail by smtp with html body

C# send mail by smtp with html body. (add reference System.Net)
using System.Net.Mail;

public static void Sendalertmail(string SendToList, string MailSubJect, string MailBody)
{

string fromEmail = "Administrator@test.com";//sending email from...
string ToEmail = SendToList; //destination email
string body = MailBody;
string subject = MailSubJect;
try
{
MailMessage mm = new MailMessage(fromEmail, ToEmail);
mm.Subject = MailSubJect;
mm.Body = MailBody;
mm.IsBodyHtml = true;
SmtpClient sMail = new SmtpClient("192.168.1.1");//exchange or smtp server goes here.
sMail.DeliveryMethod = SmtpDeliveryMethod.Network;
sMail.Send(mm);
}
catch (Exception ex)
{
//do something
}

}

Get sharepoint user name or email address

c# get sharepoint user name or email address
-------
static public string GetUserEMail(object user, ClientContext context)
{
Dictionary userNameCache = new Dictionary();
if (user == null)
{
return string.Empty;
}

var username = string.Empty;
var useremail = string.Empty;
var spUser = user as FieldUserValue;
if (spUser != null)
{
if (!userNameCache.TryGetValue(spUser.LookupId, out useremail))
{
var userInfoList = context.Web.SiteUserInfoList;
context.Load(userInfoList);
var query = new CamlQuery { ViewXml = "" + spUser.LookupId + "" };
var users = userInfoList.GetItems(query);
context.Load(users, items => items.Include(
item => item.Id,
item => item["Name"]));
var principal = users.GetById(spUser.LookupId);
context.Load(principal);
context.ExecuteQuery();
username = principal["Name"] as string;
useremail = username.Substring(username.IndexOf("\\") + 1) + "@test.com";
userNameCache.Add(spUser.LookupId, useremail);
}
}
return useremail;
}

Apr 14, 2011

Proxy Autoconfig , PAC

In Browser , setting as use PAC.
http://proxycfg/browser.pac


browser.pac content is as :

function FindProxyForURL(url, host)
{
if (isPlainHostName(host) ||
shExpMatch(url, "*.mycompany.*") ||
isInNet(host, "192.168.0.0", "255.255.0.0"))
return "DIRECT";
if (isInNet(myIpAddress(), "192.168.0.0", "255.255.240.0"))
return "PROXY proxy.mycompany.com:3128; DIRECT";
else
return "PROXY proxy.othersite.com:8080; DIRECT";
}



-- Description
isPlainHostName(host) -> check if local lan server
shExpMatch(url, "*.mycompany.*") -> check url use local web site server
isInNet(host, "192.168.0.0", "255.255.0.0")) -> check server IP if in LAN
isInNet(myIpAddress(), "192.168.0.0", "255.255.240.0") -> CHeck if My IP address is in local site subnet

Feb 22, 2011

SQL Server using decode / instr function

1. "charindex('Taiwan',description)" can be act as instr.
2. "case WHEN charindex('Taiwan',description) > 0 then 'Taiwan Local' else 'Other contury' end as location" can be act as decode.
3. full sql is like :
select mac,description,case WHEN charindex('Taiwan',description) > 0 then 'Taiwan Local' else 'Other contury' end as location from tmpdata

Jan 7, 2011

Sharepoint 2010 disable user "alert me"

There are two ways to disable "alert me"
1. Sharepoint administration -> application management -> Web Application -> Manage web application -> Application Ex. 80 , then "general Settings"
-> set "Alerts" option as "off"

2. Through permission level , remove "alert me".

Sharepoint 2010 master page layout , fix content display width .

1.
## Copy v4.master as custom.master , and set as default master page , and then under <head> , above </head> add following code -> style type="text/css" ...

<style type="text/css">
.s4-specialNavLinkList
{
display:none !important;
}
.ms-cui-ribbonTopBars > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
UL.ms-cui-tabBody {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
BODY #s4-titlerow > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
#s4-bodyContainer > DIV {
MARGIN: 0px auto; WIDTH: 1000px; FLOAT: none
}
.s4-help {
DISPLAY: none !important;
}
.s4-search {
DISPLAY: none !important;
}
.s4-titletext {
DISPLAY: none !important;
}
body #s4-leftpanel{font-size: 10pt !important; font-family: Verdana !important;}
</style>


2. Hide the left panel at all.
1. Site Actions > Edit Page >
2. # Insert > Web Part (or add a Web Part to a Web Part zone)
3. # Under Media and Content select Content Editor and click Add , then save
4. Enter the following HTML / CSS into content and click OK

<style type="text/css">
body #s4-leftpanel { display: none; }
.s4-ca { margin-left: 0px; }
</style>


## There is a good reference doc for sharepoint 2010 layout component at http://erikswenson.blogspot.com/2010/01/sharepoint-2010-base-css-classes.html

Nov 2, 2010

Sharepoint 2010 connect to sql server and oracle database

1. Menu add connection strings in c:\inetpub\wwwroot\wss\VirtualDirectories\\web.config
Ex.
/* for sql server and oracle*/
<connectionStrings>
<add name="AdventureWorksConnectionString" connectionString="Data Source=192.168.0.1;Initial Catalog=AdventureWorks;User Id=sa;Password=smpsqladm1" />
<add name="OracleConnectionString" connectionString="Data Source=Ora_TEST;User ID=system;Password=system_pwd" providerName="System.Data.OracleClient" />
</connectionStrings>

2. In Sharepoint virtual web part ascx file .

<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
</asp:DetailsView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorksConnectionString%>"
SelectCommand="select count(*) as intUnRead from yourtable">
</asp:SqlDataSource>

<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource2" EnableModelValidation="True">
</asp:DetailsView>

<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="System.Data.OracleClient"
SelectCommand="select count(*) as UnRead from testtable">
</asp:SqlDataSource>

Nov 1, 2010

Using Visual Studio 2010 add connect string to Sharepoint 2010 to query database data

1. From VS2010 , add new sharepoint 2010 empty project as , and then add one new item "Virtual Web Part" name as "SQLWebPartTest"
2. In "SQLWebPartTest" ascx file , manual add codes for DetailsView and SqlDataSource .
-----------
<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSource1" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ChangebyYourConnectionString %>"
SelectCommand="select * from ChangebyYourTable">
</asp:SqlDataSource>

<asp:DetailsView ID="DetailsView2" runat="server"
DataSourceID="SqlDataSource2" EnableModelValidation="True">
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:ChangebyYourConnectionString2 %>"
SelectCommand="select * from ChangebyYourTable">
</asp:SqlDataSource>
--------------
3. In the project "Solution Explorer" , right click in "Feature1" to add one "Event Receiver" and name it as "Feature1.EventReceiver.cs"
--- In "Feature1.EventReceiver.cs"
#1 Add using
using System.Reflection;
using Microsoft.SharePoint.Administration;

#2 Add following code in "public class Feature1EventReceiver : SPFeatureReceiver"
private ModificationEntry[] entries =

//Ensure there's a connectionStrings section.
new ModificationEntry(
"connectionStrings"
,"configuration"
,"<connectionStrings/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
//Create the connectionstring.
,new ModificationEntry(
"add[@name='ChangebyYourConnectionString'][@connectionString='Data Source=192.168.0.1;Initial Catalog=ChangebyYourDB;User Id=ChangebyYourID;Password=ChangebyYourPWD']"
,"configuration/connectionStrings"
,"<add name='ChangebyYourConnectionString' connectionString='Data Source=192.168.0.1;Initial Catalog=ChangebyYourDB;User Id=ChangebyYourID;Password=ChangebyYourPWD'/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,false)
,new ModificationEntry(
"add[@name='ChangebyYourConnectionString2'][@connectionString='Data Source=192.168.0.100;Initial Catalog=AdventureWorks;User Id=ChangebyYourID;Password=ChangebyYourPWD']"
,"configuration/connectionStrings"
,"<add name='ChangebyYourConnectionString2' connectionString='Data Source=192.168.2.100;Initial Catalog=AdventureWorks;User Id=ChangebyYourID;Password=ChangebyYourPWD'/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,false)
};

public override void FeatureActivated(SPFeatureReceiverProperties properties)

//Get a reference to the web application and then remove entries for the blorum.
SPSite site = properties.Feature.Parent as SPSite;
SPWebApplication webApplication = site.WebApplication;

site.RootWeb.Title = "Set from activating code at " + DateTime.Now.ToString();
site.RootWeb.Update();

foreach (ModificationEntry entry in entries)

webApplication.WebConfigModifications.Add(CreateModification(entry));


webApplication.WebService.WebConfigModifications.Clear();
webApplication.WebService.ApplyWebConfigModifications();




public override void FeatureDeactivating(SPFeatureReceiverProperties properties)

SPSite site = properties.Feature.Parent as SPSite;
SPWebApplication webApplication = site.WebApplication;

site.RootWeb.Title = "Set from deactivating code at " + DateTime.Now.ToString();
site.RootWeb.Update();

foreach (ModificationEntry entry in entries)

if (!entry.CreateOnly)
webApplication.WebConfigModifications.Remove(CreateModification(entry));


webApplication.WebService.ApplyWebConfigModifications();



private SPWebConfigModification CreateModification(ModificationEntry entry)

SPWebConfigModification modification = new SPWebConfigModification(entry.Name, entry.XPath);
modification.Owner = Assembly.GetExecutingAssembly().FullName;
modification.Sequence = 0;
modification.Type = entry.ModificationType;
modification.Value = entry.Value;

return modification;


private struct ModificationEntry

public string Name;
public string XPath;
public string Value;
public SPWebConfigModification.SPWebConfigModificationType ModificationType;
public bool CreateOnly;

public ModificationEntry(string name, string xPath, string value,
SPWebConfigModification.SPWebConfigModificationType modificationType, bool createOnly)

Name = name;
XPath = xPath;
Value = value;
ModificationType = modificationType;
CreateOnly = createOnly;


4. Press F5 in VS2010 to open Sharepoint site , and insert add webpart from "custom" location.

Jun 9, 2010

Open large text file fast and consume little resource tool

Open large text file fast and consume little resource tool.
I try to open a .txt file with 300MB size by notepad/notepad++ , those txt editor use lots of memory and slow my windows system. Finally the pop-up message show me "file too large,cannot open.".
After try to use "LTFViewer" to open the large file, the performance is very good and only a little resource to by occupy.

http://www.swiftgear.com/fltfviewer/fLTFViewr.zip

Apr 7, 2010

Get windows eventlog and specified time record

'This vbscript is for retrieve windows eventlog "Application" , SourceName="YourService.exe" , EventCode=1 log record
' and then execute c:\maint\batch\execproc.bat to do something

Set dtmStartDate = CreateObject("WbemScripting.SWbemDateTime")
'1440 is one day , "Now - 3/1440" is represent for 3 minutes ago
DateToCheck = Now - 3/1440
dtmStartDate.SetVarDate DateToCheck, True
intNumberID=1
Set objWMI = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colLoggedEvents = objWMI.ExecQuery _
("Select * from Win32_NTLogEvent Where Logfile = 'Application' and TimeWritten >='" & dtmStartDate & "'")

For Each objEvent in colLoggedEvents
If objEvent.EventCode = intNumberID Then
if objEvent.SourceName="YourService.exe" then
Set shell = CreateObject("WScript.Shell")
Set exec = shell.run("c:\maint\batch\execproc.bat")
end if
End if

Next

WScript.Quit

Mar 3, 2010

Hide user from exchange address list by msExchHideFromAddressLists

' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = ""
' Filter on user objects.
strFilter = "(&(objectCategory=person)(objectClass=user))"

' Comma delimited list of attribute values to retrieve.
strAttributes = "sAMAccountName,cn,distinguishedName"

' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False

' Run the query.
Set adoRecordset = adoCommand.Execute

' Enumerate the resulting recordset.
Do Until adoRecordset.EOF
' Retrieve values and display.
strName = adoRecordset.Fields("sAMAccountName").Value
strDName = adoRecordset.Fields("distinguishedName").Value
strCN = adoRecordset.Fields("cn").value
'Change "test_admin" to your data
if strName="test_admin" then
'Wscript.Echo "NT Name: " & strName & ", distinguishedName: " & strDName
Set oUser = GetObject("LDAP://"&strDName)
oUser.put "msExchHideFromAddressLists", True
oUser.SetInfo
ExchangeAddressList="Disabled"
end if
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop

' Clean up.
adoRecordset.Close
adoConnection.Close