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;
}
Saving Order from Custom Package
Moderator: Phil Barton
Re: Saving Order from Custom Package
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);
}
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);
}