Connecting Tech Pros Worldwide Forums | Help | Site Map

Faxdocument.submit creates excess Fax Jobs in Fax queue

Newbie
 
Join Date: Mar 2009
Posts: 0
#1: Mar 10 '09
Hi,

I am developing a Fax application using FAXCOMEXLIB in visual studio .net 2005 on Windows XP professional and have come across a strange behaviour. A thread in a class receives the Fax request and the Fax details are filled in and submitted. Note - Even if there are multiple fax numbers i send the FAX one receipient at a time.
For the first fax received the Submit function returns single JOBID. The next FAx submitted returns 2 JObIDs and the third one returns 3 and so on. I thought probably it is holding the previous JOBID and giving it back but that is not the case. I compared all the JOBIDs and they are different. I did convert all these values to decimal and compared and still different.

This is what i get...

Sending 1st Fax..
JOBID - 201c9a0e5136e99

Sending 2nd Fax..
201c9a0e51d7658
201c9a0e51d78c9

Sending 3rd Fax..
201c9a0e52ea797
201c9a0e52eaec3
201c9a0e52ea9e1

The code ..
Class FaxServer
{
private FAXCOMEXLib.FaxDocument m_FaxDocument;
private FAXCOMEXLib.FaxServer m_FaxServer;
private FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM FaxSvrEnum;

Public FaxServer()
{
//Constructor..
m_FaxServer = new FAXCOMEXLib.FaxServer();
m_FaxServer.Connect(Environment.MachineName);
m_FaxDocument = new FAXCOMEXLib.FaxDocument();

FaxSvrEnum = (FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_Q UEUE | FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC _ENDED);
m_FaxServer.ListenToServerEvents(FaxSvrEnum);
m_FaxServer.OnOutgoingJobAdded += new IFaxServerNotify_OnOutgoingJobAddedEventHandler(fa xserver_OnOutgoingJobAdded);
m_FaxServer.OnOutgoingJobChanged += new IFaxServerNotify_OnOutgoingJobChangedEventHandler( faxserver_OnOutgoingJobChanged);
}


public void SendFax(FileDetails objFileDetails)
{
string RecipientName = "";
string FaxNumber = "";
char[] delimiterChars = { ',' };


Common.GetSectionInfo(objFileDetails.GetMsgFilePat h(), "TO", ref RecipientName); //Get Receipient Name
Thread.Sleep(500);
Common.GetLineInfo(objFileDetails.GetMsgFilePath() , 2, ref FaxNumber); //Get Fax Number

if (RecipientName == "")
{
Log.Info("Recipient Name missing for File - " + objFileDetails.GetMsgFileName());
}

if (FaxNumber == "")
{
//Log that fax number is missing and hence could not be sent..
return;
}

string[] arrFaxNumbers = FaxNumber.Split(delimiterChars);

try
{
foreach (string strFaxNumber in arrFaxNumbers)
{

m_FaxDocument.Body = objFileDetails.GetTxtFilePath();
m_FaxDocument.Recipients.Add(strFaxNumber, RecipientName);

m_FaxDocument.DocumentName = objFileDetails.GetMsgFileName();
Log.Info("Sending Fax for File - " + objFileDetails.GetMsgFileName());

//This JobID[0] can be used to store the JobID of the fax job for later reference.
string[] JobIDs = (string [])m_FaxDocument.Submit(null);

//Expecting only 1 JobID as sending Fax to different receipient in a loop..
objFileDetails.SetJobID(JobIDs[0].ToString());
m_dJobIDList.Add(JobIDs[0].ToString(), objFileDetails);

//Lets save the JOBID in the MSG file properties.
//string fileName = objFileDetails.GetMsgFilePath().Substring(FileFull Path.LastIndexOf("\\") + 1);
string fileName = objFileDetails.GetMsgFileName();
string filePath = objFileDetails.GetMsgFilePath().Substring(0, objFileDetails.GetMsgFilePath().LastIndexOf("\\")) ;

DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
DSOFile.SummaryProperties summary;
dso.Open(objFileDetails.GetMsgFilePath(), false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
summary = dso.SummaryProperties;
summary.Comments = string.Join(",", JobIDs);
dso.Close(true);

}
}
catch (Exception ex)
{
Log.Error("Exception occured while sending Fax for File - " + objFileDetails.GetMsgFilePath() + ".Please Investigate." ,ex);
}
}
}
Any clues guys..

Newbie
 
Join Date: Mar 2009
Posts: 0
#2: Mar 10 '09

re: Faxdocument.submit creates excess Fax Jobs in Fax queue


Hi,

I am developing a Fax application using FAXCOMEXLIB in visual studio .net 2005 on Windows XP professional and have come across a strange behaviour. A thread in a class receives the Fax request and the Fax details are filled in and submitted. Note - Even if there are multiple fax numbers i send the FAX one receipient at a time.
For the first fax received the Submit function returns single JOBID. The next FAx submitted returns 2 JObIDs and the third one returns 3 and so on. I thought probably it is holding the previous JOBID and giving it back but that is not the case. I compared all the JOBIDs and they are different. I did convert all these values to decimal and compared and still different.

This is what i get...

Sending 1st Fax..
JOBID - 201c9a0e5136e99

Sending 2nd Fax..
201c9a0e51d7658
201c9a0e51d78c9

Sending 3rd Fax..
201c9a0e52ea797
201c9a0e52eaec3
201c9a0e52ea9e1

The code ..
Expand|Select|Wrap|Line Numbers
  1. Class FaxServer
  2. {
  3.     private FAXCOMEXLib.FaxDocument m_FaxDocument;
  4.         private FAXCOMEXLib.FaxServer m_FaxServer;
  5.         private FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM FaxSvrEnum;
  6.  
  7.     Public FaxServer()
  8.       {
  9.         //Constructor..
  10.         m_FaxServer = new FAXCOMEXLib.FaxServer();
  11.             m_FaxServer.Connect(Environment.MachineName);
  12.             m_FaxDocument = new FAXCOMEXLib.FaxDocument();
  13.  
  14.             FaxSvrEnum = (FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE |         FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED);
  15.                 m_FaxServer.ListenToServerEvents(FaxSvrEnum);
  16.                 m_FaxServer.OnOutgoingJobAdded += new         IFaxServerNotify_OnOutgoingJobAddedEventHandler(faxserver_OnOutgoingJobAdded);
  17.                 m_FaxServer.OnOutgoingJobChanged += new         IFaxServerNotify_OnOutgoingJobChangedEventHandler(faxserver_OnOutgoingJobChanged);
  18.     }
  19.  
  20.  
  21.     public void SendFax(FileDetails objFileDetails)
  22.         {
  23.             string RecipientName = "";
  24.             string FaxNumber = "";
  25.             char[] delimiterChars = { ',' };
  26.  
  27.  
  28.             Common.GetSectionInfo(objFileDetails.GetMsgFilePath(), "TO", ref RecipientName);     //Get Receipient Name
  29.             Thread.Sleep(500);
  30.             Common.GetLineInfo(objFileDetails.GetMsgFilePath(), 2, ref FaxNumber);               //Get Fax Number
  31.  
  32.             if (RecipientName == "")
  33.             {
  34.                 Log.Info("Recipient Name missing for File - " + objFileDetails.GetMsgFileName());
  35.             }
  36.  
  37.             if (FaxNumber == "")
  38.             {
  39.                 //Log that fax number is missing and hence could not be sent..
  40.                 return;
  41.             }
  42.  
  43.             string[] arrFaxNumbers = FaxNumber.Split(delimiterChars);
  44.  
  45.             try
  46.             {
  47.                 foreach (string strFaxNumber in arrFaxNumbers)
  48.                 {
  49.  
  50.                     m_FaxDocument.Body = objFileDetails.GetTxtFilePath();
  51.                     m_FaxDocument.Recipients.Add(strFaxNumber, RecipientName);
  52.  
  53.                     m_FaxDocument.DocumentName = objFileDetails.GetMsgFileName();
  54.                     Log.Info("Sending Fax for File - " + objFileDetails.GetMsgFileName());
  55.  
  56.                     //This JobID[0] can be used to store the JobID of the fax job for later reference.
  57.                     string[] JobIDs = (string [])m_FaxDocument.Submit(null);
  58.  
  59.                     //Expecting only 1 JobID as sending Fax to different receipient in a loop..
  60.                     objFileDetails.SetJobID(JobIDs[0].ToString());
  61.                     m_dJobIDList.Add(JobIDs[0].ToString(), objFileDetails);
  62.  
  63.                     //Lets save the JOBID in the MSG file properties.
  64.                     //string fileName = objFileDetails.GetMsgFilePath().Substring(FileFullPath.LastIndexOf("\\") + 1);
  65.                     string fileName = objFileDetails.GetMsgFileName();
  66.                     string filePath = objFileDetails.GetMsgFilePath().Substring(0, objFileDetails.GetMsgFilePath().LastIndexOf("\\"));
  67.  
  68.                     DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();
  69.                     DSOFile.SummaryProperties summary;
  70.                     dso.Open(objFileDetails.GetMsgFilePath(), false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
  71.                     summary = dso.SummaryProperties;
  72.                     summary.Comments = string.Join(",", JobIDs);
  73.                     dso.Close(true);
  74.  
  75.                 }
  76.             }
  77.             catch (Exception ex)
  78.             {
  79.                 Log.Error("Exception occured while sending Fax for File - " + objFileDetails.GetMsgFilePath() + ".Please Investigate." ,ex);
  80.             }
  81.     }
  82. }
  83.  
Please respond asap...thanks in advance..
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,774
#3: Mar 11 '09

re: Faxdocument.submit creates excess Fax Jobs in Fax queue


Since its the Submit method that seems to be problemmatic, it might help if you include that code. I see where you call it in line 57, but that doesn't help.

I do wonder though... The FaxDocument is a member variable? Does this mean it is the same instance of a fax document getting reused over and over? Are its values being cleared between re-uses? Could this be cleaned up to become a new instance of a new document each time?
Reply

Tags
c #, fax, faxcomexlib, faxcomlib, windows fax service, windows xp, windowx xp