Faxdocument.submit creates excess Fax Jobs in Fax queue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mukwizard
    New Member
    • Mar 2009
    • 2

    #1

    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 ..
    Class FaxServer
    {
    private FAXCOMEXLib.Fax Document m_FaxDocument;
    private FAXCOMEXLib.Fax Server m_FaxServer;
    private FAXCOMEXLib.FAX _SERVER_EVENTS_ TYPE_ENUM FaxSvrEnum;

    Public FaxServer()
    {
    //Constructor..
    m_FaxServer = new FAXCOMEXLib.Fax Server();
    m_FaxServer.Con nect(Environmen t.MachineName);
    m_FaxDocument = new FAXCOMEXLib.Fax Document();

    FaxSvrEnum = (FAXCOMEXLib.FA X_SERVER_EVENTS _TYPE_ENUM.fset OUT_QUEUE | FAXCOMEXLib.FAX _SERVER_EVENTS_ TYPE_ENUM.fsetF XSSVC_ENDED);
    m_FaxServer.Lis tenToServerEven ts(FaxSvrEnum);
    m_FaxServer.OnO utgoingJobAdded += new IFaxServerNotif y_OnOutgoingJob AddedEventHandl er(faxserver_On OutgoingJobAdde d);
    m_FaxServer.OnO utgoingJobChang ed += new IFaxServerNotif y_OnOutgoingJob ChangedEventHan dler(faxserver_ OnOutgoingJobCh anged);
    }


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


    Common.GetSecti onInfo(objFileD etails.GetMsgFi lePath(), "TO", ref RecipientName); //Get Receipient Name
    Thread.Sleep(50 0);
    Common.GetLineI nfo(objFileDeta ils.GetMsgFileP ath(), 2, ref FaxNumber); //Get Fax Number

    if (RecipientName == "")
    {
    Log.Info("Recip ient 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.B ody = objFileDetails. GetTxtFilePath( );
    m_FaxDocument.R ecipients.Add(s trFaxNumber, RecipientName);

    m_FaxDocument.D ocumentName = objFileDetails. GetMsgFileName( );
    Log.Info("Sendi ng 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.Ad d(JobIDs[0].ToString(), objFileDetails) ;

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

    DSOFile.OleDocu mentProperties dso = new DSOFile.OleDocu mentProperties( );
    DSOFile.Summary Properties summary;
    dso.Open(objFil eDetails.GetMsg FilePath(), false, DSOFile.dsoFile OpenOptions.dso OptionDefault);
    summary = dso.SummaryProp erties;
    summary.Comment s = string.Join("," , JobIDs);
    dso.Close(true) ;

    }
    }
    catch (Exception ex)
    {
    Log.Error("Exce ption occured while sending Fax for File - " + objFileDetails. GetMsgFilePath( ) + ".Please Investigate." ,ex);
    }
    }
    }
    Any clues guys..
  • mukwizard
    New Member
    • Mar 2009
    • 2

    #2
    Faxdocument.sub mit 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 ..
    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_QUEUE | 		FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED);
    	            m_FaxServer.ListenToServerEvents(FaxSvrEnum);
            	    m_FaxServer.OnOutgoingJobAdded += new 		IFaxServerNotify_OnOutgoingJobAddedEventHandler(faxserver_OnOutgoingJobAdded);
    	            m_FaxServer.OnOutgoingJobChanged += new 		IFaxServerNotify_OnOutgoingJobChangedEventHandler(faxserver_OnOutgoingJobChanged);
    	}
    
    
    	public void SendFax(FileDetails objFileDetails)
            {
                string RecipientName = "";
                string FaxNumber = "";
                char[] delimiterChars = { ',' };
                        
    
                Common.GetSectionInfo(objFileDetails.GetMsgFilePath(), "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(FileFullPath.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);
                }
    	}
    }
    Please respond asap...thanks in advance..
    Last edited by tlhintoq; Mar 11 '09, 03:11 PM. Reason: [CODE] ... [/CODE] tags added

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      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?

      Comment

      Working...