public AUResponseModel CreateShipment(AURequestModel auRequest) { AUResponseModel respone = new AUResponseModel(); string result = string.Empty; respone.Status = WebApiCalling(auRequest, ref respone); respone.Quantity = auRequest.Quantity; respone.InvoiceNumber = auRequest.InvoiceNumber; return(respone); }
public AURequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail) { try { AURequestModel au = new AURequestModel(); //Address au.ShipFrom = MappShipFrom(directBookingDetail.ShipFrom); au.ShipTo = MappShipTo(directBookingDetail.ShipTo); var referance = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1; var ProductDescription = string.Join("-", directBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()); var productDescriptionWithSpecialInstrucation = ProductDescription + " SPI " + referance; //Addition au.ClientId = "232"; au.CustomerId = "197"; au.WarehouseId = "221"; au.UserId = directBookingDetail.CustomerRateCard.CourierAccountNo; au.UserName = "******"; au.DirectShipmentDraftid = directBookingDetail.DirectShipmentDraftId; au.InvoiceNumber = directBookingDetail.FrayteNumber; au.ProductDescription = productDescriptionWithSpecialInstrucation; au.Quantity = directBookingDetail.Packages.Sum(k => k.CartoonValue); au.Value = directBookingDetail.Packages.Sum(k => k.Value); au.Weight = directBookingDetail.CustomerRateCard.Weight; au.CollectionDate = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("MM/dd/yyyy"); au.Currency = directBookingDetail.Currency.CurrencyCode; au.DestinationCountry = "AUS"; au.CarrierType = "TOLLCARTONS"; return(au); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Shipment is not created " + ex.Message)); return(null); } }
private bool WebApiCalling(AURequestModel auRequest, ref AUResponseModel respone) { bool status = false; string qeury = "Client_Id=" + auRequest.ClientId.Trim() + "&Customer_Id=" + auRequest.CustomerId.Trim() + "&Warehouse_Id=" + auRequest.WarehouseId.Trim() + "&User_Id=" + auRequest.UserId.Trim() + "&user_name=" + auRequest.UserName.Trim() + "&invoice_number=" + auRequest.InvoiceNumber.Trim() + "&delname=" + auRequest.ShipTo.Name.Trim() + "&deladdr1=" + auRequest.ShipTo.Address1.Trim() + "&deladdr2=" + auRequest.ShipTo.Address2 + "&deladdr3=" + auRequest.ShipTo.City + "&deladdr4=" + auRequest.ShipTo.State.Trim() + "&State=" + auRequest.ShipTo.State.Trim() + "&postcode=" + auRequest.ShipTo.PostalCode.Trim() + "&delPhone=" + auRequest.ShipTo.Phone.Trim() + "&delemail=" + (string.IsNullOrWhiteSpace(auRequest.ShipTo.Email) ? "''" : auRequest.ShipTo.Email) + "&product_description=" + auRequest.ProductDescription.Trim() + "&shipped_quantity=" + Convert.ToInt32(auRequest.Quantity) + "&value=" + auRequest.Value + "&weight=" + auRequest.Weight + "&shipped_date=" + auRequest.CollectionDate.Trim() + "&Currency=" + auRequest.Currency.Trim() + "&ShipperName1=" + auRequest.ShipFrom.Name.Trim() + "&ShipperAddr1=" + auRequest.ShipFrom.Address1.Trim() + "&ShipperAddr2=" + (string.IsNullOrWhiteSpace(auRequest.ShipTo.Address2.Trim()) ? "''" : auRequest.ShipTo.Address2.Trim()) + "&ShipperAddr3=" + auRequest.ShipFrom.City.Trim() + "&ShipperCity=" + auRequest.ShipFrom.City.Trim() + "&ShipperState=" + (string.IsNullOrWhiteSpace(auRequest.ShipFrom.State.Trim()) ? auRequest.ShipFrom.City.Trim() : auRequest.ShipFrom.State.Trim()) + "&ShipperPostcode=" + auRequest.ShipFrom.PostalCode + "&ShipperCountry=" + auRequest.ShipFrom.Country + "&DestinationCountry=" + auRequest.DestinationCountry + "&Carriertype=" + auRequest.CarrierType; string url = "http://eretail.amservices.net.au:82/api/PDFLabelV2?" + qeury; var uri = new Uri(url); WebClient client = new WebClient(); client.UseDefaultCredentials = true; client.Credentials = CredentialCache.DefaultCredentials; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; SslProtocols _Tls12 = (SslProtocols)0x00000C00; SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12; ServicePointManager.SecurityProtocol = Tls12; //lable string Image = string.Empty; string labelName = string.Empty; labelName = FrayteShortName.AU; // Create a file to write to. Image = labelName + "_" + auRequest.InvoiceNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + "1" + " of " + "1" + ")" + ".pdf"; var targeturl = AppSettings.UploadFolderPath + "/Shipments/" + auRequest.DirectShipmentDraftid + "/"; //end if (System.IO.Directory.Exists(targeturl)) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { client.DownloadFile(uri, targeturl + Image); status = File.Exists(targeturl + Image); respone.Status = status; respone.TempDownload_Folder = targeturl; respone.TempDownlaodLabelName = Image; } else { client.DownloadFile(uri, targeturl + Image); status = File.Exists(targeturl + Image); respone.Status = status; respone.TempDownload_Folder = targeturl; respone.TempDownlaodLabelName = Image; } } else { if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(targeturl); client.DownloadFile(uri, targeturl + Image); status = File.Exists(targeturl + Image); respone.Status = status; respone.TempDownload_Folder = targeturl; respone.TempDownlaodLabelName = Image; } else { System.IO.Directory.CreateDirectory(targeturl); client.DownloadFile(uri, targeturl + Image); status = File.Exists(targeturl + Image); respone.Status = status; respone.TempDownload_Folder = targeturl; respone.TempDownlaodLabelName = Image; } } return(status); }