FaxMan SDK Version 4.7
Querying the FaxMan Log Database

 

The FaxMan control can also display the faxes which meet the requirements of a query specified using the LogQuery property. To query the fax database you must set the LogQuery property to the query string and then set the Log property to a value of 5 (Query) which indicates you wish to display the faxes which meet your query criteria.

 

It’s important to note that the query is in effect a snapshot of the database at the point at which the query is specified. If you query for all faxes sent today and subsequently send another fax, that fax won’t be in your query results unless you requery the database again by setting the Log property to a value of 5 (Query).

  

The FaxLogAdd Event

As faxes are moved from log to log, the FaxMan server notifies all users of the movements. This notification comes to your applications in the form of the FaxLogAdd event.

 

The FaxLogAdd event is called with the following parameters:

 

Index – integer specifying the index of the FaxMan control in a control array

 

LogType – integer specifying the log that’s being added to (pending, sending, etc...)

 

FaxID – long value specifying the unique ID assigned to this fax by the FaxMan system.

 

LogIndex – integer specifying which item was added. This item is only valid if the FaxMan log control is currently viewing the proper log; in other words, if LogType = FaxMan.Log, then and only then can you use the LogIndex to examine the newly added log item. Otherwise, LogIndex will be negative one (-1).

 

Note carefully the bold type in the LogIndex explanation. The reason for this is pretty obvious if you consider that there are five logs being tracked by the FaxMan server, and each control can only view one at a time. Clearly, there could be plenty of activity in the logs that aren’t currently being viewed. This leads us naturally to another bold type concept: Do not, under any circumstances, switch logs in the FaxLogAdd event. It may seem that it’s the logical thing to do if the current log isn’t the log that’s being added to, but it’s an extremely bad idea, as it takes entirely too much time to switch logs to do so in an event call, and is prone to causing problems of other kinds.

 

You’re probably wondering now how to access an item in a different log during the FaxLogAdd event. The method to handle this is quite straightforward: simply add a separate FaxMan control for each log you want to watch. The controls can be rendered invisible to your users by moving them off the screen or sizing them extremely small (remember, the Visible property must be on). In each control, you would add code to monitor the FaxLogAdd event, each control only looking for events that affect it. This way you can avoid having to switch logs during the FaxLogAdd event and still be guaranteed that you’ll see all the information for each update.

 

The FaxLogRemove Event

When a fax is removed from the current log, the FaxMan server notifies all users of the movements. This notification comes to your applications in the form of the FaxLogRemove event.

 

The FaxLogRemove event is called with the following parameters:

 

Index – integer specifying the index of the FaxMan control in a control array

 

FaxID – long value specifying the unique ID assigned to this fax by the FaxMan system.

 

 

Searching for a Fax by ID

Let’s say that you’re tracking each fax your application sends in an external database. In the database you’re storing all kinds of extra information, say a picture of the person you’re faxing to and their pet’s name, and you’re linking all of this to FaxMan by storing the fax ID in the record as well. You want to iterate through the database records and print the results of the fax, along with the picture and the pet’s name.

 

All of this raises a simple question:

 

Given a unique FaxMan fax ID (as returned after scheduling in the FaxLogID property), how do you get the information for that fax?

 

The answer to this question is simple: use the FindFax method which takes the FaxID as a parameter and returns a FaxItem object. The FaxItem object contains all the Log properties for that fax item.

 

For Example:

 

' dwID is the fax ID we’re searching for

Dim Fx As FaxItem

 

Set Fx = FaxMan1.FindFax(dwID)

 

‘ Dipslay the Company Name

Print Fx.LogCompany

 

Deleting Log entries

Entries in the FaxMan log are not deleted automatically. Your application can delete log entries by selecting the log you wish to delete entries in using the Log property, then calling the DeleteLogEntry method with the index of the log entry to remove. 

Do not delete a log entry that is currently sending. You must first cancel the fax, then wait for it to be placed in the failed log.

 

When a log entry is deleted, any fax files with an .FMF extension listed in the LogFiles property will be deleted by the control.

 

Configuring the log display

The Visual Log display in the FaxMan control is highly configurable. You can programmatically specify which columns are displayed, their order and widths. Your end users can also use a mouse to drag and drop columns and resize the columns. Right clicking the mouse over the column headers will also allow end-users to select which columns are displayed. The ColWidthChanged event will be fired when the user resizes a column in the control.

 

The ColName and ColWidth properties control the order and width of the columns which are displayed.

 

It’s important to note that FaxMan does not store the current settings for the log display. If you wish these settings to be restored when your application is restarted, you must do so yourself. The following code should allow you to save/restore these settings:

 

Global Const MAX_HDRITEMS = 22

 

Private Sub Form_Load()

Dim I% 

Dim tmp As String * 255 

 

For I = 0 To MAX_HDRITEMS-1 

FaxMan1.ColWidth(I) = GetPrivateProfileInt("Columns", Str$(I), 

10, "faxtst.ini")

If GetPrivateProfileString("ColumnHdrs", Str$(I), "", tmp, 255, 

"faxtst.ini") Then

FaxMan1.ColName(I) = Trim$(tmp) 

End If 

Next I 

End Sub

 

Private Sub Form_Unload

Dim I% 

 

' Save the column Widths 

For I = 0 To MAX_HDRITEMS-1 

WritePrivateProfileString "Columns", Str$(I), 

Str$(FaxMan1.ColWidth(I)), "faxtst.ini"

WritePrivateProfileString "ColumnHdrs", Str$(I), 

FaxMan1.ColName(I), "faxtst.ini"

Next I 

End Sub 

See Also

Appendices

 

 


© 2013 Data Techniques, Inc. All Rights Reserved.

Send comments on this topic.