First off let me apologize if my question is exceedingly newbish--I've only been working with the SDK for a day now.
My goal is to use some custom logic to take certain SoftPro field values from the currently open order for the current user and compute new values for some other fields and update those fields and save the file. I am able to connect to my server on a button click but when I make my GetOrder call on the SoftPro.OrderTracking.Client.OrderTracking object I get from server.GetService... I have success if I don't have the file open but failure (with "file is locked by user xyz") if I do have it open.
So I'm rather stumped. Do I have to have the user close the file before I can manipulate it? Can I use the shell to do whatever is needed to release the locks, do my operations, and then use the shell to reopen the file? Is there a way to impersonate the current user? Or am I making this way too complicated? The key is I need to so my modifications as part of the normal file validaton/save pipeline in order to keep my target fields accurate for document production, etc.
BTW, it also seems that using the LockManager to ask if the IOrder object is locked returns false and yet my next line of code that calls GetOrder in r/w mode and fails with a lock exception!
Here's some cleaned up code (most of it from the SimplePackage sample and sample code from the docs):
Code: Select all
private void MyButtonHandler(object sender, EventArgs e)
{
// build credentials for a user with full-privileges and connect to the server
NetworkCredential credential = new NetworkCredential(@"<username here>", @"<password here>", SoftPro.ClientModel.Constants.ServerDomain);
SelectServer server = new SelectServer(null, new Uri(@"http://localhost:8080"), credential);
// Create the order tracking client
SoftPro.OrderTracking.Client.OrderTracking ot = server.GetService<SoftPro.OrderTracking.Client.OrderTracking>();
// Create the specification for the existing order.
OrderQuerySpec spec = new OrderQuerySpec()
{
BaseOrderNumber = @"2011080001-test",
Prefix = @"",
Suffix = @""
};
// this line generates "Order 2011080001-test is locked for editing by user xyz"
// if read-only parameter is set to true then it succeds but I obviously cannot directly modify the order object
IOrder order = ot.GetOrder(spec, false);
ot.CloseOrder(order);
return;
}
Thanks,
Joe