1

一次获取 ARServerUser 上下文并在循环中多次调用 setEntry 方法是否很好,或者有没有更好的方法来做到这一点?

4

1 回答 1

1

The API provides this. Look in the ARServerUser javadoc:

It is used like this:

//connect to AR server
ARServerUser server = new ARServerUser();
server.setServer("localhost");
server.setUser("Demo");
server.setPassword("");
// begin bulk transaction
server.beginBulkEntryTransaction();
//create and submit Entry Objects

for(int x = 0; x < 10; x++){
  try {
        Entry entry = new Entry();
        entry.put(Constants.AR_CORE_SUBMITTER, new Value(submitter));
        entry.put(Constants.AR_CORE_STATUS,new Value(status, DataType.ENUM));
        entry.put(Constants.AR_CORE_SHORT_DESCRIPTION, new Value(shortDesc));
        entryIdOut = server.createEntry(formName, entry);
    } catch (ARException e) {
        ARExceptionHandler(e, "Cannot create the entry." );
    }
}
//Commit Bulk transaction: all entries are saved to Remedy
 List<BulkEntryReturn>  bulkIds = server.endBulkEntryTransaction(Constants.AR_BULK_ENTRY_ACTION_SEND);
 //bulkIds now contains all the entry Ids for your committed entries

Note that the code above has some uninitialized variables, so will not run as is (and may throw an ARBulkException)

于 2020-02-15T20:20:51.863 回答