0

I created a fax job interface for my web app using FAXCOMEXLib. The faxing mechanism is working and sending faxes properly. I am attempting to set up some logging of the fax status, and I am using listeners, as defined in the docs:

    public FaxInterface()
    {
        faxSrv = new FaxServer();
        var serverName = Environment.MachineName;
        faxSrv.Connect(serverName);
        faxSrv.OnOutgoingJobChanged += faxSrv_OnOutgoingJobChanged;
        faxSrv.OnOutgoingJobAdded += faxSrv_OnOutgoingJobAdded;
        faxSrv.OnOutgoingJobRemoved += faxSrv_OnOutgoingJobRemoved;
        faxSrv.ListenToServerEvents(FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE |
                            FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetIN_QUEUE);
    }

And this works. My event listeners are getting triggered properly. But I am having trouble with some of the data in the JobChanged listener, which is defined below:

    private void faxSrv_OnOutgoingJobChanged(FaxServer pfaxserver, string bstrjobid, FaxJobStatus pjobstatus)
    {
        using (IDbConnection db = new SqlConnection(ConnectionStringHelper.ConnectionString))
        {
            db.Execute("update T_FAXLOG set LogText = CONCAT(LogText, @newText) where JobId = @jobId", new { newText = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:ff tt") + " " + pjobstatus.Status.ToString() + Environment.NewLine, jobId = bstrjobid });
        }
    }

My problem is that I seem to be getting an unexpected value in the pjobstatus.Status that is passed to my function. If I "View Definition" of the pjobstatus.Status type (which is this: enum FAX_JOB_STATUS_ENUM), I see this in the definition:

namespace FAXCOMEXLib
{
    public enum FAX_JOB_STATUS_ENUM
    {
        fjsPENDING = 1,
        fjsINPROGRESS = 2,
        fjsFAILED = 8,
        fjsPAUSED = 16,
        fjsNOLINE = 32,
        fjsRETRYING = 64,
        fjsRETRIES_EXCEEDED = 128,
        fjsCOMPLETED = 256,
        fjsCANCELED = 512,
        fjsCANCELING = 1024,
        fjsROUTING = 2048
    }
}

However, when I run my app and "Pause" my fax process in my server, I get the value "49" in the status field. And, as you can see, that number is nowhere in the definition. I would expect to get a "16" for a pause, but I get a "49". Am I missing something here? Is there some other documentation of this elsewhere? Or do I need to decode that value somehow?

Thanks in advance.

Matt Spinks
  • 6,380
  • 3
  • 28
  • 47
  • It is a [Flags] enum, easier to see when you write the constants in hex like it is done in the faxcomex.h SDK file. So 39 == 32 + 4 + 2 + 1. Transmission is pending, it is trying to send but there is no line. 4 isn't documented. – Hans Passant Aug 29 '17 at 21:17
  • Oh, of course. And wouldn't you know, I posted the wrong value. I meant "49" instead of "39". So "49" would be 32 + 16 + 1, which would be "no-line", "paused", and "pending". Is there any easy way to extract the individual hex values from that number in C# (that you know of)? – Matt Spinks Aug 29 '17 at 21:22
  • The Enum.HasFlag() method jumps to mind. Do what works. – Hans Passant Aug 29 '17 at 21:27

0 Answers0