/// <summary>
        /// Post请求DHL接口
        /// </summary>
        /// <param name="ap">ShipmentValidateRequestAP实例</param>
        /// <param name="serverUrl">请求DHL接口的服务地址</param>
        /// <returns></returns>
        public ShipmentValidateResponse PostDHLShipment(ShipmentValidateRequestAP ap, string serverUrl)
        {
            var ns = new XmlSerializerNamespaces();

            ns.Add("req", "http://www.dhl.com");
            var responseResult = HttpHelper.PostSendRequest(ap, serverUrl, ns);

            try
            {
                var response = SerializeUtil.DeserializeFromXml <ShipmentValidateResponse>(responseResult);
                return(response);
            }
            catch (InvalidOperationException ex)
            {
                try
                {
                    var result = SerializeUtil.DeserializeFromXml <ShipmentValidateErrorResponse>(responseResult);
                    if (result != null)
                    {
                        throw new BusinessLogicException(result.Response.Status.Condition[0].ConditionData);
                    }
                }
                catch (InvalidOperationException ioex)
                {
                    var errorResult = SerializeUtil.DeserializeFromXml <LMS.Data.Express.DHL.Response.ErrorResponse>(responseResult);
                    if (errorResult != null)
                    {
                        throw new BusinessLogicException(errorResult.Response.Status.Condition[0].ConditionData);
                    }
                }
            }
            return(null);
        }
        const int errortype = 2; //-运费接口错误
        /// <summary>
        /// 获取需要更新的运单
        /// </summary>
        /// <returns></returns>
        public static List <VenderInfoPackageRequest> GetUpdatePriceWayBillList(string lastUpdateTime)
        {
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            DataTable dt        = dbUtility.ExecuteData("exec P_GetBatchFreightCostWayBillNumberList N'" + _status + "',N'" + lastUpdateTime + "'");
            var       list      = new List <VenderInfoPackageRequest>();

            if (dt != null && dt.Rows.Count > 0)
            {
                Log.Info("LMS需要更新成本价运单总数是" + dt.Rows.Count);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var v = new VenderInfoPackageRequest();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case "VenderCode":
                            v.VenderCode = dt.Rows[i][j].ToString();
                            break;

                        case "CountryCode":
                            v.CountryCode = dt.Rows[i][j].ToString();
                            break;

                        case "WayBillNumber":
                            v.WayBillNumber = dt.Rows[i][j].ToString();
                            break;

                        case "PackageRequest":
                            if (string.IsNullOrWhiteSpace(dt.Rows[i][j].ToString()))
                            {
                                continue;
                            }
                            v.Packages = SerializeUtil.DeserializeFromXml <List <VenderPackageRequest> >(dt.Rows[i][j].ToString());
                            break;

                        case "OutShippingMethodID":
                            v.ShippingMethodId = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "GoodsTypeID":
                            v.ShippingTypeId = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "CustomerID":
                            v.CustomerId = Guid.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "EnableTariffPrepay":
                            v.EnableTariffPrepay = bool.Parse(dt.Rows[i][j].ToString());
                            break;
                        }
                    }
                    list.Add(v);
                }
            }
            Log.Info("LMS需要更新成本价运单获取完毕!");
            return(list);
        }
