Maybe I'm missing something painfully obvious, but can't figure out how to open a document in its native application using the Worksite 8.0 libraries and C#. I successfully have an IManDocuments collection returned from a search, but the CheckOut doesn't work from there. Below is the code snippet that returns my document and attempts the checkout.
public string SearchForFile(string Library, string DocNum, Int32 hWnd)
{
// Searches for a file and returns:
// 0: Document Not Found
// 1: 1 Document found. Opens document.
// Credentials and server name replaced for demo purpose
UserDMS udms = new UserDMS("username","pwd","serverinstance");
if (udms.IsLoggedIn == true)
{
//Form1.lblStatus.Text = "Log in successfull";
objSession = udms.Session;
}
else
{
MessageBox.Show("Login failed!");
return null;
}
IManWorkArea oWorkArea = objSession.WorkArea;
ManStrings colDBs = new ManStringsClass();
foreach(IManDatabase oDB in oWorkArea.Session.Databases)
{
colDBs.Add(oDB.Name);
}
IManProfileSearchParameters searchparams = oWorkArea.Session.DMS.CreateProfileSearchParameters();
searchparams.Add(imProfileAttributeID.imProfileCustom5, Library);
searchparams.Add(imProfileAttributeID.imProfileCustom17, DocNum);
IManDocuments oRetDox = (IManDocuments)oWorkArea.SearchDocuments(colDBs, searchparams, true);
// We get one document back from our search.
//string strResult = oRetDox.Count.ToString();
switch (strResult)
{
case "0":
strResult = "Document was unable to be located.";
break;
case "1":
strResult = "Document found!";
IManDocument objDoc = (IManDocument) oRetDox.ItemByIndex(1);
// I thought this section was supposed to do what I'm asking, but
// the document never gets checked out (at least according to the
// history log for the document.
OpenCmd cmd = new OpenCmd();
ContextItems context = new ContextItems();
context.Add ("ParentWindow", hWnd);
context.Add("SelectedNRTDocuments",objDoc);
cmd.Initialize(context);
cmd.Execute();
break;
default:
strResult = "An error occurred.";
break;
}
if (udms.IsLoggedIn == true)
{
udms.Logout();
}
// return results message.
return strResult;
}
Any insight would be much appreciated!
Thanks,
Steve
Edited by dsaxman on 05/09/05 12:38 PM (server time).