//public int InsurenceCurrency { get; set; } public static byte[] CreateLabel(ShippingLabel dhl, out string awbNumber) { var shipmentLabel = GetLabelRequestXML(dhl); //ShipmentResponse shimentResponse = SendRequest(shipmentLabel); var labelData = SendRequest(shipmentLabel, out awbNumber); if (labelData.StartsWith("ERROR")) { //Mail.SendMailOnLabelIssue(dhl, labelData); return(new byte[] { }); } return(Convert.FromBase64String(labelData)); }
private static string GetLabelRequestXML(ShippingLabel label) { var xml = ""; xml = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath("~/Models/DHL/ShipmentLabel.xml")); xml = xml.Replace("%%SITEID%%", label.SiteID); xml = xml.Replace("%%PASSWORD%%", label.Password); xml = xml.Replace("%%SHIPPERACCOUNTNUMBER%%", label.ShipperAccountNumber); xml = xml.Replace("%%CONSIGNEE_COMPANYNAME%%", label.Consignee_CompanyName); xml = xml.Replace("%%CONSIGNEE_ADDRESS1%%", label.Consignee_Address1 + " " + label.Consignee_AddressNumber); xml = xml.Replace("%%CONSIGNEE_ADDRESS2%%", label.Consignee_Address2); xml = xml.Replace("%%CONSIGNEE_CITY%%", label.Consignee_City); xml = xml.Replace("%%CONSIGNEE_POSTALCODE%%", label.Consignee_PostalCode); xml = xml.Replace("%%CONSIGNEE_COUNTRYCODE%%", label.Consignee_CountryCode); xml = xml.Replace("%%CONSIGNEE_COUNTRYNAME%%", label.Consignee_CountryName); xml = xml.Replace("%%CONSIGNEE_CONTACT_PERSONNAME%%", label.Consignee_Contact_PersonName); xml = xml.Replace("%%CONSIGNEE_CONTACT_PHONENUMBER%%", label.Consignee_Contact_PhoneNumber); xml = xml.Replace("%%ITEMNUMBER%%", label.ItemNumber); xml = xml.Replace("%%WEIGHT%%", label.Weight.ToString()); xml = xml.Replace("%%PAYMENT_DATE%%", DateTime.Now.ToString("yyyy-MM-dd")); xml = xml.Replace("%%ITEM_NAME%%", label.ItemName); xml = xml.Replace("%%SHIPPERID%%", label.ShipperID); xml = xml.Replace("%%SHIPPERNAME%%", label.ShipperName); xml = xml.Replace("%%REGISTEREDACCOUNT%%", label.RegisteredAccount); xml = xml.Replace("%%SHIPPER_ADDRESS1%%", label.Shipper_Address1 + " " + label.Shipper_AddressNumber); xml = xml.Replace("%%SHIPPER_ADDRESS2%%", label.Shipper_Address2); xml = xml.Replace("%%SHIPPER_CITY%%", label.Shipper_City); xml = xml.Replace("%%SHIPPER_POSTALCODE%%", label.Shipper_PostalCode); xml = xml.Replace("%%SHIPPER_COUNTRYCODE%%", label.Shipper_CountryCode); xml = xml.Replace("%%SHIPPER_COUNTRYNAME%%", label.Shipper_CountryName); xml = xml.Replace("%%SHIPPER_PHONENUMBER%%", label.Shipper_PhoneNumber); xml = xml.Replace("%%SHIPMENT_TYPE%%", label.ShipmentType); xml = xml.Replace("%%DUTY%%", label.Duty); xml = xml.Replace("%%INSURENCE_VALUE%%", DHL.ShippingLabel.GetInsurenceValue(label.SelectedInsurenceValue)); xml = xml.Replace("%%CUSTOM_VALUE%%", DHL.ShippingLabel.GetCustomValue(label.SelectedInsurenceValue)); xml = xml.Replace("%%SPECIAL_SERVICE_TYPE%%", DHL.ShippingLabel.GetShipmentType(label.SelectedInsurenceValue)); return(xml); }