Page 1 of 1

Order creation via the API

Posted: Fri Oct 03, 2008 11:45 am
by cbigden
Can someone explain why we can create a new order via the API with no exceptions thrown or messges being returned from the SaveOrder method and we can see the order in the UI's Search Results window yet the UI will not display the order. Rather a message box is displayed. Please see attached screen shot.

Re: Order creation via the API

Posted: Fri Oct 03, 2008 11:51 am
by cbigden
Additional information: Order was created by extrracting the data from an existing order and then attempting to create a new order from that same data.

We subsequently tried to open the Order via the API and received the following exception:
"Error executing business rule 'SoftPro.BusinessRules.Core.DefaultHudLine'\nInputs:\n\t1. \n\t2. \n\t3. \n\t4. \n\t5. \n"

StackTrace follows:

at SoftPro.BusinessRules.Base.BusinessRuleBase.Execute(Object[] inputs, ExecutionInfo ruleInfo)
at SoftPro.BusinessObjects.Base.Engine.GetRuleDataValue(IBusinessObject businessObject, String ruleInstanceName, Object potentialNewValue)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.FulfillDataItemNormally(Dependency depItem, DataValue sourceItem)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataValue(String dataItemName)
at SoftPro.BusinessObjects.Base.HUDLineEngine.GetHudItemsFor(IHudLine line, List`1& dependencies)
at SoftPro.BusinessObjects.Base.Engine.GetRuleDataValue(IBusinessObject businessObject, String ruleInstanceName, Object potentialNewValue)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.FulfillDataItemNormally(Dependency depItem, DataValue sourceItem)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataValue(String dataItemName)
at SoftPro.BusinessObjects.Base.BusinessObjectBase.GetDataItem(String dataItemName)
at SoftPro.BusinessObjects.Base.Engine.ReleaseCalculatedChildRequests()
at SoftPro.BusinessObjects.Core.Order.Load(Guid primaryID, ContextRoot rootContext)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetBusinessObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean allowDisambiguation, SqlDataReader openReader, Boolean allowLoad, Boolean loadingAsCopy, Boolean acquiringRoot, Guid idForNewObject)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.GetRootObject(String contextName, Guid primaryKey, ContextRoot rootContext, Boolean loadingAsCopy)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.AcquireRootReference(String contextName, Guid primaryKey, Boolean loadAsCopy)
at SoftPro.BusinessObjects.Base.BusinessObjectCache.AcquireRootReference(String contextName, Guid primaryKey)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrderObject(Guid id)
at SoftPro.OrderTracking.Client.OrderTracking.OpenOrder(Guid id, Boolean readOnly)
at SoftPro.OrderTracking.Client.OrderTracking.GetOrder(OrderQuerySpec spec, Boolean readOnly)
at ConsoleApplication.Program.Main(String[] args) in D:\\IOrderSurrogateTest\\ConsoleApplication\\Program.cs:line 65"

Re: Order creation via the API

Posted: Fri Oct 03, 2008 11:56 am
by cbigden
It appears there must be some sort of dependency on the HUDLine data. We are currently not serializing any HUD data and therefore we are also not writing any HUD data to the newly created order prior to saving. What are the implications of doing this?

Re: Order creation via the API

Posted: Fri Oct 03, 2008 12:54 pm
by Phil Barton
If you have the latest service pack, then the answer is as simple as doing an overlay. Overlay does a complete copy of any user-entered data from a source order or template into the destination order. Here is some example code of how to use the overlay functionality:

Code: Select all

SelectServer server = new SelectServer(null, new Uri(@"<URI To Select Server>"), new NetworkCredential(@"<user name>", @"<plain-text password>", SoftPro.Select.Client.Constants.SelectDomain));
SoftPro.OrderTracking.Client.OrderTracking ot = server.GetService<SoftPro.OrderTracking.Client.OrderTracking>();
OrderCreationSpec spec = new OrderCreationSpec();	// Use the order numbering manager for the currently logged in user.

spec.Templates.Add(@"<Template Name or Order Number");  // Add the template or order to overlay

using ( IOrder order = ot.CreateOrder() )  // Order is created and the data from the template(s)/order(s) is/are copied to the new order
{
	try
	{
                // Do work on the order

		ValidationMessage[] messages;

		if ( !ot.SaveOrder(order, out messages) )
		{
			// Handle save failure
		}
		else
		{
			// Handle save success
		}
	}
	finally
	{
		ot.CloseOrder(order); // Must be done to ensure proper clean up
	}
}

Re: Order creation via the API

Posted: Fri Oct 03, 2008 1:33 pm
by cbigden
Phil, our intent is not to copy an order inside of Select but rather create a new order in select from data that is recieved from some external source. We were only using select as a source of the data because we can easily serialize that data and then attempt to create a new order from that data. So our question is what dependencies are there among the various classes that would create such a situation. Is there some minimal amount of data and or some related data that must be populated in a newly created order to be able to save that order and then be able to successfully view it.

Re: Order creation via the API

Posted: Fri Oct 03, 2008 3:54 pm
by Phil Barton
Let me look into this further based off of the stack trace above and I will post an answer to this forum.

Re: Order creation via the API

Posted: Thu Jun 18, 2009 3:53 am
by jcreyes
I'm encountering a "Failed to load the SoftPro business rules for order" exception upon executing the following code lifted from the SDK.

Image

Any help to resolve this issue will be greatly appreciated. Thanks!

Re: Order creation via the API

Posted: Thu Jun 18, 2009 9:05 am
by John Morris
Are you copying our dlls out of the install folder?

Try copying your test program exe into the SoftPro Select client installation folder (C:\Program Files\SoftPro\Select).

Re: Order creation via the API

Posted: Thu Jun 18, 2009 8:24 pm
by jcreyes
Yes, I'm copying the dlls from the install folder.

Running the program exe in the Select folder did the trick!

Thanks John!