mibuso.com

Microsoft Business Solutions online community
It is currently Fri Nov 28, 2014 11:41 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Autoimport fob objects
PostPosted: Mon Apr 11, 2011 9:46 pm 
Offline

Joined: Sat Nov 15, 2008 12:55 pm
Posts: 8
Location: Pontevedra
Country: Spain (es)
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.

_________________
Felipe Crespo


Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Thu Apr 21, 2011 10:32 am 
Offline

Joined: Fri Apr 15, 2011 3:04 pm
Posts: 8
Location: Mumbai
Country: India (in)
Yes,Please


Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Aug 05, 2011 10:13 am 
Offline

Joined: Sat Nov 15, 2008 12:55 pm
Posts: 8
Location: Pontevedra
Country: Spain (es)
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
============

Code: Select all
        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
=========================
Code: Select all
 
   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;


Attachment:
File comment: FobTools Folder
FobTools_Folder.jpg
FobTools_Folder.jpg [ 18.3 KiB | Viewed 3981 times ]



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 Crespo


Last edited by fcrespo on Wed Jan 04, 2012 5:52 pm, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Aug 05, 2011 10:18 am 
Offline

Joined: Sat Nov 15, 2008 12:55 pm
Posts: 8
Location: Pontevedra
Country: Spain (es)
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 Crespo


Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Sep 16, 2011 10:45 am 
Offline

Joined: Wed Aug 24, 2011 4:14 pm
Posts: 8
Country: France (fr)
Hello,

Could you please share the objects.

Thanks a lot


Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Sep 16, 2011 10:50 am 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Tue Sep 02, 2008 7:37 am
Posts: 4615
Location: Hyderabad
Country: India (in)
May I know which version you are using?

_________________
-Mohana
http://mibuso.com/blogs/mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav


Top
 Profile  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Sep 16, 2011 3:01 pm 
Offline

Joined: Sat Nov 15, 2008 12:55 pm
Posts: 8
Location: Pontevedra
Country: Spain (es)
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.zip

_________________
Felipe Crespo


Last edited by fcrespo on Thu Nov 24, 2011 10:02 am, edited 1 time in total.

Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Sep 16, 2011 4:17 pm 
Offline

Joined: Wed Aug 24, 2011 4:14 pm
Posts: 8
Country: France (fr)
Hello,

I am using a NAV2009 SP1 classic.

Thanks


Top
 Profile E-mail  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Fri Sep 16, 2011 6:35 pm 
Offline
MVP Microsoft Dynamics NAV
NAV TechDays 2014 attendee

Joined: Tue Sep 02, 2008 7:37 am
Posts: 4615
Location: Hyderabad
Country: India (in)
Check this blog
http://dynamicsuser.net/blogs/vanvugt/archive/2011/08/24/how-to-use-exportobjects-or-importobjects.aspx

_________________
-Mohana
http://mibuso.com/blogs/mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav


Top
 Profile  
 
 Post subject: Re: Autoimport fob objects
PostPosted: Mon Sep 19, 2011 9:30 am 
Offline

Joined: Sat Nov 15, 2008 12:55 pm
Posts: 8
Location: Pontevedra
Country: Spain (es)
My solution allows import *.fob files. The blog one is for *.txt and the user have to compile objects manually...

_________________
Felipe Crespo


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to:  
cron