.Net and Navision 5.0 - Friendship Forever

    The plot.

    And so, hello.
    While working in the office, which deals with the introduction of such a thing as Ms Dynamics Nav, I had to face one problem, the solution of which was by the means of Navik himself (I allow myself such a familiar appeal), was impossible.
    The essence of the problem is this:
    introducing the system into a translation company, there was a tough problem with the names of the files, since the requirements stated that the name that the source file was named should fully correspond to the name that the already translated file will receive. With all this, the customer required writing files to the MS SQL database. Since Navik is so far from Unicode, all the built-in file functions distorted the name, removing umlauts, axants and other elements of the European alphabet.
    To solve this problem, the task was to write a dll that will write files with the correct names to the database. And then, on demand, return these files from the database to the file system. With all this, there was a problem with downloading large files, therefore, again, a strong-willed decision was made to use such a thing as FILESTREAM in MS SQL.


    Chapter i

    I sincerely hope that the essence of the problem has become clear. Now let's proceed to the resolution.
    Since your humble servant best handles C #, I decided to write it on it. I’ve never done anything like this, so I had to dig through a bunch of materials.
    The first step was to write a series of functions that carry out the above activities, without being connected to the mobile.
    The next step is to make our Com library available. That is, register [assembly: ComVisible (true)] in the AssemblyInfo.cs file.

    Next, register it accordingly in the regasm system.
    Regasm d: /Classlibraryfornav.dll / codebase / tlb

    Chapter II

    Now we need to prepare a table where all this will be written.
    First, we create the table in Navigation, and then edit it in MS SQL to connect FILESTREAM.
    At first, the table looks like this:
    But then, turn on the FILESTREAM server on Escuel:

    To enable FILESTREAM, you need to:

    1. Launch SQL Server Configuration Manager and put all three checkmarks in the properties of SQL Server on the FILESTREAM tab; then execute the following query: 2. Next, add a filegroup and designate a file vault. Well, we’ll slightly correct the plate itself: we execute the following three commands: a. ALTER TABLE ***. Dbo. *** ADD [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL UNIQUE - required for FILESTREAM

    EXEC sp_configure filestream_access_level, 2

    ALTER database currentDb

    ALTER database currentDb
    NAME= 'Upload',
    FILENAME = 'C:\Users\Administrator\Upload'
    TO FILEGROUP Uploads

    b. ALTER TABLE ***. Dbo. *** ADD UploadFiles VARBINARY (MAX) FILESTREAM - he himself, actually
    c. ALTER TABLE ***. Dbo. *** ADD FileFullName NVARCHAR (MAX) - a field poorly perceived by Navik, but necessary for multilingual display.

    That is, it turns out that we have two fields duplicated:
    Id = NavId - one for navigated, the other for FILESTREAM
    FileName! = FullFileName - the first contains the name of the file with the path converted to ASCII, so that it can be viewed in the navigator. And the FullFileName field, which is not available to Navizhn but necessary to save a full file name.

    Chapter III

    The next step, we connect our dll-ku to Navik. That is, in Codeunit we create a variable of type Automation and in the subtype we find our registered library, with a specific class that we created. It turned out like this for me: image

    Further already in the code:

    CREATE ("Var");
    “Var” .PutToDataBase ('Order', 'Material', 'Project', TRUE);

    When using Arabic, for example, the language, questions are displayed in the Navik anyway. You can deal with this only by putting the Arabic language, and we switch the program to this language as a whole.

    Also popular now: