Notification of mailbox sync

Is there a way to create some sort of notification when a Flexy syncs with the data mailbox. Can we watch a status on the Flexy and see when the esync has completed?

We are currently polling the data mailbox on a regular basis but would like to come up with a method of knowing when the syncs take place so then we can go and get the data.

@tedsch

There is no built-in functionality to check for when data is synced, but you can use the function I’ve written below for that purpose. Please note, this script is provided as is and is not guaranteed to work in all scenarios.

I’ve written a function below that you can use to check the event log for a particular event ID by opening an export block descriptor. I’ve included a lot of comments in the function to help explain it.

USER SECTION

FUNCTION checkEvent($strToCheck$, $ebd$)
  $newDataFound% = 0
  PRINT TIME$ + ": Checking for data synchronization..."
  $file$ = "exp:" + $ebd$
  // Open EBD as file over the last one minute
  OPEN $file$ FOR TEXT INPUT AS 1
  // Loop through lines in text file
  $Loop:
  $A$ = GET 1 // Get the next line of the file
  IF ($A$ <> "") THEN // If the line is not empty then..
    $E% = INSTR 1,$A$,$strToCheck$ // Search for the string event ID entered as the $strToCheck$ function parameter
    IF $E% <> 0 THEN // If not 0 (means that the string was found), go to send the email notification, update the Boolean tag, and close the file
      $newDataFound% = 1
      PRINT "Data has been synced"
      CLOSE 1
      // Send notification email
      SENDMAIL "emailaddress@domain.com", "", "Data has been synchronized", "You can now pull the data that was synced with event " + $strToCheck$
      Print "Email has been sent"
    ENDIF
  ELSE GOTO $Loop
  ENDIF
  CLOSE 1
  PRINT TIME$ + ": Ending check for data synchronization"
ENDFN
END

The function takes two parameters, a string to check ($strToCheck$) and an export block descriptor ($ebd$). I’m using the event ID 1073773732 which is recorded in the Event Log when the Data management (DataMailbox, eSync) is complete. The accompanying description is esync-End of Data management export (0 min).

I’ve used our Export Block Descriptor (EBD) Helper online tool to generate an EBD of “$dtEV $ftT $st_s60 $et_s0” which retrieves the event log in text format with a start time of 60 seconds ago to an end time of 0 seconds ago. You can of course customize this time frame to best suit your needs.

In your Flexy’s Init section, you can set a timer to call the function. In my example below, I’ve called it every 60 seconds.

INIT SECTION

TSET 1, 60
ONTIMER 1, "goto CheckEventFunction"

CheckEventFunction Label in a User Section

CheckEventFunction:
eventString$ = "1073773732"
ebdString$ = "$dtEV $ftT $st_m1 $et_s0"
@checkEvent(eventString$, ebdString$)
END

Using the above timer, the function will be called every 60 seconds to check the event log over the past 60 seconds for the specified event.

Please let us know if you have any further questions, and I hope this helps.

-Ashley@HMS

Is the event ID that is listed the same no matter if it is a scheduled sync or if the sync is taking place due to an upload on alarm?

@tedsch

Yes, the event ID is going to be the same whether it’s a scheduled sync or if it’s uploaded due to an alarm. Furthermore, our eSync service uses the same event ID as well.

I also want to mention that if you’re using this function to check for any other event ID and not using relative time in your EBD, you may need to add a script within the function that checks the timestamps on the event logs.

Please let me know if you have any other questions.

Ashley

Can you explain a bit the relative time in your EBD statement?

@tedsch

Sure! It is simply relative time from when the EBD is being exported. In other words, the time relative from now.

  • $st_m1 = start time: 1 minute before now
  • $et_s0 = end time: 0 minutes (so now)

I hope that clears things up. To learn more about export block descriptors, please see page 202 in our General Reference Guide.

Ashley

Had to remove the spaces in the ebdString$ to get it tested successfully on the EBD Helper.

Then I am testing this out today on a Flexy and the function never finds the event of the data mailbox sync.

@tedsch

Would you be able to private message me a backup tar with support files included so that I can take a look at your program.bas and event log files?

Ashley the code that was posted was working correctly.

The issue is when the event log starts to mute repeating events to save space then we can no longer see any of the data sync events.

During the mute process the events are no longer listed individually in the log files so when the event log is queried every minute it will show as being blank in the Get 1 statement.