Transaction Abort Error - Adding Attachments to Create Order

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

Post Reply
enendza
Posts: 75
Joined: Wed Oct 16, 2019 12:22 pm

Transaction Abort Error - Adding Attachments to Create Order

Post by enendza »

Using SDK 4.3.60210.108 (4.3.38) for our SoftPro Integration, we are trying to create a SoftPro Order along with some attachments.
Order creation works fine for everything other than getting the attachment added to the required folder.

We have tried two ways for it and are getting the same error of the transaction being aborted.

Code Snippet 01

Code: Select all

	            IAttachmentFolder folderItem = iOrder.Attachments.NewFolder();
                    folderItem.Name = "Commitments";

                    IAttachmentFile fileNew =
                            folderItem.NewFile("sample", @"C:\fullpath\sample.txt", "", AttachmentSource.Attached);
                   

Code Snippet 02

Code: Select all

	            IAttachmentFolder folderItem = iOrder.Attachments.NewFolder();
                    folderItem.Name = "Commitments";

                    using (FileStream stream = File.Open("C:\\fullpath\\sample.txt", FileMode.Open))
                    {
                        IAttachmentFile newFile =
                            folderItem.NewFile("sample", stream, ".txt", "", AttachmentSource.Attached);
                    }
                   
We have validated that the active profile selected is the default one and is able to add documents using the SoftPro Desktop App.
Any idea on attaching documents would help.

Thanks !!!

The error we are getting is - "The transaction has aborted."
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Transaction Abort Error - Adding Attachments to Create Order

Post by BobRichards »

Unfortunately I can't replicate your error. This is what I did to create an order and attach a file from the file system. These lines are from a console application - and are almost identical to what you did.

Code: Select all

IOrderStore os = ss.GetService<IOrderStore>();
IOrder order = os.NewOrder();

IAttachmentFolder folderItem = order.Attachments.NewFolder();
folderItem.Name = "Commitments";

IAttachmentFile fileNew =
    folderItem.NewFile("sample", @"C:\temp\t.txt", "description", AttachmentSource.Attached);

os.ApplyChanges(order);
os.CloseOrder(order);
Can you provide more information? I assume you used the same user when you tested from the Select application to validate it had Attachment Folder create permission?
Bob Richards, Senior Software Developer, SoftPro
enendza
Posts: 75
Joined: Wed Oct 16, 2019 12:22 pm

Re: Transaction Abort Error - Adding Attachments to Create Order

Post by enendza »

The exact code looks like this for the Order creation.

FileController.cs

Code: Select all

	using (var server = new SelectServer(serverUri, auth))
                {
                    string reason;
                    if (!server.TryAuthenticate(out reason))
                    {
                        System.Console.WriteLine(reason);
                    }

                    var spec = new OrderCreationSpec();
                    spec.Templates.Clear();
                    spec.Templates.Add("Order/Template");
                    server.ChooseProfile += new EventHandler<ChooseProfileEventArgs>(chooseProfile);
                    // Get profile
                    IProfileManager profileMgr = server.GetService<IProfileManager>();
                    server.ChooseProfile += new EventHandler<ChooseProfileEventArgs>(ss_ChooseProfile);
                    IProfileInfo profile = profileMgr.Profiles.Where(t => t.Path == "Default").FirstOrDefault();
                    if (profile != null)
                    {
                        //Activate Profile
                        profileMgr.ActiveProfile = profileMgr.GetProfile(profile.ID);
                    }
                    var orderStore = server.GetService<IOrderStore>();
                    dynamic order = null;
                    order = new OrderService(server).CreateOrder(payload);                   
                    return Ok((IOrderInfo)order);
                }

OrderService.cs

Code: Select all

public IOrderInfo CreateOrder(Order payload)
        {
            Environment.SetEnvironmentVariable("SPS_DISABLECERTPIN", "1");
            decimal amount;
            var os = ss.GetService<IOrderStore>();
            OrderCreationSpec spec = CreateSpec(payload);
            IOrder iOrder = os.NewOrder(spec);

            IAttachmentFolder folderItem = iOrder.Attachments.NewFolder();
            folderItem.Name = "Commitments";


            IAttachmentFile fileNew =
                folderItem.NewFile("Test", @"C:\TestDocument.txt", "description", AttachmentSource.Attached);
            try
            {
                os.ApplyChanges(iOrder);
            } catch (Exception ex)
            {
                Console.WriteLine("Unable to process file.", "FAIL", ex);
            }
            
        }
Every time the Changes are being applied to the iOrder, the exception is thrown :

Exception Details -

Code: Select all

 
 {"The transaction has aborted."}
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233087
    HelpLink: null
    InnerException: null
    Message: "The transaction has aborted."
    Source: "SoftPro.ClientModel"
    StackTrace: "   at SoftPro.ClientModel.AsyncResult`1.get_Result()\r\n   at SoftPro.OrderTracking.Client.Orders.OrderStore.SoftPro.OrderTracking.Client.Orders.IOrderStore.EndApplyChanges(IAsyncResult ar)\r\n   at SoftPro.OrderTracking.Client.Orders.OrderStore.SoftPro.OrderTracking.Client.Orders.IOrderStore.ApplyChanges(IOrder order)\r\n   at Tryon.SoftPro.API.Services.OrderService.CreateOrder(Order payload) in C:\\Workspace\\TryonTitle\\Tryon.SoftPro.API\\Tryon.SoftPro.API\\Services\\OrderService.cs:line 53"
    TargetSite: {T get_Result()}
 

Additional Information : Some part of the code was removed where other Order Properties are being set for creating the order. We have been creating orders using the API in this manner for sometime now and everything works fine apart from the attachments.
Please suggest if there's anything else that we should try. Also, is there a document for Order Creation API or using the SDK in general that we can find.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Transaction Abort Error - Adding Attachments to Create Order

Post by BobRichards »

I'm afraid without actually testing your source code, I cannot help. To be clear, are you saying that if you omit the four file attachment code lines then everything works perfectly? If so, I just keep wondering if it is file system permission issue with the executable user. If it is a Windows service that is creating the orders, then validate the service user has sufficient privilege.

The only information available on our API is contained in the Select SDK help file and the DevForum website.

If you can't get your code to work, then contact the Select Customer Service and escalate your issue.

Sorry. :(
enendza
Posts: 75
Joined: Wed Oct 16, 2019 12:22 pm

Re: Transaction Abort Error - Adding Attachments to Create Order

Post by enendza »

Yes exactly. Removing the 4 file attachment code lines works just fine. We have been creating orders with a lot of other details. And it fails only during the file attachment.

There is no SDK Help file that we could find where the SDK was installed
Also, for checking if the service user has sufficient privilege, do we have to contact the Sales Team or the Developers Team ?

Thank you for your help !!
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Transaction Abort Error - Adding Attachments to Create Order

Post by BobRichards »

When you installed the SDK originally, it should have written the file "SelectSdk.chm" to "C:\Program Files (x86)\SoftPro\Select SDK". The help file should be available from the start menu also at "SoftPro Select SDK".

You had to install it on your development machine but not on production machines.

If you have access to Select developers I guess I would try them first. Otherwise call 800.848.0143 and start with Customer Service.
Bob Richards, Senior Software Developer, SoftPro
Post Reply