The plot.
And so, hello.
Working in an office that deals with the introduction of such a thing as Ms Dynamics Nav had to face one problem, the solution of which by means of Navik himself (I allow myself to be so familiar), was impossible.
The essence of the problem is as follows:
introducing the system into the enterprise that is engaged in translation, there was a tough problem with the file names, since the requirements stated that the name that was named for the source file must fully match the name that the already translated file will receive. With all this, the customer required to write files to the MS SQL database. Since Navik is sooo far from Unicode, all the built-in functions for working with files distorted the name, removing umlauts, axants and other elements of the European alphabet.
To solve this problem, the task was to write a dll-ku that will write files with correct names to the database. And then, on request, return these files from the database to the file system. With all this, there was a problem with downloading large files, so, again, a strong decision was made to use such a thing as FILESTREAM in MS SQL.
Decision
Chapter i
I sincerely hope that the essence of the problem has become clear. Now proceed to the resolution.
Since your obedient servant handles C # best of all, I decided to write on it. I've never done anything like this, so I had to search through a bunch of materials.
First of all, a series of functions was written, which carry out the above described activity, without connecting to the mobile.
The next step is to make our Com library available. That is to register [assembly: ComVisible (true)] in the AssemblyInfo.cs file
Further, respectively, register it in the system regasm - ohm.
Regasm d: /Classlibraryfornav.dll / codebase / tlb
Chapter II
Now we need to prepare a table where all this will be recorded.
First, we create a table in Navizhn, and then edit it in MS SQL, to connect FILESTREAM.
At first, the table looks like this:
But then, we turn on the FILESTREAM server on Esquel:
')
To enable FILESTREAM:
1. Start SQL Server Configuration Manager and in the properties of SQL Server on the FILESTREAM tab put all three checkboxes; then run the following query:
EXEC sp_configure filestream_access_level, 2
RECONFIGURE
2. Next, you need to add a file group and label the file storage.
ALTER database currentDb
ADD FILEGROUP Uploads
CONTAINS FILESTREAM
GO
ALTER database currentDb
ADD FILE
(
NAME= 'Upload',
FILENAME = 'C:\Users\Administrator\Upload'
)
TO FILEGROUP Uploads
GO
Well, a little tweak the plate itself:
execute the following three commands:
a. ALTER TABLE ***. Dbo. *** ADD [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL UNIQUE - required for FILESTREAM
b. ALTER TABLE ***. Dbo. *** ADD UploadFiles VARBINARY (MAX) FILESTREAM - he himself
c. ALTER TABLE ***. Dbo. *** ADD FileFullName NVARCHAR (MAX) is a field badly perceived by Navik, but necessary, for a multi-language display.
That is, it turns out that we have duplicated two fields:
Id = NavId - one for navigate, another for FILESTREAM
FileName! = FullFileName - the first one contains the name of the file with the path, converted to ASCII, so that it can be viewed in the file. And the field FullFileName, inaccessible Navizhnu, but necessary to save the full name of the file.
Chapter three
The next stage, we connect our dll-ku to Navik. That is, in the Codeunit we create a variable of type Automation and in the subtype we find our registered library, with a specific class created by us. It happened to me like this:
Further, already in the code:
CREATE ("Var");
“Var” .PutToDataBase ('Order', 'Material', 'Project', TRUE);
Ps
When using Arabic, for example, in a language, questions are displayed in any way. You can fight this only by installing Arabic, and switch the program to this language entirely.