国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

FAXCOM和FXSCOMEX 傳真編程

2019-11-17 02:36:47
字體:
來源:轉載
供稿:網友

FAXCOM和FXSCOMEX 傳真編程

需要引用的dl,如下信息,早起使用的是FXSCOM.DLL,現在微軟提供了相應的擴展,其程序集為,FXSCOMEX.dll

FXSCOMEX.dll 提供跟加健全的方法,可以說所有關于傳真的操作都在這個dll中。

以下是傳真中使用的主要方法:

  1. 首先定義一個封裝傳真人相關信息的Bean
 1  //定義傳真需要封裝的傳真人相關的信息 2   public  class FaxPeopleBean 3     { 4       public string Name; 5       public string FaxNumber; 6       public string Company; 7  8       public DateTime ScheduleTime; 9 10       public FaxPeopleBean()11       {12           ScheduleTime = QLOAParams.DtSqlDbMinValue;13       }14     }
View Code

  2. 發送傳真的方法

 1         public object sendFaxBatchDoc(FaxPeopleBean recipient, FaxPeopleBean sender, List<string> docList) 2         { 3             bool isConnected=false; 4             FaxServer objFaxServer=null; 5             try 6             { 7                 objFaxServer = new FaxServer(); 8                 FaxDocument objFaxDocument = new FaxDocument(); 9                 Object jobIds;//每次發送后,都會返回一個傳真作業id,用于監控此傳真的發送情況10                 //Connect to the fax server11                 objFaxServer.Connect(""); //""代表連接到本地機器服務,也可以使用其它網絡傳真服務器12                 isConnected = true;13                 SetOutgoingQueue(objFaxServer);14                 objFaxDocument.Sender.Name = sender.Name;15                 objFaxDocument.Sender.Company = sender.Company;16                 objFaxDocument.Sender.FaxNumber = sender.FaxNumber;17                 if (sender.ScheduleTime != QLOAParams.DtSqlDbMinValue)18                 {19                     // Specify that the fax is to be sent at a particular time20                     objFaxDocument.ScheduleType = FAXCOMEXLib.FAX_SCHEDULE_TYPE_ENUM.fstSPECIFIC_TIME;21                     //CDate converts the time to the Date data type22                     objFaxDocument.ScheduleTime = sender.ScheduleTime;23                 }24 25                 //Set the fax PRiority26                 objFaxDocument.Priority = FAXCOMEXLib.FAX_PRIORITY_TYPE_ENUM.fptHIGH;27                 // 'Add the recipient28                 objFaxDocument.Recipients.Add(recipient.FaxNumber, recipient.Name);29                 string[] files = docList.ToArray();30                 object bodys = files;31                 objFaxDocument.Bodies = bodys;32                 int result = objFaxDocument.ConnectedSubmit2(objFaxServer, out jobIds);33                 return jobIds;34             }35             finally36             {37                 if (isConnected && objFaxServer!=null)38                 {39                     objFaxServer.Disconnect();40                 }                  41             }42         }

  3. 用于設置傳真的一些屬性,必須連接過后才可以設置

       public void SetOutgoingQueue(FaxServer objFaxServer)        {            FaxOutgoingQueue objFaxOutgoingQueue;            //'Get the outgoing queue object            objFaxOutgoingQueue = objFaxServer.Folders.OutgoingQueue;            //'Refresh the queue object            objFaxOutgoingQueue.Refresh();            objFaxOutgoingQueue.Retries = 10; //重試10次后不再發生            objFaxOutgoingQueue.RetryDelay = 1;            //The Branding property is a Boolean value that indicates whether the fax service generates a brand (banner)            //at the top of outgoing fax transmissions. A brand contains transmission-related information, such as the transmitting            //station identifier, date, time, and page count.            objFaxOutgoingQueue.Branding = true;        }

  4. 取消某個傳真的發送

        public void CancelOutgoingQueue(string faxJobid)        {            FaxServer objFaxServer = new FaxServer();            FaxOutgoingQueue objFaxOutgoingQueue;            FaxOutgoingJob objFaxOutgoingJob;            //'Connect to the fax server            objFaxServer.Connect("");            //'Get the outgoing queue object            objFaxOutgoingQueue = objFaxServer.Folders.OutgoingQueue;            //'Refresh the queue object            objFaxOutgoingQueue.Refresh();            try            {                objFaxOutgoingJob = (FaxOutgoingJob)objFaxOutgoingQueue.GetJob(faxJobid);               //找不到時會發生異常                objFaxOutgoingJob.Cancel();            }            catch { }            objFaxServer.Disconnect();        }

  5.  需要對傳真發送情況進行監控

FAXCOMEXLib.FaxServer _faxServer= new FaxServer();            _faxServer.Connect("");            _faxServer.OnOutgoingJobChanged +=FaxServer_OnOutgoingJobChanged;
 _faxServer.ListenToServerEvents( FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED | FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE;

  6. 監控的方法在這里

     public void FaxServer_OnOutgoingJobChanged(FAXCOMEXLib.IFaxServer pFaxServer, string bstrJobId, FAXCOMEXLib.IFaxJobStatus pJobStatus)        {        //根據pJobStatus 枚舉可以實時的獲取,傳真的發生情況,具體的操作代碼可以寫作這里
     }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柳州市| 和硕县| 灌云县| 佳木斯市| 堆龙德庆县| 江阴市| 离岛区| 永嘉县| 吉林省| 旬阳县| 江西省| 富源县| 洞口县| 沭阳县| 虞城县| 南木林县| 咸宁市| 乌兰浩特市| 尉犁县| 精河县| 巴彦淖尔市| 修武县| 息烽县| 五华县| 崇信县| 万载县| 南和县| 宣武区| 浑源县| 大厂| 宜兰市| 广水市| 元朗区| 福清市| 昭平县| 鄂托克前旗| 广灵县| 伊川县| 荣成市| 永城市| 手游|