Normal Topic Automatic file imports (Read 1031 times)
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Automatic file imports
Jul 12th, 2023 at 1:41pm
Print Post Print Post  
I have set up an Auto Import for the backup databases at our 4 locations.  It works fine at this location, but at the other locations. The databases do not close after the import.

A pop-up saying, "The Current Record has been changed and has not been committed to the database.  Are you sure you want to close this record." comes up instead.

The instructions are below for both computers:

Master Application Program

Var vI as Int


    IF FileExists("\\SESAMESERVER\DATA\ANT\ANT1-M.TXT") Or
        FileExists("\\SESAMESERVER\DATA\NG\NG1-M.TXT") Or
        FileExists("\\SESAMESERVER\DATA\SR\SR1-M.TXT") Or
        FileExists("\\SESAMESERVER\DATA\SM\SM1-M.TXT")    Then
    {
//        If @AskUser("There are files to be imported.", "", "Do you wish to import them now") Then
//        {
            ClientLocalValue("CLVImport", 1)
            vI = @SelectTreeItem(@Application + "!Forms!Add Data!CUSTOMER!CUSTOMER")
           @SAVE
           @EXIT
           ExitSesame()

//        }
    }
   

Customer On Form Entry


//In the example above I am using Customers as the database and Form name. Then in your Form's On Form Entry event, you would put code like the following.

Subroutine CheckForFileAndImport(vFilePath as String)

    If FileExists(vFilePath)
    {
        RunImportSpec(vFilePath)
        If @ResultSetTotal() > 0 Then
        {
            FileDelete(vFilePath)
        }
    }

End Subroutine




Var vI as Int
Var vFile as String

If @ClientLocalValue("CLVImport") = 1 Then
{
    vI = @LoadImportSpec("ALL")
    ClientLocalValue("CLVImport", 0)
    If vI = 1 Then
    {
        vFile = "\\SESAMESERVER\Data\Ant\ANT1-M.TXT"
        CheckForFileAndImport(vFile)
        vFile = "\\SESAMESERVER\Data\NG\NG1-M.TXT"
        CheckForFileAndImport(vFile)
        vFile = "\\SESAMESERVER\Data\SM\SM1-M.TXT"
        CheckForFileAndImport(vFile)
     vFile = "\\SESAMESERVER\Data\SR\SR1-M.TXT"
        CheckForFileAndImport(vFile)
    }
}

Instructions below for remote location.


Var vI as Int

    IF FileExists("z:\backup\SM\ANT1.TXT") Or
        FileExists("z:\backup\SM\NG1.TXT") Or
        FileExists("z:\backup\SM\SR1.TXT") Or
        FileExists("C:\Sesame2\DATA\SM1.TXT")    Then
    {
//        If @AskUser("There are files to be imported.", "", "Do you wish to import them now") Then
//        {
            ClientLocalValue("CLVImport", 1)
            vI = @SelectTreeItem(@Application + "!Forms!Add Data!CUSTOMER!CUSTOMER")
           @SAVE
           @EXIT
           ExitSesame()

//        }
    }
   


//In the example above I am using Customers as the database and Form name. Then in your Form's On Form Entry event, you would put code like the following.

Subroutine CheckForFileAndImport(vFilePath as String)

    If FileExists(vFilePath)
    {
        RunImportSpec(vFilePath)
        If @ResultSetTotal() > 0 Then
        {
            FileDelete(vFilePath)
        }
    }

End Subroutine




Var vI as Int
Var vFile as String

If @ClientLocalValue("CLVImport") = 1 Then
{
    vI = @LoadImportSpec("ALL")
    ClientLocalValue("CLVImport", 0)
    If vI = 1 Then
    {
        vFile = "z:\backup\SM\ANT1.TXT"
        CheckForFileAndImport(vFile)
        vFile = "z:\backup\SM\NG1.TXT"
        CheckForFileAndImport(vFile)
        vFile = "C:\Sesame2\DATA\SM1.TXT"
        CheckForFileAndImport(vFile)
     vFile = "z:\backup\SM\SR1.TXT"
        CheckForFileAndImport(vFile)
    }
}

I tried adding another @SAVE, but that did not work.

The only difference is our location has a SERVER and with 7 workstations, while the other locations have 1 computer is both SERVER and Client.
  
Back to top
 
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Automatic file imports
Reply #1 - Aug 6th, 2023 at 11:22pm
Print Post Print Post  
Once the import is done for each database, I have to click on the command button [DELIVERED].  This searches the non-delivered records to check if a delivery was done and posts the information to our inventory database. 

I have tried to add this process to the On Form Open section which includes the Import process, but it would only check the new records.

My next option is to:
1. Open the database once to import the new records. It closes once the import is done.
2. Reopen the database in Search Mode (The preset). 
Step 1 and 2 would be performed by the Task Manager
3. Activate the [DELIVERED] button's programming based on the @TIME (After business hours.)  The programming will not work outside that time unless the [DELIVERED] button is clicked.   

Is there a simple way to do this?
  

sold_database.png ( 10 KB | 18 Downloads )
sold_database.png
Back to top
 
IP Logged
 
cbislander
Full Member
***
Offline



Posts: 103
Joined: Mar 22nd, 2018
Re: Automatic file imports
Reply #2 - Aug 7th, 2023 at 2:56pm
Print Post Print Post  
Hopefully, I figure out how to do this.

The first step to import, works off a batch file for all the databases.
The works fine and does so quickly.

The second step was to open each database at a specific time. 20:46  The programming for the command button is copied to  "On Retrieve Spec Open" and will only work within a certain time frame: ie:  20:45 - 21:00

Each database has a different open schedule and time frame to perform the mass update.

The Mass Update does slow things down, so it is better to do it after hours.

  
Back to top
 
IP Logged