Exemplo n.º 1
0
    public override void Process()
    {
        try
        {
            Start = String.IsNullOrEmpty(Request["start"]) ? 0 : Convert.ToInt32(Request["start"]);
            Size  = String.IsNullOrEmpty(Request["size"]) ? Config.GetInt("imageManagerListSize") : Convert.ToInt32(Request["size"]);
        }
        catch (FormatException)
        {
            State = ResultState.InvalidParam;
            WriteResult();
            return;
        }


        var buildingList = new List <String>();
        var listArray    = new List <String>();

        try
        {
            FtpUtil _ftp = new FtpUtil();
            //int _storeid = CookieBLL.GetStoreIdCookie();
            int    _memid    = 3;
            string localPath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.ProductDescription.ToString(), "Behind_" + _memid.ToString(), DateTime.Now.Year.ToString());
            listArray = _ftp.GetFileList(localPath);

            for (var i = 0; i < listArray.Count; i++)
            {
                listArray[i] = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.ProductDescription.ToString(), "Behind_" + _memid.ToString(), DateTime.Now.Year.ToString(), listArray[i]);
            }

            //var localPath = Server.MapPath(PathToList);

            //buildingList.AddRange(Directory.GetFiles(localPath, "*", SearchOption.AllDirectories)
            //    .Where(x => SearchExtensions.Contains(Path.GetExtension(x).ToLower()))
            //    .Select(x => PathToList + x.Substring(localPath.Length).Replace("\\", "/")));
            //Total = buildingList.Count;
            //FileList = buildingList.OrderBy(x => x).Skip(Start).Take(Size).ToArray();

            FileList = listArray.ToArray();
            Total    = listArray.Count;
        }
        catch (UnauthorizedAccessException)
        {
            State = ResultState.AuthorizError;
        }
        catch (DirectoryNotFoundException)
        {
            State = ResultState.PathNotFound;
        }
        catch (IOException)
        {
            State = ResultState.IOError;
        }
        finally
        {
            WriteResult();
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// 海关商检反馈信息
        /// </summary>
        /// <returns></returns>
        public override string[] GetIcpOutResult()
        {
            FtpUtil ftp = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);

            string[] inflist = null;
            inflist = ftp.GetFileList(config.GZJCIcpInfoTrade.FtpUrl + "out");
            return(inflist);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 海关商检反馈信息
        /// </summary>
        /// <returns></returns>
        public override string[] GetCustomsOutResult(Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型 type)
        {
            FtpUtil ftp = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);

            string[] inflist = null;
            switch (type)
            {
            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品检查:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.REPORT/out");
                break;

            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品订单:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBEBTRADE.REPORT/out");
                break;

            case Hyt.Model.WorkflowStatus.OrderStatus.商检反馈报文类型.商品审核报文:
                inflist = ftp.GetFileList(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.AUDIT/out");
                break;
            }
            return(inflist);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 查询海关订单
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <returns></returns>
        /// <remarks>2016-8-18 杨浩 重构</remarks>
        public override Result SearchCustomsOrder(int orderId)
        {
            var result = new Result()
            {
                Status = true
            };

            try
            {
                var resultDic = new Dictionary <int, string>();

                var    ftp         = new FtpUtil(FTPUri, FTPName, FTPPassword);
                string ftpResponse = "";


                #region

                /*
                 * <?xml version="1.0" encoding="UTF-8"?>
                 * <DocRec>
                 * <Head>
                 * <MessageID><![CDATA[KJDOCREC_KJGGPT2016110315520669308]]></MessageID>
                 * <MessageType><![CDATA[KJDOCREC]]></MessageType>
                 * <Sender><![CDATA[KJGGPT]]></Sender>
                 * <Receiver><![CDATA[GZXINRAO]]></Receiver>
                 * <SendTime><![CDATA[20161103155206]]></SendTime>
                 * <FunctionCode><![CDATA[]]></FunctionCode>
                 * <SignerInfo><![CDATA[]]></SignerInfo>
                 * <Version><![CDATA[2.0]]></Version>
                 * </Head>
                 * <Declaration>
                 * <OrgMessageID><![CDATA[F9F53112-3A28-4912-92EC-BD3085085FC8]]></OrgMessageID>
                 * <OrgMessageType><![CDATA[CEB311Message]]></OrgMessageType>
                 * <OrgSenderID><![CDATA[GZXINRAO]]></OrgSenderID>
                 * <OrgReceiverID><![CDATA[KJCUSTOM]]></OrgReceiverID>
                 * <OrgRecTime><![CDATA[20161103155206]]></OrgRecTime>
                 * <RespondBy>01</RespondBy>
                 * <RespondStatus><![CDATA[F]]></RespondStatus>
                 * <RespondNotes><![CDATA[1.4.2.业务验证失败:
                 * 1.广州海关单号【501_20161029101958】重复申报...
                 * ]]></RespondNotes>
                 * <Status>F</Status>
                 * <Notes><![CDATA[1.4.2.业务验证失败:
                 * 1.广州海关单号【501_20161029101958】重复申报...
                 * ]]></Notes>
                 * </Declaration>
                 * </DocRec>
                 * */

                #endregion
                // 获取文件列表
                //string[] fileList = ftp.GetFileList(FTPUri + "cebout/");
                string[] fileList = ftp.GetFileList(FTPUri + FolderOut);

                if (fileList != null && fileList.Length > 0)
                {
                    foreach (string fileName in fileList)
                    {
                        //Stream stream = ftp.FileStream(FTPUri + "cebout/" + fileName, ref ftpResponse);
                        var stream = ftp.FileStream(FTPUri + FolderOut + fileName, ref ftpResponse);
                        #region 更新订单海关推送状态

                        string xmlData = "";
                        stream.Seek(0, SeekOrigin.Begin);
                        using (var reader = new StreamReader(stream))
                        {
                            xmlData = reader.ReadToEnd();
                        }

                        if (!string.IsNullOrEmpty(xmlData))
                        {
                            int id = 0;
                            var customsOrderLog = new SoCustomsOrderLog();

                            var xml = new XmlDocumentExtender();
                            xml.LoadXml(xmlData);
                            var _xml = xml["CEB312Message"];

                            if (_xml != null)
                            {
                                var orderReturn = _xml["OrderReturn"];

                                //订单编号
                                if (!int.TryParse(orderReturn["orderNo"].InnerText.Split('_')[0], out id))
                                {
                                    continue;
                                }

                                var customsLogInfo = BLL.Order.SoCustomsOrderLogBo.Instance.GetCustomsOrderLogInfo(id, (int)Code);

                                int status = -999;

                                switch (orderReturn["returnStatus"].InnerText)
                                {
                                case "":    // 电子口岸申报中
                                    result.Message = "电子口岸申报中!";
                                    status         = (int)OrderStatus.海关报关状态.处理中;
                                    break;

                                case "2":    // 发送海关成功
                                    status         = (int)OrderStatus.海关报关状态.处理中;
                                    result.Message = orderReturn["returnInfo"].InnerText;
                                    if (customsLogInfo.StatusCode == "3")
                                    {
                                        status         = (int)OrderStatus.海关报关状态.作废;
                                        result.Message = orderReturn["returnInfo"].InnerText;
                                    }
                                    break;

                                case "4":    // 发送海关失败
                                case "100":  // 海关退单
                                    status         = (int)OrderStatus.海关报关状态.失败;
                                    result.Message = "海关退单!";
                                    break;

                                case "120":    // 海关入库
                                    status         = (int)OrderStatus.海关报关状态.成功;
                                    result.Message = "海关入库成功!";
                                    break;

                                default:
                                    status         = (int)OrderStatus.海关报关状态.失败;
                                    result.Message = "海关推送失败!";
                                    break;
                                }
                                customsOrderLog.StatusCode = "";
                                //customsOrderLog.StatusCode = orderReturn["returnStatus"].InnerText;
                                customsOrderLog.StatusMsg = orderReturn["returnInfo"].InnerText;

                                if (resultDic.ContainsKey(orderId))
                                {
                                    resultDic[orderId] = customsOrderLog.StatusMsg;
                                }
                                else
                                {
                                    resultDic.Add(orderId, customsOrderLog.StatusMsg);
                                }


                                BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)status, 2, id);


                                if (customsLogInfo != null)
                                {
                                    customsOrderLog.LastUpdateBy = 0;
                                    if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin)
                                    {
                                        customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                                    }

                                    customsOrderLog.LastUpdateDate = DateTime.Now;
                                    customsOrderLog.ReceiptContent = xmlData;
                                    customsOrderLog.SysNo          = customsLogInfo.SysNo;
                                    customsOrderLog.FileName       = customsLogInfo.FileName;
                                    customsOrderLog.Packets        = customsLogInfo.Packets;
                                    BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog);
                                }
                            }
                            else
                            {
                                _xml = xml["DocRec"];
                                if (_xml != null)
                                {
                                    var status = _xml["Declaration"]["Status"].InnerText;
                                }
                            }
                        }

                        ftp.DeleteFile(FTPUri + FolderOut + fileName);//删除回执文件
                        #endregion
                    }


                    if (resultDic.ContainsKey(orderId))
                    {
                        result.Message = resultDic[orderId];
                    }
                    else
                    {
                        result.Message = "暂无回执";
                    }
                }
                else
                {
                    var customsLogInfo = BLL.Order.SoCustomsOrderLogBo.Instance.GetCustomsOrderLogInfo(orderId, (int)Code);
                    result.Status  = false;
                    result.Message = customsLogInfo != null?customsLogInfo.StatusMsg:"没有找到回执文件,请稍后重试!";
                }
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }