Current Open Orders(s) from a package

Discussions related to custom development with Select.
Post Reply
dflood2
Posts: 12
Joined: Thu Mar 11, 2010 12:11 pm

Current Open Orders(s) from a package

Post by dflood2 »

Hi we have a package that runs an app inside of softPro. We link this app with softPro by the softPro order.number. Is is possible to find the current open order(s) in softPro that a user has open when they open/actavate our package?

Let me know

Thanks

David Flood
Hadi Chemaly

Re: Current Open Orders(s) from a package

Post by Hadi Chemaly »

The following is a method extracted from the ZipCodePackage sample shipped with the Select SDK:

Code: Select all

/// <summary>
/// If an order is open and active in Select, return it. Otherwise return null.
/// </summary>
private IOrder GetActiveOrder()
{
    IWindowManager windowManager = GetService<IWindowManager>();
    IWindowFrame activeDocument = windowManager.ActiveDocument;
    if (activeDocument == null)
        return null;

    IRunningDocumentsManager runningDocumentsManager = GetService<IRunningDocumentsManager>();
    IRunningDocumentInformation runningDocumentInformation = runningDocumentsManager.FindDocument(activeDocument.DocumentHandle);
    if (runningDocumentInformation == null)
        return null;

    EditorPane p = runningDocumentInformation.Data as EditorPane;
    if (p == null)
        return null;

    return p.GetProperty("Order") as IOrder;
}
I believe it achieves what you're asking for.
Hadi Chemaly

Re: Current Open Orders(s) from a package

Post by Hadi Chemaly »

**Correction to my previous post:

You actually don't need to get the IRunningDocumentManager involved to get the IOrder. It can simply be achieved like this:

Code: Select all

/// <summary>
/// If an order is open and active in Select, return it. Otherwise return null.
/// </summary>
private IOrder GetActiveOrder()
{
    IWindowManager windowManager = GetService<IWindowManager>();
    IWindowFrame activeDocument = windowManager.ActiveDocument;
    if (activeDocument != null)
    {
        object order = activeDocument.GetProperty("Order");
        if (order != null)
            return order as IOrder;
    }
    return null;
}
In fact this is the recommended way to get your active order.
Post Reply