Page 1 of 1

Using document properties in VB.NET

PostPosted:Thu May 16, 2019 10:14 am
by zaans2
I am working on a desktop client for in-house use. I am writingit inVisual Basic.NET using the .NET SDK 1.2.2.

I have the following code (where `ws` is an `OKMWebservice` instance)
Code: Select all
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim search = TextBox1.Text
        Try
            For Each result In ws.findByContent(search)
                Dim doc = ws.getDocumentProperties(result.node.path)
                ListView1.Items.Add(doc.title)
            Next
        Catch exc As System.Exception
            Console.WriteLine(exc)
        End Try
    End Sub
I want to show the title of the documents that are the results of a search. However because of how the fields in the class `Document` are named I get the following error message:
Code: Select all
'title' is ambiguous because multiple kinds of members with this name exist in class 'Document'.
This would be easily solved if I used C# instead of VB.NET, but I have to use VB.NET as everything we do is written in VB.NET.
This could be easily solved if I used C# instead of VB.NET or directly used the REST services. However I would like to keep using the SDK and I have to use VB.NET as everything we do is written in VB.NET.

Is there a way I can still access the title/properties while still using the VB.NET and the SDK?

Re: Using document properties in VB.NET

PostPosted:Fri May 17, 2019 6:41 pm
by jllort
You get a property named path -> /okm:root/folder/file.docx -> what you might convert to file.docx

Re: Using document properties in VB.NET

PostPosted:Mon May 20, 2019 7:39 am
by zaans2
Yeah I can work with that. It is still annoying that an SDK made for .NET doesn't work properly for VB.NET. Especially because it can easily be fixed.

Re: Using document properties in VB.NET

PostPosted:Thu May 23, 2019 8:03 pm
by jllort
I'm not a VB specialist but I think you might use SDK ddl.

Re: Using document properties in VB.NET

PostPosted:Tue Jun 04, 2019 1:34 pm
by zaans2
I am no VB expert either, just started working with it. I am indeed using the SDK dll, which is marketed as a .NET SDK (and VB.NET is part of the .NET framework)

The issue is that VB.NET is case insensitive, where C# is case sensitive. So in C# the fields "TITLE" and "title" are different fields. In VB.NET both of these cannot be used as VB.NET sees them as the same and doesn't know which one to use.

This can be easily solved by naming the constant "TITLE" something like "_TITLE". This way it would also work in VB.NET as it sees it as different than "TITLE" and "title". So far this issue is the only one I found in compatibility with VB.NET (which again is also part of the .NET framework) and it is not limited to just this property (Node author is another one)

Re: Using document properties in VB.NET

PostPosted:Fri Jul 05, 2019 2:45 pm
by pherrera
Hi,
Please try the properties (author or title) of type Document, with this test dll:
(67.94 KiB) Downloaded 184 times
I await your comments, greetings.

Re: Using document properties in VB.NET

PostPosted:Thu Jul 11, 2019 9:14 am
by zaans2
It now works fine for author, but not for title. I no longer get the error message but title is just an empty string for every document.

Re: Using document properties in VB.NET

PostPosted:Fri Jul 12, 2019 2:38 pm
by pherrera
By default when you upload a document to the repository it does not have a title, so it returns an empty string, you must add it from the OpenKM UI or using the setProperties method from sdk.net, for example:
https://docs.openkm.com/kcenter/view/sd ... Properties

After this if it works with the title, we will work on this to launch a new version of the sdk.

Thanks for the observation, greetings.

Re: Using document properties in VB.NET

PostPosted:Fri Jul 12, 2019 2:58 pm
by zaans2
Okay understood. So if i understand correctly there is currently now way to get just the name of the document directly from the object?

The change does work for the 'author' field. I couldn't access that before and I now can.

Re: Using document properties in VB.NET

PostPosted:Sun Jul 14, 2019 8:26 am
by jllort
What is trying to explain is when you upload a document you set the name attribute but not the title. You must call an additional method after uploading the document for setting the attribute. That's the reason why after uploading the document you get an empty title because uploading document and setting title are split methods ( the title is not set in the document creation process, but might be done later ).

If we understood, with the change in the SDK, now you are getting the name. Confirm this point and we will rebuild a new SDK version.

Re: Using document properties in VB.NET

PostPosted:Mon Jul 15, 2019 8:17 am
by zaans2
That I have to set the title manually after I understood.

About getting the name. With the alpha version of the SDK provided there is no property called 'name'. Only a static field called 'NAME' with the value "okm:name" so currently I can't get a name via the SDK

Re: Using document properties in VB.NET

PostPosted:Mon Jul 15, 2019 4:23 pm
by pherrera
At the moment you can get the name of the document by extracting it from document.path

For example:

Imports System.IO
Code: Select all
	    Dim doc = New Document()
            doc = ws.getDocumentProperties("942516de-3fd9-4506-b7e4-9d01796dee57")
            Dim name = Path.GetFileName(doc.path)

Re: Using document properties in VB.NET

PostPosted:Tue Jul 16, 2019 7:31 am
by zaans2
Yeah that is how I currently get the name. I just would have expected it to also be a property of the class `Document` since it is part of the document in the user interface of the web application.

Re: Using document properties in VB.NET

PostPosted:Fri Jul 19, 2019 6:31 pm
by pherrera
The name is not a property of the document object, but the only property that exists in the core is the path.
The document object of the sdk is the same as the one of the core for us a variable name does not make sense if the name already forms part of the path it is duplicating data and from the side of the core we would have to calculate it equally.