Hi!
Does anyone have a working example of an IManExt2.DbSelectionCmd?
I tried following the Extension Library Reference Manual, using something like the code pasted below, but after the call to the Update() method, I always get a status of "nrGrayedCommand". Maybe someone can give me a hint?
Thanks for your time.
Regards,
Wolfgang
// C#
IManDMS dms = new ManDMSClass();
IManSession sess = dms.Sessions.Add("SERVERNAME");
try {
sess.TrustedLogin();
ContextItems context = new ContextItemsClass();
context.Add("IManExt.DoOK", true);
context.Add("IManExt2.DbSelectionCmd.MultipleSelection", false);
// Construct a list of NRTSession objects
List<NRTSession> dmsSessionList = new List<NRTSession>();
foreach (NRTSession session in dms.Sessions) {
dmsSessionList.Add(session);
}
NRTSession[] dmsSessionArray = dmsSessionList.ToArray();
context.Add("SelectedNRTSessions", dmsSessionArray);
// Only set the IManSession into the context items
// -- does not seem to work, either
//context.Add("SelectedIManSession", sess);
DbSelectionCmd dbSelCmd = new DbSelectionCmdClass();
dbSelCmd.Initialize(context);
dbSelCmd.Update();
Console.WriteLine("STATUS={0}", ((CommandStatus) dbSelCmd.Status));
if (dbSelCmd.Status == (int) CommandStatus.nrActiveCommand) {
dbSelCmd.Execute();
bool success = (bool) context.Item("IManExt.Refresh");
Console.WriteLine("SUCCESS={0}", success);
string[] databaseNames = (string[]) context.Item("SelectedDatabases");
Console.WriteLine("#DB={0}", databaseNames.Length);
for (int i = 0; i < databaseNames.Length; ++i) {
Console.WriteLine(" DB#{0}={1}", i, databaseNames);
}
}
} catch (Exception ex) {
Console.WriteLine("ERROR MSG={0}", ex.Message);
} finally {
sess.Logout();
dms.Close();
}