示例#1
0
        /// <summary>
        /// 调用BNS接口获取文件,返回为连接地址
        /// </summary>
        /// <param name="_strPubNo"></param>
        /// <param name="_bIsAllFile"></param>
        /// <param name="_eitype"></param>
        /// <returns></returns>
        public string[] GetBnsFiles(string _strPubNo, bool _bIsAllFile, EpdsInterfaceType _eitype)
        {
            logger.DebugFormat("***获取BNS文件,公开号为:[{0}]**开始", _strPubNo);

            //服务
            //EPDS_BSN_ServiceReference.EpdsInterface service = new EPDS_BSN_ServiceReference.EpdsInterface();
            EPDS_BSN_ServiceReference.Service service = new EPDS_BSN_ServiceReference.Service();

            //获取参数
            string publicNo = _strPubNo.Trim();
            string leibie = "";

            //调用服务,返回结果
            //string[] resultURL = service.BnsByPubNo(publicNo, _bIsAllFile);
            string[] resultURL = new string[0] { };
            switch (_eitype)
            {
                case EpdsInterfaceType.ApNo:
                    resultURL = service.BnsByAppNo(publicNo);
                    break;
                case EpdsInterfaceType.PubNo:
                    resultURL = service.BnsByPubNo(publicNo);
                    break;
                case EpdsInterfaceType.CnDocNm:
                    resultURL = service.BnsByPubNo(publicNo);
                    break;
            }

            logger.DebugFormat("***公开号为:[{0}]的BNS文件共[{1}]个", _strPubNo, resultURL.Length);

            return resultURL;
        }
示例#2
0
        /// <summary>
        /// 通过EPDS接口下载PDF文件
        /// </summary>
        /// <param name="_strPubNo"></param>
        /// <param name="_eitype"></param>
        /// <returns></returns>
        private string[] DownLoadPdfFiles(string _strPubNo, EpdsInterfaceType _eitype)
        {
            logger.DebugFormat("***下载BNS文件,公开号为:[{0}]**开始", _strPubNo);

            //获取参数
            string publicNo = _strPubNo.Trim();

            string[] resultURL = new string[0] { };

            try
            {
                resultURL = GetBnsFiles(publicNo, true, _eitype);
                if (resultURL.Length > 0 && resultURL[0].Contains(".pdf"))
                {
                    string strPdfPath = "";
                    switch (_eitype)
                    {
                        case EpdsInterfaceType.ApNo:
                            strPdfPath = Cpic.Cprs2010.Cfg.Data.cnDataService.getImgPdfFilePath(publicNo);
                            break;
                        case EpdsInterfaceType.PubNo:
                            strPdfPath = Cpic.Cprs2010.Cfg.Data.DocdbDataService.getImgPdfFilePath(publicNo);
                            break;
                        case EpdsInterfaceType.CnDocNm:
                            //resultURL = service.BnsByPubNo(publicNo);
                            break;
                    }

                    //如果目录不存在,则创建
                    if (!System.IO.Directory.Exists(strPdfPath))
                    {
                        System.IO.Directory.CreateDirectory(strPdfPath);
                    }

                    System.Net.WebClient mywebclient = new System.Net.WebClient();

                    for (int nIdx = 0; nIdx < resultURL.Length; nIdx++)
                    {
                        mywebclient.DownloadFile(resultURL[nIdx], string.Format(@"{0}\{1}_{2}.pdf", strPdfPath, publicNo, nIdx + 1));

                        resultURL[nIdx] = string.Format(@"{0}\{1}_{2}.pdf", strPdfPath, publicNo, nIdx + 1);
                    }
                }

                logger.DebugFormat("***下载结束,公开号为:[{0}]的BNS文件共[{1}]个", _strPubNo, resultURL.Length);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
            }

            return resultURL;
        }
示例#3
0
        /// <summary>
        /// 获取PDF文件路径,如果不存在,则通过BSN接口下载至本地
        /// </summary>
        /// <param name="_strPubNo"></param>
        /// <param name="_bIsAllFile"></param>
        /// <param name="_eitype"></param>
        /// <returns></returns>
        public string[] GetPdfFilesByPath(string _strPubNo, EpdsInterfaceType _eitype)
        {
            logger.DebugFormat("***获取BNS文件,公开号为:[{0}]**开始", _strPubNo);

            //获取参数
            string publicNo = _strPubNo.Trim();

            string[] resultURL = new string[0] { };
            switch (_eitype)
            {
                case EpdsInterfaceType.ApNo:
                    resultURL = Cpic.Cprs2010.Cfg.Data.cnDataService.getImgPdfFile(publicNo);
                    break;
                case EpdsInterfaceType.PubNo:
                    resultURL = Cpic.Cprs2010.Cfg.Data.DocdbDataService.getImgPdfFile(publicNo);
                    break;
                case EpdsInterfaceType.CnDocNm:
                    //resultURL = service.BnsByPubNo(publicNo);
                    break;
            }

            ////----如果本地获取不到则通过接口获取,并下载至本地存储-----.//////
            if (true && (resultURL.Length < 1))
            {
                resultURL = DownLoadPdfFiles(_strPubNo, _eitype);
            }

            logger.DebugFormat("***公开号为:[{0}]的BNS文件共[{1}]个", _strPubNo, resultURL.Length);

            return resultURL;
        }