Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi All,

This is my first post here, so please be kind ;)

Many years ago I wrote an application to do some of our back office processing... namely storing PDF files against a specific contact in SuperOffice.

It was initially written for SO v6.3, and then updated to v7.5. Which all worked.

A few weeks back I was upgraded to SO v8 and since then I've had problems.

My code will correctly generate the activity line against a contact, but it will not store the pdf file attachment into the SO Archive. When I try to open the document in SO I get a "cannot be found" response.

The code generates no errors.

I have referenced the v8 SuperOfficeDB.InterOp.DLL.

The SO Archive folder is a network share which has been setup to allow full permissions for everyone.

I've stripped out just the create SODocument code and created a little test project which follows the example in the SuperOffice documentation and that doesn't work (see code sample)

            Dim filename As String = "c:\pdfs\inv\0000194325.pdf"

            Dim cn As Database
            cn = New Database

            cn.Login("username", "password")

            Dim d As SODocument

            d = cn.CreateDocument()

            With d
                .SetDefaults()
                .Contact = cn.GetContact(2)
                .Header = "Added through SuperCOM"
                .Save()
            End With

            With d
                .ReplaceFile(filename, False)
                .Save()
            End With

Can anyone shed any light on this or give me some pointers as to what could be the issue?

Kind Regards

Dave Hayzen

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Dave, 

I'm curious is this is related to the 32/64bit issue... Anything using SuperOfficeDB.interop.dll must run as a 32 bit (x86) process. 

Could this be it?

Best regards!

Af: Tony Yates 1. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Thanks for your reply Tony.  

The application is a 32 bit app and is configured for x86 build.

If I set for x64, I get dll load issues.

Nice thought, but doesn't appear to be the issue.

Regards

Dave

Af: Dave Hayzen 1. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi,
Per-Arne and I have verified this. We can reproduce it. (I used a vb script using the application instance).

Afraid this is the result of the netserver c# docplugin port.
We are looking into fixing it for the upcoming 8.1.
(Not promissing anything here and now, but it is prioritized).

Conrad

Af: Conrad Weyns 1. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

Many thanks for your response.

I am glad you have managed to reproduce the problem :)

However, to hear this is a bug within the DLL is worrying me as this problem is currently crippling our business. So an urgent fix is required.

Because we cannot automatically store our invoices against the contacts in SO we are having to manually print and post all invoices to customers. This is giving us a serious resource issue plus the additional cost of posting invoices (£700+ per month).  We currently have thousands of invoice & delivery notes waiting to be processed by our backoffice system into SO.

This DLL worked in v6.3 & v7.5. I was not expecting it to be broken in v8.

Is there any way I can temporarily use v7.5 of the DLL to do this task against the v8 database?  Or have things changed too much for it to work ?  I only exercise a limited number of methods...

Kind regards

Dave

Af: Dave Hayzen 2. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Dave,
The classic VB docplugin used in Win is no more.
Win now uses the netserver C# docplugin dll instead.
This is a major advantage for our partners that make their own plugins and use both the Win & the Web client.

That said, we sometimes fall flat on our faces!
Testing the COM API is very time consuming.

God willing, there might be a work-around.
Can you look into using:

Database.AddDocument or the recently added Database.AddDocumentForAssocaite methods.

I have tested these from a vb script and I know they work
Example script:

Set app = CreateObject( "SuperOffice.Application" )
If Not app Is Nothing Then
    Set db = app.Database
    Set doc = db.AddDocument( "d:/AddThisDoc1.txt", vbTrue, 13, 41, 0 )
    WScript.Echo doc.filename
Else
    WScript.Echo "Error getting application object"
End If

You can then afterwards use the returned doc instance to change document fields as needed and Save once more.

Regards,
Conrad

 

 

.

 

Af: Conrad Weyns 2. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

 

Once again - thanks for the reply.

I shall have a look at the AddDocument & AddDocumentForAssociate methods.

I'll let you know how I get on :)

regards

Dave

Af: Dave Hayzen 2. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

I am currently having a play with the AddDocument method...

Everytime I call the AddDocument method, it opens the PDF in a new window.

Is there a way to stop this behaviour as this is an automated process.

regards

Dave

 Dim filename As String = "c:\pdfs\inv\0000194325.pdf"

            Dim cn As Database
            cn = New Database

            cn.Login("username", "password")


            Dim d As SODocument
            d = cn.AddDocument(filename, False, 2, 0, 0)

            With d

                'Lookup the template id for "Inc. Document"
                Dim i As IListTextItem = Nothing
                i = cn.GetListItemByName(SOTableId.enTableDocTmpl, "Inc. document")
                .Template = i

                .Header = "Added through SuperCOM"
                .Description = "INVOICE 0000194325"
                .filename = "0000194325.pdf"

                .Save()

            End With
Af: Dave Hayzen 2. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Ah, yes that was an issue with AddDocument. (Been like this for years!)

Try AddDocumentForAssociate where we tried to be a bit smarter.
This is a newer method.

Function AddDocumentForAssociate(ByVal i_FilePath As String, ByVal i_RemoveOriginal As Boolean, ByVal i_OpenCreatedDocument As Boolean, ByVal i_AssociateId As Long, ByVal i_ContactId As Long, ByVal i_PersonId As Long, ByVal i_ProjectId As Long) As IDocument

Add an existing file to the document archive on behalf of some associate, returning a new document object for the file.

Conrad

 

Af: Conrad Weyns 2. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

I do not have AddDocumentForAssociate coming up as a method within the DLL I have.

SDK v8.0.6004.1310

Product Version : 8.0.1000.0

I wonder if you have a newer release...?

Regards

Dave

Af: Dave Hayzen 5. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Dave,
You are right. It is in 8.1, not 8.0
I am afraid this means that the options for a work-around are exhausted.
ReplaceFile is broken, and AddDocument has no way of turning off the default open file behavour.
I believe that the 8.1 Win client release is just around the corner.
Conrad

 



Af: Conrad Weyns 5. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

Ok, understood.

Many thanks for your help.

What I shall do as a temporary solution is write a watcher for the instance of Adobe reader and tell it to close, otherwise when I process the 1000+ invoices that machine will run out of resources.

I look forward to SO 8.1 :)

As a question for the future... You previously mentioned that going forward COM is not the preferred way to do this sort of thing.  I'm assuming I can achieve the same result using NetServer... can you point me in the direction of some documented examples using NetServer please?

Kind regards

Dave Hayzen

Af: Dave Hayzen 5. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

> You previously mentioned that going forward COM is not the preferred way to do this sort of thing.  I'm assuming I can achieve the same result using NetServer... can you point me in the direction of some documented examples using NetServer please?

I think that was with regards to the Quote system.

We need to ask Tony for advise on using netserver for your use case.
I expect you will be able to port your applicaton to C# quite easily.
I actual fact, that may well be your work-around!

My general advice when targetting a running Win app is to use the Application object as much as possible as it will update the GUI and avoid a lengthy login. I.o.w. not fire up SuperOfficeDB.dll.

Conrad

Af: Conrad Weyns 5. jun 2017

RE: Problem creating an SODocument with attachment using SuperOfficeDB.InterOp.DLL

Hi Conrad,

I am now running SuperOffice 8.1 and need to modify our code to use the latest SDK so that I don't keep getting Adobe opening up on every SODocument archive attachment.

Can you advise as to where I can get the latest SDK as I am running v8.0.6004.1310.

 

Kind regards

Dave Hayzen

 

Af: Dave Hayzen 19. mar 2018