Autoimport fob objects

fcrespo
Member Posts: 9
The company I'm working has more than 100 shops using Navision SQL client on localhost. We use MSMQ and Webservices to get online sales info but updates on Navision databases are very hard because we have to connect them through VNC clients and import fob objects manually.
Finally I get the solution to autoimport fob objects using a NAS, CFront and FTP. The NAS checks a folder where fob objects are uploaded and when detects a new fob file autoimports it using CFront.
I've found lots of solutions like CSideIntegration Utilities (http://www.mibuso.com/forum/viewtopic.php?f=7&t=44886&start=0) but all them needs a Navision session opened and import objects as text. Of course using NAS we are using a session, but we don't care if the user closes his Navision session.
If the import process fail, we can get the result of the CFront Error Message through a MSMQ sent via WebService.
If someone is interested I can share the solution.
Finally I get the solution to autoimport fob objects using a NAS, CFront and FTP. The NAS checks a folder where fob objects are uploaded and when detects a new fob file autoimports it using CFront.
I've found lots of solutions like CSideIntegration Utilities (http://www.mibuso.com/forum/viewtopic.php?f=7&t=44886&start=0) but all them needs a Navision session opened and import objects as text. Of course using NAS we are using a session, but we don't care if the user closes his Navision session.
If the import process fail, we can get the result of the CFront Error Message through a MSMQ sent via WebService.
If someone is interested I can share the solution.
Felipe Crespo
0
Comments
-
Yes,Please0
-
PRERREQUISITES
==============
- Microsoft Dynamic Nav 5.0 SP1
- Navision Application Server 5.0 SP1
- C/Front 5.0 SP1
- Navision Job Queue Module*
- Automation library to interop with C/Front from C/AL**
* Navision Job Queue Module is not necesary but smarter. NAS and a timer is enough.
** I developed a simple c# wrapper (FobTool.dll). I can mail if needed.
HOWTO
======
I created a codeunit with functions to be called from one Task Queue Entry (CU 50000 - Task Queue Management). The main function (ImportFob) checks a directory looking for new *.fob files. If one fob file is detected it connects to CFront and call to CFront function ImportFob(). After import the file is moved to a directory for processed files, if any error occurs it will be moved to another directory.
Task Queue Entry throws ImportFob function every day and captures the success message or error message. I use a WebService to send a message if any error occurs (Implemented in Navision Task Queue module).
SAMPLE CODES
============
- C# Wrapper
============public bool ImportFob(String importPath, String importMode) { NavisionImportMode ImportMode; switch (importMode) { case "Overwrite": ImportMode = NavisionImportMode.Overwrite; break; case "Skip": ImportMode = NavisionImportMode.Skip; break; case "ThrowError": ImportMode = NavisionImportMode.ThrowError; break; default: ImportMode = NavisionImportMode.Overwrite; break; } try { CFrontDotNet.Instance.ImportFOB(importPath, ImportMode); } catch (Exception e) { this.SetErrorMsg(e.Message); this.Disconnect(); return false; } return true; }
- ImportFob C/AL Function
=========================IF ISCLEAR(gFobAuto) THEN CREATE(gFobAuto); MESSAGE('[NASFobImport] Buscando fobs en %1', gTPVSetup."Fobs Path"); CLEAR(lExplorer); lExplorer.RESET; lExplorer.SETRANGE(Path, gTPVSetup."Fobs Path"); lExplorer.SETRANGE("Is a file",TRUE); IF lExplorer.FINDSET THEN BEGIN lFobPath := lExplorer.Path + lExplorer.Name; IF FILE.EXISTS(lFobPath) THEN BEGIN lImportedFileName := FORMAT(CURRENTDATETIME,0,'<Year,2><Month,2><Day,2><Hours24,2><Minutes,2><Seconds,2>') + '_' + lExplorer.Name; lFobImportPath := gTPVSetup."Fobs Imported Path" + lImportedFileName; lFobErrorPath := gTPVSetup."Fobs Error Path" + lImportedFileName; MESSAGE('[NASFobImport] Procesando fichero %1', lExplorer.Path + lExplorer.Name); // ############ CONEXIÓN ################# MESSAGE('[NASFobImport] Conectando a Navision [CFront]...'); lConRes := gFobAuto.Connect(gTPVSetup."FobTools Path", '', '', gTPVSetup.Servername, gTPVSetup."Navision Database", COMPANYNAME, TRUE, '', ''); IF lConRes THEN BEGIN MESSAGE('[NASFobImport] Conectado a Navision [CFront].') END ELSE BEGIN ERROR('[NASFobImport] Error conectando a Navision [CFront]: %1', GetError()); END; // ############ IMPORTACIÓN ################# MESSAGE('[NASFobImport] Importando fichero %1', lFobPath); lImpRes := gFobAuto.ImportFob(lFobPath, 'Overwrite'); IF lImpRes THEN BEGIN IF FILE.EXISTS(lFobPath) THEN FILE.RENAME(lFobPath,lFobImportPath); MESSAGE('[NASFobImport] Fichero %1 importado con éxito.', lFobPath); END ELSE BEGIN IF FILE.EXISTS(lFobPath) THEN FILE.RENAME(lFobPath,lFobErrorPath); ERROR('[NASFobImport] Error importando %1: %2',lFobPath,GetError()); END; // ############ DESCONEXIÓN ################# MESSAGE('[NASFobImport] Desconectando...'); lDiscRes := gFobAuto.Disconnect(); IF lDiscRes THEN BEGIN MESSAGE('[NASFobImport] Desconectado.') END ELSE BEGIN ERROR('[NASFobImport] Error desconectando: %1',GetError()); END; gMsg := STRSUBSTNO('[NASFobImport] Fichero %1 importado con éxito.', lFobPath); END; END;
It's necesary to change default paramater values to connect to a Native database.
Thanks to ykerzreho for the request.
Connect function parameters:
netType values:-
"NativeNetB"
"NativeSecureTcp"
"NativeTcp"
"SqlDefault"
"SqlNamedPipe"
"SqlTcpSocket"
default value :"SqlDefault"
driverType values-
"Native"
"Sql"
default value :"sql"
Felipe Crespo0 -
Navision 5.0 SP1 is needed because C/Front only implements ImportFob() in this version.
I detected some problems importing tables that contains fields used in SIFT tables (like Item Ledged Entry, G/L Entry,...)Felipe Crespo0 -
Hello,
Could you please share the objects.
Thanks a lot0 -
May I know which version you are using?0
-
C/Front 5.00 SP1 is needed because is the only one that contains required functions.
Link of wrapper library: http://dl.dropbox.com/u/24474654/FobTools.zipFelipe Crespo0 -
Hello,
I am using a NAV2009 SP1 classic.
Thanks0 -
My solution allows import *.fob files. The blog one is for *.txt and the user have to compile objects manually...Felipe Crespo0
-
Hi fcrespo,
The link given to download the object is not working. am in need of those objects. Can you share the Object ?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions