public string UploadFile()
        {
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            int aa = files.Count;

            int             _pictype = FormString.IntSafeQ("pictype");
            HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
            CertificateType _certype = (CertificateType)_pictype;

            if (file != null)
            {
                byte[] bytes = null;
                using (var binaryReader = new BinaryReader(file.InputStream))
                {
                    bytes = binaryReader.ReadBytes(file.ContentLength);
                }
                FtpUtil _ftp        = new FtpUtil();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), "behind_" + memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), Guid.NewGuid().ToString());
                string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return(dicpathfull);
            }
            return("");
        }
        public string MemUploadImg()
        {
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            int             aa       = files.Count;
            int             _pictype = FormString.IntSafeQ("pictype");
            HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
            CertificateType _certype = (CertificateType)_pictype;

            if (file != null)
            {
                byte[] bytes = null;
                using (var binaryReader = new BinaryReader(file.InputStream))
                {
                    bytes = binaryReader.ReadBytes(file.ContentLength);
                }
                FtpUtil _ftp        = new FtpUtil();
                Random  _rd         = new Random();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, _certype.ToString(), memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
            }

            return("");
        }
        public void TestMethod1()
        {
            // bool isCon = FtpUtil.Connect("ftp://192.168.123.128:21/", "root", "root");
            bool result = FtpUtil.UploadFile("D:/image/02.jpg", "ftp://192.168.123.128:21", "root", "root");

            if (result)
            {
            }
        }
        public string CreateStyle()
        {
            string str = "wqweqdasdadq121312";

            byte[]  bytes       = System.Text.Encoding.Default.GetBytes(str);
            FtpUtil _ftp        = new FtpUtil();
            string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), "behind_" + memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), Guid.NewGuid().ToString());
            string  dicpathfull = dicpath + ".html";
            string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);

            _ftp.UploadFile(certifapath, bytes, true);
            return(dicpathfull);
        }
        public string UploadLicense()
        {
            int    memid    = CookieBLL.GetRegisterCookie();
            string memcodes = "";

            if (memid <= 0)
            {
                if (System.Web.HttpContext.Current.Session[CommonKey.MobileNoRegister] != null && System.Web.HttpContext.Current.Session[CommonKey.MobileYZCode] != null)
                {
                    memcodes = System.Web.HttpContext.Current.Session[CommonKey.MobileNoRegister].ToString();
                }
            }
            else
            {
                memcodes      = memid.ToString();
                ViewBag.MemId = memid;
            }
            if (!string.IsNullOrEmpty(memcodes))
            {
                HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
                int             aa       = files.Count;
                int             _pictype = FormString.IntSafeQ("pictype");
                HttpPostedFile  file     = System.Web.HttpContext.Current.Request.Files[0];
                CertificateType _certype = (CertificateType)_pictype;
                if (file != null)
                {
                    byte[] bytes = null;
                    using (var binaryReader = new BinaryReader(file.InputStream))
                    {
                        bytes = binaryReader.ReadBytes(file.ContentLength);
                    }
                    FtpUtil _ftp        = new FtpUtil();
                    Random  _rd         = new Random();
                    string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Certifacate.ToString(), memcodes, DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                    string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
                    string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                    _ftp.UploadFile(certifapath, bytes, true);
                    //return dicpathfull;
                    return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
                }
            }
            return("");
        }
