public TradelaneMappedUnMappedShipment IsAllHawbAssigned(int tradelaneShipmentId) { TradelaneMappedUnMappedShipment result = new TradelaneMappedUnMappedShipment(); result = new TradelaneBookingRepository().IsAllHawbAssigned(tradelaneShipmentId); return(result); }
public FrayteResult UpdateHAWBNumber(int shipmentId, int hawbNumber) { FrayteResult result = new FrayteResult(); result = new TradelaneBookingRepository().UpdateHAWBNumber(shipmentId, hawbNumber); return(result); }
public List <TradelaneCartonLabelReport> GetCartonLabelObj(int tradelaneShipmentId, string hawb) { try { List <TradelaneCartonLabelReport> list = new List <TradelaneCartonLabelReport>(); TradelaneCartonLabelReport reportModel = new TradelaneCartonLabelReport(); var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); reportModel.MAWB = ShipmentDetail.AirlinePreference.AilineCode + " " + ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(4, 4); reportModel.MAWBBarCode = ShipmentDetail.AirlinePreference.AilineCode + ShipmentDetail.MAWB; reportModel.TotalPieces = dbContext.TradelaneShipmentDetails.Where(a => a.TradelaneShipmentId == tradelaneShipmentId).ToList().Count.ToString(); reportModel.HawbScannedCarton = dbContext.TradelaneShipmentDetails.Where(a => a.HAWB == hawb && a.IsScaned == true).Count(); reportModel.HAWBBarCodeValue = hawb; reportModel.HAWBTotalPieces = ShipmentDetail.HAWBPackages.Where(a => a.HAWB == hawb).FirstOrDefault().PackagesCount; reportModel.HAWB = hawb + " " + ShipmentDetail.DestinationAirport.AirportCode; reportModel.HAWBBarCode = hawb + " " + ShipmentDetail.DestinationAirport.AirportCode; reportModel.DestinationAirportCode = ShipmentDetail.DestinationAirport.AirportCode; reportModel.Destination = ShipmentDetail.DestinationAirport.AirportCode; reportModel.Departure = ShipmentDetail.ShipFrom.Country.Name; reportModel.CarrierCode2 = ShipmentDetail.AirlinePreference.CarrierCode2; reportModel.DepartureAirportCode = ShipmentDetail.DepartureAirport.AirportCode; list.Add(reportModel); return(list); } catch (Exception ex) { return(null); } }
public IHttpActionResult UploadMAWBDocument() { string status = string.Empty; var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { HttpFileCollection files = httpRequest.Files; HttpPostedFile file = files[0]; if (!string.IsNullOrEmpty(file.FileName)) { try { int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); int UserId = Convert.ToInt32(httpRequest.Form["UserId"].ToString()); string DocType = httpRequest.Form["DocType"].ToString(); string filename = file.FileName; string documentType = string.Empty; if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/")); } string fileNameWithoutExtension = new TradelaneBookingRepository().GetFileNameFromString(filename); if (!string.IsNullOrEmpty(fileNameWithoutExtension)) { var list = new TradelaneBookingRepository().GetMAWBDocuments(ShipmentId, FrayteShipmentDocumentType.MAWB); string extension = new TradelaneBookingRepository().GetFileExtensionFromString(filename); if (list != null && list[0].RevisionNumber > 1) { filename = fileNameWithoutExtension + "_REV - " + (list[0].RevisionNumber + 1) + "." + extension; } string filepath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/" + filename); file.SaveAs(filepath); FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(ShipmentId, FrayteShipmentDocumentType.MAWB, filename, UserId); if (result.Status) { status = "Ok"; } else { status = "Failed"; } } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } return(Ok(status)); }
public FrayteResult AssigneedHAWB(List <TrackTradelanePackage> packages) { FrayteResult result = new FrayteResult(); result = new TradelaneBookingRepository().AssigneedHAWB(packages); return(result); }
public ExportManifestPdfModel GetExportManifestPDFDataSource(int TradelaneShipmentId) { ExportManifestPdfModel EMPM = new ExportManifestPdfModel(); var Result = dbContext.ExpressManifests.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).FirstOrDefault(); TradelaneBooking ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(TradelaneShipmentId, ""); if (Result != null) { EMPM.ExportManifestName = "Origin Manifest-" + Result.BarCode + " (" + ShipmentDetail.ShipmentHandlerMethod.DisplayName + ")"; EMPM.BarCode = Result.BarCode; EMPM.PrintedBy = dbContext.Users.Where(a => a.UserId == Result.CreadtdBy.Value).FirstOrDefault().ContactName; EMPM.PrintedOn = GetDateTimeString(Result.CreadtdBy, Result.CreatedOn); EMPM.PickUpAddress = UtilityRepository.ConcatinateExpressAddress(ShipmentDetail.ShipFrom); EMPM.MawbInfo = new List <ExpressMawbInformationModel>(); var MawbDtl = dbContext.TradelaneShipmentAllocations.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).ToList(); if (MawbDtl != null && MawbDtl.Count > 0) { foreach (var MD in MawbDtl) { ExpressMawbInformationModel ExMa = new ExpressMawbInformationModel(); ExMa.Airline = GetAirlineName(MD.AirlineId); ExMa.ETA = GetDateTimeZone(MD.AgentId, MD.EstimatedDateofArrival).Item1; ExMa.ETD = GetDateTimeZone(MD.AgentId, MD.EstimatedDateofDelivery).Item1; ExMa.ETATimeZone = GetDateTimeZone(MD.AgentId, MD.EstimatedDateofDelivery).Item2; ExMa.ETDTimeZone = GetDateTimeZone(MD.AgentId, MD.EstimatedDateofDelivery).Item2; ExMa.FlightNo = MD.FlightNumber; var AirlineCode = ExMa.Airline.Split('-'); ExMa.Mawb = AirlineCode[1].Substring(1, 3) + " " + MD.MAWB.Substring(0, 4) + " " + MD.MAWB.Substring(4, 4); EMPM.MawbInfo.Add(ExMa); } } EMPM.BagsInfo = new List <BagDetail>(); var list = dbContext.spGet_GetExpressManifestedShipments(Result.ExpressManifestId).ToList(); ExpressViewManifest EVM = new ExpressViewManifest(); EVM.ManifestedList = new List <ExpressManifestDetail>(); if (list != null && list.Count > 0) { var Bags = list.GroupBy(a => a.BagBarCode).ToList(); foreach (var b in Bags) { BagDetail Bg = new BagDetail(); EVM.ManifestName = Bags.FirstOrDefault().FirstOrDefault().BarCode; Bg.BagNumber = b.FirstOrDefault().BagBarCode; Bg.Carrier = b.FirstOrDefault().Carrier; Bg.ExporterName = b.FirstOrDefault().ContactName; Bg.TotalPieces = b.FirstOrDefault().TotalNoOfShipments.Value; Bg.TotalWeight = b.FirstOrDefault().TotalWeight; EMPM.BagsInfo.Add(Bg); } } } return(EMPM); }
public IHttpActionResult ChangeMAWBAddress(TradelBookingAdress address) { try { FrayteResult result = new TradelaneBookingRepository().ChangeMAWBAddress(address); return(Ok(result)); } catch (Exception ex) { return(BadRequest()); } }
public TradelaneBooking TradelaneBookingDetails(int shipmentId, string callingType) { try { TradelaneBooking shipment = new TradelaneBookingRepository().GetTradelaneBookingDetails(shipmentId, callingType); return(shipment); } catch (Exception ex) { return(null); } }
public List <TradelaneCustomer> GetCustomers(int userId, string moduleType) { try { List <TradelaneCustomer> customers = new TradelaneBookingRepository().GetCustomers(userId, moduleType); return(customers); } catch (Exception ex) { return(null); } }
public TradelaneFile ShipmentCoLoadForm(int tradelaneShipmentId) { TradelaneFile result = new TradelaneFile(); TradelaneBooking ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); List <TradelaneBookingCoLoadFormModel> ColoadModel = new TradelaneReportsRepository().ColoadReportObj(ShipmentDetail); ReportTemplate.Tradelane.CoLoadBookingForm report = new ReportTemplate.Tradelane.CoLoadBookingForm(); if (ColoadModel[0].OperationZoneId == 1) { report.Parameters["lblWebSite"].Value = "WWW.FRAYTE.COM"; report.Parameters["lblCompany"].Value = "FRAYTE LOGISTICS LTD"; report.Parameters["lblAddress1"].Value = "UNIT 2306, 23/F, Trendy Center"; report.Parameters["lblAddress2"].Value = "682-684 Castle Peak Road"; report.Parameters["lblAddress3"].Value = "CHEUNG SHA WAN, HONG KONG"; } else { report.Parameters["lblWebSite"].Value = "WWW.FRAYTE.CO.UK"; report.Parameters["lblCompany"].Value = "FRAYTE LOGISTICS LTD"; report.Parameters["lblAddress1"].Value = "UNIT 2306, 23/F, Trendy Center"; report.Parameters["lblAddress2"].Value = "682-684 Castle Peak Road"; report.Parameters["lblAddress3"].Value = "CHEUNG SHA WAN, HONG KONG"; } report.DataSource = ColoadModel; PdfExportOptions options = new PdfExportOptions(); options.ImageQuality = PdfJpegImageQuality.Highest; options.PdfACompatibility = PdfACompatibility.None; string fileName = "Co_Load_Booking_Form_for_" + (!string.IsNullOrEmpty(ColoadModel[0].MawbNo) ? ColoadModel[0].DestinationAirport + "_" + ColoadModel[0].MawbNo : ColoadModel[0].FrayteNumber) + ".pdf"; string filePath = AppSettings.WebApiPath + "/UploadFiles/Tradelane/" + tradelaneShipmentId + "/" + fileName; string filePhysicalPath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/"); filePhysicalPath += fileName; if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/")); } if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } report.ExportToPdf(filePhysicalPath, options); result.FileName = fileName; result.FilePath = filePath; return(result); }
public IHttpActionResult UploadOtherDocument() { string status = string.Empty; var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { HttpFileCollection files = httpRequest.Files; HttpPostedFile file = files[0]; if (!string.IsNullOrEmpty(file.FileName)) { try { int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); int UserId = Convert.ToInt32(httpRequest.Form["UserId"].ToString()); string DocType = httpRequest.Form["DocType"].ToString(); string filename = file.FileName; string documentType = string.Empty; if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/")); } string filepath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + ShipmentId + "/" + filename); if ((System.IO.File.Exists(filepath))) { documentType = new TradelaneBookingRepository().GetFileDocumentType(ShipmentId, filename); status = documentType; } else { file.SaveAs(filepath); FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(ShipmentId, FrayteShipmentDocumentType.OtherDocument, filename, UserId); if (result.Status) { status = "Ok"; } else { status = "Failed"; } } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } } } return(Ok(status)); }
public IHttpActionResult RemoveTradelaneDocument(int TradelaneShipmentDocumentId) { try { FrayteResult result = new FrayteResult(); result = new TradelaneBookingRepository().RemoveTradelaneDocument(TradelaneShipmentDocumentId); return(Ok(result)); } catch (Exception ex) { return(BadRequest()); } }
public IHttpActionResult UploadBatteryForms() { try { var httpRequest = HttpContext.Current.Request; ShipmentRepository shipmentRepository = new ShipmentRepository(); HttpFileCollection files = httpRequest.Files; int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); int UserId = Convert.ToInt32(httpRequest.Form["UserId"].ToString()); var docfiles = new List <string>(); string filePathToSave = string.Format(FrayteTradelaneDocumentPath.ShipmentDocument, ShipmentId); string fileFullPath = ""; filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave); if (!System.IO.Directory.Exists(filePathToSave)) { System.IO.Directory.CreateDirectory(filePathToSave); } //This code will execute only when user will upload the document if (files.Count > 0) { HttpPostedFile file = files[0]; if (!string.IsNullOrEmpty(file.FileName)) { if (!File.Exists(filePathToSave + file.FileName)) { //Save in server folder fileFullPath = filePathToSave + file.FileName; file.SaveAs(fileFullPath); //Save file name and other information in DB FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(ShipmentId, FrayteShipmentDocumentType.BatteryForm, file.FileName, UserId); return(Ok(result)); } else { return(BadRequest("BatteryForm")); } } } return(BadRequest()); } catch (Exception ex) { return(BadRequest()); } }
public IHttpActionResult PrintLabel(TradelanePrintLabel PrintLabelObj) { var Tradelaneshipment = new TradelaneBookingRepository().GetTradelaneDetail(PrintLabelObj); if (PrintLabelObj.CartonList != null && Tradelaneshipment != null && Tradelaneshipment.TradelaneShipmentId > 0) { var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(Tradelaneshipment.TradelaneShipmentId, ""); var HawbCount = ShipmentDetail.HAWBPackages.Where(a => a.HAWB == PrintLabelObj.Hawb).FirstOrDefault().PackagesCount; var Result = new TradelaneBookingRepository().HawbUpdate(ShipmentDetail, PrintLabelObj); var Files = new TradelaneDocument().ShipmentCartonLabel(Tradelaneshipment.TradelaneShipmentId, HawbCount, Tradelaneshipment.TradelaneShipmentDetailId, PrintLabelObj.Hawb); TradelanePrintLabelResponseModel model = new TradelanePrintLabelResponseModel(); string filePhysicalPath = string.Empty; model.FileName = Files != null && Files.FileName != null ? Files.FileName : ""; model.FileExtension = ".png"; filePhysicalPath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + Tradelaneshipment.TradelaneShipmentId + "/" + Files.FileName); using (MemoryStream ms = new MemoryStream()) { using (FileStream file = new FileStream(filePhysicalPath, FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[file.Length]; file.Read(bytes, 0, (int)file.Length); ms.Write(bytes, 0, (int)file.Length); //string test = ms.ToString(); //StreamReader sr = new StreamReader(filePhysicalPath); //string tsd = sr.ReadToEnd(); //var res = File.ReadAllBytes(filePhysicalPath); //string result = System.Text.Encoding.UTF8.GetString(res); HttpResponseMessage httpResponseMessage = new HttpResponseMessage(); httpResponseMessage.Content = new ByteArrayContent(bytes); httpResponseMessage.Content.Headers.Add("download-status", "downloaded"); httpResponseMessage.Content.Headers.Add("x-filename", model.FileName); httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); httpResponseMessage.Content.Headers.ContentDisposition.FileName = model.FileName; httpResponseMessage.StatusCode = HttpStatusCode.OK; model.ByteArray = httpResponseMessage; } } return(Ok(model)); } else { return(BadRequest()); } }
public HttpResponseMessage BookingInitials(int userId) { //Step 1: Get Country list List <FrayteCountryCode> lstCountry = new List <FrayteCountryCode>(); lstCountry = new CountryRepository().lstCountry(); //Step 2: Get Shipment Hanler Methods var lstShipmentHandlerMethods = new MasterDataRepository().GetShipmentHandlerMethod(); //Step 3: Get Currency var lstCurrencyTypes = new MasterDataRepository().GetCurrencyType(); //Step4: Get Customer Detail var customerDetail = new TradelaneBookingRepository().GetCustomerDetail(userId); //Step4.1: Get Customer Detail var customerAddress = new TradelaneBookingRepository().UserDefaultAddresses(userId); // Step 5 : Get Country PhoneCode List <FrayteCountryPhoneCode> lstCountryPhones = new List <FrayteCountryPhoneCode>(); lstCountryPhones = new CountryRepository().GetCountryPhoneCodeList(); // step:6 get all operation zones var OperaionZones = new OperationZoneRepository().GetOperationZone(); // step:7 get all Airlines var listAirlines = new MasterDataRepository().GetAirlines(); var timeZones = new TimeZoneRepository().GetShipmentTimeZones(); var lstincoterm = new BreakBulkRepository().GetIncoterms(); return(this.Request.CreateResponse( HttpStatusCode.OK, new { Countries = lstCountry, CurrencyTypes = lstCurrencyTypes, ShipmentMethods = lstShipmentHandlerMethods, CustomerDetail = customerDetail, CustomerAddress = customerAddress, CountryPhoneCodes = lstCountryPhones, AirLines = listAirlines, TimeZones = timeZones, OperaionZones = OperaionZones, Incoterm = lstincoterm })); }
public IHttpActionResult ShipmentMAWBAsHAWB(ShipmentMAWBAsHAWBModel obj) { try { if (obj != null) { bool status = new TradelaneBookingRepository().ShipmentMAWBAsHAWB(obj); return(Ok(status)); } return(BadRequest()); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return(BadRequest()); } }
public IHttpActionResult PlaceBooking(TradelaneBooking shipment) { shipment = new TradelaneBookingRepository().SaveShipment(shipment, ""); if (shipment.ShipmentStatusId != (int)FrayteTradelaneShipmentStatus.Draft) { TradelaneEmailModel model = new TradelaneEmailRepository().TradelaneEmailObj(shipment.TradelaneShipmentId); // Fill all the required info in the email model model.ShipmentDetail.ShipFrom.IsMailSend = shipment.ShipFrom.IsMailSend; model.ShipmentDetail.ShipTo.IsMailSend = shipment.ShipTo.IsMailSend; model.ShipmentDetail.NotifyParty.IsMailSend = shipment.NotifyParty.IsMailSend; new TradelaneEmailRepository().FillBookingInformationEmailModel(model); if (shipment.ShipmentStatusId == (int)FrayteTradelaneShipmentStatus.Pending) { // Send Shipment info email created by new TradelaneEmailRepository().SendEmail_E1(model); // Send Booking Confirmation email to customer new TradelaneEmailRepository().FillBookingConfirmationEmailModel(model); new TradelaneEmailRepository().SendEmail_E2(model); } else { // Customer Confirmation email new TradelaneEmailRepository().SendEmail_E2_1(model); // Send MAWB AllocationEMail new TradelaneEmailRepository().FillModel_E3(model); new TradelaneEmailRepository().SendEmail_E3(model); // Add shipment tracking new TradelaneBookingRepository().SaveShipmentTracking(shipment); // Add FLight Detail new TradelaneBookingRepository().SaveShipmentFlightDetail(shipment); } } return(Ok(shipment)); }
public TradelaneFile ShipmentCartonLabel(int tradelaneShipmentId, int CartonCount, int TradelaneShipmentDetailId, string Hawb) { TradelaneFile result = new TradelaneFile(); var model = new TradelaneReportsRepository().GetCartonLabelObj(tradelaneShipmentId, Hawb); ReportTemplate.Tradelane.PackageLabel shipmentDetailReport = new Report.Generator.ReportTemplate.Tradelane.PackageLabel(); model.FirstOrDefault().ScannedPieces = int.Parse(model.FirstOrDefault().TotalPieces); model.FirstOrDefault().TotalPieces = model.FirstOrDefault().HawbScannedCarton + "/" + model.FirstOrDefault().HAWBTotalPieces; shipmentDetailReport.DataSource = model; ImageExportOptions options = new ImageExportOptions(); options.Resolution = 150; var Name = new TradelaneBookingRepository().GetLastScannedCarton(tradelaneShipmentId); string fileName = Name + ".jpeg"; string filePath = AppSettings.WebApiPath + "/UploadFiles/Tradelane/" + tradelaneShipmentId + "/" + fileName; string filePhysicalPath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/" + fileName); if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + tradelaneShipmentId + "/")); } if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } shipmentDetailReport.ExportToImage(filePhysicalPath, options); string resultPath = @"" + filePhysicalPath + ""; using (System.Drawing.Image img = System.Drawing.Image.FromFile(resultPath)) { img.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone); resultPath = @"" + filePhysicalPath + ""; img.Save(resultPath, System.Drawing.Imaging.ImageFormat.Jpeg); } result.FileName = fileName; result.FilePath = filePath; return(result); }
public IHttpActionResult PrintLabelWithPath(TradelanePrintLabel PrintLabelObj) { var Tradelaneshipment = new TradelaneBookingRepository().GetTradelaneDetail(PrintLabelObj); if (PrintLabelObj.CartonList != null && Tradelaneshipment != null && Tradelaneshipment.TradelaneShipmentId > 0) { var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(Tradelaneshipment.TradelaneShipmentId, ""); var HawbCount = ShipmentDetail.HAWBPackages.Where(a => a.HAWB == PrintLabelObj.Hawb).FirstOrDefault().TotalCartons; var Result = new TradelaneBookingRepository().HawbUpdate(ShipmentDetail, PrintLabelObj); var Files = new TradelaneDocument().ShipmentCartonLabel(Tradelaneshipment.TradelaneShipmentId, HawbCount, Tradelaneshipment.TradelaneShipmentDetailId, PrintLabelObj.Hawb); TradelanePrintLabelResponseModel model = new TradelanePrintLabelResponseModel(); string filePhysicalPath = string.Empty; model.FileName = Files != null && Files.FileName != null ? Files.FileName : ""; model.FileExtension = ".jpeg"; // AppSettings.WebApiPath + "UploadFiles\\Tradelane\\ model.FilePath = AppSettings.WebApiPath + "UploadFiles\\Tradelane\\" + Tradelaneshipment.TradelaneShipmentId + "/" + Files.FileName; return(Ok(model)); } else { return(BadRequest()); } }
public TradelaneFile HAWBLabel(string HAWB, int index, int TradelaneShipmentDetailId) { TradelaneFile result = new TradelaneFile(); List <HawbLabel> _model = new List <HawbLabel>(); HawbLabel model = new TradelaneBookingRepository().CreateHawbLabels(HAWB, index, TradelaneShipmentDetailId); _model.Add(model); ReportTemplate.Tradelane.HAWBLabel report = new ReportTemplate.Tradelane.HAWBLabel(); report.DataSource = _model; string fileName = "HAWB_No_" + model.HAWB + ".pdf"; PdfExportOptions options = new PdfExportOptions(); options.ImageQuality = PdfJpegImageQuality.Highest; options.PdfACompatibility = PdfACompatibility.None; string filePath = AppSettings.WebApiPath + "/UploadFiles/Tradelane/" + model.TradelaneShipmentId + "/" + fileName; string filePhysicalPath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + model.TradelaneShipmentId + "/" + fileName); if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + model.TradelaneShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + model.TradelaneShipmentId + "/")); } if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } report.ExportToPdf(filePhysicalPath, options); result.FileName = fileName; result.FilePath = filePath; return(result); }
public TradelaneFile TadelaneShipmentDriverManifest(int TradelaneShipmentId, int userId) { TradelaneFile result = new TradelaneFile(); List <ExpressReportDriverManifest> model = new TradelaneBookingRepository().TradeLaneDriverManifest(TradelaneShipmentId, userId); ReportTemplate.Tradelane.DriverManifestExpressSolution report = new ReportTemplate.Tradelane.DriverManifestExpressSolution(); report.DataSource = model; string filePhysicalPath = string.Empty; string fileName = "Destination Manifest TLN" + "-" + "MN" + "-" + model[0].Code + "-" + model[0].MAWB + ".pdf"; string filePath = AppSettings.WebApiPath + "/UploadFiles/Tradelane/" + TradelaneShipmentId + "/" + fileName; if (AppSettings.ShipmentCreatedFrom == "BATCH") { filePhysicalPath = AppSettings.UploadFolderPath + "/Tradelane/" + TradelaneShipmentId + "/" + fileName; if (!System.IO.Directory.Exists(AppSettings.UploadFolderPath + "/Tradelane/" + TradelaneShipmentId + "/")) { System.IO.Directory.CreateDirectory(AppSettings.UploadFolderPath + "/Tradelane/" + TradelaneShipmentId + "/"); } } else { filePhysicalPath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + TradelaneShipmentId + "/" + fileName); if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + TradelaneShipmentId + "/"))) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + TradelaneShipmentId + "/")); } } if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } report.ExportToPdf(filePhysicalPath); result.FileName = fileName; result.FilePath = filePath; return(result); }
public IHttpActionResult SaveMAWBdetail(TradelaneMAWBDetail mawbDetail) { try { new TradelaneBookingRepository().SaveSalesOrderNumber(mawbDetail.HAWBpackages); var result = new MawbAllocationRepository().SaveMawbDetail(mawbDetail); if (result.Status) { result = new TradelaneBookingRepository().UpdateMAWBDetail(mawbDetail); new TradelaneEmailRepository().MawbUpdateMail(mawbDetail.TradelaneShipmentId); return(Ok(result)); } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest()); } }
public List <ExpressReportDriverManifest> GetDriverManifestReportObj(int tradelaneShipmentId, int userId) { List <ExpressReportDriverManifest> list = new List <ExpressReportDriverManifest>(); try { var user = dbContext.Users.Find(userId); string refNO = CommonConversion.GetNewFrayteNumber(); var customerDetail = (from r in dbContext.Users join s in dbContext.TradelaneShipments on r.UserId equals s.CustomerId where s.TradelaneShipmentId == tradelaneShipmentId select new { CustomerName = r.CompanyName }).FirstOrDefault(); var Result = dbContext.ExpressManifests.Where(a => a.TradelaneShipmentId == tradelaneShipmentId).FirstOrDefault(); var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); var hub = (from r in dbContext.ExpressManifests join h in dbContext.Hubs on r.HubId equals h.HubId where r.TradelaneShipmentId == tradelaneShipmentId select h ).FirstOrDefault(); ExpressReportDriverManifest reportObj = new ExpressReportDriverManifest(); reportObj.Ref = refNO; reportObj.Barcode = Result.BarCode; reportObj.DriverManifestName = "Destination Manifest-" + Result.BarCode + " (" + ShipmentDetail.ShipmentHandlerMethod.DisplayName + ")"; // EMPM.ExportManifestName = "Origin Manifest-" + Result.BarCode + " (" + ShipmentDetail.ShipmentHandlerMethod.DisplayName + ")"; reportObj.Hub = hub.Code; reportObj.MAWB = ShipmentDetail.AirlinePreference.AilineCode + " " + ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(4, 4); reportObj.PrintedBy = user.ContactName; var userInfo = (from r in dbContext.Users join tz in dbContext.Timezones on r.TimezoneId equals tz.TimezoneId where r.UserId == userId select tz ).FirstOrDefault(); var UserTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name); //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo); DateTime date = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item1; string time = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item2); // Append the created by time zone in time reportObj.PrintedDateTime = date.ToString("dd-MMM-yy") + " " + time + " " + userInfo.OffsetShort; //reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, ""); if (hub != null) { TradelBookingAdress address = new TradelBookingAdress(); address.Address = hub.Address; address.Address2 = hub.Address2; address.City = hub.City; address.State = hub.State; address.PostCode = hub.PostCode; address.Country = new FrayteCountryCode(); address.Phone = hub.TelephoneNo; address.CompanyName = hub.Name; var country = dbContext.Countries.Where(p => p.CountryId == hub.CountryId).FirstOrDefault(); if (country != null) { address.Country.CountryId = country.CountryId; address.Country.Code = country.CountryCode; address.Country.Code2 = country.CountryCode2; address.Country.Name = country.CountryName; } reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(address, ""); } //reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, ""); reportObj.MAWBChargeableWeight = ShipmentDetail.HAWBPackages.Sum(p => p.TotalWeight * p.TotalCartons); reportObj.MAWBGrossWeight = ShipmentDetail.HAWBPackages.Sum(p => p.TotalWeight * p.TotalCartons); if (ShipmentDetail.ShipmentHandlerMethod.ShipmentHandlerMethodId == 5) { var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId && p.LegNum == "Leg2").OrderByDescending(p => p.TradelaneShipmentAllocationId).FirstOrDefault(); reportObj.FlightNumber = shipmentAllocation.FlightNumber; var Airline = dbContext.Airlines.Find(shipmentAllocation.AirlineId); if (Airline != null) { reportObj.Airline = Airline.AirLineName + " - " + Airline.CarrierCode3; } var timezone = dbContext.Timezones.Find(shipmentAllocation.TimezoneId); if (timezone != null) { var TimeZoneInfor = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name); //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo); DateTime date1 = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item1; string time1 = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item2); // Append the created by time zone in time reportObj.ETA = date1.ToString("dd-MMM-yy") + " " + time1; reportObj.ETATimeZone = "(" + timezone.OffsetShort + ")"; } } else { var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).OrderByDescending(p => p.TradelaneShipmentAllocationId).FirstOrDefault(); reportObj.FlightNumber = shipmentAllocation.FlightNumber; var Airline = dbContext.Airlines.Find(shipmentAllocation.AirlineId); if (Airline != null) { reportObj.Airline = Airline.AirLineName + " - " + Airline.CarrierCode3; } var timezone = dbContext.Timezones.Find(shipmentAllocation.TimezoneId); if (timezone != null) { var TimeZoneInfor = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name); //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo); DateTime date1 = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item1; string time1 = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item2); // Append the created by time zone in time reportObj.ETA = date1.ToString("dd-MMM-yy") + " " + time1; reportObj.ETATimeZone = "(" + timezone.OffsetShort + ")"; } } reportObj.CarrierBags = new List <ExpressReportDriverManifestBagDetail>(); ExpressReportDriverManifestBagDetail mn; var detail = (from r in dbContext.ExpressManifests join b in dbContext.ExpressBags on r.ExpressManifestId equals b.ManifestId where r.TradelaneShipmentId == tradelaneShipmentId select b).GroupBy(group => group.Courier).Select(p => new { key = p.Key, data = p.Select(q => new { Id = q.DriverManifestId, DriverManifestNumber = dbContext.ExpressDriverManifests.Where(a => a.ExpressDriverManifestId == q.DriverManifestId).FirstOrDefault().DriverManifestBarCode, Carrier = q.Courier, BagBarCode = q.BagBarCode, BagId = q.BagId, BagNumber = q.BagNumber, HubCarrierId = q.HubCarrierId }).ToList() }).ToList(); if (detail.Count > 0) { foreach (var item in detail) { int hubCarrierId = item.data[0].HubCarrierId.HasValue ? item.data[0].HubCarrierId.Value : 0; var hubCarrier = dbContext.HubCarriers.Where(p => p.HubCarrierId == hubCarrierId).FirstOrDefault(); mn = new ExpressReportDriverManifestBagDetail(); mn.Carrier = item.key; mn.CutOffTime = hubCarrier.CutOffTime; mn.NoOfBags = item.data.Count; decimal totalWeight = 0.00M; int totalPieces = 0; foreach (var item1 in item.data) { var ship = (from r in dbContext.Expresses join d in dbContext.ExpressDetails on r.ExpressId equals d.ExpressId where r.BagId == item1.BagId select d ).ToList(); totalPieces += ship.Count; totalWeight = ship.Sum(p => p.Weight * p.CartonQty); } mn.TotalPieces = totalPieces; mn.TotalWeight = totalWeight; reportObj.CarrierBags.Add(mn); } reportObj.CarrierManifests = new List <ExpressReportDriverCarrierManifest>(); ExpressReportDriverCarrierManifest cm; foreach (var item in detail) { cm = new ExpressReportDriverCarrierManifest(); int hubCarrierId = item.data[0].HubCarrierId.HasValue ? item.data[0].HubCarrierId.Value : 0; cm.CarrierManifestBarcoede = item.data.FirstOrDefault().DriverManifestNumber; cm.CarrierManifest = item.key + " - (" + item.data.FirstOrDefault().DriverManifestNumber + ")" + " Destination Manifest"; cm.CarrierBagDetails = new List <ExpressReportCarrierBagDetail>(); ExpressReportCarrierBagDetail d; var hubCarrier = dbContext.HubCarriers.Where(p => p.HubCarrierId == hubCarrierId).FirstOrDefault(); if (hubCarrier != null) { TradelBookingAdress address = new TradelBookingAdress(); address.Address = hubCarrier.Address; address.Address2 = hubCarrier.Address2; address.City = hubCarrier.City; address.State = hubCarrier.State; address.PostCode = hubCarrier.PostCode; address.Country = new FrayteCountryCode(); address.Phone = hubCarrier.TelephoneNo; address.CompanyName = hubCarrier.CompanyName; var country = dbContext.Countries.Where(p => p.CountryId == hubCarrier.CountryId).FirstOrDefault(); if (country != null) { address.Country.CountryId = country.CountryId; address.Country.Code = country.CountryCode; address.Country.Code2 = country.CountryCode2; address.Country.Name = country.CountryName; } cm.DropOffAddress = UtilityRepository.ConcatinateAddress(address, ""); } foreach (var item1 in item.data) { d = new ExpressReportCarrierBagDetail(); d.BagNumber = item1.BagNumber; var sdf = (from r in dbContext.Expresses join ed in dbContext.ExpressDetails on r.ExpressId equals ed.ExpressId where r.BagId == item1.BagId select ed ).ToList(); d.TotalPieces = sdf.Count; d.ExporterName = customerDetail.CustomerName; d.TotalWeight = sdf.Sum(p => p.CartonQty * p.Weight); d.Carrier = item.key; d.BagId = item1.BagId; d.TermAndCondition = hubCarrier.TermAndCondition; cm.CarrierBagDetails.Add(d); } reportObj.CarrierManifests.Add(cm); } } list.Add(reportObj); return(list); } catch (Exception ex) { return(list); } }
public List <TradelaneManifestReport> ManifestReportModel(int tradelaneShipmentId, int userId) { List <TradelaneManifestReport> list = new List <TradelaneManifestReport>(); TradelaneManifestReport reportModel = new TradelaneManifestReport(); TradelaneBooking shipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); if (shipmentDetail != null) { if (userId > 0) { reportModel.PrintedBy = dbContext.Users.Find(userId).ContactName; } else { reportModel.PrintedBy = dbContext.Users.Find(shipmentDetail.CreatedBy).ContactName; } if (!string.IsNullOrEmpty(reportModel.MAWB)) { reportModel.MAWB = shipmentDetail.AirlinePreference.AilineCode + " " + shipmentDetail.MAWB.Substring(0, 4) + " " + shipmentDetail.MAWB.Substring(4, 4); } else { reportModel.MAWB = ""; } reportModel.FrayteNumber = shipmentDetail.FrayteNumber; reportModel.AirlineCode = shipmentDetail.AirlinePreference.AilineCode; reportModel.Console = string.Empty; reportModel.CreatedOn = DateTime.UtcNow; reportModel.Arrival = string.Empty; if (shipmentDetail.ShipmentHandlerMethod.ShipmentHandlerMethodId != 5) { if (shipmentDetail.MAWBAgentId.HasValue && shipmentDetail.MAWBAgentId.Value > 0) { var allocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).FirstOrDefault(); if (allocation != null) { if (allocation.EstimatedDateofDelivery.HasValue && !string.IsNullOrEmpty(allocation.FlightNumber)) { reportModel.FlightAndDate = allocation.FlightNumber + " / " + shipmentDetail.DepartureAirport.AirportCode + " / " + allocation.EstimatedDateofDelivery.Value.ToString("dd-MMM-yy"); } reportModel.ETD = allocation.EstimatedDateofDelivery; reportModel.ETA = allocation.EstimatedDateofArrival; fillExportAgentDetail(reportModel, shipmentDetail.MAWBAgentId.Value); reportModel.ImportAgent = ""; } else { reportModel.ImportAgent = ""; reportModel.ExportAgent = ""; } } else { reportModel.ImportAgent = ""; reportModel.ExportAgent = ""; } } else { var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).ToList(); if (shipmentAllocation.Count > 1) { var allocation = shipmentAllocation.Where(p => p.LegNum == "Leg1").FirstOrDefault(); if (allocation.EstimatedDateofDelivery.HasValue && !string.IsNullOrEmpty(allocation.FlightNumber)) { reportModel.FlightAndDate = allocation.FlightNumber + " / " + shipmentDetail.DepartureAirport.AirportCode + " / " + allocation.EstimatedDateofDelivery.Value.ToString("dd-MMM-yy"); } int ExportAgent = shipmentAllocation.Where(p => p.LegNum == "Leg1").FirstOrDefault().AgentId.Value; int ImportAgent = shipmentAllocation.Where(p => p.LegNum == "Leg2").FirstOrDefault().AgentId.Value; fillExportAgentDetail(reportModel, ExportAgent); fillImportAgentDetail(reportModel, ImportAgent); } else { reportModel.ExportAgent = ""; reportModel.ImportAgent = ""; } } reportModel.Loading = shipmentDetail.DepartureAirport.AirportCode; reportModel.DisCharge = shipmentDetail.DestinationAirport.AirportCode; reportModel.TotalPackages = shipmentDetail.HAWBPackages.Sum(p => p.PackagesCount); reportModel.TotalVolume = Math.Round(shipmentDetail.HAWBPackages.Sum(p => p.TotalVolume), 2).ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM3" : "IN3"); reportModel.TotalWeight = shipmentDetail.HAWBPackages.Sum(p => p.TotalWeight).ToString() + " " + (shipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB"); reportModel.TotalCartons = shipmentDetail.HAWBPackages.Sum(p => p.TotalCartons); reportModel.TotalShipments = shipmentDetail.HAWBPackages.Count(); fillImportPackageDetail(reportModel, shipmentDetail); } list.Add(reportModel); return(list); }
public List <TradelaneBookingReportMAWB> GetMAWBObj(int tradelaneShipmentId) { try { List <TradelaneBookingReportMAWB> list = new List <TradelaneBookingReportMAWB>(); TradelaneBookingReportMAWB reportModel = new TradelaneBookingReportMAWB(); var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, ""); var Custompdf = new TradelaneShipmentRepository().GetMawbCustomizePdf(tradelaneShipmentId); string mawb = string.Empty; if (!string.IsNullOrEmpty(ShipmentDetail.MAWB)) { if (ShipmentDetail.MAWB.Length == 8) { mawb = ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(3, 4); } else { mawb = ShipmentDetail.MAWB; } } reportModel.MAWB = mawb; reportModel.ShipperAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, ShipmentDetail.DepartureAirport.AirportCode); reportModel.ShipperAccountNumber = string.Empty; reportModel.ConsigneeAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, ShipmentDetail.DestinationAirport.AirportCode); reportModel.ConsigneeAccountNumber = string.Empty; reportModel.NotifyParty = ShipmentDetail.IsNotifyPartySameAsReceiver ? "NOTIFY: " + reportModel.ConsigneeAddress : "NOTIFY: " + UtilityRepository.ConcatinateAddress(ShipmentDetail.NotifyParty, ""); reportModel.CarrierAgent = string.Empty; reportModel.AirportofDeparture = ShipmentDetail.ShipFrom.Country.Name; reportModel.DestinationAirport = ShipmentDetail.DestinationAirport.AirportName; reportModel.DestinationAirportCode = ShipmentDetail.DestinationAirport.AirportCode; reportModel.CurencyCode = ShipmentDetail.DeclaredCurrency.CurrencyCode; reportModel.AmountOfInsurance = ShipmentDetail.InsuranceAmount.HasValue ? ShipmentDetail.InsuranceAmount.Value : 0; reportModel.MAWBCode = ShipmentDetail.AirlinePreference.AilineCode; reportModel.MAWBWithCode = ShipmentDetail.AirlinePreference.AilineCode + " " + mawb; reportModel.MAWBCountryCode = ShipmentDetail.ShipFrom.Country.Code; reportModel.ShipmentDescription = ShipmentDetail.ShipmentDescription; reportModel.Airline = ShipmentDetail.AirlinePreference.AirLineName; reportModel.IssuingCarriersAgentNameandCity = Custompdf.IssuingCarriersAgentNameandCity; reportModel.AccountNo = Custompdf.AccountNo; reportModel.DeclaredValueForCarriage = Custompdf.DeclaredValueForCarriage; reportModel.DeclaredValueForCustoms = Custompdf.DeclaredValueForCustoms; reportModel.ValuationCharge = Custompdf.ValuationCharge; reportModel.Tax = Custompdf.Tax; reportModel.TotalOtherChargesDueAgent = Custompdf.TotalOtherChargesDueAgent; reportModel.TotalOtherChargesDueCarrier = Custompdf.TotalOtherChargesDueCarrier; reportModel.OtherCharges = Custompdf.OtherCharges; reportModel.ChargesAtDestination = Custompdf.ChargesAtDestination; reportModel.TotalCollectCharges = Custompdf.TotalCollectCharges; reportModel.CurrencyConversionRates = Custompdf.CurrencyConversionRates; reportModel.TotalPrepaid = Custompdf.TotalPrepaid; reportModel.TotalCollect = Custompdf.TotalCollect; reportModel.HandlingInformation = Custompdf.HandlingInformation; reportModel.AgentsIATACode = Custompdf.AgentsIATACode; if (UtilityRepository.GetOperationZone().OperationZoneId == 1) { reportModel.IssuedBy = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine; reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine; reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON"; } else { reportModel.IssuedBy = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine; reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine; reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON"; } List <HAWBTradelanePackage> package; var collection = (from r in dbContext.TradelaneShipmentDetails join s in dbContext.TradelaneShipments on r.TradelaneShipmentId equals s.TradelaneShipmentId select new { HAWBNumber = s.HAWBNumber, TradelaneShipmentId = r.TradelaneShipmentId, TradelaneShipmentDetailId = r.TradelaneShipmentDetailId, CartonNumber = r.CartonNumber, CartonValue = r.CartonValue, Length = r.Length, Width = r.Width, Height = r.Height, Weight = r.Weight, HAWB = r.HAWB }).Where(p => p.TradelaneShipmentId == tradelaneShipmentId).ToList(); if (collection.Count > 0) { package = collection.GroupBy(x => x.HAWB) .Select(group => new HAWBTradelanePackage { TradelaneShipmentId = group.FirstOrDefault().TradelaneShipmentId, HAWB = group.Key, HAWBNumber = group.FirstOrDefault().HAWBNumber.HasValue ? group.FirstOrDefault().HAWBNumber.Value : 0, TotalCartons = group.Select(p => p.CartonValue).Sum(), EstimatedWeight = group.Select(p => p.Weight * p.CartonValue).Sum(), TotalVolume = group.Select(p => (p.Length * p.Width * p.Height) * p.CartonValue).Sum(), TotalWeight = group.Select(p => p.Weight * p.CartonValue).Sum(), Packages = group.Select(subGroup => new TradelanePackage { CartonNumber = subGroup.CartonNumber, CartonValue = subGroup.CartonValue, HAWB = subGroup.HAWB, Height = subGroup.Height, Length = subGroup.Length, TradelaneShipmentDetailId = subGroup.TradelaneShipmentDetailId, TradelaneShipmentId = subGroup.TradelaneShipmentId, Weight = subGroup.Weight, Width = subGroup.Width }).ToList() }).ToList(); } else { return(null); } if (package != null) { reportModel.TotalCartons = package.Sum(p => p.TotalCartons); reportModel.TotalWeight = package.Sum(p => p.TotalWeight); reportModel.EstimatedWeight = package.Sum(p => p.EstimatedWeight); reportModel.TotalVolume = reportModel.TotalVolume = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? Math.Round(package.Sum(p => p.TotalVolume) / (100 * 100 * 100), 2) : Math.Round(package.Sum(p => p.TotalVolume) / (39.37M * 39.37M * 39.37M), 2); reportModel.DimensionUnit = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM" : "IN"; reportModel.WeightUnit = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB"; reportModel.VolumeUnit = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CBM" : "CBM"; reportModel.ShipmentDescription += Environment.NewLine + "VOL " + reportModel.TotalVolume + " " + reportModel.VolumeUnit; reportModel.ShipmentDescription += Environment.NewLine + "VOL WEIGHT = " + reportModel.TotalWeight + " " + reportModel.WeightUnit; reportModel.CreatedOn = DateTime.UtcNow; reportModel.Signature = "Frayte Logistics SPX"; reportModel.CreatedOnCountry = "Hong Kong"; } list.Add(reportModel); return(list); } catch (Exception ex) { return(null); } }
public List <TradelanePreAlertDocument> GetShipmentOtherDocuments(int shipmentId) { List <TradelanePreAlertDocument> list = new TradelaneBookingRepository().GetShipmentOtherDocuments(shipmentId); return(list); }
public IHttpActionResult UploadOtherDocument() { try { int id = 0; var httpRequest = HttpContext.Current.Request; ShipmentRepository shipmentRepository = new ShipmentRepository(); HttpFileCollection files = httpRequest.Files; //This code will execute only when user will upload the document if (files.Count > 0) { int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); int CustomerId = Convert.ToInt32(httpRequest.Form["CustomerId"].ToString()); int UserId = Convert.ToInt32(httpRequest.Form["UserId"].ToString()); int HubId = Convert.ToInt32(httpRequest.Form["HubId"].ToString()); var docfiles = new List <string>(); // Entry in tradelane tables id = new ExpressManifestRepository().TradelaneEntryFromManifest(ShipmentId, UserId, CustomerId, HubId); string filePathToSave = string.Format(FrayteTradelaneDocumentPath.ShipmentDocument, id); string fileFullPath = ""; filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave); if (!System.IO.Directory.Exists(filePathToSave)) { System.IO.Directory.CreateDirectory(filePathToSave); } HttpPostedFile file = files[0]; if (!string.IsNullOrEmpty(file.FileName)) { if (!File.Exists(filePathToSave + file.FileName)) { //Save in server folder fileFullPath = filePathToSave + file.FileName; file.SaveAs(fileFullPath); //Save file name and other information in DB FrayteResult result = new TradelaneBookingRepository().SaveShipmentDocument(id, FrayteShipmentDocumentType.OtherDocument, file.FileName, UserId); if (result.Status) { return(Ok(id)); } else { return(BadRequest("OtherDocument")); } } else { return(BadRequest("OtherDocument")); } } } if (id > 0) { return(Ok(id)); } return(BadRequest()); } catch (Exception ex) { return(BadRequest()); } }
public IHttpActionResult SaveTradelaneIntegration(ExpressTradelaneIntegration integratedShipment) { TradelaneBooking shipment = new TradelaneBooking(); new ExpressManifestRepository().MapIntegratedShipmentToTradelaneShipment(integratedShipment, shipment); TradelaneBooking dbShipment = new TradelaneBookingRepository().SaveShipment(shipment, "Express"); if (!dbShipment.Error.Status) { TradelaneEmailModel model = new TradelaneEmailRepository().TradelaneEmailObj(dbShipment.TradelaneShipmentId); // Fill all the required info in the email model integratedShipment.MAWBList.FirstOrDefault().TradelaneId = dbShipment.TradelaneShipmentId; // model.ShipmentDetail.ShipFrom = new TradelBookingAdress(); model.ShipmentDetail.ShipFrom.IsMailSend = dbShipment.ShipFrom.IsMailSend; // model.ShipmentDetail.ShipTo = new TradelBookingAdress(); model.ShipmentDetail.ShipTo.IsMailSend = dbShipment.ShipTo.IsMailSend; model.ShipmentDetail.NotifyParty.IsMailSend = dbShipment.NotifyParty.IsMailSend; new TradelaneEmailRepository().FillBookingInformationEmailModel(model); // Update Status for AWB // Send Shipment info email created by // new TradelaneEmailRepository().SendEmail_E1(model); // Customer Confirmation email new TradelaneEmailRepository().SendEmail_E2_1(model); // Send MAWB AllocationEMail new TradelaneEmailRepository().FillModel_E3(model); new TradelaneEmailRepository().SendEmail_E3(model); // Add shipment tracking new TradelaneBookingRepository().SaveShipmentTracking(shipment); // Add FLight Detail new TradelaneBookingRepository().SaveShipmentFlightDetail(shipment); new ExpressManifestRepository().UpdateExpressShipmentStatus(integratedShipment.Shipment.Packages); // Update MAWBAllocation var File = new TradelaneShipmentsController().CreateDocument(dbShipment.TradelaneShipmentId, 0, FrayteTradelaneShipmentDocumentEnum.CoLoadForm, ""); var FilePath = AppSettings.UploadFolderPath + "/Tradelane" + "/" + integratedShipment.MAWBList.FirstOrDefault().TradelaneId + "/" + File.FileName; if (File.FileName != null && File.FileName != "") { } else { FilePath = ""; } new MawbAllocationRepository().SaveExpressMawbAllocation(integratedShipment.MAWBList, FilePath, "Express"); // update tradelane Shipment id in express table new ExpressManifestRepository().SaveExportManifest(dbShipment.TradelaneShipmentId, integratedShipment.Shipment); var file = new TradelaneShipmentsController().CreateDocument(dbShipment.TradelaneShipmentId, 0, FrayteTradelaneShipmentDocumentEnum.ExportManifest, ""); new TradelaneBookingRepository().SaveShipmentDocument(dbShipment.TradelaneShipmentId, FrayteTradelaneShipmentDocumentEnum.ExportManifest, file.FileName, integratedShipment.Shipment.CreatedBy); var file1 = new TradelaneShipmentsController().CreateDocument(dbShipment.TradelaneShipmentId, dbShipment.CreatedBy, FrayteTradelaneShipmentDocumentEnum.DriverManifest, ""); new TradelaneBookingRepository().SaveShipmentDocument(dbShipment.TradelaneShipmentId, FrayteTradelaneShipmentDocumentEnum.DriverManifest, file1.FileName, integratedShipment.Shipment.CreatedBy); new MawbAllocationRepository().SendMawbAllocationMail(integratedShipment.MAWBList, FilePath, "Express"); } return(Ok(integratedShipment)); }
public IHttpActionResult MAWBDetails(string action) { try { TradelaneMAWBDetail detail = new TradelaneMAWBDetail(); var ads = WebUtility.UrlDecode(action); var wsdsd = UtilityRepository.Base64UrlDecode(ads); var dfd = UtilityRepository.Decrypt(wsdsd, EncriptionKey.PrivateKey); var InitialDetail = new TradelaneBookingRepository().GetDetailsFormString(dfd); if (InitialDetail != null && !string.IsNullOrEmpty(InitialDetail.FrayteNumber) && InitialDetail.AgentId > 0 && InitialDetail.ShipmentMethodHandlerId > 0 && (string.IsNullOrEmpty(InitialDetail.Leg) || (!string.IsNullOrEmpty(InitialDetail.Leg) || InitialDetail.Leg == "Leg1" || InitialDetail.Leg == "Leg2"))) { int TradelaneShipmentId = new TradelaneBookingRepository().ValidateMAWBInitial(InitialDetail); bool validAgent = false; if (TradelaneShipmentId > 0) { if (InitialDetail.ShipmentMethodHandlerId != 5) { validAgent = new TradelaneBookingRepository().ValidateAgent(InitialDetail.AgentId, TradelaneShipmentId); } else { validAgent = new TradelaneBookingRepository().ValidateAgent(InitialDetail.AgentId, TradelaneShipmentId, InitialDetail.Leg); } if (validAgent) { bool status = new TradelaneBookingRepository().IsMAWBUploaded(TradelaneShipmentId, InitialDetail.AgentId, InitialDetail.Leg); detail.FrayteNumber = InitialDetail.FrayteNumber; detail.AgentId = InitialDetail.AgentId; detail.TradelaneShipmentId = TradelaneShipmentId; detail.HAWBpackages = GetGroupedHAWBPieces(TradelaneShipmentId); detail.List = new MawbAllocationRepository().GetMawbAllocation(TradelaneShipmentId, InitialDetail.Leg); detail.IsMAWBAllocated = status; return(Ok(detail)); } else { return(BadRequest("SessionExpired")); } } else { return(BadRequest()); } } else { return(BadRequest()); } } catch (Exception ex) { return(BadRequest()); } }
public TradelanePackageDetailExcel GetPiecesDetailFromExcel() { TradelanePackageDetailExcel frayteShipmentDetailexcel = new TradelanePackageDetailExcel(); var httpRequest = HttpContext.Current.Request; List <TradelanePackage> _shipmentdetail = new List <TradelanePackage>(); if (httpRequest.Files.Count > 0) { HttpFileCollection files = httpRequest.Files; HttpPostedFile file = files[0]; int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); if (!string.IsNullOrEmpty(file.FileName)) { //int ShipmentId = Convert.ToInt32(httpRequest.Form["ShipmentId"].ToString()); string connString = ""; string filename = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss_") + file.FileName; string filepath = HttpContext.Current.Server.MapPath("~/UploadFiles/Tradelane/" + filename); file.SaveAs(filepath); 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) { 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, "Pieces"); } } } else { var excel = new ExcelQueryFactory("excelFileName"); var oldCompanies = (from c in excel.Worksheet <TradelanePackage>("sheet1") select c); 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 + "]"; using (var adapter = new OleDbDataAdapter(query, conn)) { adapter.Fill(ds, "Pieces"); } } } var exceldata = ds.Tables[0]; // Step 1: Validate for excel column string PiecesColumnList = "CartonNumber,CartonQTY,Length,Width,Height,Weight"; bool IsExcelValid = UtilityRepository.CheckUploadExcelFormat(PiecesColumnList, exceldata); if (!IsExcelValid) { frayteShipmentDetailexcel.Message = "Columns are not matching with provided template columns. Please check the column names."; } else { if (exceldata.Rows.Count > 0) { frayteShipmentDetailexcel.TotalUploaded = exceldata.Rows.Count; _shipmentdetail = new TradelaneBookingRepository().GetPiecesDetail(exceldata); frayteShipmentDetailexcel.Packages = new List <TradelanePackage>(); frayteShipmentDetailexcel.Packages = _shipmentdetail; frayteShipmentDetailexcel.Message = "OK"; frayteShipmentDetailexcel.SuccessUploaded = _shipmentdetail.Count; new TradelaneBookingRepository().SavePackagedetailShipment(frayteShipmentDetailexcel.Packages, ShipmentId); } else { frayteShipmentDetailexcel.Message = "No records found."; } } if ((System.IO.File.Exists(filepath))) { System.IO.File.Delete(filepath); } } else { frayteShipmentDetailexcel.Message = "Excel file not valid"; } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); if (ex != null && !string.IsNullOrEmpty(ex.Message) && ex.Message.Contains("Sheet1$")) { frayteShipmentDetailexcel.Message = "Sheet name is invalid."; } else { frayteShipmentDetailexcel.Message = "Error while uploading the excel."; } return(frayteShipmentDetailexcel); } } } return(frayteShipmentDetailexcel); }