Ejemplo n.º 1
0
        public static int QueryFaxList()
        {
            int iCount = 0;
            /////////////////////////////////////接收传真///////////////////////////////////
            FaxService fax = new FaxService();

            string xml = ToServiceXML.getQueryResultForRecvTaskXMLstr(); //拼装xml数据
            string QueryResultForRecvTaskBack = "";
            //string QueryResultForRecvTaskBack1 = "";
            string filePath = ConfigurationManager.AppSettings["UploadFile"].ToString() + "\\";
            while (!String.IsNullOrEmpty(QueryResultForRecvTaskBack = fax.QueryResultForRecvTask(xml)))
            {
                iCount++;
                ; //开始远程调用
                //QueryResultForRecvTaskBack1 = QueryResultForRecvTaskBack.Replace(">", ">\r\n");
                //tb_XML.Text = QueryResultForRecvTaskBack1;

                ///////////////////////////////////解析反馈结果(只接收一个传真)///////////////////////////////////////

                XmlDocument m_XmlDoc = new XmlDocument();
                try
                {
                    m_XmlDoc.LoadXml(QueryResultForRecvTaskBack);
                    XmlNamespaceManager nsmgr = new XmlNamespaceManager(m_XmlDoc.NameTable);
                    XmlNodeList nodeList = m_XmlDoc.ChildNodes;
                    XmlNode node = nodeList.Item(1);
                    string ErrorFlag = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ErrorFlag").InnerText;
                    string ReturnMessage = node.FirstChild.SelectSingleNode("Header").SelectSingleNode("ReturnMessage").InnerText;
                    string ServerTaskID = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("ServerTaskID").InnerText;
                    string FaxNumber = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("FaxNumber").InnerText;
                    string CallingNumber = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("CallingNumber").InnerText;
                    string FaxSID = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("FaxSID").InnerText;
                    string Result = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("Result").InnerText;
                    string StartTime = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("StartTime").InnerText;
                    string CostTime = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("CostTime").InnerText;
                    string NumOfPages = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("NumOfPages").InnerText;
                    string RecvFileName = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("RecvFileName").InnerText;
                    string FileSize = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("FileSize").InnerText;
                    string BillingFee = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("RecvFaxResult").SelectSingleNode("BillingFee").InnerText;
                    string fileName = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("Document").Attributes.GetNamedItem("FileName").Value;
                    string ContentType = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("Document").Attributes.GetNamedItem("ContentType").Value;
                    string EncodingType = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("Document").Attributes.GetNamedItem("EncodingType").Value;
                    string DocumentExtension = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("Document").Attributes.GetNamedItem("DocumentExtension").Value;
                    string filestr = node.FirstChild.SelectSingleNode("QueryResultForRecvTaskResponse").SelectSingleNode("QueryResultForRecvTaskResult").SelectSingleNode("Document").InnerText;
                    string fileUrl = "";
                    filestr = filestr == null ? "" : filestr.Trim();
                    if (!filestr.Equals(""))
                    {
                        ToBase64.SaveDecodingToFile(filestr, filePath + fileName);
                        //file = "文件存放在:" + "d:\\35fax\\" + fileName;
                        fileUrl = UploadFile(filePath + fileName);
                    }

                    AutoReciveFaxDA.SaveAutoReciveFax(fileUrl, "CMSJOB", ServerTaskID, CallingNumber);
                    //string queryResultS = "";
                    //queryResultS = queryResultS + "ErrorFlag :" + ErrorFlag + "\r\n" + "ReturnMessage:" + ReturnMessage + "\r\n" + "ServerTaskID :" + ServerTaskID + "\r\n" +
                    //    "FaxNumber :" + FaxNumber + "\r\n" + "CallingNumber :" + CallingNumber + "\r\n" + "FaxSID :" + FaxSID + "\r\n" + "Result :" + Result + "\r\n" +
                    //    "StartTime :" + StartTime + "\r\n" + "CostTime :" + CostTime + "\r\n" + "NumOfPages :" + NumOfPages + "\r\n" + "RecvFileName :" + RecvFileName + "\r\n" +
                    //    "FileSize :" + FileSize + "\r\n" + "BillingFee :" + BillingFee + "\r\n" + file + "\r\n";
                    //tb_QueryResultForRecvTask.Text = queryResultS;
                }
                catch (Exception ex)
                {
                    ex.GetBaseException();
                }
            }

            return iCount;
        }