Beispiel #6
0
        public string UploadImageFileForBit()
        {
            int    _pictype = QueryString.IntSafeQ("pictype");
            string filename = QueryString.SafeQ("name");

            using (Stream filesStream = System.Web.HttpContext.Current.Request.InputStream)
            {
                CertificateType _certype = (CertificateType)_pictype;
                byte[]          bytes    = new byte[filesStream.Length];
                filesStream.Read(bytes, 0, bytes.Length);
                // 设置当前流的位置为流的开始
                filesStream.Seek(0, SeekOrigin.Begin);
                FtpUtil _ftp        = new FtpUtil();
                Random  _rd         = new Random();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, _certype.ToString(), memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), _rd.Next(100000, 999999).ToString());
                string  dicpathfull = dicpath + filename.Substring(filename.LastIndexOf("."));
                string  certifapath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
                _ftp.UploadFile(certifapath, bytes, true);
                return("{\"jsonrpc\" : \"2.0\", \"result\" : null, \"pic_raw\" : \"" + dicpathfull + "\"}");
            }

            return("");
        }
        public string UploadProductImages()
        {
            HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            int aa = files.Count;

            HttpPostedFile file = System.Web.HttpContext.Current.Request.Files[0];

            if (file != null)
            {
                byte[] bytes = null;
                using (var binaryReader = new BinaryReader(file.InputStream))
                {
                    bytes = binaryReader.ReadBytes(file.ContentLength);
                }
                FtpUtil _ftp        = new FtpUtil();
                string  dicpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.Product.ToString(), "Behind-" + memid.ToString(), DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("dd"), Guid.NewGuid().ToString()); //生成图片路径
                string  dicpathfull = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));                                                                                                                                                                                                        //指明图片的扩展名
                string  picpath     = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);                                                                                                                                                                              //指明上传路径

                _ftp.UploadFile(picpath, bytes, true);
                return(dicpathfull);
            }
            return("");
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="IcpType"></param>
        /// <param name="ProductSysNoList"></param>
        /// <returns></returns>
        /// <remarks>2016-4-1 王耀发 创建</remarks>
        public override Result PushGoods(string ProductSysNoList)
        {
            Result result = new Result();

            CIcp model = new CIcp();

            model.IcpType = (int)Model.CommonEnum.商检.广州白云机场;
            List <CIcpGoodsItem> CIcpGoodsItemList = new List <CIcpGoodsItem>();

            string[] sArray = ProductSysNoList.Split(',');

            foreach (string i in sArray)
            {
                int ProductSysNo             = int.Parse(i);
                IcpBYJiChangGoodsInfo Entity = IcpBo.Instance.GetIcpBYJiChangGoodsInfoEntityByPid(ProductSysNo);
                CIcpGoodsItemList.Add(new CIcpGoodsItem()
                {
                    IcpType      = model.IcpType,
                    ProductSysNo = ProductSysNo,
                    EntGoodsNo   = Entity.EntGoodsNo
                });
            }
            Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.InternationalTrade internationaltrade = new Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.InternationalTrade();
            internationaltrade.Head        = new Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.Head();
            internationaltrade.Declaration = new Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.Declaration();
            internationaltrade.Declaration.GoodsRegHead = new Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.GoodsRegHead();
            internationaltrade.Declaration.GoodsRegList = new Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.GoodsRegList();
            internationaltrade.Declaration.GoodsRegList.GoodsContentList = new List <Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.GoodsContent>();
            //生成最大流水号
            string MaxSerialNumber = GetMaxSerialNumberByMType(model.IcpType.ToString(), config.GZJCIcpInfoTrade.GoodsMessageType);
            string fileName        = config.GZJCIcpInfoTrade.GoodsMessageType + "_" + config.GZJCIcpInfoTrade.Sender + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + MaxSerialNumber;

            internationaltrade.Head = SetIcpGoodsHead(fileName, config.GZJCIcpInfoTrade.GoodsMessageType);
            internationaltrade.Declaration.GoodsRegHead = SetIcpGoodsHeadData();

            List <Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.GoodsContent> GoodsContentList = SetIcpGoodsBodyData(CIcpGoodsItemList);

            if (GoodsContentList.Count != 0)
            {
                internationaltrade.Declaration.GoodsRegList.GoodsContentList = SetIcpGoodsBodyData(CIcpGoodsItemList);
                string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Hyt.Model.Icp.GZBaiYunJiChang.Goods.Goods.InternationalTrade>(internationaltrade);
                str = str.Replace("encoding=\"utf-16\"", "encoding=\"UTF-8\"");

                FtpUtil ftp       = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);
                string  msg       = "";
                string  MessageID = fileName;
                fileName = fileName + ".xml";
                try
                {
                    ftp.UploadFile(config.GZJCIcpInfoTrade.FtpUrl + "in", fileName, Encoding.UTF8.GetBytes(str), out msg);
                    //新增商检表信息
                    int UserSysNo = AdminAuthenticationBo.Instance.Current.Base.SysNo;
                    model.SourceSysNo    = 0;
                    model.MessageID      = MessageID;
                    model.MessageType    = config.GZJCIcpInfoTrade.GoodsMessageType;
                    model.SerialNumber   = MaxSerialNumber;
                    model.XmlContent     = str;
                    model.CreatedBy      = UserSysNo;
                    model.CreatedDate    = DateTime.Now;
                    model.Status         = (int)IcpStatus.商品商检推送状态.已推送;
                    model.LastUpdateBy   = UserSysNo;
                    model.LastUpdateDate = DateTime.Now;
                    model.SysNo          = IcpDao.Instance.Insert(model);
                    if (model.SysNo > 0) //
                    {
                        if (CIcpGoodsItemList != null)
                        {
                            foreach (var item in CIcpGoodsItemList)
                            {
                                var m = new CIcpGoodsItem
                                {
                                    SourceSysNo    = 0,
                                    IcpType        = model.IcpType,
                                    MessageID      = MessageID,
                                    IcpGoodsSysNo  = model.SysNo,
                                    ProductSysNo   = item.ProductSysNo,
                                    EntGoodsNo     = item.EntGoodsNo,
                                    CreatedBy      = UserSysNo,
                                    CreatedDate    = DateTime.Now,
                                    LastUpdateBy   = UserSysNo,
                                    LastUpdateDate = DateTime.Now
                                };
                                IcpDao.Instance.InsertIcpGoodsItem(m);
                            }
                        }
                    }
                    result.Status  = true;
                    result.Message = internationaltrade.Head.MessageID;
                }
                catch (Exception ex)
                {
                    result.Status  = false;
                    result.Message = ex.Message;
                }
            }
            else
            {
                result.Status  = false;
                result.Message = "商品备案信息无效";
            }
            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// 订单备案
        /// </summary>
        /// <returns></returns>
        /// <remarks>2016-3-21 王耀发 添加</remarks>
        public override Result PushOrder(int OrderSysNo)
        {
            Result result  = new Result();
            int    IcpType = (int)Model.CommonEnum.商检.广州白云机场;

            Hyt.Model.Icp.GZBaiYunJiChang.Order.InternationalTrade internationaltrade = new Hyt.Model.Icp.GZBaiYunJiChang.Order.InternationalTrade();
            internationaltrade.Head                  = new Hyt.Model.Icp.GZBaiYunJiChang.Order.Head();
            internationaltrade.Declaration           = new Hyt.Model.Icp.GZBaiYunJiChang.Order.Declaration();
            internationaltrade.Declaration.OrderHead = new Hyt.Model.Icp.GZBaiYunJiChang.Order.OrderHead();
            internationaltrade.Declaration.OrderList = new Hyt.Model.Icp.GZBaiYunJiChang.Order.OrderList();
            internationaltrade.Declaration.OrderList.OrderContentList = new List <Hyt.Model.Icp.GZBaiYunJiChang.Order.OrderContent>();

            //生成最大流水号
            string MaxSerialNumber = GetMaxSerialNumberByMType(IcpType.ToString(), config.GZJCIcpInfoTrade.OrderMessageType);
            string fileName        = config.GZJCIcpInfoTrade.OrderMessageType + "_" + config.GZJCIcpInfoTrade.Sender + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + MaxSerialNumber;

            internationaltrade.Head = SetIcpOrderHead(fileName, config.GZJCIcpInfoTrade.OrderMessageType);
            internationaltrade.Declaration.OrderHead = SetIcpOrderHeadData();
            internationaltrade.Declaration.OrderList.OrderContentList.Add(SetOrderContent(OrderSysNo));

            string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Hyt.Model.Icp.GZBaiYunJiChang.Order.InternationalTrade>(internationaltrade);

            str = str.Replace("encoding=\"utf-16\"", "encoding=\"UTF-8\"");

            FtpUtil ftp       = new FtpUtil(config.GZJCIcpInfoTrade.FtpUrl, config.GZJCIcpInfoTrade.FtpName, config.GZJCIcpInfoTrade.FtpPassword);
            string  msg       = "";
            string  MessageID = fileName;

            fileName = fileName + ".xml";

            try
            {
                ftp.UploadFile(config.GZJCIcpInfoTrade.FtpUrl + "in", fileName, Encoding.UTF8.GetBytes(str), out msg);

                //新增商检表信息
                int  UserSysNo = AdminAuthenticationBo.Instance.Current.Base.SysNo;
                CIcp model     = new CIcp();
                model.SourceSysNo    = OrderSysNo;
                model.IcpType        = IcpType;
                model.MessageID      = MessageID;
                model.MessageType    = config.GZJCIcpInfoTrade.OrderMessageType;
                model.SerialNumber   = MaxSerialNumber;
                model.XmlContent     = str;
                model.CreatedBy      = UserSysNo;
                model.CreatedDate    = DateTime.Now;
                model.Status         = (int)IcpStatus.商品商检推送状态.已推送;
                model.LastUpdateBy   = UserSysNo;
                model.LastUpdateDate = DateTime.Now;
                model.SysNo          = IcpDao.Instance.Insert(model);

                var soItems = SoOrderBo.Instance.GetOrderItemsByOrderId(OrderSysNo);
                foreach (SoOrderItem item in soItems)
                {
                    var m = new CIcpGoodsItem
                    {
                        SourceSysNo    = OrderSysNo,
                        IcpType        = model.IcpType,
                        MessageID      = MessageID,
                        IcpGoodsSysNo  = model.SysNo,
                        ProductSysNo   = item.ProductSysNo,
                        EntGoodsNo     = "None",
                        CreatedBy      = UserSysNo,
                        CreatedDate    = DateTime.Now,
                        LastUpdateBy   = UserSysNo,
                        LastUpdateDate = DateTime.Now
                    };
                    IcpDao.Instance.InsertIcpGoodsItem(m);
                }
                //更新订单的商检推送状态
                SoOrderBo.Instance.UpdateOrderGZJCStatus(OrderSysNo, (int)OrderStatus.销售单推送状态.已推送);
                result.Status  = true;
                result.Message = internationaltrade.Head.MessageID;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// 上传订单至海关
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <param name="warehouseSysNo">仓库编号</param>
        /// <param name="customsLogInfo">海关日志</param>
        /// <param name="orderStatus">订单状态 S-订单新增,C-订单取消</param>
        /// <returns></returns>
        /// <remarks>2016-3-23 杨浩 创建</remarks>
        private Result Upload(int orderId, int warehouseSysNo, SoCustomsOrderLog customsLogInfo, string orderStatus = "S")
        {
            var result = new Result()
            {
                Status = false
            };

            //xml文件名
            string fileName = "";
            //获取当前时间
            int    Year     = DateTime.Now.Year;
            int    Month    = DateTime.Now.Month;
            int    Day      = DateTime.Now.Day;
            int    Hour     = DateTime.Now.Hour;
            int    Minute   = DateTime.Now.Minute;
            int    Second   = DateTime.Now.Second;
            string SendTime = Year.ToString() + (Month < 10 ? "0" + Month.ToString() : Month.ToString()) + (Day < 10 ? "0" + Day.ToString() : Day.ToString());

            SendTime += (Hour < 10 ? "0" + Hour.ToString() : Hour.ToString()) + (Minute < 10 ? "0" + Minute.ToString() : Minute.ToString()) + (Second < 10 ? "0" + Second.ToString() : Second.ToString());
            //if (customsLogInfo == null)
            //{
            string MessageIDNo = BLL.Basic.ReceiptNumberBo.Instance.GetCustomsOrderNo();

            fileName = MessageType + SendTime + MessageIDNo;
            //}
            //else
            //{
            //    fileName = customsLogInfo.FileName;
            //}

            var orderInfo   = BLL.Order.SoOrderBo.Instance.GetEntityNoCache(orderId);
            var receiveInfo = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(orderInfo.ReceiveAddressSysNo);

            #region  载数据

            string OrderId     = orderId.ToString();
            string IEFlag      = "I";                         //进出口标识 I:进口;E:出口
            string OrderStatus = orderStatus;                 // "S";//订单状态 S-订单新增,C-订单取消
            string EntRecordNo = XinYinSenderID;              //电商平台企业备案号(代码)
            //string EntRecordName = "深圳信营贸易有限公司";// "深圳市信营国际电子商务有限公司";//电商平台企业名称
            string EntRecordName      = config.EntRecordName; // "深圳市信营国际电子商务有限公司";//电商平台企业名称
            string OrderName          = receiveInfo.Name;     //订单人姓名
            string OrderDocType       = "01";                 //订单人证件类型01:身份证、02:护照、03:其他
            string OrderDocId         = receiveInfo.IDCardNo;
            string OrderPhone         = receiveInfo.MobilePhoneNumber;
            string OrderGoodTotal     = (orderInfo.ProductAmount + orderInfo.ProductChangeAmount).ToString("F2");
            string OrderGoodTotalCurr = "142";                                       //订单商品总额币制,人民币(CNY/142)
            string Freight            = orderInfo.FreightAmount.ToString("F2");      //运费
            string FreightCurr        = "142";                                       //运费币制
            string Tax       = orderInfo.TaxFee.ToString("F2");                      //行邮税
            string TaxCurr   = "142";
            string Note      = "";                                                   //备注
            string OrderDate = orderInfo.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"); //订单日期,精确到秒 YYYY-MM-DD:HH:MM:SS


            var onlinePaymentFilter = new Hyt.Model.Parameter.ParaOnlinePaymentFilter()
            {
                OrderSysNo = orderId,
                Id         = 1
            };
            var onlinePayments = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePayments(onlinePaymentFilter).Rows;

            if (onlinePayments == null || (onlinePayments != null && onlinePayments.Count() <= 0))
            {
                result.Status  = false;
                result.Message = "订单没有支付单!";
                return(result);
            }

            string orderNo = onlinePayments[0].BusinessOrderSysNo;

            if (string.IsNullOrEmpty(orderNo))
            {
                result.Status  = false;
                result.Message = "订单编号异常!";
                return(result);
            }


            string strxml = "";
            strxml += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
            strxml += "<Manifest>";
            strxml += "<Head>";
            strxml += "<MessageID>" + fileName + "</MessageID>";
            strxml += "<MessageType>" + MessageType + "</MessageType>";
            strxml += "<SenderID>" + XinYinSenderID + "</SenderID>";
            strxml += "<SendTime>" + SendTime + "</SendTime>";
            strxml += "<Version>" + Version + "</Version>";
            strxml += "</Head>";
            strxml += "<Declaration>";
            strxml += "<EOrder>";
            strxml += "<OrderId>" + orderNo + "</OrderId>";
            strxml += "<IEFlag>" + IEFlag + "</IEFlag>";
            strxml += "<OrderStatus>" + OrderStatus + "</OrderStatus>";
            strxml += "<EntRecordNo>" + EntRecordNo + "</EntRecordNo>";
            strxml += "<EntRecordName>" + EntRecordName + "</EntRecordName>";
            strxml += "<OrderName>" + OrderName + "</OrderName>";
            strxml += "<OrderDocType>" + OrderDocType + "</OrderDocType>";
            strxml += "<OrderDocId>" + OrderDocId + "</OrderDocId>";
            strxml += "<OrderPhone>" + OrderPhone + "</OrderPhone>";
            strxml += "<OrderGoodTotal>" + OrderGoodTotal + "</OrderGoodTotal>";
            strxml += "<OrderGoodTotalCurr>" + OrderGoodTotalCurr + "</OrderGoodTotalCurr>";
            strxml += "<Freight>" + Freight + "</Freight>";
            strxml += "<FreightCurr>" + FreightCurr + "</FreightCurr>";
            strxml += "<Tax>" + Tax + "</Tax>";
            strxml += "<TaxCurr>" + TaxCurr + "</TaxCurr>";
            strxml += "<Note>" + Note + "</Note>";
            strxml += "<OrderDate>" + OrderDate + "</OrderDate>";
            strxml += "</EOrder>";
            strxml += "<EOrderGoods>";

            var orderItemList = BLL.Order.SoOrderBo.Instance.GetOrderItemsByOrderId(orderId);

            foreach (var item in orderItemList)
            {
                var warehouseProductInfo = Hyt.BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(warehouseSysNo, item.ProductSysNo);
                if (warehouseProductInfo == null)
                {
                    result.Message = "订单中有产品(系统编号:" + item.ProductSysNo + ")在仓库中不存在!";
                    return(result);
                }

                string customsNo = warehouseProductInfo.CustomsNo;
                if (customsNo == "")
                {
                    result.Message = "订单中有产品(系统编号:" + item.ProductSysNo + ")无海关备案号!";
                    return(result);
                }

                strxml += "<EOrderGood>";
                strxml += "<GNo>" + item.SysNo + "</GNo>";
                strxml += "<ChildOrderNo></ChildOrderNo>";
                strxml += "<StoreRecordNo>" + EntRecordNo + "</StoreRecordNo>";
                strxml += "<StoreRecordName>" + EntRecordName + "</StoreRecordName>";
                strxml += "<CopGNo>" + item.ProductSysNo + "</CopGNo>";
                strxml += "<CustomsListNO>" + warehouseProductInfo.CustomsNo + "</CustomsListNO>"; //商品海关备案号
                strxml += "<DecPrice>" + item.SalesUnitPrice + "</DecPrice>";
                strxml += "<Unit>001</Unit>";                                                      //计量单位(件/011)
                strxml += "<GQty>" + item.Quantity + "</GQty>";                                    //商品数量
                strxml += "<DeclTotal>" + (item.SalesAmount + item.ChangeAmount).ToString("F2") + "</DeclTotal>";
                strxml += "<Notes></Notes>";
                strxml += "</EOrderGood>";
            }
            strxml += "</EOrderGoods>";
            strxml += "</Declaration>";
            strxml += "</Manifest>";

            #endregion
            var customsOrderLog = new SoCustomsOrderLog();

            if (customsLogInfo != null)
            {
                customsOrderLog = customsLogInfo;
            }

            customsOrderLog.Packets = strxml;

            strxml = Encrypt(strxml);
            //上传xml文件
            MemoryStream stream          = new MemoryStream();
            byte[]       buffer          = Encoding.Default.GetBytes(strxml);
            string       msg             = "";
            string       _ftpImageServer = FtpUrl + "UPLOAD/";


            customsOrderLog.StatusCode   = "";
            customsOrderLog.StatusMsg    = "处理中";
            customsOrderLog.LastUpdateBy = 0;
            if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin)
            {
                customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
            }
            customsOrderLog.LastUpdateDate = DateTime.Now;
            customsOrderLog.CreateDate     = DateTime.Now;
            customsOrderLog.CreatedBy      = customsOrderLog.LastUpdateBy;
            customsOrderLog.ReceiptContent = "";
            customsOrderLog.FileName       = fileName;
            customsOrderLog.OrderSysNo     = orderId;

            FtpUtil ftp = new FtpUtil(_ftpImageServer, FtpUserName, FtpPassword);
            //上传xml文件
            ftp.UploadFile(_ftpImageServer, customsOrderLog.FileName + ".xml", buffer, out msg);
            //if (customsLogInfo != null)
            //{
            //    customsOrderLog.CreateDate = customsLogInfo.CreateDate;
            //    customsOrderLog.CreatedBy = customsLogInfo.CreatedBy;
            //    customsOrderLog.SysNo = customsLogInfo.SysNo;
            //    BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog);
            //}
            if (customsLogInfo == null)
            {
                BLL.Order.SoCustomsOrderLogBo.Instance.AddCustomsOrderLog(customsOrderLog);
            }
            else
            {
                BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog);
            }
            if (orderStatus == "S")
            {
                BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.处理中, 2, orderId);
            }
            else
            {
                BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.作废, 2, orderId);
            }

            result.Status  = true;
            result.Message = "提交成功!";

            return(result);
        }
Beispiel #11
0
        public override Model.Result AddOrderTrade(int orderSysno)
        {
            Result result = new Result();

            try
            {
                var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);

                var        config   = Hyt.BLL.Config.Config.Instance.GetAnnaConfig();
                CrCustomer customer = Hyt.BLL.CRM.CrCustomerBo.Instance.GetModel(order.CustomerSysNo);

                WhWarehouse warehouseMod = Hyt.BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);

                BsArea wareDistrictEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(warehouseMod.AreaSysNo);
                BsArea wareCityEntity     = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(wareDistrictEntity.ParentSysNo);
                BsArea wareProvinceEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(wareDistrictEntity.ParentSysNo);

                SoReceiveAddress srenity      = Hyt.BLL.Order.OutboundReturnBo.Instance.GetSoReceiveAddressBysoOrderSysNo(order.SysNo);
                string           buyer_idcard = "";
                if (!string.IsNullOrEmpty(srenity.IDCardNo))
                {
                    buyer_idcard = srenity.IDCardNo.Trim().ToUpper();
                }

                BsArea DistrictEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(srenity.AreaSysNo);
                string District       = DistrictEntity.AreaName.Trim();
                BsArea CityEntity     = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(DistrictEntity.ParentSysNo);
                string City           = CityEntity.AreaName.Trim();
                BsArea ProvinceEntity = Hyt.BLL.Basic.BasicAreaBo.Instance.GetArea(CityEntity.ParentSysNo);
                string Province       = ProvinceEntity.AreaName.Trim();

                CBFnOnlinePayment payment = FinanceBo.Instance.GetOnPaymentBySourceSysNo(order.SysNo);
                payment.CusPaymentCode = config.PaymentCode;
                IList <CBSoOrderItem> datao = SoOrderBo.Instance.GetCBOrderItemsByOrderId(order.SysNo);

                LgDeliveryType deliveryType = Hyt.BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                order.OrderItemList = new List <SoOrderItem>();
                List <int> ProSysNo = new List <int>();
                foreach (CBSoOrderItem item in datao)
                {
                    ProSysNo.Add(item.ProductSysNo);

                    order.OrderItemList.Add(item);
                }
                IList <CBPdProduct> productList = Hyt.BLL.Product.PdProductBo.Instance.GetProductInfoList(ProSysNo);
                foreach (var mod in productList)
                {
                    var tempitem = datao.First(p => p.ProductSysNo == mod.SysNo);
                    if (tempitem != null)
                    {
                        tempitem.OrginCountry = Hyt.BLL.Basic.OriginBo.Instance.GetEntity(mod.OriginSysNo).Origin_Name;
                    }
                }

                Order pushOrder = new Order();
                pushOrder.OrderHead             = new OrderHead();
                pushOrder.OrderPaymentLogistics = new OrderPaymentLogistics();
                pushOrder.itemList = new List <OrderList>();
                BindOrderHeadData(order, pushOrder.OrderHead, payment, srenity, buyer_idcard, District, City, Province,
                                  warehouseMod, wareDistrictEntity, wareCityEntity, wareProvinceEntity);
                BindOrderItemListData(datao, pushOrder.itemList);
                OrderPaymentLogistic(pushOrder.OrderPaymentLogistics, payment, deliveryType);

                string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Order>(pushOrder);
                str = str.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
                str = str.Replace("Root", "ROOT");
                str = str.Replace("<itemList>", "");
                str = str.Replace("</itemList>", "");

                FtpUtil ftp      = new FtpUtil(config2.RequestUrl, config2.Account, config2.Password);
                string  msg      = "";
                string  fileName = DateTime.Now.ToString("yyyyMMddhhmmssffff") + ".xml";
                try
                {
                    ftp.UploadFile(config2.RequestUrl, fileName, Encoding.UTF8.GetBytes(str), out msg);
                }
                catch (Exception ex)
                {
                    result.Status  = false;
                    result.Message = ex.Message;
                }

                result.Message = str;
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(result);
        }
    public override void Process()
    {
        byte[] uploadFileBytes = null;
        string uploadFileName  = null;

        HttpPostedFile file = null;

        if (UploadConfig.Base64)
        {
            uploadFileName  = UploadConfig.Base64Filename;
            uploadFileBytes = Convert.FromBase64String(Request[UploadConfig.UploadFieldName]);
        }
        else
        {
            file           = Request.Files[UploadConfig.UploadFieldName];
            uploadFileName = file.FileName;

            if (!CheckFileType(uploadFileName))
            {
                Result.State = UploadState.TypeNotAllow;
                WriteResult();
                return;
            }
            if (!CheckFileSize(file.ContentLength))
            {
                Result.State = UploadState.SizeLimitExceed;
                WriteResult();
                return;
            }

            uploadFileBytes = new byte[file.ContentLength];

            try
            {
                file.InputStream.Read(uploadFileBytes, 0, file.ContentLength);
            }
            catch (Exception)
            {
                Result.State = UploadState.NetworkError;
                WriteResult();
            }
        }


        try
        {
            int _memid = memid;

            FtpUtil _ftp           = new FtpUtil();
            string  dicpath        = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesSystemName, ImagesSysPathCode.ProductDescription.ToString(), "Behind_" + _memid.ToString(), DateTime.Now.ToString("yyyy"), Guid.NewGuid().ToString());
            string  dicpathfull    = dicpath + file.FileName.Substring(file.FileName.LastIndexOf("."));
            string  productpicpath = FilePath.PathCombine(ConfigCore.Instance.ConfigCommonEntity.FtpImagesRootPath, dicpathfull);
            _ftp.UploadFile(productpicpath, uploadFileBytes, true);
            Result.Url   = dicpathfull;
            Result.State = UploadState.Success;
        }
        catch (Exception ex)
        {
            Result.State        = UploadState.FileAccessError;
            Result.ErrorMessage = ex.Message;
        }
        finally
        {
            WriteResult();
        }

        //return dicpathfull;


        //Result.OriginFileName = uploadFileName;

        //var savePath = PathFormatter.Format(uploadFileName, UploadConfig.PathFormat);
        //var localPath = Server.MapPath(savePath);
        //try
        //{
        //    if (!Directory.Exists(Path.GetDirectoryName(localPath)))
        //    {
        //        Directory.CreateDirectory(Path.GetDirectoryName(localPath));
        //    }
        //    File.WriteAllBytes(localPath, uploadFileBytes);
        //    Result.Url = savePath;
        //    Result.State = UploadState.Success;
        //}
        //catch (Exception e)
        //{
        //    Result.State = UploadState.FileAccessError;
        //    Result.ErrorMessage = e.Message;
        //}
        //finally
        //{
        //    WriteResult();
        //}
    }
