|
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..
|