Exemple #3
0
        public TotalPackageAddressExt GetTotalPackageAddress()
        {
            var result = new TotalPackageAddressExt();
            var xml    =
                _systemConfigurationRepository.Single(s => s.DictionaryID == sysConfig.TotalPackageAddress && s.IsEnable);

            if (xml != null && !xml.ConfigurationValue.IsNullOrWhiteSpace())
            {
                try
                {
                    result = SerializeUtil.DeserializeFromXml <TotalPackageAddressExt>(xml.ConfigurationValue);
                }
                catch (Exception ex)
                {
                    Log.Exception(ex);
                }
            }
            return(result);
        }
 /// <summary>
 /// 按时间查询
 /// </summary>
 /// <param name="datetime">UTC 格式是20150104120000
 /// DateTime (YYYYMMDDhhmmss)
 ///o YYYY year
 ///o MM month
 ///o DD day
 ///o HH hours (24 notation)
 ///o mm minutes
 ///o ss seconds
 ///</param>
 /// <returns></returns>
 public static Tracking GetTrackInfoByTime(long datetime)
 {
     if (datetime > 0)
     {
         string url = Datetimeurl.FormatWith(B2CTrackUrl, Userid, Mkey, datetime);
         Log.Info("开始请求Url:{0}".FormatWith(url));
         try
         {
             var xdoc = new XmlDocument();
             xdoc.Load(url);
             Log.Info("Url:{0},请求结果:{1}".FormatWith(url, xdoc.OuterXml));
             return(SerializeUtil.DeserializeFromXml <Tracking>(xdoc.OuterXml));
         }
         catch (Exception ex)
         {
             Log.Exception(ex);
         }
         Log.Info("完成请求Url:{0}".FormatWith(url));
     }
     return(null);
 }
 /// <summary>
 /// 按单号查询跟踪信息
 /// </summary>
 /// <param name="ordernumber"></param>
 /// <returns></returns>
 public static Tracking GetTrackInfoByNumber(string ordernumber)
 {
     if (!ordernumber.IsNullOrWhiteSpace())
     {
         string url = Keycodeurl.FormatWith(B2CTrackUrl, Userid, Mkey, ordernumber);
         Log.Info("开始请求Url:{0}".FormatWith(url));
         try
         {
             var xdoc = new XmlDocument();
             xdoc.Load(url);
             Log.Info("Url:{0},请求结果:{1}".FormatWith(url, xdoc.OuterXml));
             return(SerializeUtil.DeserializeFromXml <Tracking>(xdoc.OuterXml));
         }
         catch (Exception ex)
         {
             Log.Exception(ex);
         }
         Log.Info("完成请求Url:{0}".FormatWith(url));
     }
     return(null);
 }
Exemple #6
0
        public static void RegisterBundles(BundleCollection bundles)
        {
            //启用压缩配置
            BundleTable.EnableOptimizations = ConfigurationManager.AppSettings["EnableOptimizations"] == "true";
            //重新处理bundle忽略资源的规则
            bundles.IgnoreList.Clear();
            AddDefaultIgnorePatterns(bundles.IgnoreList);

            //配置文件列表
            var fileList = new List <StaticFileModel>();
            //获取js配置的文件
            var jsFilePath  = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "/Configs/Scripts.config");
            var cssFilePath = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "/Configs/Styles.config");
            var jsFileList  = SerializeUtil.DeserializeFromXml <List <StaticFileModel> >(jsFilePath);
            var cssFileList = SerializeUtil.DeserializeFromXml <List <StaticFileModel> >(cssFilePath);

            if (jsFileList.AnyOne())
            {
                fileList.AddRange(jsFileList);
            }
            if (cssFileList.AnyOne())
            {
                fileList.AddRange(cssFileList);
            }

            fileList.ForEach(f =>
            {
                string type = f.Type.Trim().ToLower(), virtualUrl = f.VirtualUrl.Trim().ToLower();
                if (type.Equals("js"))
                {
                    bundles.Add(new ScriptBundle(virtualUrl).Include(f.Srcs.ToArray()));
                }
                else if (type.Equals("css"))
                {
                    bundles.Add(new StyleBundle(virtualUrl).Include(f.Srcs.ToArray()));
                }
            });
        }
Exemple #7
0
        public void DHLShipmentRequest()
        {
            ShipmentValidateRequestAP ap = new ShipmentValidateRequestAP()
            {
                Billing = new Billing()
                {
                    DutyPaymentType      = DutyTaxPaymentType.R,
                    ShipperAccountNumber = "550000055",
                    ShippingPaymentType  = ShipmentPaymentType.S
                },
                Commodity = new[]
                {
                    new Commodity()
                    {
                        CommodityCode = "111111",
                        CommodityName = "xiaoming"
                    }
                },
                Consignee = new Consignee()     //收货人
                {
                    AddressLine = new[]
                    {
                        "2711 St", "Appt 211"
                    },
                    City        = "RedWood City",
                    CompanyName = "Prasanta INC",
                    Contact     = new Contact()
                    {
                        //Email = new Email()
                        //{
                        //    Body = "*****@*****.**",
                        //    cc = new[] { "String", "String" },
                        //    From = "*****@*****.**",
                        //    ReplyTo = "String",
                        //    Subject = "String",
                        //    To = "*****@*****.**"
                        //},
                        PersonName     = "Prasanta Sinha",
                        FaxNumber      = "11234325423",
                        PhoneExtension = 45232,
                        PhoneNumber    = "11234325423",
                        Telex          = "454586"
                    },
                    CountryCode  = "US",
                    CountryName  = "United States of America",
                    DivisionCode = "CA",
                    PostalCode   = "94065"
                },
                Dutiable = new Dutiable()
                {
                    DeclaredCurrency = "USD",
                    DeclaredValue    = "50.11",
                    ShipperEIN       = "Text"
                },
                LanguageCode  = "en",
                PiecesEnabled = PiecesEnabled.Y,
                Reference     = new[]
                {
                    new Reference()
                    {
                        ReferenceID   = "String",
                        ReferenceType = "St"
                    }
                },
                Request = new Request()
                {
                    ServiceHeader = new ServiceHeader()
                    {
                        MessageReference = "1234567890123456789012345678901",
                        //MessageTime = DateTime.Parse("2011-10-27T15:28:56.000-08:00"),
                        Password = "******",
                        SiteID   = "DServiceVal"
                    }
                },
                ShipmentDetails = new ShipmentDetails()     //出货详情
                {
                    Contents          = "For testing purpose only. Please do not ship",
                    CurrencyCode      = "USD",
                    Date              = DateTime.Parse("2014-04-06"),
                    DimensionUnit     = DimensionUnit.C,
                    DoorTo            = DoorTo.DD,
                    GlobalProductCode = "P",
                    LocalProductCode  = "P",
                    NumberOfPieces    = 1,
                    PackageType       = PackageType.EE,
                    Weight            = (decimal)0.5,
                    WeightUnit        = WeightUnit.K,
                    //InsuredAmount = "10000",
                    Pieces = new[]
                    {
                        new Piece
                        {
                            // PieceID = "String",
                            Depth = 2,
                            // DimWeight = (decimal)2.111,
                            Height = 2,
                            //PackageType = PackageType.EE,
                            Weight = (decimal)0.5,
                            Width  = 2
                        }
                    }
                },
                Shipper = new Shipper()     //发货人
                {
                    ShipperID   = "550000055",
                    AddressLine = new[] { "333 Twin" },
                    City        = "Kuala Lumpur",
                    CompanyName = "Santa inc",
                    Contact     = new Contact()
                    {
                        //Email = new Email()
                        //{
                        //    Body = "*****@*****.**",
                        //    cc = new[] { "String" },
                        //    From = "*****@*****.**",
                        //    ReplyTo = "*****@*****.**",
                        //    Subject = "String",
                        //    To = "*****@*****.**"
                        //},
                        PersonName     = "santa santa",
                        FaxNumber      = "17456356365",
                        PhoneExtension = 6536,
                        PhoneNumber    = "15356456364",
                        Telex          = "74558"
                    },
                    CountryCode  = "MY",
                    CountryName  = "Malaysia",
                    DivisionCode = "KL",
                    PostalCode   = "94065"
                }
            };

            var ns = new XmlSerializerNamespaces();

            ns.Add("req", "http://www.dhl.com");
            string url            = "https://xmlpitest-ea.dhl.com/XMLShippingServlet";
            var    responseResult = HttpHelper.PostSendRequest(ap, url, ns);

            try
            {
                var response =
                    SerializeUtil.DeserializeFromXml <LMS.Data.Express.DHL.Response.ShipmentValidateResponse>(
                        responseResult);

                Assert.IsNotNull(response);
            }
            catch (Exception)
            {
                var response =
                    SerializeUtil.DeserializeFromXml <LMS.Data.Express.DHL.Response.Error.ShipmentValidateErrorResponse>(
                        responseResult);

                Assert.Fail();
            }
        }
        /// <summary>
        /// 获取需要提交到顺丰的运单信息
        /// </summary>
        /// <param name="wayBillNumbers">运单号集合</param>
        /// <returns></returns>
        public static List <WayBillSfModel> GetWayBillSfModelList(List <string> wayBillNumbers)
        {
            if (!wayBillNumbers.Any())
            {
                return(null);
            }
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            DataTable dt        = dbUtility.ExecuteData("exec P_GetNlPostWayBillNumberInfoList N'" + string.Join(",", wayBillNumbers) + "'");
            var       list      = new List <WayBillSfModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                Log.Info("LMS获取需要提交到顺丰的运单信息总数是" + dt.Rows.Count);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var model = new WayBillSfModel();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case "WayBillNumber":
                            model.WayBillNumber = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingCompany":
                            model.ShippingCompany = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingName":
                            model.ShippingName = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingPhone":
                            model.ShippingPhone = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingAddress":
                            model.ShippingAddress = dt.Rows[i][j].ToString();
                            break;

                        case "PackageNumber":
                            model.PackageNumber = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "CountryCode":
                            model.CountryCode = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingZip":
                            model.ShippingZip = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingState":
                            model.ShippingState = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingCity":
                            model.ShippingCity = dt.Rows[i][j].ToString();
                            break;

                        case "IsReturn":
                            model.IsReturn = bool.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "ApplicationInfo":
                            if (string.IsNullOrWhiteSpace(dt.Rows[i][j].ToString()))
                            {
                                continue;
                            }
                            model.ApplicationInfo = SerializeUtil.DeserializeFromXml <List <ApplicationInfoSfModel> >(dt.Rows[i][j].ToString());
                            break;
                        }
                    }
                    list.Add(model);
                }
            }
            Log.Info("LMS获取需要提交到顺丰的运单信息完毕!");
            return(list);
        }
        /// <summary>
        /// 获取需要提交到顺E宝的运单信息
        /// </summary>
        /// <param name="wayBillNumbers">运单号集合</param>
        /// <returns></returns>
        public static List <SebModel> GetWayBillSfModelList(List <string> wayBillNumbers)
        {
            if (!wayBillNumbers.Any())
            {
                return(null);
            }
            string    sql       = @"SELECT  w.WayBillNumber ,
		                    s.ShippingCompany ,
		                    ISNULL(s.ShippingFirstName,'') + ' ' + ISNULL(s.ShippingLastName,'') ShippingName ,
		                    s.ShippingPhone ,
		                    ISNULL(s.ShippingAddress,'') + ' ' + ISNULL(s.ShippingAddress1,'') + ' '
		                    + ISNULL(s.ShippingAddress2,'') ShippingAddress ,
		                    ISNULL(c.PackageNumber,1) PackageNumber ,
		                    w.CountryCode ,
		                    s.ShippingZip ,
		                    s.ShippingState ,
		                    s.ShippingCity ,
		                    w.InShippingMethodID ShippingMethodID ,
		                    CONVERT(XML, ( SELECT  a.ApplicationName ,
                                                    a.HSCode HsCode,
								                    a.Qty ,
								                    a.UnitWeight ,
								                    a.UnitPrice
						                    FROM     dbo.ApplicationInfos a
						                    WHERE    a.WayBillNumber = w.WayBillNumber
								                    AND a.CustomerOrderID = c.CustomerOrderID
								                    AND a.IsDelete = 0
						                    FOR
						                    XML PATH('ApplicationInfoSfModel') ,
							                    ROOT('ArrayOfApplicationInfoSfModel')
						                    )) AS ApplicationInfo
	                    FROM    dbo.WayBillInfos w
			                    LEFT JOIN dbo.ShippingInfos s ON w.ShippingInfoID = s.ShippingInfoID
			                    LEFT JOIN dbo.CustomerOrderInfos c ON w.CustomerOrderID = c.CustomerOrderID
	                    WHERE w.WayBillNumber IN('"     + string.Join("','", wayBillNumbers) + "')";
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            DataTable dt        = dbUtility.ExecuteData(sql);
            var       list      = new List <SebModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                Log.Info("LMS获取需要提交到顺E宝的运单信息总数是" + dt.Rows.Count);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var model = new SebModel();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case "WayBillNumber":
                            model.WayBillNumber = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingCompany":
                            model.ShippingCompany = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingName":
                            model.ShippingName = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingPhone":
                            model.ShippingPhone = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingAddress":
                            model.ShippingAddress = dt.Rows[i][j].ToString();
                            break;

                        case "PackageNumber":
                            model.PackageNumber = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "CountryCode":
                            model.CountryCode = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingZip":
                            model.ShippingZip = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingState":
                            model.ShippingState = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingCity":
                            model.ShippingCity = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingMethodID":
                            model.ShippingMethodId = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "ApplicationInfo":
                            if (string.IsNullOrWhiteSpace(dt.Rows[i][j].ToString()))
                            {
                                continue;
                            }
                            model.ApplicationInfo = SerializeUtil.DeserializeFromXml <List <ApplicationInfoSfModel> >(dt.Rows[i][j].ToString());
                            break;
                        }
                    }
                    list.Add(model);
                }
            }
            Log.Info("LMS获取需要提交到顺E宝的运单信息完毕!");
            return(list);
        }
        /// <summary>
        /// 获取需要更新收货运费的运单
        /// </summary>
        /// <returns></returns>
        public static List <WayBillPriceModel> GetUpdatePriceWayBillList()
        {
            DbUtility dbUtility = new SqlDbUtility(_lmsCon);
            DataTable dt        = dbUtility.ExecuteData(@"SELECT r.WayBillNumber,r.ReceivingExpenseID,w.EnableTariffPrepay,c.CustomerID,c.CustomerTypeID,w.GoodsTypeID,
	            w.CountryCode,w.InShippingMethodID,ISNULL(s.ShippingCity,'') ShippingCity,ISNULL(s.ShippingState,'') ShippingState,
				ISNULL(s.ShippingZip,'') ShippingZip,CONVERT(XML, (SELECT Length, Width,Height,Weight
                FROM WaybillPackageDetails PackageRequest
                WHERE PackageRequest.WayBillNumber=w.WayBillNumber
                FOR XML Path('PackageRequest'),ROOT('ArrayOfPackageRequest')))AS PackageRequest
                FROM dbo.ReceivingExpenses r LEFT JOIN dbo.WayBillInfos w ON r.WayBillNumber=w.WayBillNumber
	            LEFT JOIN dbo.Customers c ON w.CustomerCode=c.CustomerCode
				LEFT JOIN dbo.ShippingInfos s ON w.ShippingInfoID=s.ShippingInfoID
                WHERE IsNoGet=0 AND DATEDIFF(DAY,w.CreatedOn,GETDATE())>=1
                AND EXISTS(SELECT 1 FROM WaybillPackageDetails wp WHERE w.WayBillNumber=wp.WayBillNumber)");
            var       list      = new List <WayBillPriceModel>();

            if (dt != null && dt.Rows.Count > 0)
            {
                Log.Info("LMS收货需要更新运费运单总数是" + dt.Rows.Count);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var v = new WayBillPriceModel();
                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        switch (dt.Columns[j].ColumnName)
                        {
                        case "EnableTariffPrepay":
                            v.EnableTariffPrepay = bool.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "CountryCode":
                            v.CountryCode = dt.Rows[i][j].ToString();
                            break;

                        case "WayBillNumber":
                            v.WayBillNumber = dt.Rows[i][j].ToString();
                            break;

                        case "CustomerID":
                            v.CustomerId = Guid.Parse(dt.Rows[i][j].ToString());
                            break;

                        //case "CustomerTypeID":
                        //    v.CustomerTypeID = Int32.Parse(dt.Rows[i][j].ToString());
                        //    break;
                        case "PackageRequest":
                            v.Packages = SerializeUtil.DeserializeFromXml <List <PackageRequest> >(dt.Rows[i][j].ToString());
                            break;

                        case "InShippingMethodID":
                            v.ShippingMethodId = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "GoodsTypeID":
                            v.ShippingTypeId = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "ReceivingExpenseID":
                            v.ReceivingExpenseID = Int32.Parse(dt.Rows[i][j].ToString());
                            break;

                        case "ShippingCity":
                            v.ShippingInfo.ShippingCity = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingState":
                            v.ShippingInfo.ShippingState = dt.Rows[i][j].ToString();
                            break;

                        case "ShippingZip":
                            v.ShippingInfo.ShippingZip = dt.Rows[i][j].ToString();
                            break;
                        }
                    }
                    list.Add(v);
                }
            }
            Log.Info("LMS收货需要更新运费运单获取完毕!");
            return(list);
        }