Saving Order from Custom Package

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
tlyde_LCTMHS
Posts: 8
Joined: Thu Jul 18, 2013 12:21 pm

Saving Order from Custom Package

Post by tlyde_LCTMHS »

I have a custom package and I access the data from an open active order. I also write data to the order. My question is how can I save the order programmatically once I have written data to it.
There is no Save method for the order.

The code below shows how I get the active order:

private IOrder get_SelectActiveOrderReference()
{
IWindowManager windowManager = GetService<IWindowManager>(); // this GetService inherits from Package class
IWindowFrame activeDocument = windowManager.ActiveDocument;
if (activeDocument == null)
{
return null;
}

SoftPro.Select.Shell.IRunningDocumentsManager runningDocumentsManager =
GetService<IRunningDocumentsManager>();
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.IOrder;

}
neetab
Posts: 22
Joined: Wed Apr 17, 2013 3:20 pm

Re: Saving Order from Custom Package

Post by neetab »

Example below creates an order and saves it.

SoftPro.OrderTracking.Client.OrderTracking ot = server.GetService<SoftPro.OrderTracking.Client.OrderTracking>();

using (IOrder order = ot.CreateOrder())
{
try
{
// TODO: Manipulate the order

ValidationMessage[] messages;

// Save the order. A failure to save will return false. Error messages will be returned in
// the messages out parameter.
if (!ot.SaveOrder(order, out messages))
{
// Handle order save failure
}
else
{
// Handle order save success
}
}
finally
{
// This MUST be called to release any locks on the order.
ot.CloseOrder(order);
}
Post Reply