public IntegrtaionResult MapUSPSIntegrationResponse(USPSResponse response) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (response.trackingNumber != null) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.USPS; integrtaionResult.TrackingNumber = response.trackingNumber; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = response.trackingNumber; obj.ImageUrl = response.labelImage; integrtaionResult.PieceTrackingDetails.Add(obj); return(integrtaionResult); } else { integrtaionResult.Status = false; integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.IsMailSend = true; integrtaionResult.Error.Custom = new List <string>(); integrtaionResult.Error.Address = new List <string>(); integrtaionResult.Error.Package = new List <string>(); integrtaionResult.Error.Service = new List <string>(); integrtaionResult.Error.ServiceError = new List <string>(); integrtaionResult.Error.Miscellaneous = new List <string>(); integrtaionResult.Error.Miscellaneous.Add(response.error); return(integrtaionResult); } }
public IntegrtaionResult MapDPDCHIntegrationResponse(DPDChResponseModel dpdchShipmentResponse) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (dpdchShipmentResponse.Error == null) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.DPDCH; integrtaionResult.TrackingNumber = dpdchShipmentResponse.ShipmentResponses.ParcelLabelNumber[0].ToString(); integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); foreach (var data in dpdchShipmentResponse.ShipmentResponses.ParcelLabelNumber) { CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = data; obj.ImageByte = dpdchShipmentResponse.ParcelLabelPDF; integrtaionResult.PieceTrackingDetails.Add(obj); } } else { integrtaionResult.Error = dpdchShipmentResponse.Error; integrtaionResult.ErrorCode = new List <FrayteApiError>(); { List <FrayteApiError> _api = new FrayteApiErrorCodeRepository().SaveFinilizeApiError(integrtaionResult.Error, FrayteLogisticServiceType.DPDCH, null); integrtaionResult.ErrorCode = _api; } integrtaionResult.Status = false; } return(integrtaionResult); }
public IntegrtaionResult MapEAMGlobalIntegrationResponse(EAMGlobalResponse eamPostalResponse, List <PackageDraft> Packages) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (eamPostalResponse.Status) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.EAM; integrtaionResult.TrackingNumber = eamPostalResponse.AWB; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); int counter = 0; for (int i = 0; i < Packages.Count(); i++) { for (int j = 0; j < Packages[i].CartoonValue; j++) { CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = string.Concat(eamPostalResponse.AWB, counter); obj.ImageUrl = eamPostalResponse.LabelUrl; integrtaionResult.PieceTrackingDetails.Add(obj); counter++; } } } else { integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.Service = new List <string>(); integrtaionResult.Error.Service.AddRange(eamPostalResponse.ERROR); integrtaionResult.Status = false; } return(integrtaionResult); }
public IntegrtaionResult MapBringIntegrationResponse(BringResponseModel bringResponse) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (bringResponse.errors == null) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.BRING; integrtaionResult.TrackingNumber = bringResponse.consignments[0].confirmation.consignmentNumber; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); foreach (var data in bringResponse.consignments[0].confirmation.packages) { CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = data.packageNumber; obj.ImageUrl = bringResponse.consignments[0].confirmation.links.labels; integrtaionResult.PieceTrackingDetails.Add(obj); } } else { integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.Service = new List <string>(); foreach (var item in bringResponse.errors) { string error = string.Empty; error = item.code + "-" + "" + item.messages; integrtaionResult.Error.Service.Add(error); } integrtaionResult.Status = false; } return(integrtaionResult); }
public string ExpressDownloadDPDHtmlImage(CourierPieceDetail pieceDetails, int totalPiece, int count, int DirectShipmentid, string Carrier) { string Image = string.Empty; if (Image != null) { string labelName = string.Empty; labelName = Carrier; // Create a file to write to. Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".html"; if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentid + "/")) { File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentid + "/" + Image, pieceDetails.ImageByte); } else { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentid + "/"); File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentid + "/" + Image, pieceDetails.ImageByte); } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + DirectShipmentid + "/")) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { File.WriteAllText(AppSettings.LabelFolder + "/Express/" + DirectShipmentid + "/" + Image, pieceDetails.ImageByte); } else { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + DirectShipmentid + "/" + Image); File.WriteAllText(path, pieceDetails.ImageByte); } } else { if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + DirectShipmentid); File.WriteAllText(AppSettings.LabelFolder + "/Express/" + DirectShipmentid + "/" + Image, pieceDetails.ImageByte); } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + DirectShipmentid)); File.WriteAllText(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + DirectShipmentid + "/" + Image), pieceDetails.ImageByte); } } } } return(Image); }
public IntegrtaionResult MapSkyPostalIntegrationResponse(SkyPostalResponse response) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (response.data[0].label_tracking_number_01 != null) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.SKYPOSTAL; integrtaionResult.TrackingNumber = response.data[0].label_tracking_number_01; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = response.data[0].label_tracking_number_01; obj.ImageUrl = response.data[0].label_url_pdf; integrtaionResult.PieceTrackingDetails.Add(obj); return(integrtaionResult); } else { integrtaionResult.Status = false; integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.IsMailSend = true; integrtaionResult.Error.Custom = new List <string>(); integrtaionResult.Error.Address = new List <string>(); integrtaionResult.Error.Package = new List <string>(); integrtaionResult.Error.Service = new List <string>(); integrtaionResult.Error.ServiceError = new List <string>(); integrtaionResult.Error.Miscellaneous = new List <string>(); for (int i = 0; i < response.data.Count; i++) { for (int j = 0; j < response.data[i].error.Count; j++) { integrtaionResult.Error.Miscellaneous.Add(response.data[i].error[j].error_description); } } } return(integrtaionResult); }
public IntegrtaionResult MapAUIntegrationResponse(AUResponseModel auResponse) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (auResponse != null) { integrtaionResult.Status = auResponse.Status; integrtaionResult.CourierName = FrayteCourierCompany.AU; integrtaionResult.TrackingNumber = auResponse.InvoiceNumber; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); for (int i = 0; i < auResponse.Quantity; i++) { string PieceTrackingNumber = string.Concat(auResponse.InvoiceNumber, i.ToString()); CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = PieceTrackingNumber; obj.ImageUrl = auResponse.TempDownload_Folder; obj.LabelName = auResponse.TempDownlaodLabelName; integrtaionResult.PieceTrackingDetails.Add(obj); } } else { integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.Miscellaneous = new List <string>(); integrtaionResult.Error.Miscellaneous.Add(auResponse.Error); integrtaionResult.ErrorCode = new List <FrayteApiError>(); { List <FrayteApiError> _api = new FrayteApiErrorCodeRepository().SaveFinilizeApiError(integrtaionResult.Error, FrayteLogisticServiceType.DPD, null); integrtaionResult.ErrorCode = _api; } integrtaionResult.Status = false; } return(integrtaionResult); }
public IntegrtaionResult MapCanadaPostIntegrationResponse(EtowerResponseModel eTowerResponse, List <OrderItem> orderItems) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (eTowerResponse.status == "Success") { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.CANADAPOST; integrtaionResult.TrackingNumber = eTowerResponse.data[0].trackingNo; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); int counter = 1; for (int i = 0; i < orderItems.Count; i++) { CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = string.Concat(eTowerResponse.data[0].trackingNo, counter); obj.ImageByte = eTowerResponse.data[0].labelContent; integrtaionResult.PieceTrackingDetails.Add(obj); counter++; } } else { integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.Service = new List <string>(); foreach (var item in eTowerResponse.errors) { string error = string.Empty; error = item.code + "-" + "" + item.message; integrtaionResult.Error.Service.Add(error); } integrtaionResult.Status = false; } return(integrtaionResult); }
public string DownloadExpressUSPSImage(CourierPieceDetail pieceDetails, int totalPiece, int count, int ExpressShipmentid) { string Imagename = string.Empty; if (pieceDetails.ImageUrl != null) { string labelName = string.Empty; labelName = FrayteShortName.USPS; // Create a file to write to. Imagename = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".png"; if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/")) { File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Imagename, pieceDetails.ImageUrl); } else { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/"); File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Imagename, pieceDetails.ImageUrl); } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/")) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Imagename, pieceDetails.ImageUrl); } else { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Imagename); File.WriteAllText(path, pieceDetails.ImageUrl); } } else { if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid); File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Imagename, pieceDetails.ImageUrl); } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid)); string path = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + ExpressShipmentid + "/" + Imagename); try { bool status = false; byte[] bytes = Convert.FromBase64String(pieceDetails.ImageUrl); Image image; using (MemoryStream ms = new MemoryStream(bytes)) { image = Image.FromStream(ms); System.Drawing.Bitmap bmpUploadedImage = new System.Drawing.Bitmap(image); System.Drawing.Image thumbnailImage = bmpUploadedImage.GetThumbnailImage(812, 1624, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); thumbnailImage.Save(@"" + path); } status = File.Exists(path); if (status) { return(Imagename); } else { Imagename = string.Empty; } } catch (Exception ex) { Imagename = string.Empty; } } } } } return(Imagename); }
public string DownloadExpressDPDCHBytetoImage(CourierPieceDetail pieceDetails, int totalPiece, int count, int shipmentId) { string Image = string.Empty; if (Image != null) { string labelName = string.Empty; labelName = FrayteCourierCompany.DPDCH; // Create a file to write to. Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".pdf"; if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + shipmentId + "/")) { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + shipmentId + "/" + Image); try { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadLine(); } } else { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + shipmentId + "/"); string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + shipmentId + "/" + Image); try { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadLine(); } } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + shipmentId + "/")) { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + shipmentId + "/" + Image); if (AppSettings.ShipmentCreatedFrom == "BATCH") { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } else { try { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.ReadLine(); } } } else { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + shipmentId + "/" + Image); if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + shipmentId); try { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } catch (Exception e) { } } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + shipmentId)); try { byte[] sPDFDecoded = Convert.FromBase64String(pieceDetails.ImageByte); File.WriteAllBytes(path, sPDFDecoded); } catch (Exception e) { } } } } } return(Image); }
public string DownloadExpressEAMImageTOPDF(CourierPieceDetail pieceDetails, int totalPiece, int count, int ExpressShipmentid, HubService Carrier) { string Image = string.Empty; if (pieceDetails.ImageUrl != null) { string labelName = string.Empty; labelName = Carrier.HubCarrier; // Create a file to write to. if (pieceDetails.ImageUrl.Contains(".html")) { Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".html"; } else { Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".pdf"; } if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/")) { var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image; try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path1); status = File.Exists(path1); if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } else { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/"); var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image; try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path1); status = File.Exists(path1); if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/")) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte); var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image; try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path1); status = File.Exists(path1); if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } else { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image); File.WriteAllText(path, pieceDetails.ImageByte); } } else { if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid); var path1 = AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image; try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path1); status = File.Exists(path1); if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid)); string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image); try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path); status = File.Exists(path); if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } } } } return(Image); }
public string DownloadExpressSkyPostalImage(CourierPieceDetail pieceDetails, int totalPiece, int count, int ExpressShipmentid) { string Image = string.Empty; if (pieceDetails.ImageUrl != null) { string labelName = string.Empty; labelName = FrayteShortName.SKYPOSTAL; // Create a file to write to. Image = labelName + "_" + pieceDetails.PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + count + " of " + totalPiece + ")" + ".pdf"; if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/")) { File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte); } else { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/"); File.WriteAllText(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte); } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/")) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte); } else { string path = HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image); File.WriteAllText(path, pieceDetails.ImageByte); } } else { if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid); File.WriteAllText(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid + "/" + Image, pieceDetails.ImageByte); } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/Express/" + ExpressShipmentid)); string path = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + ExpressShipmentid + "/" + Image); try { bool status = false; 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; client.DownloadFile(pieceDetails.ImageUrl, path); status = File.Exists(path); string resultPath = @"" + path + ""; using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor()) { pdfDocumentProcessor.LoadDocument(resultPath); int angle = 0; foreach (PdfPage page in pdfDocumentProcessor.Document.Pages) { angle = (angle + 180) % 360; page.Rotate = angle; } pdfDocumentProcessor.SaveDocument(resultPath); } if (status) { return(Image); } else { Image = string.Empty; } } catch (Exception ex) { Image = string.Empty; } } } } } return(Image); }
public string DownloadAUPDF(CourierPieceDetail pieceDetails, int totalPiece, int count, int DirectShipmentid) { string Image = string.Empty; if (Image != null) { string labelName = string.Empty; labelName = FrayteShortName.AU; Image = pieceDetails.LabelName; // Create a file to write to. if (AppSettings.LabelSave == "") { if (System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentid + "/")) { } else { } } else { if (System.IO.Directory.Exists(AppSettings.LabelFolder + "/" + DirectShipmentid + "/")) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { } else { } } else { // labelimage.RotateFlip(RotateFlipType.Rotate90FlipNone); if (AppSettings.ShipmentCreatedFrom == "BATCH") { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/" + DirectShipmentid); } else { System.IO.Directory.CreateDirectory(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/" + DirectShipmentid)); if (System.IO.Directory.Exists(pieceDetails.ImageUrl)) { string[] files = System.IO.Directory.GetFiles(pieceDetails.ImageUrl); // Copy the files and overwrite destination files if they already exist. foreach (string s in files) { // Use static Path methods to extract only the file name from the path. var destFile = System.IO.Path.Combine(HostingEnvironment.MapPath(AppSettings.LabelFolder + "/" + DirectShipmentid), pieceDetails.LabelName); System.IO.File.Copy(s, destFile, true); System.IO.Directory.Delete(pieceDetails.ImageUrl, true); } } } } } } return(Image); }