Modifying the order the current user has open

Discussions related to custom development with Select.
Post Reply
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Modifying the order the current user has open

Post by joe.mag »

All,

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;
}
Any help would be greatly appreciated!

Thanks,

Joe
Mark McKenna

Re: Modifying the order the current user has open

Post by Mark McKenna »

Welcome!

From within the shell, you will want to access the open order directly using various window management services provided by the SDK. This generally involves getting the handle to the active window frame and then using that to uncover the related IOrder reference for the open order, with which you can interact directly. There is an example of this in the Select SDK help under the topic Integrate ProForm with External Systems.

Let us know if you need further assistance.
joe.mag
Posts: 122
Joined: Thu Aug 04, 2011 3:11 pm

Re: Modifying the order the current user has open

Post by joe.mag »

Mark,

See, the newbish question fear was fully realized! You are the man--that's exactly what I needed to set me in the right direction! Thanks a million!

Joe
Post Reply