Change in API in Windows 2003 server

  • Thread starter Thread starter Nicolas Caron
  • Start date Start date
N

Nicolas Caron

When calling the FaxGetJob API using the JobID of a fax that has been
successfully sent, in Windows 2K or XP a valid FAX_JOB_ENTRY is
returned with the Status field set to FPS_COMPLETED.

Doing the exact same thing in Windows 2003 server, the JobEntry field
is just NULL when you call FaxGetJob with a JobID of a successfully
sent fax...

So basically my question is, on Windows 2003 server, how am I supposed
to know the difference between a fax that has been cancelled by the
user or one that has been successfully sent?

Thanks,
NC
 
Where are you getting the ID that you are passing to FaxGetJob?
What's the error code returned from GetLastError()? Sharing your code
snippet (including where you get the Job ID from) would help.

--
Raghavendra R
Microsoft Printing, Imaging and Fax Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.'
 
Raghavendra said:
Where are you getting the ID that you are passing to FaxGetJob?
What's the error code returned from GetLastError()? Sharing your code
snippet (including where you get the Job ID from) would help.

The Job ID I get from FaxSendDocument and the code works perfectly fine
in Windows 2000 and XP

While I can't share the exact code (NDA) here is basically what I do

FaxSendDocument // here I get the JobID

.. . . // Do lots os stuff here

FaxGetJob(ID) // Here I want to get the status of the job

If the job is completed, in win 2K and XP I get the job with the
FAX_JOB_ENTRY status field set to FPS_COMPLETE... on Win 2003 the
FAX_JOB_ENTRY I get from FaxGetJob is just null...
 
Two things
(1) When a job is successfully completed its archived in SentItems if
archiving is true & the job is deleted from the queue. So FaxGetJob should
fail. I am wondering how your code can work even in Windows 2000 or XP. The
time you call FaxGetJob is critical. After a job is finished (successfully
completed) there are some things to be done & hence for a short while it
stays in Queue & it gets deleted after that. If FaxGetJob call comes during
that short while FaxGetJob will succeed. Otherwise I think it should fail.
(2) Is FaxGetJob returning TRUE or FALSE? If FALSE what's the error code
returned from GetLastError()? I think it should return a failure (FALSE)
when it sets the out parameter to NULL.

Can you locate your fax in 'Fax Client Console'? Perhaps in SentItems folder
view?

If your goal is to find whether the submitted job is finished successfully
then what your logic (from what I can understand) is incorrect. On Windows
XP & Windows Server 2003, use Fax Service Extended COM API. Specifically use
FaxServer.ListentToServerEvents. You can read the documentation in MSDN. Or
if you don't want your program to be too complex, you can call FaxGetJob in
an infinite loop after every <n> seconds & break out of the loop for certain
status values like completed, failed etc.

--
Raghavendra R
Microsoft Printing, Imaging and Fax Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.'
 
Raghavendra said:
I am wondering how your code can work even in Windows
2000 or XP.

It does indeed seems weird that my code would work in 2K and XP but it
does :)

Could it be that the archiving options default to false on 2K and XP
and to true on 2003? That would explain why jobs stay in the queue and
thus my code works fine on XP and 2000... I will investigate further...
Or if you don't want your
program to be too complex, you can call FaxGetJob in an infinite loop
after every <n> seconds & break out of the loop for certain status
values like completed, failed etc.

This is basically what I do.

From what you say, completed jobs should not return anything from
FaxGetJob. It seems to be the exact same thing with canceled jobs...
How can I know if a job that stops existing has been completed or
canceled?
 
Good question. Actually there is no reliable way to achieve this without
using events. Look at FaxInitializeEventQueue in Windows 2000 Fax API.
Otherwise you can only get a hacky solution. You can use a combination of
FaxGetDeviceStatus & FaxGetJob & work out something. FaxGetDeviceStatus
returns FAX_DEVICE_STATUS whose status field has FPS_COMPLETED flag. So my
advise would be to use FaxInitializeEventQueue or the equivalent in the new
APIs.

--
Raghavendra R
Microsoft Printing, Imaging and Fax Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.'
 
Raghavendra said:
Good question. Actually there is no reliable way to achieve this
without using events. Look at FaxInitializeEventQueue in Windows 2000
Fax API. Otherwise you can only get a hacky solution. You can use a
combination of FaxGetDeviceStatus & FaxGetJob & work out something.
FaxGetDeviceStatus returns FAX_DEVICE_STATUS whose status field has
FPS_COMPLETED flag. So my advise would be to use
FaxInitializeEventQueue or the equivalent in the new APIs.

Ok... I fail to see why a FPS_COMPLETED status has been created in the
FAX_JOB_ENTRY structure if it is not to be used to identify completed
jobs though.

What exactly is the purpose of this status? Or is it just, basically,
useless?
 
FaxGetJob is an API to get the details for a job that's present in the
Queue. When a job is completed, it's deleted from the Queue. So it makes
sense that a completed job is not retrievable from FaxGetJob.

FAX_JOB_ENTRY has two fields Status & QueueStatus. Status is for the device
& QueueStatus is for the fax job. Values for status are in the context of
device & so FPS_COMPLETED does make sense. For your question of whether one
can ever get a value of FPS_COMPLETED from FaxGetJob, the answer is yes, but
rarely. As I mentioned earlier completed jobs stay in Queue for a short time
before getting deleted.

All said, the right way for you is to use fax events. Period.

--
Raghavendra R
Microsoft Printing, Imaging and Fax Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.'
 
Raghavendra said:
FaxGetJob is an API to get the details for a job that's present in
the Queue. When a job is completed, it's deleted from the Queue. So
it makes sense that a completed job is not retrievable from FaxGetJob.

FAX_JOB_ENTRY has two fields Status & QueueStatus. Status is for the
device & QueueStatus is for the fax job. Values for status are in the
context of device & so FPS_COMPLETED does make sense. For your
question of whether one can ever get a value of FPS_COMPLETED from
FaxGetJob, the answer is yes, but rarely. As I mentioned earlier
completed jobs stay in Queue for a short time before getting deleted.

All said, the right way for you is to use fax events. Period.

Ok thanks... that helps me understand.

I will change my code to use events.

I'd like to point out though that on Windows 2000 and Windows XP, once
a fax is sent successfully, FaxGetJob still returns a valid
FAX_JOB_ENTRY structure which doesn't seem to be the intended
behavior...
 
Back
Top