/*
* This program assumes that the following variables have been declared
* sPerson :The information of employees to be added
* sQuery :Character string containing search expression
* sReturn :Character string containing return expression
* updateData :Character string containing update data
*/
// Create ShunService object
// Host name in the connection destination: DirSvr1
// Port number: 33101
// Shunsaku File name: fileA
ShunService service = new ShunService();
service.Host = "DirSvr1";
service.Port = 33101;
service.ShunsakuFile = "fileA";
service.Connect();
// Turn off auto-commit mode
service.AutoCommit = false;
ShunRecordCollection insertRecords = new ShunRecordCollection();
ShunRecord personRecord = new ShunRecord( sPerson );
insertRecords.Add( personRecord );
// Add data
service.Insert( insertRecords );
//Switch Shunsaku File in the connection destination to fileD
service.ChangeShunsakuFile("fileD");
ShunSearchRequirement req = new ShunSearchRequirement();
req.QueryExpression = sQuery;
req.ReturnExpression = sReturn;
// Search the update data
ShunResultSet rs = service.Search( req );
ShunRecord updateRecord = null;
foreach ( ShunRecord record in rs.Records ) {
updateRecord = record;
}
updateRecord.Data = updateData;
ShunRecordCollection updateRecords = new ShunRecordCollection();
updateRecords.Add( updateRecord );
//Update data
service.Update( updateRecords );
// Commit the updates made so far
service.Commit();
service.Disconnect(); |