GetService<IWindowManager>() returns null
Posted: Mon Jun 20, 2016 2:13 pm
I am trying to get the active order, but my windowsmanager is null. Am I missing something?
private IOrder GetActiveOrder()
{
// Open connection to server.
NetworkCredential creds = new NetworkCredential("<Username>", "<password>", "[SERVER]");
SelectServer sps = new SelectServer("http://SP-APP-TEST:8080", creds);
string reason;
if (!sps.TryAuthenticate(out reason))
{
Console.WriteLine(reason);
return null;
}
//Authentication passes
SoftPro.Select.Shell.IWindowManager windowManager = sps.GetService<IWindowManager>();
if (windowManager == null) return null; //but, windowManager is null
SoftPro.Select.Shell.IWindowFrame activeDocument = windowManager.ActiveDocument;
if (activeDocument == null) return null;
SoftPro.Select.Shell.IRunningDocumentsManager runningDocumentsManager =
sps.GetService<IRunningDocumentsManager>();
if (runningDocumentsManager == null) return null;
SoftPro.Select.Shell.IRunningDocumentInformation runningDocumentInformation =
runningDocumentsManager.FindDocument(activeDocument.DocumentHandle);
if (runningDocumentInformation == null) return null;
SoftPro.Select.Shell.EditorPane p = runningDocumentInformation.Data as EditorPane;
if (p == null) return null;
return p.GetProperty("Order") as SoftPro.OrderTracking.Client.Orders.IOrder;
}
private IOrder GetActiveOrder()
{
// Open connection to server.
NetworkCredential creds = new NetworkCredential("<Username>", "<password>", "[SERVER]");
SelectServer sps = new SelectServer("http://SP-APP-TEST:8080", creds);
string reason;
if (!sps.TryAuthenticate(out reason))
{
Console.WriteLine(reason);
return null;
}
//Authentication passes
SoftPro.Select.Shell.IWindowManager windowManager = sps.GetService<IWindowManager>();
if (windowManager == null) return null; //but, windowManager is null
SoftPro.Select.Shell.IWindowFrame activeDocument = windowManager.ActiveDocument;
if (activeDocument == null) return null;
SoftPro.Select.Shell.IRunningDocumentsManager runningDocumentsManager =
sps.GetService<IRunningDocumentsManager>();
if (runningDocumentsManager == null) return null;
SoftPro.Select.Shell.IRunningDocumentInformation runningDocumentInformation =
runningDocumentsManager.FindDocument(activeDocument.DocumentHandle);
if (runningDocumentInformation == null) return null;
SoftPro.Select.Shell.EditorPane p = runningDocumentInformation.Data as EditorPane;
if (p == null) return null;
return p.GetProperty("Order") as SoftPro.OrderTracking.Client.Orders.IOrder;
}