public TradelaneFile CreateDocument(int tradelaneShipmentId, int userId, string documentType, string documentTypeName)
        {
            try
            {
                TradelaneFile result = new TradelaneFile();

                switch (documentType)
                {
                case FrayteTradelaneShipmentDocumentEnum.ShipmentDetail:
                    result = new TradelaneDocument().ShipmentDetails(tradelaneShipmentId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.HAWB:
                    result = new TradelaneDocument().ShipmentHAWB(tradelaneShipmentId, documentTypeName);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.Manifest:
                    result = new TradelaneDocument().ShipmentManifest(tradelaneShipmentId, userId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.CoLoadForm:
                    result = new TradelaneDocument().ShipmentCoLoadForm(tradelaneShipmentId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.MAWB:
                    result = new TradelaneDocument().ShipmentMAWB(tradelaneShipmentId, documentTypeName);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.CartonLabel:
                    result = new TradelaneDocument().ShipmentCartonLabel(tradelaneShipmentId, 0, 0, "");
                    break;

                case FrayteTradelaneShipmentDocumentEnum.BagLabel:
                    result = new TradelaneDocument().ShipmentBagLabel(tradelaneShipmentId, userId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.DriverManifest:
                    result = new TradelaneDocument().ShipmentDriverManifest(tradelaneShipmentId, userId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.ExportManifest:
                    result = new TradelaneDocument().ShipmentExportManifest(tradelaneShipmentId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.BagNumber:
                    result = new TradelaneDocument().ShipmentExportBagNumber(tradelaneShipmentId, userId);
                    break;

                case FrayteTradelaneShipmentDocumentEnum.REV:
                    //   new TradelaneShipmentRepository().ShipmentMAWBDocDownload(tradelaneShipmentId, 0, 0);
                    break;
                }

                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #2
0
        public CreateBagModel CreateBag(string AWBNumber, int ScannedBy, int MobileEventId)
        {
            CreateBagModel result = new ExpressScannedAWBRepository().CreateBag(AWBNumber, ScannedBy, MobileEventId);

            if (result.BagId > 0 && result.Status == true && result.IsBagCreated == true)
            {
                var result1 = new TradelaneDocument().ShipmentExportBagNumber(result.BagId, ScannedBy);
                result.FilePath = result1.FilePath;
                result.FileName = result1.FileName;
            }
            Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(new Exception("AWBNumber, ScannedBy, MobileEventId values for CreateBag Action is : " + AWBNumber + ", " + ScannedBy + ", " + MobileEventId)));
            return(result);
        }
Exemple #3
0
        public CreateBagModel BagClose(int BagId)
        {
            var BagDtl = new ExpressScannedAWBRepository().BagClose(BagId);

            if (BagDtl.BagId > 0 && BagDtl.Status == true)
            {
                var result1 = new TradelaneDocument().ShipmentBagLabel(BagDtl.BagId, BagDtl.CustomerId);
                BagDtl.FilePath = result1.FilePath;
                BagDtl.FileName = result1.FileName;
            }
            Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(new Exception("BagId value for BagClose Action is : " + BagId)));
            return(BagDtl);
        }
        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());
            }
        }
Exemple #5
0
        public CreateBagModel GetBagLabel(int BagId)
        {
            var BagDtl = new ExpressScannedAWBRepository().GetBagsModel(BagId);

            if (BagDtl.BagId > 0)
            {
                BagDtl.Status = false;
                var result1 = new TradelaneDocument().ShipmentBagLabel(BagDtl.BagId, BagDtl.CustomerId);
                if (!string.IsNullOrEmpty(result1.FileName) && !string.IsNullOrEmpty(result1.FilePath))
                {
                    BagDtl.FilePath = result1.FilePath;
                    BagDtl.FileName = result1.FileName;
                    BagDtl.Status   = true;
                }
            }
            else
            {
                BagDtl.Status = false;
            }
            Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(new Exception("BagId value for GetBagLabel Action is : " + BagId)));
            return(BagDtl);
        }
        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());
            }
        }