Beispiel #13
0
        /// <summary>
        /// 推送订单
        /// </summary>
        /// <returns></returns>
        /// <remarks>2016-3-21 王耀发 创建</remarks>
        public override Result PushOrder(int soOrderSysNo)
        {
            Result result  = new Result();
            int    IcpType = (int)Model.CommonEnum.商检.广州南沙;

            Hyt.Model.Manual.SoOrderMods order = SoOrderBo.Instance.GetSoOrderMods(soOrderSysNo);
            order.ReceiveAddress         = SoOrderBo.Instance.GetOrderReceiveAddress2(order.ReceiveAddressSysNo);
            order.ReceiverProvince       = ((Hyt.Model.Manual.SoReceiveAddressMod)order.ReceiveAddress).ReceiverProvince.Trim();
            order.ReceiverCity           = ((Hyt.Model.Manual.SoReceiveAddressMod)order.ReceiveAddress).ReceiverCity.Trim();
            order.ReceiverArea           = ((Hyt.Model.Manual.SoReceiveAddressMod)order.ReceiveAddress).ReceiverArea.Trim();
            order.OrderItemList          = SoOrderBo.Instance.GetOrderItemsByOrderId(order.SysNo);
            order.OrderInvoice           = SoOrderBo.Instance.GetFnInvoice(order.InvoiceSysNo);
            order.ReceiptVoucher         = Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherByOrder(soOrderSysNo);
            order.ReceiptVoucherItemList = Hyt.BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(order.ReceiptVoucher.SysNo);

            IList <int> proIdList = new List <int>();
            List <Hyt.Model.Manual.SoOrderItemByPro> soProList = new List <Model.Manual.SoOrderItemByPro>();

            foreach (var item in order.OrderItemList)
            {
                proIdList.Add(item.ProductSysNo);
            }

            IList <IcpGZNanShaGoodsInfo> proList = Hyt.BLL.Product.PdProductBo.Instance.GetIcpGZNanShaGoodsInfoList(proIdList);

            if (order.OrderItemList.Count != proList.Count)
            {
                return(new Result()
                {
                    Message = "订单明细有尚未备案的商品,推送失败", Status = false
                });
            }
            foreach (var proItem in proList)
            {
                SoOrderItem item = order.OrderItemList.First(p => p.ProductSysNo == proItem.ProductSysNo);

                Hyt.Model.Manual.SoOrderItemByPro mod = new Model.Manual.SoOrderItemByPro();
                mod.GCode        = proItem.Gcode;
                mod.ProductSysNo = proItem.ProductSysNo;
                mod.Hscode       = proItem.HSCode;
                mod.CiqGoodsNo   = proItem.CIQGoodsNo;
                mod.ProductName  = proItem.Gname;
                mod.Brand        = proItem.Brand;
                mod.Spec         = proItem.Spec;
                mod.Origin       = proItem.AssemCountry;
                mod.QtyUnit      = proItem.Unit;
                mod.Qty          = item.Quantity.ToString();
                mod.DecPrice     = item.SalesUnitPrice;
                mod.DecTotal     = item.SalesAmount;
                mod.SellWebSite  = proItem.SellWebSite;
                soProList.Add(mod);
            }

            ////测试
            //foreach (var proItem in order.OrderItemList)
            //{
            //    var product = Hyt.BLL.Product.PdProductBo.Instance.GetProduct(proItem.ProductSysNo);
            //    //获取启邦商品备案信息
            //    var IcpQiBang = Hyt.BLL.ApiIcq.IcpBo.Instance.GetIcpQiBangGoodsInfoEntityByPid(proItem.ProductSysNo);

            //    Hyt.Model.Manual.SoOrderItemByPro mod = new Model.Manual.SoOrderItemByPro();
            //    mod.GCode = IcpQiBang.item_code;
            //    mod.ProductSysNo = proItem.ProductSysNo;
            //    mod.Hscode = IcpQiBang.item_id;
            //    mod.CiqGoodsNo = IcpQiBang.ciqgoodsno;
            //    mod.ProductName = IcpQiBang.item_name;
            //    mod.Brand = Hyt.BLL.Product.PdBrandBo.Instance.GetEntity(product.BrandSysNo).Name;
            //    mod.Spec = IcpQiBang.item_spec;
            //    mod.Origin = IcpQiBang.origincountry;
            //    mod.QtyUnit = "克";
            //    mod.Qty = proItem.Quantity.ToString();
            //    mod.DecPrice = proItem.SalesUnitPrice;
            //    mod.DecTotal = proItem.SalesAmount;
            //    mod.SellWebSite = "http://www.gaopin999.com/";
            //    soProList.Add(mod);

            //}


            Hyt.Model.Icp.GZNanSha.Order.Root root = new Hyt.Model.Icp.GZNanSha.Order.Root();
            root.head                    = new Model.Icp.GZNanSha.Head();
            root.body                    = new Model.Icp.GZNanSha.Order.OrderBody();
            root.body.record             = new Model.Icp.GZNanSha.Order.OrderBodyRecord();
            root.body.record.cusOrderMod = new Model.Icp.GZNanSha.Order.CustomOrderMod();
            root.body.record.cusOrderMod.orderGoodsList = new Model.Icp.GZNanSha.Order.OrderGoodsList();

            //生成最大流水号
            string   MaxSerialNumber = GetMaxSerialNumberByMType(IcpType.ToString(), config.NSIcpInfo.OrderMessageType);
            DateTime now             = DateTime.Now;
            string   strDate         = now.ToString("yyyyMMddHHmmssfff");
            string   strDateMid      = now.ToString("yyyyMMddHHmmss");
            //string fileName = config.NSIcpInfo.OrderMessageType + "_" + strDate + MaxSerialNumber;
            string fileName  = config.NSIcpInfo.OrderMessageType + "_" + strDate;
            string MessageID = "ICIP" + strDateMid;

            SetCustomOrderHead(MessageID, root.head);
            BindCusOrderData(order, root.body.record.cusOrderMod);
            BindCusOrderGoodsData(soProList, root.body.record.cusOrderMod.orderGoodsList);

            string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Model.Icp.GZNanSha.Order.Root>(root);

            str = str.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
            str = str.Replace("Root", "ROOT");
            FtpUtil ftp = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);
            string  msg = "";

            fileName = fileName + ".xml";
            try
            {
                ftp.UploadFile(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBEBTRADE.REPORT/in", fileName, Encoding.UTF8.GetBytes(str), out msg);
                //新增商检表信息
                int  UserSysNo = AdminAuthenticationBo.Instance.Current.Base.SysNo;
                CIcp model     = new CIcp();
                model.SourceSysNo    = soOrderSysNo;
                model.IcpType        = Hyt.Model.CommonEnum.商检.广州南沙.GetHashCode();
                model.MessageID      = MessageID;
                model.MessageType    = config.NSIcpInfo.OrderMessageType;
                model.SerialNumber   = MaxSerialNumber;
                model.XmlContent     = str;
                model.Status         = (int)IcpStatus.商品商检推送状态.已推送;
                model.CreatedBy      = UserSysNo;
                model.CreatedDate    = DateTime.Now;
                model.LastUpdateBy   = UserSysNo;
                model.LastUpdateDate = DateTime.Now;
                model.SysNo          = IcpDao.Instance.Insert(model);
                //插入明细
                foreach (var proItem in proList)
                {
                    var m = new CIcpGoodsItem
                    {
                        SourceSysNo    = soOrderSysNo,
                        IcpType        = model.IcpType,
                        MessageID      = MessageID,
                        IcpGoodsSysNo  = model.SysNo,
                        ProductSysNo   = proItem.ProductSysNo,
                        EntGoodsNo     = "None",
                        CreatedBy      = UserSysNo,
                        CreatedDate    = DateTime.Now,
                        LastUpdateBy   = UserSysNo,
                        LastUpdateDate = DateTime.Now
                    };
                    IcpDao.Instance.InsertIcpGoodsItem(m);
                }
                //foreach (var proItem in order.OrderItemList)
                //{
                //    var m = new CIcpGoodsItem
                //    {
                //        SourceSysNo = soOrderSysNo,
                //        IcpType = model.IcpType,
                //        MessageID = MessageID,
                //        IcpGoodsSysNo = model.SysNo,
                //        ProductSysNo = proItem.ProductSysNo,
                //        EntGoodsNo = "None",
                //        CreatedBy = UserSysNo,
                //        CreatedDate = DateTime.Now,
                //        LastUpdateBy = UserSysNo,
                //        LastUpdateDate = DateTime.Now
                //    };
                //    IcpDao.Instance.InsertIcpGoodsItem(m);
                //}
                //更新订单的商检推送状态
                SoOrderBo.Instance.UpdateOrderNsStatus(soOrderSysNo, (int)OrderStatus.商检状态.已推送);
                result.Status  = true;
                result.Message = root.head.MessageID;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #14
0
        /// <summary>
        /// 上传xml文件
        /// 2015-10-09 王耀发 创建
        /// </summary>
        /// <param name="RequestText"></param>
        public static string UploadXmlFile(string RequestText)
        {
            //获取当前时间
            int    Year     = DateTime.Now.Year;
            int    Month    = DateTime.Now.Month;
            int    Day      = DateTime.Now.Day;
            int    Hour     = DateTime.Now.Hour;
            int    Minute   = DateTime.Now.Minute;
            int    Second   = DateTime.Now.Second;
            string SendTime = Year.ToString() + (Month < 10 ? "0" + Month.ToString() : Month.ToString()) + (Day < 10 ? "0" + Day.ToString() : Day.ToString());

            SendTime += (Hour < 10 ? "0" + Hour.ToString() : Hour.ToString()) + (Minute < 10 ? "0" + Minute.ToString() : Minute.ToString()) + (Second < 10 ? "0" + Second.ToString() : Second.ToString());

            //RequestText = "{\"MessageIDNo\":\"0000\",\"Declaration\": {\"EOrder\": {\"OrderId\": \"141226133900128\",\"IEFlag\": \"I\",\"OrderStatus\": \"S\",";
            //RequestText += "\"EntRecordNo\": \"PTE51001412020000001\",\"EntRecordName\": \"顺丰速运集团(上海)速运有限公司\",\"OrderName\": \"刘青青\",\"OrderDocType\": \"01\",";
            //RequestText += "\"OrderDocId\": \"342401198207050086\",\"OrderPhone\": \"18682088326\",\"OrderGoodTotal\": \"198\",\"OrderGoodTotalCurr\": \"142\",";
            //RequestText += "\"Freight\": \"7\",\"FreightCurr\": \"142\",\"Tax\": \"0\",\"TaxCurr\": \"142\",\"Note\": \"任你你测试\",\"OrderDate\": \"2014-12-26 15:52:02\"},";
            //RequestText += "\"EOrderGoods\": [{\"GNo\": \"商品序号1\",\"ChildOrderNo\": \"子订单编号\",\"StoreRecordNo\": \"PTE51001412020000001\",\"StoreRecordName\": \"顺丰速运集团(上海)速运有限公司\",";
            //RequestText += "\"CopGNo\": \"99\",\"CustomsListNO\": \"GDO51411406260000181\",\"DecPrice\": \"99\",\"Unit\": \"125\",\"GQty\": \"2\",\"DeclTotal\": \"198\",\"Notes\": \"任你你测试\"},";
            //RequestText += "{";
            //RequestText += "\"GNo\": \"商品序号2\",\"ChildOrderNo\": \"子订单编号\",\"StoreRecordNo\": \"PTE51001412020000001\",\"StoreRecordName\": \"顺丰速运集团(上海)速运有限公司\",\"CopGNo\": \"99\",";
            //RequestText += "\"CustomsListNO\": \"GDO51411406260000181\",\"DecPrice\": \"99\",\"Unit\": \"125\",\"GQty\": \"2\",\"DeclTotal\": \"198\",\"Notes\": \"任你你测试\"}]}}";
            var jsonObject = JObject.Parse(RequestText);

            string MessageIDNo        = jsonObject["MessageIDNo"].ToString();
            string OrderId            = jsonObject["Declaration"]["EOrder"]["OrderId"].ToString();
            string IEFlag             = jsonObject["Declaration"]["EOrder"]["IEFlag"].ToString();
            string OrderStatus        = jsonObject["Declaration"]["EOrder"]["OrderStatus"].ToString();
            string EntRecordNo        = jsonObject["Declaration"]["EOrder"]["EntRecordNo"].ToString();
            string EntRecordName      = jsonObject["Declaration"]["EOrder"]["EntRecordName"].ToString();
            string OrderName          = jsonObject["Declaration"]["EOrder"]["OrderName"].ToString();
            string OrderDocType       = jsonObject["Declaration"]["EOrder"]["OrderDocType"].ToString();
            string OrderDocId         = jsonObject["Declaration"]["EOrder"]["OrderDocId"].ToString();
            string OrderPhone         = jsonObject["Declaration"]["EOrder"]["OrderPhone"].ToString();
            string OrderGoodTotal     = jsonObject["Declaration"]["EOrder"]["OrderGoodTotal"].ToString();
            string OrderGoodTotalCurr = jsonObject["Declaration"]["EOrder"]["OrderGoodTotalCurr"].ToString();
            string Freight            = jsonObject["Declaration"]["EOrder"]["Freight"].ToString();
            string FreightCurr        = jsonObject["Declaration"]["EOrder"]["FreightCurr"].ToString();
            string Tax       = jsonObject["Declaration"]["EOrder"]["Tax"].ToString();
            string TaxCurr   = jsonObject["Declaration"]["EOrder"]["TaxCurr"].ToString();
            string Note      = jsonObject["Declaration"]["EOrder"]["Note"].ToString();
            string OrderDate = jsonObject["Declaration"]["EOrder"]["OrderDate"].ToString();


            string strxml = "";

            strxml += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
            strxml += "<Manifest>";
            strxml += "<Head>";
            strxml += "<MessageID>" + ApiConfig.MessageType + SendTime + MessageIDNo + "</MessageID>";
            strxml += "<MessageType>" + ApiConfig.MessageType + "</MessageType>";
            strxml += "<SenderID>" + ApiConfig.XinYinSenderID + "</SenderID>";
            strxml += "<SendTime>" + SendTime + "</SendTime>";
            strxml += "<Version>" + ApiConfig.Version + "</Version>";
            strxml += "</Head>";
            strxml += "<Declaration>";
            strxml += "<EOrder>";
            strxml += "<OrderId>" + OrderId + "</OrderId>";
            strxml += "<IEFlag>" + IEFlag + "</IEFlag>";
            strxml += "<OrderStatus>" + OrderStatus + "</OrderStatus>";
            strxml += "<EntRecordNo>" + EntRecordNo + "</EntRecordNo>";
            strxml += "<EntRecordName>" + EntRecordName + "</EntRecordName>";
            strxml += "<OrderName>" + OrderName + "</OrderName>";
            strxml += "<OrderDocType>" + OrderDocType + "</OrderDocType>";
            strxml += "<OrderDocId>" + OrderDocId + "</OrderDocId>";
            strxml += "<OrderPhone>" + OrderPhone + "</OrderPhone>";
            strxml += "<OrderGoodTotal>" + OrderGoodTotal + "</OrderGoodTotal>";
            strxml += "<OrderGoodTotalCurr>" + OrderGoodTotalCurr + "</OrderGoodTotalCurr>";
            strxml += "<Freight>" + Freight + "</Freight>";
            strxml += "<FreightCurr>" + FreightCurr + "</FreightCurr>";
            strxml += "<Tax>" + Tax + "</Tax>";
            strxml += "<TaxCurr>" + TaxCurr + "</TaxCurr>";
            strxml += "<Note>" + Note + "</Note>";
            strxml += "<OrderDate>" + OrderDate + "</OrderDate>";
            strxml += "</EOrder>";
            strxml += "<EOrderGoods>";

            foreach (JObject item in jsonObject["Declaration"]["EOrderGoods"])
            {
                strxml += "<EOrderGood>";
                strxml += "<GNo>" + item["GNo"].ToString() + "</GNo>";
                strxml += "<ChildOrderNo>" + item["ChildOrderNo"].ToString() + "</ChildOrderNo>";
                strxml += "<StoreRecordNo>" + item["StoreRecordNo"].ToString() + "</StoreRecordNo>";
                strxml += "<StoreRecordName>" + item["StoreRecordName"].ToString() + "</StoreRecordName>";
                strxml += "<CopGNo>" + item["CopGNo"].ToString() + "</CopGNo>";
                strxml += "<CustomsListNO>" + item["CustomsListNO"].ToString() + "</CustomsListNO>";
                strxml += "<DecPrice>" + item["DecPrice"].ToString() + "</DecPrice>";
                strxml += "<Unit>" + item["Unit"].ToString() + "</Unit>";
                strxml += "<GQty>" + item["GQty"].ToString() + "</GQty>";
                strxml += "<DeclTotal>" + item["DeclTotal"].ToString() + "</DeclTotal>";
                strxml += "<Notes>" + item["Notes"].ToString() + "</Notes>";
                strxml += "</EOrderGood>";
            }
            strxml += "</EOrderGoods>";
            strxml += "</Declaration>";
            strxml += "</Manifest>";
            try
            {
                strxml = AESHelper.Encrypt(strxml);
                //上传xml文件
                MemoryStream stream          = new MemoryStream();
                byte[]       buffer          = Encoding.Default.GetBytes(strxml);
                string       msg             = "";
                string       _ftpImageServer = ApiConfig.FtpUrl + "UPLOAD/";
                string       _ftpUserName    = ApiConfig.FtpUserName;
                string       _ftpPassword    = ApiConfig.FtpPassword;
                FtpUtil      ftp             = new FtpUtil(_ftpImageServer, _ftpUserName, _ftpPassword);
                //上传xml文件
                ftp.UploadFile(_ftpImageServer, ApiConfig.MessageType + SendTime + MessageIDNo + ".xml", buffer, out msg);
                return(ApiConfig.MessageType + SendTime + MessageIDNo + ".xml");
            }
            catch (Exception e)
            {
                //显示错误信息
                return("");
            }
        }
Beispiel #15
0
        /// <summary>
        /// 上传订单至海关
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <param name="warehouseSysNo">仓库编号</param>
        /// <param name="customsLogInfo">海关日志</param>
        /// <param name="appType">报文类型 企业报送类型。1-新增 2-变更 3-删除。默认为1。</param>
        /// <returns></returns>
        /// <remarks>2016-6-4 杨浩 创建</remarks>
        private Result Upload(int orderId, int warehouseSysNo, SoCustomsOrderLog customsLogInfo, string appType = "1")
        {
            var result = new Result()
            {
                Status = false
            };

            try
            {
                var order = BLL.Order.SoOrderBo.Instance.GetEntity(orderId);
                if (order == null)
                {
                    result.Message = "该订单不存在";
                    return(result);
                }
                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);

                var onlinePaymentFilter = new Hyt.Model.Parameter.ParaOnlinePaymentFilter()
                {
                    OrderSysNo = orderId,
                    Id         = 1
                };
                var onlinePayments = Hyt.BLL.Finance.FinanceBo.Instance.GetOnlinePayments(onlinePaymentFilter).Rows;

                if (onlinePayments == null || (onlinePayments != null && onlinePayments.Count() <= 0))
                {
                    result.Status  = false;
                    result.Message = "订单没有支付单!";
                    return(result);
                }

                string orderNo = onlinePayments[0].BusinessOrderSysNo;
                if (string.IsNullOrEmpty(orderNo))
                {
                    result.Status  = false;
                    result.Message = "报关订单编号不能为空,请检查支付单字段 BusinessOrderSysNo";
                    return(result);
                }

                // 收货人 区 市 省
                var receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                var receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                var receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                var warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(warehouseSysNo);
                var shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                var dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                var deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                var CEBMessage = new CEB311Message();
                CEBMessage.GAOrder = new List <GAOrder>();
                CEBMessage.guid    = System.Guid.NewGuid().ToString("D").ToUpper();
                CEBMessage.version = "1.0";

                var gaOrder = new GAOrder();
                gaOrder.OrderHead                  = new OrderHead();
                gaOrder.OrderHead.acturalPaid      = order.CashPay.ToString();// (order.ProductAmount + order.ProductChangeAmount).ToString(); //recVoucher.ReceivedAmount.ToString();
                gaOrder.OrderHead.appStatus        = "2";
                gaOrder.OrderHead.appTime          = DateTime.Now.ToString("yyyyMMddHHmmss");
                gaOrder.OrderHead.appType          = appType;// "1";
                gaOrder.OrderHead.batchNumbers     = "";
                gaOrder.OrderHead.buyerIdNumber    = order.ReceiveAddress.IDCardNo;
                gaOrder.OrderHead.buyerIdType      = "1";
                gaOrder.OrderHead.buyerName        = order.ReceiveAddress.Name;
                gaOrder.OrderHead.buyerRegNo       = order.CustomerSysNo.ToString();
                gaOrder.OrderHead.consignee        = order.ReceiveAddress.Name;
                gaOrder.OrderHead.consigneeAddress = order.ReceiveAddress.StreetAddress;
                //gaOrder.OrderHead.consigneeDitrict = receiverDistrict.AreaCode;
                gaOrder.OrderHead.consigneeTelephone = order.ReceiveAddress.MobilePhoneNumber;
                gaOrder.OrderHead.currency           = "142";
                gaOrder.OrderHead.discount           = order.OrderDiscountAmount.ToString();
                gaOrder.OrderHead.ebcCode            = EbcCode; //"44306609EP";
                gaOrder.OrderHead.ebcName            = EbcCode; //"广州华迅捷通电子商务有限公司";
                gaOrder.OrderHead.ebpCode            = EbcCode;
                gaOrder.OrderHead.ebpName            = EbcName;
                gaOrder.OrderHead.freight            = order.FreightAmount.ToString();
                gaOrder.OrderHead.goodsValue         = order.ProductAmount.ToString();
                gaOrder.OrderHead.guid = System.Guid.NewGuid().ToString("D").ToUpper();
                //gaOrder.OrderHead.note = "";
                gaOrder.OrderHead.orderNo   = orderNo;// order.SysNo.ToString();
                gaOrder.OrderHead.orderType = "I";

                gaOrder = SetPayCodeAndPayName(order.PayTypeSysNo, gaOrder);

                gaOrder.OrderHead.payTransactionId = onlinePayments[0].VoucherNo; // recVoucher.VoucherItems[0].VoucherNo;
                gaOrder.OrderHead.taxTotal         = order.TaxFee.ToString();     // "0";
                gaOrder.OrderList = new List <OrderList>();
                int _gnum = 1;
                foreach (var item in order.OrderItemList)
                {
                    var orderList = new OrderList();
                    #region 条形码商品
                    var RefProductName     = item.ProductName;
                    var RefProductSysNo    = item.ProductSysNo;
                    var RefProductQuantity = item.Quantity;
                    BLL.Product.PdProductBo.Instance.RefProductQuantity(ref RefProductSysNo, ref RefProductQuantity, ref RefProductName, order.SysNo);
                    #endregion
                    //orderList.barCode = "";
                    orderList.country      = "116";
                    orderList.currency     = "142";
                    orderList.gnum         = _gnum.ToString();
                    orderList.itemDescribe = "";
                    //orderList.itemName = item.ProductName;
                    //orderList.itemNo = item.ProductSysNo.ToString();// "";
                    orderList.itemName = RefProductName;
                    orderList.itemNo   = RefProductSysNo.ToString();
                    //orderList.note = "";
                    orderList.price = item.SalesUnitPrice.ToString();
                    //orderList.qty = item.Quantity.ToString();
                    orderList.qty        = RefProductQuantity.ToString();
                    orderList.totalPrice = (item.SalesAmount + item.ChangeAmount).ToString();
                    orderList.unit       = "007";
                    gaOrder.OrderList.Add(orderList);

                    _gnum++;
                }
                CEBMessage.GAOrder.Add(gaOrder);

                CEBMessage.BaseTransfer = new BaseTransfer();
                //CEBMessage.BaseTransfer.copCode = EbcCode;
                //CEBMessage.BaseTransfer.copName = EbcName;
                CEBMessage.BaseTransfer.copCode = EbcCode;
                CEBMessage.BaseTransfer.copName = EbcName;
                // 电子口岸固定DXP
                CEBMessage.BaseTransfer.dxpId   = DxpId;// "DXPENTTEST510001";
                CEBMessage.BaseTransfer.dxpMode = "DXP";
                //CEBMessage.BaseTransfer.note = "";

                XmlSerializerNamespaces xmlNs = new XmlSerializerNamespaces();
                xmlNs.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                xmlNs.Add("nousexmlns", "http://www.chinaport.gov.cn/ceb");
                string xmlData = this.XmlSerialize <CEB311Message>(CEBMessage, xmlNs);
                xmlData = xmlData.Replace(":nousexmlns", "");
                xmlData = xmlData.Replace("encoding=\"utf-16\"", "encoding=\"UTF-8\"");

                // 上传文件
                var    ftp         = new FtpUtil(FTPUri, FTPName, FTPPassword);
                string ftpResponse = "";
                var    random      = new Random();
                string fileName    = "GZEPORT_" + FTPName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + random.Next(10000, 100000).ToString() + ".xml";



                ftp.UploadFile(FTPUri + FolderIn, fileName, Encoding.UTF8.GetBytes(xmlData), out ftpResponse);

                #region 海关推送日志
                var customsOrderLog = new SoCustomsOrderLog();

                if (customsLogInfo != null)
                {
                    customsOrderLog = customsLogInfo;
                }

                customsOrderLog.Packets    = xmlData;
                customsOrderLog.StatusCode = appType;

                if (appType == "1")//1-新增 2-变更 3-删除
                {
                    customsOrderLog.StatusMsg = "新增中";
                }
                else if (appType == "2")
                {
                    customsOrderLog.StatusMsg = "变更中";
                }
                else if (appType == "3")
                {
                    customsOrderLog.StatusMsg = "删除中";
                }



                customsOrderLog.LastUpdateBy = 0;
                if (BLL.Authentication.AdminAuthenticationBo.Instance.IsLogin)
                {
                    customsOrderLog.LastUpdateBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo;
                }
                customsOrderLog.LastUpdateDate = DateTime.Now;
                customsOrderLog.CreateDate     = DateTime.Now;
                customsOrderLog.CreatedBy      = customsOrderLog.LastUpdateBy;
                customsOrderLog.ReceiptContent = "";
                customsOrderLog.FileName       = fileName;
                customsOrderLog.OrderSysNo     = orderId;
                customsOrderLog.CustomsChannel = (int)this.Code;
                customsOrderLog.StatusCode     = appType;


                if (customsLogInfo == null)
                {
                    BLL.Order.SoCustomsOrderLogBo.Instance.AddCustomsOrderLog(customsOrderLog);
                }
                else
                {
                    BLL.Order.SoCustomsOrderLogBo.Instance.UpdateCustomsOrderLog(customsOrderLog);
                }

                BLL.Order.SoOrderBo.Instance.UpdateOrderApiStatus((int)Hyt.Model.WorkflowStatus.OrderStatus.海关报关状态.处理中, 2, orderId);
                #endregion

                result.Status  = true;
                result.Message = "提交成功!";
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }
Beispiel #16
0
        public static void ComPressProductPic()
        {
            bool IsFtpServer = bool.Parse(ConfigurationManager.AppSettings["IsFtpServer"]);
            int  Num_i       = Convert.ToInt16(ConfigurationManager.AppSettings["NumOnceDeal"]);

            int SleepTime = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SleepTime"]);
            IList <ConfigPicComPressEntity> picconfig = ConfigPicComPressBLL.Instance.GetConfigListByPicSource((int)SourcePicTypeEnum.Product);

            while (true)
            {
                IList <ProductStylePicsEntity> _piclist = new List <ProductStylePicsEntity>();
                _piclist = ProductStylePicsBLL.Instance.GetStylePicsNoComPress(Num_i);
                if (_piclist != null && _piclist.Count > 0)
                {
                    //ParallelOptions po = new ParallelOptions();
                    //po.MaxDegreeOfParallelism = 15; //最多并发50个任务
                    string FtpServerPath = "";
                    string ImagePath     = "";
                    if (IsFtpServer)
                    {
                        FtpServerPath = ConfigurationManager.AppSettings["FtpServerPathPrefix"].ToString();
                    }
                    ImagePath = ConfigurationManager.AppSettings["ImagePath"].ToString();

                    if (picconfig != null && picconfig.Count > 0)
                    {
                        string allids     = "0";
                        string successids = "0";
                        string failids    = "0";
                        string error      = "1";
                        foreach (ProductStylePicsEntity o in _piclist)
                        {
                            allids = allids + "," + o.Id.ToString();
                            string filepath = FtpServerPath + ImagePath.Replace("/", "\\") + o.PicUrl.Replace("/", "\\") + "." + o.PicSuffix;
                            try
                            {
                                if (IsFtpServer)
                                {
                                    foreach (ConfigPicComPressEntity en in picconfig)
                                    {
                                        Image       sourceImg = Image.FromFile(filepath);
                                        ImageFormat _imgf     = sourceImg.RawFormat;
                                        string      savepath  = FtpServerPath + ImagePath.Replace("/", "\\") + o.PicUrl.Replace("/", "\\") + en.PicName + "." + o.PicSuffix;

                                        int Width  = en.Width;
                                        int Height = en.Height;
                                        using (Image ThumbImgl = PicTool.GetImageThumb(sourceImg, Width, Height))
                                        {
                                            ThumbImgl.Save(savepath, _imgf);
                                            ThumbImgl.Dispose();
                                        }
                                        sourceImg.Dispose();
                                    }
                                }
                                else
                                {
                                    FtpUtil _ftp         = new FtpUtil();
                                    string  downloadpath = ImagePath + o.PicUrl + "." + o.PicSuffix;
                                    byte[]  _byt         = _ftp.DownloadFile(downloadpath);
                                    Image   sourceImg    = PicTool.GetImageByBytes(_byt);



                                    foreach (ConfigPicComPressEntity en in picconfig)
                                    {
                                        int    Width      = en.Width;
                                        int    Height     = en.Height;
                                        string uploadpath = ImagePath + o.PicUrl + en.PicName + "." + o.PicSuffix;
                                        using (Image ThumbImgl = PicTool.GetImageThumb(sourceImg, Width, Height))
                                        {
                                            byte[] _byts = PicTool.GetByteByImage(ThumbImgl);
                                            _ftp.UploadFile(uploadpath, _byts, false);
                                            ThumbImgl.Dispose();
                                        }
                                    }
                                    sourceImg.Dispose();
                                }
                                successids = successids + "," + o.Id.ToString();
                            }
                            catch (Exception ex)
                            {
                                LogUtil.Log(ex);

                                failids = failids + "," + o.Id.ToString();
                            }
                        }
                        ProductStylePicsBLL.Instance.ComPressComplete(allids, successids, failids);
                    }

                    Thread.Sleep(SleepTime);
                }
            }
        }
Beispiel #17
0
        public override Result AddOrderTrade(int orderSysno)
        {
            Result result = new Result();

            try
            {
                SoOrder order = BLL.Order.SoOrderBo.Instance.GetEntity(orderSysno);
                if (order == null)
                {
                    result.Message = "该订单不存在";
                    return(result);
                }
                order.ReceiveAddress = BLL.Order.SoOrderBo.Instance.GetOrderReceiveAddress(order.ReceiveAddressSysNo);
                order.OrderItemList  = DataAccess.Order.ISoOrderItemDao.Instance.GetOrderItemsByOrderSysNo(order.SysNo);
                ParaVoucherFilter voucherFilter = new ParaVoucherFilter();
                voucherFilter.SourceSysNo = order.SysNo;
                CBFnReceiptVoucher recVoucher = BLL.Finance.FinanceBo.Instance.GetReceiptVouchers(voucherFilter).Rows.FirstOrDefault();
                recVoucher.VoucherItems = BLL.Finance.FnReceiptVoucherBo.Instance.GetReceiptVoucherItem(recVoucher.SysNo);
                // 收货人 区 市 省
                BsArea receiverDistrict = BLL.Basic.BasicAreaBo.Instance.GetArea(order.ReceiveAddress.AreaSysNo);
                BsArea receiverCity     = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverDistrict.ParentSysNo);
                BsArea receiverProvince = BLL.Basic.BasicAreaBo.Instance.GetArea(receiverCity.ParentSysNo);
                // 发货人 市
                CBWhWarehouse warehouse   = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouse(order.DefaultWarehouseSysNo);
                BsArea        shipperCity = BLL.Basic.BasicAreaBo.Instance.GetArea(warehouse.CitySysNo);

                DsDealer dealer = BLL.Distribution.DsDealerBo.Instance.GetDsDealer(order.DealerSysNo);

                LgDeliveryType deliveryType = BLL.Logistics.DeliveryTypeBo.Instance.GetDeliveryType(order.DeliveryTypeSysNo);

                EasycrossOrder newOrder = new EasycrossOrder();
                newOrder.OrderHead             = new OrderHead();
                newOrder.OrderList             = new List <OrderList>();
                newOrder.OrderPaymentLogistics = new OrderPaymentLogistics();

                newOrder.OrderHead.accessType         = "1";
                newOrder.OrderHead.agentCode          = "4404580006";
                newOrder.OrderHead.agentName          = "珠海易跨境电子商务服务有限公司";
                newOrder.OrderHead.appStatus          = "2";
                newOrder.OrderHead.appTime            = DateTime.Now.ToString("yyyyMMddHHmmss");
                newOrder.OrderHead.appUid             = "1105910159";
                newOrder.OrderHead.appUname           = "东方口岸";
                newOrder.OrderHead.batchNumbers       = "";
                newOrder.OrderHead.cbeCode            = "D00236";
                newOrder.OrderHead.cbeName            = "珠海爱勤电子科技有限公司";
                newOrder.OrderHead.charge             = order.OrderAmount.ToString();
                newOrder.OrderHead.consignee          = order.ReceiveAddress.Name;
                newOrder.OrderHead.consigneeAddress   = order.ReceiveAddress.StreetAddress;
                newOrder.OrderHead.consigneeCountry   = "";
                newOrder.OrderHead.consigneeTelephone = !string.IsNullOrWhiteSpace(order.ReceiveAddress.MobilePhoneNumber)
                    ? order.ReceiveAddress.MobilePhoneNumber : order.ReceiveAddress.PhoneNumber;
                newOrder.OrderHead.currency         = "142";
                newOrder.OrderHead.customer         = order.ReceiveAddress.Name;
                newOrder.OrderHead.customerId       = order.ReceiveAddress.IDCardNo;
                newOrder.OrderHead.ecpCode          = "W0098";
                newOrder.OrderHead.ecpName          = "珠海爱勤电子科技有限公司";
                newOrder.OrderHead.freight          = order.FreightAmount.ToString();
                newOrder.OrderHead.goodsValue       = order.ProductAmount.ToString();
                newOrder.OrderHead.idType           = "1";
                newOrder.OrderHead.ieType           = "I";
                newOrder.OrderHead.modifyMark       = "1";
                newOrder.OrderHead.note             = "";
                newOrder.OrderHead.orderNo          = order.SysNo.ToString();
                newOrder.OrderHead.other            = "";
                newOrder.OrderHead.shipper          = BLL.Stores.StoresBo.Instance.GetStoreById(0).ErpName;
                newOrder.OrderHead.shipperAddress   = "";
                newOrder.OrderHead.shipperCountry   = "142";
                newOrder.OrderHead.shipperTelephone = "";
                newOrder.OrderHead.tax = order.TaxFee.ToString();
                newOrder.OrderHead.totalLogisticsNo = "";
                newOrder.OrderHead.tradeCountry     = "";
                newOrder.OrderHead.wrapType         = "";
                foreach (SoOrderItem item in order.OrderItemList)
                {
                    PdProduct      product      = BLL.Product.PdProductBo.Instance.GetProduct(item.SysNo);
                    PdProductStock productStock = BLL.Warehouse.PdProductStockBo.Instance.GetEntityByWP(order.DefaultWarehouseSysNo, item.ProductSysNo);

                    string  brandName = "无";
                    PdBrand brand     = BLL.Product.PdBrandBo.Instance.GetEntity(product.BrandSysNo);
                    if (brand != null)
                    {
                        brandName = brand.Name;
                    }

                    OrderList orderList = new OrderList();
                    orderList.barCode        = "";
                    orderList.brand          = brandName;
                    orderList.codeTs         = "";
                    orderList.country        = "";
                    orderList.currency       = "142";
                    orderList.describe       = "";
                    orderList.discount       = "";
                    orderList.giftFlag       = "";
                    orderList.goodsModel     = "";
                    orderList.goodsName      = item.ProductName;
                    orderList.goodsNo        = productStock.ProductSku;
                    orderList.itemNo         = "";
                    orderList.note           = "";
                    orderList.packNum        = "";
                    orderList.price          = item.SalesUnitPrice.ToString();
                    orderList.priceTotal     = item.SalesAmount.ToString();
                    orderList.purposeCode    = "";
                    orderList.quantity       = item.Quantity.ToString();
                    orderList.shelfGoodsName = item.ProductName;
                    orderList.taxCode        = "";
                    orderList.unit           = "007";
                    orderList.wasteMaterials = "1";
                    orderList.wrapType       = "";
                    newOrder.OrderList.Add(orderList);
                }
                //newOrder.OrderPaymentLogistics.logisticsCode = "";
                newOrder.OrderPaymentLogistics.logisticsName = deliveryType.DeliveryTypeName;
                //newOrder.OrderPaymentLogistics.logisticsNo = "";
                //newOrder.OrderPaymentLogistics.paymentCode = "";
                //newOrder.OrderPaymentLogistics.paymentName = "";
                //newOrder.OrderPaymentLogistics.paymentNo = "";
                //newOrder.OrderPaymentLogistics.paymentType = "";
                //newOrder.OrderPaymentLogistics.trackNo = "";

                XmlSerializerNamespaces xmlNs = new XmlSerializerNamespaces();
                xmlNs.Add("nousexmlns", "http://www.chinaport.gov.cn/ecss");
                string xmlData = this.XmlSerialize <EasycrossOrder>(newOrder, xmlNs);
                xmlData = xmlData.Replace(":nousexmlns", "");
                xmlData = xmlData.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");

                // 上传文件
                FtpUtil ftp         = new FtpUtil(FTPUri, FTPName, FTPPassword);
                string  ftpResponse = "";
                ftp.UploadFile(FTPUri, "Testfilename.xml", Encoding.UTF8.GetBytes(xmlData), out ftpResponse);
            }
            catch (Exception ex)
            {
                result.Message = "向" + this.Code + "物流推送订单报错:" + ex.StackTrace;
                return(result);
            }

            return(result);
        }
Beispiel #18
0
        /// <summary>
        /// 商品备案
        /// </summary>
        /// <returns></returns>
        /// <remarks>2016-3-21 王耀发 创建</remarks>
        public override Result PushGoods(string ProductSysNoList)
        {
            Result result = new Result();
            CIcp   model  = new CIcp();

            model.IcpType = (int)Model.CommonEnum.商检.广州南沙;
            List <CIcpGoodsItem> CIcpGoodsItemList = new List <CIcpGoodsItem>();

            string[] sArray = ProductSysNoList.Split(',');

            foreach (string i in sArray)
            {
                int ProductSysNo            = int.Parse(i);
                IcpGZNanShaGoodsInfo Entity = IcpBo.Instance.GetIcpGZNanShaGoodsInfoEntityByPid(ProductSysNo);
                CIcpGoodsItemList.Add(new CIcpGoodsItem()
                {
                    IcpType      = model.IcpType,
                    ProductSysNo = ProductSysNo,
                    EntGoodsNo   = Entity.Gcode
                });
            }

            Model.Icp.GZNanSha.CommodityInspection mod = SetMod(model);
            List <Hyt.Model.Icp.GZNanSha.CommodityInspectionLists> modLists = SetModLists(CIcpGoodsItemList);

            Hyt.Model.Icp.GZNanSha.Root root = new Hyt.Model.Icp.GZNanSha.Root();
            root.head                                         = new Hyt.Model.Icp.GZNanSha.Head();
            root.body                                         = new Hyt.Model.Icp.GZNanSha.Body();
            root.body.goodSrecord                             = new Model.Icp.GZNanSha.GOODSRECORD();
            root.body.goodSrecord.record                      = new Model.Icp.GZNanSha.Record();
            root.body.goodSrecord.record.cargoList            = new Model.Icp.GZNanSha.CARGO.CARGOLIST();
            root.body.goodSrecord.record.cargoList.recordList = new List <Hyt.Model.Icp.GZNanSha.Record1>();

            //生成最大流水号
            string   MaxSerialNumber = GetMaxSerialNumberByMType(model.IcpType.ToString(), config.NSIcpInfo.GoodsMessageType);
            DateTime now             = DateTime.Now;
            string   strDate         = now.ToString("yyyyMMddHHmmssfff");
            string   strDateMid      = now.ToString("yyyyMMddHHmmss");

            //string fileName = config.NSIcpInfo.GoodsMessageType + "_" + strDate + MaxSerialNumber;
            string MessageID = "ICIP" + strDateMid;
            string fileName  = config.NSIcpInfo.GoodsMessageType + "_" + strDate;

            SetCustomHead(MessageID, root.head);
            SetCustomBodyData(root.body.goodSrecord.record, mod);
            SetCustomBodyData(root.body.goodSrecord.record.cargoList, modLists);
            string str = Hyt.Util.Serialization.SerializationUtil.XmlSerialize <Model.Icp.GZNanSha.Root>(root);

            str = str.Replace("encoding=\"utf-16\"", "encoding=\"utf-8\"");
            FtpUtil ftp = new FtpUtil(config.NSIcpInfo.FtpUrl, config.NSIcpInfo.FtpName, config.NSIcpInfo.FtpPassword);
            string  msg = "";

            //string MessageID = fileName;
            fileName = fileName + ".xml";
            try
            {
                ftp.UploadFile(config.NSIcpInfo.FtpUrl + "4200.IMPBA.SWBCARGOBACK.REPORT/in", fileName, Encoding.UTF8.GetBytes(str), out msg);
                //新增商检表信息
                int UserSysNo = AdminAuthenticationBo.Instance.Current.Base.SysNo;
                model.SourceSysNo    = 0;
                model.MessageID      = MessageID;
                model.MessageType    = config.NSIcpInfo.GoodsMessageType;
                model.SerialNumber   = MaxSerialNumber;
                model.XmlContent     = str;
                model.CreatedBy      = UserSysNo;
                model.CreatedDate    = DateTime.Now;
                model.Status         = (int)IcpStatus.商品商检推送状态.已推送;
                model.LastUpdateBy   = AdminAuthenticationBo.Instance.Current.Base.SysNo;
                model.LastUpdateDate = DateTime.Now;
                model.SysNo          = IcpDao.Instance.Insert(model);
                if (model.SysNo > 0) //
                {
                    if (CIcpGoodsItemList != null)
                    {
                        foreach (var item in CIcpGoodsItemList)
                        {
                            var m = new CIcpGoodsItem
                            {
                                SourceSysNo    = 0,
                                IcpType        = model.IcpType,
                                MessageID      = MessageID,
                                IcpGoodsSysNo  = model.SysNo,
                                ProductSysNo   = item.ProductSysNo,
                                EntGoodsNo     = item.EntGoodsNo,
                                CreatedBy      = UserSysNo,
                                CreatedDate    = DateTime.Now,
                                LastUpdateBy   = UserSysNo,
                                LastUpdateDate = DateTime.Now
                            };
                            IcpDao.Instance.InsertIcpGoodsItem(m);
                        }
                    }
                }
                result.Status  = true;
                result.Message = root.head.MessageID;
            }
            catch (Exception ex)
            {
                result.Status  = false;
                result.Message = ex.Message;
            }
            return(result);
        }