public List <eCommerceManualTracking> GetManualTracking(int shipmentId) { List <eCommerceManualTracking> list = new List <eCommerceManualTracking>(); list = new eCommerceShipmentRepository().GetManualTracking(shipmentId); return(list); }
public IHttpActionResult SetPrintPackageStatus(int eCommercePackageTrackingDetailId, string Type) { FrayteResult result = new FrayteResult(); result = new eCommerceShipmentRepository().SetPrintPackageStatus(eCommercePackageTrackingDetailId, Type); return(Ok(result)); }
public PrintLabel GetLabelFile(int eCommerceShipmentId, string LabelType) { PrintLabel file = new PrintLabel(); file = new eCommerceShipmentRepository().GetLabelFile(eCommerceShipmentId, LabelType); return(file); }
public FraytePackageResult PrintLabelAsPDF(int eCommerceShipmentId, string CourierCompany) { FraytePackageResult result = new FraytePackageResult(); var detail = new eCommerceShipmentRepository().GeteCommerceBookingDetail(eCommerceShipmentId, ""); var LabelDetail = new eCommerceShipmentRepository().GetLabelDetail(eCommerceShipmentId); string pdfFileName = string.Empty; string physycalpath = string.Empty; string str = string.Empty; string prfix = string.Empty; if (CourierCompany == FrayteCourierCompany.DHL || CourierCompany == FrayteCourierCompany.DHLExpress) { prfix = FrayteShortName.DHL; } str = prfix + "_" + detail.Packages[0].TrackingNo + " (All)"; pdfFileName = AppSettings.WebApiPath + "PackageLabel/eCommerce/" + eCommerceShipmentId + "/"; physycalpath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/" + str + ".pdf"); if (File.Exists(physycalpath)) { result.PackagePath = pdfFileName; result.IsDownloaded = true; } else { result.PackagePath = ""; result.IsDownloaded = false; } return(result); }
public IHttpActionResult CreateManifest(FrayteManifestShipment ManifestShipment) { var result = new ManifestRepository().CreateManifest(ManifestShipment); if (ManifestShipment.ModuleType == FrayteShipmentServiceType.eCommerce) { foreach (var item in ManifestShipment.DirectShipments) { // If All the Hscode for a shipment is mapped then send invoice email var Status = new eCommerceShipmentRepository().ISAllHSCodeMapped(item.ShipmentId); if (Status.Status) { eCommerceTaxAndDutyInvoiceReport invoiceReport = new eCommerceShipmentRepository().GeteCommerceInvoiceObj(item.ShipmentId); var reportResult = new Report.Generator.ManifestReport.eCommerceInvoiceReport().GenerateInvoiceReport(item.ShipmentId, invoiceReport); if (reportResult.Status) { var status = new eCommerceShipmentRepository().SaveeCommerceInvoice(item.ShipmentId, invoiceReport); try { // send mail to receiver with attached invoice new ShipmentEmailRepository().sendInVoiceMail(item.ShipmentId); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } } } return(Ok(result)); }
public PrintLabel GeneratePacakgelabel(int eCommerceShipmentId, int Id, string LabelType) { PrintLabel file = new PrintLabel(); file = new eCommerceShipmentRepository().GeneratePacakgelabel(eCommerceShipmentId, Id, LabelType); return(file); }
public IHttpActionResult CreateCommunication(InVoiceCommunication inVoiceCommunication) { try { FrayteResult result = new eCommerceShipmentRepository().CreateCommunication(inVoiceCommunication); return(Ok(result)); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(BadRequest()); } }
public List <UserEmailCommunication> GetEmailCommunication(int userId, int shipmentId) { try { List <UserEmailCommunication> list = new eCommerceShipmentRepository().GetEmailCommunication(userId, shipmentId); return(list); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(null); } }
public eCommerceTaxAndDutyInvoiceReport GetShipmentInvoice(string frayteNumber) { eCommerceTaxAndDutyInvoiceReport InvoiceReport = new eCommerceTaxAndDutyInvoiceReport(); var shipment = dbContext.eCommerceShipments.Where(p => p.FrayteNumber == frayteNumber).FirstOrDefault(); if (shipment != null) { InvoiceReport = new eCommerceShipmentRepository().GeteCommerceInvoiceObj(shipment.eCommerceShipmentId); // Fill extra data in invoice object new eCommerceShipmentRepository().GeteCommerceInvoceData(shipment.eCommerceShipmentId, InvoiceReport); } return(InvoiceReport); }
public FrayteResult SetShipmentHSCode(int eCommerceShipmentDetailid, string HSCode, string Description, int HsCodeId) { try { FrayteResult result = new HsCodeJobRepository().SetShipmentHSCode(eCommerceShipmentDetailid, HSCode, Description, HsCodeId); if (result.Status) { var Status = new HSCodeRepository().ISAllHSCodeMapped(eCommerceShipmentDetailid); if (Status.Status) { // Get Shipment Detail FrayteeCommerceShipmentDetail shipmentDetail = new eCommerceShipmentRepository().GeteCommerceBookingDetail(Status.Id, ""); var IsInVoiceCreated = new eCommerceShipmentRepository().IsInvoiceCreated(Status.Id); if (!IsInVoiceCreated) { // Generate model for invoice eCommerceTaxAndDutyInvoiceReport invoiceReport = new eCommerceShipmentRepository().GeteCommerceInvoiceObj(Status.Id); // Generate Invoice Report var reportResult = new Report.Generator.ManifestReport.eCommerceInvoiceReport().GenerateInvoiceReport(Status.Id, invoiceReport); if (reportResult.Status) { // Save Invoice Info var status = new eCommerceShipmentRepository().SaveeCommerceInvoice(Status.Id, invoiceReport); try { // send mail to receiver with attached invoice new ShipmentEmailRepository().sendInVoiceMail(Status.Id); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } } } return(result); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(new FrayteResult { Status = false }); } }
public IHttpActionResult SaveManualTracking(eCommTracking eCommerceTracking) { FrayteResult result = new FrayteResult(); if (eCommerceTracking != null && eCommerceTracking.Tracking != null) { eCommerceManualTracking result1 = new eCommerceShipmentRepository().SaveManualTracking(eCommerceTracking.Tracking); if (eCommerceTracking.SentEmailToReceiver && result1 != null && result1.eCommerceTrackingId > 0) { result = new ShipmentEmailRepository().SendManualTrackingEmail(eCommerceTracking.Tracking.eCommerceShipmentId, eCommerceTracking.Tracking); } return(Ok(result1)); } return(BadRequest()); }
public FrayteResult SetShipmentHSCode(int eCommerceShipmentDetailid, string HSCode) { try { FrayteResult result = new eCommerceShipmentRepository().SetShipmentHSCode(eCommerceShipmentDetailid, HSCode); return(result); } catch (Exception ex) { return(new FrayteResult { Status = false }); } }
public static void sendInvoiceEmail(string eCommerce) { try { string[] chars = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P" }; // Need to conver date time in customer time zone current = Frayte.Services.CommonConversion.ConvertToDateTime(DateTime.UtcNow.ToString("MM/dd/yyyy")); var eCommInvoices = new eCommerceShipmentRepository().GetUnpaideCommerceInvoives(); if (eCommInvoices != null && eCommInvoices.Count > 0) { foreach (var item in eCommInvoices) { var FreeStorageDateTime = item.ETADate.AddHours(item.FreeStorageTime.TotalHours); if (current > FreeStorageDateTime) { // Generate new invoice with free storage charge var invoices = new eCommerceShipmentRepository().GetShipmentInvoices(item.eCommerceShimentId); string cha = string.Empty; foreach (string x in chars) { if (invoices.FirstOrDefault().InvoiceRef.Contains(x)) { // Process... cha = x; break; } } int pos = Array.IndexOf(chars, cha); string invoiceToMake = string.Empty; if (pos > -1) { invoiceToMake = chars[pos + 1]; } new eCommerceShipmentRepository().GenerateNewInvoice(invoiceToMake, item); } } } } catch (Exception ex) { Logger _log = Get_Log(); _log.Info("Error due to eCommerce Invoive"); _log.Error(ex); } throw new NotImplementedException(); }
public FrayteManifestExcel GetManifestDetailFromExcel() { FrayteManifestExcel frayteManifestDetailexcel = new Services.Models.FrayteManifestExcel(); //var httpRequest = HttpContext.Current.Request; List <Frayte.Services.Models.FrayteManifestOnExcel> _Manifestdetail = new List <Frayte.Services.Models.FrayteManifestOnExcel>(); //Frayte.Services.Models.FrayteManifestOnExcel frayteManifestDetailexcel; //int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); string connString = ""; //string filename = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_") + file.FileName; //var filepath = HttpContext.Current.Server.MapPath(Utility.AppSettings.ManifestFolder); //var FilePaths = Directory.EnumerateFiles(Utility.AppSettings.ManifestFolder); var filePaths = Directory.GetFiles(Utility.AppSettings.ManifestFolder); foreach (var file in filePaths) { //StreamReader reader = new StreamReader(File.OpenRead(file)); //List<string> listA = new List<String>(); //List<string> listB = new List<String>(); //List<string> listC = new List<String>(); //List<string> listD = new List<String>(); ////string vara1, vara2, vara3, vara4; //while (!reader.EndOfStream) //{ // string line = reader.ReadLine(); // if (!String.IsNullOrWhiteSpace(line)) // { // string[] values = line.Split(','); // if (values.Length >= 3) // { // listA.Add(values[0]); // listB.Add(values[1]); // listC.Add(values[2]); // //listD.Add(values[3]); // } // } //} //string[] firstlistA = listA.ToArray(); //string[] firstlistB = listB.ToArray(); //string[] firstlistC = listC.ToArray(); //string[] firstlistD = listD.ToArray(); //file.Normalize(); //string contents = File.ReadAllText(file); var filepath = file; var filelen = file.Length - 15; //var sublenget = filelen5; //string filename = file.Substring(filelen, 15); var filePathLength = file.Length; var FileName = file.Split('\\'); var FileNameLength = FileName.Length; var filename = FileName[FileNameLength - 1]; //StreamReader sr = new StreamReader(filepath); //string Fulltext = sr.ReadToEnd(); //string filename = "MNUKCUS0006"; connString = new DirectShipmentRepository().getExcelConnectionString(filename, filepath); string fileExtension = ""; fileExtension = new DirectShipmentRepository().getFileExtensionString(filename); try { if (!string.IsNullOrEmpty(fileExtension)) { var ds = new DataSet(); if (fileExtension == FrayteFileExtension.CSV) { try { using (var conn = new OleDbConnection(connString)) { conn.Open(); var query = "SELECT * FROM [" + Path.GetFileName(filename) + "]"; using (var adapter = new OleDbDataAdapter(query, conn)) { adapter.Fill(ds, "CustomManifest"); } } } catch (Exception ex) { } } else { using (var conn = new OleDbConnection(connString)) { conn.Open(); DataTable dbSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); string firstSheetName = dbSchema.Rows[0]["TABLE_NAME"].ToString(); var query = "SELECT * FROM " + "[" + firstSheetName + "]";//[Sheet1$]"; using (var adapter = new OleDbDataAdapter(query, conn)) { adapter.Fill(ds, "CustomManifest"); } } } if (ds.Tables.Count > 0) { var exceldata = ds.Tables[0]; string PiecesColumnList = "CustomCommoditymap,CustomsEntryType,CustomsTotalValue,CustomsTotalVat,CustomsDuty"; //bool IsExcelValid = UtilityRepository.CheckUploadExcelFormat(PiecesColumnList, exceldata); bool IsExcelValid = true; if (!IsExcelValid) { frayteManifestDetailexcel.Message = "Columns are not matching with provided template columns. Please check the column names."; } else { if (exceldata.Rows.Count > 0) { _Manifestdetail = new eCommerceShipmentRepository().SaveCustomManifestDetail(exceldata); frayteManifestDetailexcel.FrayteManifestDetail = new List <Frayte.Services.Models.FrayteManifestOnExcel>(); frayteManifestDetailexcel.FrayteManifestDetail = _Manifestdetail; frayteManifestDetailexcel.Message = "OK"; } else { frayteManifestDetailexcel.Message = "No records found."; } } } } else { frayteManifestDetailexcel.Message = "Excel file not valid"; } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); if (ex != null && !string.IsNullOrEmpty(ex.Message) && ex.Message.Contains("Sheet1$")) { frayteManifestDetailexcel.Message = "Sheet name is invalid."; } else { frayteManifestDetailexcel.Message = "Error while uploading the excel."; } return(frayteManifestDetailexcel); } } return(frayteManifestDetailexcel); }
public FrayteResult GenerateECommerceLabelUploadShipmentReport(int eCommerceShipmentId, FrayteUploadshipment eCommerceBookingDetail, List <string> imgList, string CourierName) { FrayteResult result = new FrayteResult(); try { List <PdfImage> imglist = new List <PdfImage>(); PdfImage pbimage; foreach (var img in imgList) { pbimage = new PdfImage(); pbimage.FullPath = HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + eCommerceShipmentId + "/" + img; imglist.Add(pbimage); } string pdfPath = string.Empty; if (eCommerceBookingDetail != null) { string CourierCompany = eCommerceBookingDetail.CourierCompany; string TrackingNo = new eCommerceShipmentRepository().GetTrackingNo(eCommerceShipmentId); if (!string.IsNullOrEmpty(CourierCompany)) { pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + CourierCompany.Replace(" ", "") + "-" + TrackingNo + ".pdf"; } else { pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + CourierCompany.Replace(" ", "") + "-" + TrackingNo + ".pdf"; } } else { string[] ff = imgList[0].ToString().Split('.'); string name = ff[0].ToString(); pdfPath = HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + eCommerceShipmentId + "/" + name + ".pdf"; } if (File.Exists(pdfPath)) { File.Delete(pdfPath); } if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId)) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId); } if (CourierName == FrayteCourierCompany.TNT) { ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport(); report.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; report.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } else if (CourierName.Contains(FrayteCourierCompany.DHL)) { ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport(); dhlReport.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; dhlReport.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } else { ReportTemplate.Other.PackageLabelsPdfReport pbreport = new ReportTemplate.Other.PackageLabelsPdfReport(); pbreport.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = pbreport.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; pbreport.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } return(result); } catch (Exception ex) { result.Status = false; return(result); } }
public FrayteResult GeteCommerceShipmentLabelReportDetail(int eCommerceShipmentId, FrayteeCommerceShipmentLabelReport obj, string filename) { FrayteResult result = new FrayteResult(); FrayteeCommerceShipmentLabelReport frayteeCommerceLabelReport = new eCommerceShipmentRepository().GeteCommerceShipmentLabelReportDetail(obj); List <FrayteeCommerceShipmentLabelReport> reportDataSource = new List <FrayteeCommerceShipmentLabelReport>(); if (frayteeCommerceLabelReport != null) { ReportTemplate.Other.eCommerceLabelReport re = new ReportTemplate.Other.eCommerceLabelReport(); // Set ShipFrom Address In Label re.xrRichText1.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.LastName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address.ToUpper(); if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2)) { re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.Address2.ToUpper(); } re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.City.ToUpper(); if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode)) { re.xrRichText1.Text += " - " + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.PostCode.ToUpper(); } if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State)) { re.xrRichText1.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipFrom.State.ToUpper(); } // Set Shipto Address In Label re.xrRichText2.Text = frayteeCommerceLabelReport.eCommerceShipment.ShipTo.FirstName.ToUpper() + " " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.LastName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.CompanyName.ToUpper() + System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address.ToUpper(); if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2)) { re.xrRichText2.Text += ", " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.Address2.ToUpper(); } re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.City.ToUpper(); if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode)) { re.xrRichText2.Text += " - " + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.PostCode.ToUpper(); } if (!string.IsNullOrEmpty(frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State)) { re.xrRichText2.Text += System.Environment.NewLine + frayteeCommerceLabelReport.eCommerceShipment.ShipTo.State.ToUpper(); } reportDataSource.Add(frayteeCommerceLabelReport); re.Parameters["LogoPath"].Value = obj.BarcodePath; re.DataSource = reportDataSource; string filePathToSave = AppSettings.eCommerceLabelFolder + "/" + eCommerceShipmentId.ToString(); if (AppSettings.ShipmentCreatedFrom == "BATCH") { filePathToSave = AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId.ToString(); //filePathToSave = filePathToSave; } else { filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave); } //DevExpress.XtraPrinting.ExportOptions options = re.ExportOptions; DevExpress.XtraPrinting.ImageExportOptions imageOptions = re.PrintingSystem.ExportOptions.Image; if (imageOptions != null) { // Setup 150 DPI as default resolution for image exports imageOptions.Resolution = 3000; imageOptions.Format = ImageFormat.Jpeg; } DevExpress.XtraPrinting.PdfExportOptions pdfOptions = re.ExportOptions.Pdf; //pdfOptions.PageRange = "1"; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; if (!System.IO.Directory.Exists(filePathToSave)) { System.IO.Directory.CreateDirectory(filePathToSave); } //re.ExportToImage(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + FileName.ToString() + ".Jpeg", imageOptions); if (AppSettings.ShipmentCreatedFrom == "BATCH") { re.ExportToImage(AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId + "/" + filename + ".jpg", imageOptions); re.ExportToPdf(AppSettings.eCommerceUploadLabelFolder + eCommerceShipmentId + "/" + filename + ".pdf", pdfOptions); } else { re.ExportToImage(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + filename + ".jpg", imageOptions); re.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder) + "/" + eCommerceShipmentId + "/" + filename + ".pdf", pdfOptions); } result.Status = true; } else { result.Status = false; } return(result); }
public FrayteResult SavePaymentTransaction(OnlinePaymentModel item) { FrayteResult result = new FrayteResult(); eCommerceInvoiceTransaction transaction = new eCommerceInvoiceTransaction(); try { decimal amount = Math.Round(item.PaymentInfo.Pv_Amount, 2); if (item != null) { eCommerceInvoiceTransaction eCommerceTransaction; var invoice = dbContext.eCommerceInvoices.Where(p => p.InvoiceRef == item.PaymentInfo.Invoice_no).FirstOrDefault(); if (invoice != null) { var invoiceDetail = new eCommerceShipmentRepository().GeteCommerceInvoiceObj(invoice.ShipmentId); if (invoice.Status == eCommerceAppTaxAndDutyStatus.TaxAndDutyPaid) { try { // Make entry in transaction table eCommerceTransaction = new eCommerceInvoiceTransaction(); eCommerceTransaction.InvoiceId = invoice.InvoiceId; eCommerceTransaction.PaidAmount = amount; eCommerceTransaction.PaidBy = item.PaymentInfo.Email; eCommerceTransaction.PaidOnUtc = DateTime.UtcNow; eCommerceTransaction.PaymentMode = item.PaymentMode; dbContext.eCommerceInvoiceTransactions.Add(eCommerceTransaction); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { result.Status = false; } try { eCommerceUserCreditNote creditNote = new eCommerceUserCreditNote(); creditNote.ShipmentId = invoice.ShipmentId; creditNote.CreditNoteReference = invoice.InvoiceRef; creditNote.IssuedOnUtc = DateTime.UtcNow; creditNote.Amount = amount; creditNote.CurrencyCode = item.PaymentInfo.Currency.CurrencyCode; creditNote.eCommreceInvoiceId = invoice.InvoiceId; creditNote.IssuedTo = item.PaymentInfo.Email; creditNote.IssuedBy = 1; creditNote.Status = "NotUsed"; dbContext.eCommerceUserCreditNotes.Add(creditNote); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { } } else if (invoice.Status == eCommerceAppTaxAndDutyStatus.TaxAndDutyPartiallyPaid) { var transactions = dbContext.eCommerceInvoiceTransactions.Where(p => p.InvoiceId == invoice.InvoiceId).ToList(); try { // Make entry in transaction table eCommerceTransaction = new eCommerceInvoiceTransaction(); eCommerceTransaction.InvoiceId = invoice.InvoiceId; eCommerceTransaction.PaidAmount = amount; eCommerceTransaction.PaidBy = item.PaymentInfo.Email; eCommerceTransaction.PaidOnUtc = DateTime.UtcNow; eCommerceTransaction.PaymentMode = item.PaymentMode; dbContext.eCommerceInvoiceTransactions.Add(eCommerceTransaction); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { result.Status = false; } decimal totalPaidAmountTemp = 0.00M; if (transactions.Count > 0) { foreach (var trans in transactions) { totalPaidAmountTemp += trans.PaidAmount; } } amount = amount + Math.Round(totalPaidAmountTemp, 2); if (invoiceDetail.NettCharge == amount) { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPaid; } else if (invoiceDetail.NettCharge > amount) { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPartiallyPaid; } else { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPaid; try { eCommerceUserCreditNote creditNote = new eCommerceUserCreditNote(); creditNote.ShipmentId = invoice.ShipmentId; creditNote.CreditNoteReference = invoiceDetail.InvoiceRef; creditNote.IssuedOnUtc = DateTime.UtcNow; creditNote.Amount = amount - invoiceDetail.NettCharge; creditNote.CurrencyCode = item.PaymentInfo.Currency.CurrencyCode; creditNote.eCommreceInvoiceId = invoice.InvoiceId; creditNote.IssuedTo = item.PaymentInfo.Email; creditNote.IssuedBy = 1; creditNote.Status = "NotUsed"; dbContext.eCommerceUserCreditNotes.Add(creditNote); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } dbContext.SaveChanges(); result.Status = true; } else if (invoice.Status == eCommerceAppTaxAndDutyStatus.TaxAndDutyUnPaid) { try { // Make entry in transaction table eCommerceTransaction = new eCommerceInvoiceTransaction(); eCommerceTransaction.InvoiceId = invoice.InvoiceId; eCommerceTransaction.PaidAmount = amount; eCommerceTransaction.PaidBy = item.PaymentInfo.Email; eCommerceTransaction.PaidOnUtc = DateTime.UtcNow; eCommerceTransaction.PaymentMode = item.PaymentMode; dbContext.eCommerceInvoiceTransactions.Add(eCommerceTransaction); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { result.Status = false; } if (invoiceDetail.NettCharge == amount) { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPaid; } else if (invoiceDetail.NettCharge > amount) { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPartiallyPaid; } else { invoice.Status = eCommerceAppTaxAndDutyStatus.TaxAndDutyPaid; try { eCommerceUserCreditNote creditNote = new eCommerceUserCreditNote(); creditNote.ShipmentId = invoice.ShipmentId; creditNote.CreditNoteReference = invoiceDetail.InvoiceRef; creditNote.IssuedOnUtc = DateTime.UtcNow; creditNote.Amount = amount - invoiceDetail.NettCharge; creditNote.CurrencyCode = item.PaymentInfo.Currency.CurrencyCode; creditNote.eCommreceInvoiceId = invoice.InvoiceId; creditNote.IssuedTo = item.PaymentInfo.Email; creditNote.IssuedBy = 1; creditNote.Status = "NotUsed"; dbContext.eCommerceUserCreditNotes.Add(creditNote); dbContext.SaveChanges(); result.Status = true; } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } dbContext.SaveChanges(); result.Status = true; } } } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } return(result); }
public IHttpActionResult PrintAllLabels(int eCommerceShipmentId, string LabelType) { FrayteResult result = new eCommerceShipmentRepository().PrintAllLabels(eCommerceShipmentId, LabelType); return(Ok(result)); }
public FrayteResult Generate_Seperate_PackageLabelPDF(int eCommercShipmentId, FrayteCommerceShipmentDraft eCommerceBookingDetail) { FrayteResult result = new FrayteResult(); result.Errors = new List <string>(); List <string> list = new List <string>(); List <string> list1 = new List <string>(); var Packages = new eCommerceShipmentRepository().GetPackageDetails(eCommercShipmentId); if (Packages != null) { foreach (var pack in Packages) { var packageTracking = new eCommerceShipmentRepository().GeteCommercePackageTracking(pack.eCommerceShipmentDetailId); if (packageTracking != null && packageTracking.Count > 0) { foreach (var data in packageTracking) { list.Add(data.PackageImage); list1.Add(data.PackageImage); var resultReport = new Report.Generator.ManifestReport.PackageLabelReport().GenerateECommerceLabelReport(eCommercShipmentId, null, list1, eCommerceBookingDetail.CourierCompany, ""); if (!resultReport.Status) { result.Status = false; result.Errors.Add("All the labels Pdf are not generated for " + eCommercShipmentId.ToString()); } list1.Remove(data.PackageImage); } } else { result.Status = false; result.Errors.Add("All the labels Pdf are not generated for " + eCommercShipmentId.ToString()); } } string labelName = string.Empty; string LogisticLabel = string.Empty; var TrackingNo = new eCommerceShipmentRepository().GetTrackingNo(eCommercShipmentId); if (eCommerceBookingDetail.CourierCompany == FrayteCourierCompany.DHL || eCommerceBookingDetail.CourierCompany == FrayteCourierCompany.DHLExpress) { labelName = FrayteShortName.DHL; } LogisticLabel = labelName + "_" + TrackingNo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; var Result = new Report.Generator.ManifestReport.PackageLabelReport().GenerateECommerceLabelReport(eCommercShipmentId, eCommerceBookingDetail, list, eCommerceBookingDetail.CourierCompany, LogisticLabel); if (Result.Status) { new eCommerceShipmentRepository().SaveFrayteLabel(eCommercShipmentId, LogisticLabel, eCommLabelType.CourierLabel); } } else { result.Status = false; result.Errors.Add("All the labels Pdf are not generated fo " + eCommercShipmentId.ToString()); } return(result); }
public IHttpActionResult SaveEmailCommunication(InvoiceEmailCommunication emailCommunication) { FrayteResult result = new eCommerceShipmentRepository().SaveEmailCommunication(emailCommunication); return(Ok(result)); }
private string Generate_PackageLabelPDF(int eCommerceShipmentId) { string pageStyleSheet = HttpContext.Current.Server.MapPath("~/Content/") + "print.css"; string bootStrapStyleSheet = HttpContext.Current.Server.MapPath("~/Content/") + "bootstrap.min.css"; string pdfLogo = HttpContext.Current.Server.MapPath("~/Content/") + "FrayteLogo.png"; // var detail = new DirectShipmentRepository().GetPackageList(eCommerceShipmentId, CourierCompany, RateType); var detail = new eCommerceShipmentRepository().GetPackageList(eCommerceShipmentId); string TrackingNo = new eCommerceShipmentRepository().GetTrackingNo(eCommerceShipmentId); FrayteShipmentPackageLabel obj = new FrayteShipmentPackageLabel(); obj.PackageLabel = new List <FraytePackageLabel>(); obj.PackageLabel = detail; obj.PageStyleSheet = pageStyleSheet; obj.BootStrapStyleSheet = bootStrapStyleSheet; obj.pdfLogo = pdfLogo; string template = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Templates/PrintLabel.cshtml")); var templateService = new TemplateService(); var EmailBody = Engine.Razor.RunCompile(template, "PackageLabel_", null, obj); string pdfFileName = string.Empty; pdfFileName = TrackingNo + ".html"; string pdfFilePath = HttpContext.Current.Server.MapPath("~/UploadFiles/PDFGenerator/HTMLFile"); string pdfFullPath = pdfFilePath + @"\" + pdfFileName; using (FileStream fs = new FileStream(pdfFullPath, FileMode.Create)) { using (StreamWriter w = new StreamWriter(fs, System.Text.Encoding.UTF8)) { w.WriteLine(EmailBody); } } List <string> lstHtmlFiles = new List <string>(); lstHtmlFiles.Add(pdfFullPath); //Before creating new PDF file, remove the earlier one. System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.eCommerceLabelFolder + eCommerceShipmentId + "/")); string pdfPath = string.Empty; // pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + TrackingNo + ".pdf"; //"AWBUK-" + DateTime.UtcNow.Year.ToString().Substring(2, 2) + DateTime.UtcNow.ToString("MM") + GetFormattedManifestId(int eCommerceShipmentId) pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/") + "AWBUK-" + DateTime.UtcNow.Year.ToString().Substring(2, 2) + DateTime.UtcNow.ToString("MM") + GetFormattedManifestId(eCommerceShipmentId) + ".pdf"; if (File.Exists(pdfPath)) { File.Delete(pdfPath); } string pdfFile = string.Empty; pdfFile = Frayte.WebApi.Utility.PDFGenerator.HtmlToPdf("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/", "AWBUK-" + DateTime.UtcNow.Year.ToString().Substring(2, 2) + DateTime.UtcNow.ToString("MM") + GetFormattedManifestId(eCommerceShipmentId), lstHtmlFiles.ToArray(), null); if (System.IO.File.Exists(pdfFullPath)) { System.IO.File.Delete(pdfFullPath); } return(pdfFile); }
public IHttpActionResult AddUserCreditNote(eCommerceInvoiceCreditNote creditNote) { FrayteResult result = new eCommerceShipmentRepository().AddUserCreditNote(creditNote); return(Ok(result)); }
public eCommerceInvoiceAccounting InVoiceAndAcounting(int userId, int shipmentId) { eCommerceInvoiceAccounting result = new eCommerceShipmentRepository().GetInVoiceAndAcounting(userId, shipmentId); return(result); }
public List <DirectBookingCustomer> GeteCommerceCustomers(int userId) { var customers = new eCommerceShipmentRepository().GetDirectBookingCustomers(userId); return(customers); }
public IHttpActionResult SaveBooking(FrayteCommerceShipmentDraft eCommerceBookingDetail) { int eCommerceShipmentId = 0; FrayteResult result = new FrayteResult(); //Step 1: Save the information in database // eCommerceBookingDetail.Error eCommerceBookingDetail.Error = new eCommerceShipmentRepository().SaveBooking(eCommerceBookingDetail); if (eCommerceBookingDetail.Error.Status && eCommerceBookingDetail.BookingStatusType == FrayteBookingStatusType.Current) { //Step 2: Shipment Integrations //EasyPost Integration here List <FrayteCommercePackageTrackingDetail> shipmentPackageTrackingDetail = new List <FrayteCommercePackageTrackingDetail>(); // int Id = 0; var easyPostObj = new EasyPostRepository().MapShipmentToEasyPostShipment(eCommerceBookingDetail); var easyPostResult = new EasyPostRepository().CreateShipment(easyPostObj); eCommerceBookingDetail.Error = easyPostResult.Errors; try { if (easyPostResult.Errors.Status) { } } catch (Exception ex2) { easyPostResult.Errors.Miscellaneous = new List <string>(); easyPostResult.Errors.Miscellaneous.Add(ex2.Message); Elmah.ErrorSignal.FromCurrentContext().Raise(ex2); easyPostResult.Errors.Status = false; } if (eCommerceBookingDetail.Error != null && eCommerceBookingDetail.Error.Status == true) { //Finally Save the Order Id too to get the information of multiple shpment in Tracking Detail page. eCommerceShipmentId = new eCommerceShipmentRepository().SaveOrderNumber(eCommerceBookingDetail, easyPostResult.Order.id, eCommerceBookingDetail.CustomerId); var easypostImage = new eCommerceShipmentRepository().DownloadEasyPostImages(easyPostResult.Order.shipments[0].tracking_code, easyPostResult.Order.shipments[0].postage_label.label_url, eCommerceShipmentId); // EasyPost label string labelPath = HttpContext.Current.Server.MapPath("~/PackageLabel/eCommerce/" + eCommerceShipmentId + "/"); int calculatedHeight = 1400; int LocationY = 0; //After creating an order need to save the information in database var shipmentDetails = new eCommerceShipmentRepository().GetPackageDetails(eCommerceShipmentId); int increment = 0; int sum = eCommerceBookingDetail.Packages.Sum(p => p.CartoonValue); for (int j = 0; j < eCommerceBookingDetail.Packages.Count; j++) { for (int i = 0; i < eCommerceBookingDetail.Packages[j].CartoonValue; i++) { increment++; var data = shipmentDetails[j]; // Step 1 : database entry var trackingDetail = new eCommerceShipmentRepository().SaveEasyPostDetailTrackingDeatil(eCommerceBookingDetail, eCommerceBookingDetail.Packages[j], data, easyPostResult.Order.shipments[0].tracking_code, easyPostResult.Order.shipments[0].postage_label.label_url, eCommerceShipmentId, increment); // Step 2: Create frayte AWB label and save label name string awbLabelName = generateAWBLabel(eCommerceShipmentId, eCommerceBookingDetail, increment, eCommerceBookingDetail.Packages[j]); new eCommerceShipmentRepository().SaveAWBLabelName(trackingDetail, awbLabelName + ".pdf"); // Step 3 : crop image and save var res = new EasyPostRepository().CropeImage(trackingDetail, eCommerceBookingDetail.CourierCompany, easypostImage, labelPath, calculatedHeight, LocationY, increment, sum); LocationY += calculatedHeight; } } // Generate Courier Label Generate_Seperate_PackageLabelPDF(eCommerceShipmentId, eCommerceBookingDetail); generateAWBLabel(eCommerceShipmentId, eCommerceBookingDetail, 0, null); // Send SMS to consignee string message = string.Empty; // Generate Invoice Report if (eCommerceBookingDetail.Error.IsMailSend) { //Send mail to developer // new ShipmentEmailRepository().SendeCommerceShipmentErrorMail(eCommerceBookingDetail, eCommerceBookingDetail.Error); } if (eCommerceBookingDetail.Error.Status) { //SendDirectBookingConfirmationMailAsync(directBookingDetail); new ShipmentEmailRepository().SendeCommercreBookingConfirmationMail(eCommerceBookingDetail, eCommerceShipmentId); } FrayteDirectShipment shipmentdetail = new eCommerceShipmentRepository().GetShipmentDetail(eCommerceShipmentId); if (shipmentdetail != null) { eCommerceBookingDetail.DirectShipmentDraftId = shipmentdetail.DirectShipmentId; eCommerceBookingDetail.ShipFrom.DirectShipmentAddressDraftId = shipmentdetail.FromAddressId; eCommerceBookingDetail.ShipTo.DirectShipmentAddressDraftId = shipmentdetail.ToAddressId; eCommerceBookingDetail.ShipmentStatusId = shipmentdetail.ShipmentStatusId; } } } return(Ok(eCommerceBookingDetail)); }