How do I properly decode FaxJobStatus in FAXCOMEXLib?

204 views Asked by At

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.

0

There are 0 answers