Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2005

Tip: Looking for answers? Try searching our database.

Handling events for FaxServer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard - 18 Sep 2005 09:11 GMT
Can anyone please give me some help regarding how do you handle events for
FaxServer through .NET ie C# . My problem is I would like my application to
be notified of the events that have been fired.

Once I have called connectSubmit I would like the event,
FaxServer_OnOutgoingJobChanged to be fired so I can view the status of the
fax on wheather it has been sent or an error eg. Incorrect fax number, no
dial tone on the receiver etc.

I have tried to use WaitHandle etc with no success. Below is the following
code, This code does include the waitHandle object :-

using System;
using FAXCOMEXLib;   // COM32
namespace MyFax
{
  public class Fax
   {
      private FAXCOMEXLib.FaxServer _faxServer;
      private IFaxDocument _docToFax;   

       public FAXCOMEXLib.FaxServer FaxServer
        {
    get{return _faxServer;        }
    set{_faxServer = value;        }
        }
       public IFaxDocument Document
       {
    get{return _docToFax;        }   
    set{_docToFax = value;        }
      }

     public virtual void SendFax()
      {       
         object jobId;
         FaxServer =    new FaxServerClass();
         Document =    new FaxDocumentClass();   
               
         FaxServer.Connect(string.Empty);       
        FaxServer.ListenToServerEvents  
(FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE |
FAX_SERVER_EVENTS_TYPE_ENUM.fsetACTIVITY);

      FaxServer.OnOutgoingJobChanged += new    
IFaxServerNotify_OnOutgoingJobChangedEventHandler(FaxServer_OnOutgoingJobChanged);
               
    Document.Body = _fileToFax; // tiff file to fax
    Document.DocumentName = _nameOfDocument;
    Document.Priority     = FAX_PRIORITY_TYPE_ENUM.fptHIGH;
    Document.Recipients.Add(FaxNumber, Recipient);
    Document.AttachFaxToReceipt = true;
    Document.ReceiptType = FAX_RECEIPT_TYPE_ENUM.frtNONE;
    /************************************************* */
    // HOW TO HANDLE THIS EVENT. FAX Console/ dialer starts up
     // however once this app has started up it then returns back to and
    // assigns a jobid and continues on. My question is how to stop this
from  
    // continuing on until I get a event from OnOutgoingJobChanged.
/* ****************************************************** */
    jobId = Document.ConnectedSubmit(FaxServer);
           
}

  public void FaxServer_OnOutgoingJobChanged(FaxServer pFaxServer, string
bstrJobId, FaxJobStatus pJobStatus)
   {
      // code to to log etc that a Fax event has occurred.
    }

  public Fax()
   {
     FaxServer =    new FaxServerClass();
     Document=    new FaxDocumentClass();
           
   }
}
Robert Jordan - 18 Sep 2005 16:53 GMT
Hi Richard

>      /************************************************* */
>      // HOW TO HANDLE THIS EVENT. FAX Console/ dialer starts up
[quoted text clipped - 6 lines]
>            
> }

From what kind of application are you using your Fax class?
Console or WinForms?

Rob
Richard - 18 Sep 2005 21:55 GMT
> Hi Richard
>
[quoted text clipped - 13 lines]
>
> Rob

Hi Robert,

It is for a webforms application, however, I am using a console app as my
testharness to make sure it is working.

Regards,
Richard
Robert Jordan - 18 Sep 2005 22:50 GMT
Hi,

>>>     /************************************************* */
>>>     // HOW TO HANDLE THIS EVENT. FAX Console/ dialer starts up
[quoted text clipped - 16 lines]
> It is for a webforms application, however, I am using a console app as my
> testharness to make sure it is working.

The console application probably exits before the events
have been fired. You may try to insert Console.ReadLine()
after the ConnectedSubmit call.

However, if you plan to use the Fax API for a ASP.NET
application you must first find out whether the COM Fax-API
is a MTA oder STA COM component.

Unfortunately I was not able to install the Fax components
on my machine, so I cannot tell you the kind of the component.
Google said it's STA:

http://www.codeguru.com/forum/showthread.php?t=343002

STA COM objects must be instantiated on the same
webpage they are expected to be used and the page
must include the directive <%@ ASPCOMPAT="true" %>.

Instead of Console.ReadLine() you must use something
like that:

while (true) {
  if (isReady) break;
  Thread.Sleep (1000);
}

"isReady" must be set from within the Fax event handler.

Rob
Richard - 19 Sep 2005 08:43 GMT
> Hi,
>
[quoted text clipped - 48 lines]
>
> Rob

Rob,
Thanks for that, however, I am not developing a ASP.NET project. I also
implemented you suggestions however I'm afraid this didn't work either.  

I think I may have to work on the threading side of things to get this
working.
Richard

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.