public FrayteManifestName GenerateManifestExcel(int ManifestId)
        {
            FrayteManifestName result = new FrayteManifestName();

            try
            {
                var track = new ManifestRepository().GetManifestShipments(ManifestId);

                if (track != null && track.Count > 0)
                {
                    ReportTemplate.Other.TrackAndTraceReport rp = new ReportTemplate.Other.TrackAndTraceReport();
                    rp.DataSource = track;
                    if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Manifest" + "/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx"))
                    {
                        File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Manifest" + "/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx");
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Manifest" + "/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx");
                        result.FileName = track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/Manifest/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx";
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder + "/" + "Manifest" + "/"));
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Manifest" + "/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx");
                        result.FileName = track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/Manifest/" + track[0].CustomerCompany + " - " + track[0].Courier + " - " + track[0].ManifestNumber + ".xlsx";
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
        public FrayteManifestName GenerateTrackAndTraceExcel(FrayteTrackDirectBooking trackdetail)
        {
            FrayteManifestName result = new FrayteManifestName();
            string             Name   = "";

            if (trackdetail.CustomerName == "ALL")
            {
                var OperationZone = UtilityRepository.GetOperationZone();
                if (OperationZone.OperationZoneId == 1)
                {
                    Name = "All_HK";
                }
                else if (OperationZone.OperationZoneId == 2)
                {
                    Name = "All_UK";
                }
            }
            else
            {
                Name = trackdetail.CustomerName;
            }
            try
            {
                var track = new DirectShipmentRepository().GetTrackAndTraceDetail(trackdetail);
                if (track != null && track.Count > 0)
                {
                    ReportTemplate.Other.TrackAndTraceReport rp = new ReportTemplate.Other.TrackAndTraceReport();
                    rp.DataSource = track;
                    if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Track&Trace" + "/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"))
                    {
                        File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Track&Trace" + "/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Track&Trace" + "/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        result.FileName = Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/Track&Trace/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder + "/" + "Track&Trace" + "/"));
                        rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "Track&Trace" + "/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx");
                        result.FileName = Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/Track&Trace/" + Name + "_" + "Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx";
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }