#using <mscorlib.dll>
#using <system.dll>
#using <Fujitsu.Shunsaku.dll>
using namespace System;
using namespace Fujitsu::Shunsaku;
class SampleInsert {
public:
static void Main( String *args __gc[] ) {
ShunService *service = 0;
try {
// Create ShunService
service = new ShunService();
// Connect Shunsaku by specifying the host name and port number
service->Host = "DirSvr1";
service->Port = 33101;
service->Connect();
// Create ShunRecordCollection for adding data
ShunRecordCollection *insertRecords = new ShunRecordCollection();
// Create ShunRecord for adding data
ShunRecord *record = new ShunRecord();
// Specify data
record->Data = String::Concat(
S"<document>",
S" <base>",
S" <name>Hotel 9</name>",
S" <city>Adelaide</city>",
S" <address>Belair, Adelaide</address>",
S" <detail>http://xxxxx.com.au</detail>",
S" <price>150</price>",
S" </base>",
S" <information>",
S" <date>2006/07/18</date>",
S" </information>",
S"<note>No-smoking room with en-suite bathroom and toilet available, 5 minutes' walk to subway station XX</note>",
S"</document>" );
// Add to the collection
insertRecords->Add( record );
// Add data
service->Insert( insertRecords );
Console::WriteLine( "Addition complete" );
// Close the connection to Shunsaku
service->Disconnect();
}
catch ( ShunContinuousException *e ) {
// Processing to perform if ShunContinuousException occurs
try {
if( service != 0 && service->State == ShunConnectionState::Open ) {
service->Disconnect();
}
}
catch ( ShunException *ex ) {
Console::WriteLine( "Error message : {0}", ex->Message );
}
Console::WriteLine( "Error message : {0}", e->Message );
}
catch ( ShunConnectionTerminatedException *e ) {
// Processing to perform if ShunConnectionTerminatedException occurs
Console::WriteLine( "Error message : {0}", e->Message );
}
}
};
int main() {
return SampleInsert::Main( Environment::GetCommandLineArgs() );
} |