Using document properties in VB.NET

We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Using document properties in VB.NET

Post by zaans2 » Thu May 16, 2019 10:14 am

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?

jllort
Moderator
Moderator
Posts: 10876
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Using document properties in VB.NET

Post by jllort » Fri May 17, 2019 6:41 pm

You get a property named path -> /okm:root/folder/file.docx -> what you might convert to file.docx

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Mon May 20, 2019 7:39 am

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.

jllort
Moderator
Moderator
Posts: 10876
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Using document properties in VB.NET

Post by jllort » Thu May 23, 2019 8:03 pm

I'm not a VB specialist but I think you might use SDK ddl.

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Tue Jun 04, 2019 1:34 pm

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)

pherrera
Junior Boarder
Junior Boarder
Posts: 20
Joined: Wed Oct 12, 2016 1:41 pm

Re: Using document properties in VB.NET

Post by pherrera » Fri Jul 05, 2019 2:45 pm

Hi,
Please try the properties (author or title) of type Document, with this test dll:
OKMRest-1.2.3-alpha.zip
(67.94 KiB) Downloaded 23 times
I await your comments, greetings.

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Thu Jul 11, 2019 9:14 am

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.

pherrera
Junior Boarder
Junior Boarder
Posts: 20
Joined: Wed Oct 12, 2016 1:41 pm

Re: Using document properties in VB.NET

Post by pherrera » Fri Jul 12, 2019 2:38 pm

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.

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Fri Jul 12, 2019 2:58 pm

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.

jllort
Moderator
Moderator
Posts: 10876
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Using document properties in VB.NET

Post by jllort » Sun Jul 14, 2019 8:26 am

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.

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Mon Jul 15, 2019 8:17 am

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

pherrera
Junior Boarder
Junior Boarder
Posts: 20
Joined: Wed Oct 12, 2016 1:41 pm

Re: Using document properties in VB.NET

Post by pherrera » Mon Jul 15, 2019 4:23 pm

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)

zaans2
Junior Boarder
Junior Boarder
Posts: 31
Joined: Thu May 02, 2019 1:16 pm

Re: Using document properties in VB.NET

Post by zaans2 » Tue Jul 16, 2019 7:31 am

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.

pherrera
Junior Boarder
Junior Boarder
Posts: 20
Joined: Wed Oct 12, 2016 1:41 pm

Re: Using document properties in VB.NET

Post by pherrera » Fri Jul 19, 2019 6:31 pm

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.

Post Reply