using System;
using Fujitsu.Shunsaku;
class SampleInsert {
static public void Main( string[] args ) {
ShunService service = null;
try {
// ShunService の作成
service = new ShunService();
// ホスト名 ポート番号を指定して Shunsaku に接続
service.Host = "DirSvr1";
service.Port = 33101;
service.Connect();
// 追加用 ShunRecordCollection を作成
ShunRecordCollection insertRecords = new ShunRecordCollection();
// 追加用 ShunRecord を作成
ShunRecord record = new ShunRecord();
// データを指定
record.Data = String.Concat(
"<document>",
" <base>",
" <name>ホテル9</name>",
" <prefecture>新横浜</prefecture>",
" <address>神奈川県横浜市神奈川区</address>",
" <detail>http://xxxxx.co.jp</detail>",
" <price>6000</price>",
" </base>",
" <information>",
" <date>2006年07月18日</date>",
" </information>",
"<note>バス付 トイレ付 禁煙ルーム選択可 地下鉄 **駅徒歩05分</note>",
"</document>" );
// コレクションに追加
insertRecords.Add( record );
// データを追加
service.Insert( insertRecords );
Console.WriteLine( "追加終了" );
// Shunsaku から切断
service.Disconnect();
}
catch ( ShunContinuousException e ) {
// ShunContinuousExceptionが発生した場合の処理を記述
try {
if( service != null && service.State == ShunConnectionState.Open ) {
service.Disconnect();
}
}
catch ( ShunException ex ) {
Console.WriteLine("エラーメッセージ : {0}", ex.Message );
}
Console.WriteLine("エラーメッセージ : {0}", e.Message );
}
catch ( ShunConnectionTerminatedException e ) {
// ShunConnectionTerminatedExceptionが発生した場合の処理を記述
Console.WriteLine("エラーメッセージ : {0}", e.Message );
}
}
} |