Beispiel #1
0
        /// <summary>
        ///     Invokes the SPV3 Installer with the given arguments.
        /// </summary>
        /// <param name="args">
        ///     [0] = Target directory.
        /// </param>
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Exit("Not enough arguments!", 1);
            }

            var target = (Directory)args[0];
            var backup = (Directory)Path.Combine(target, "SPV3-" + Guid.NewGuid());

            if (!System.IO.Directory.Exists(target))
            {
                Exit("Target does not exist.", 1);
            }

            try
            {
                Console.Clear();

                Task.Run(() =>
                {
                    var manifest = ManifestRepository.LoadDefault();

                    new MetaInstaller(target, backup, Status).Install(manifest);
                })
                .GetAwaiter().GetResult();

                Exit(Banner, 0);
            }
            catch (Exception exception)
            {
                Exit(exception.ToString(), 2);
            }
        }
Beispiel #2
0
 public IosBackupClient(string backupDir, string passPhrase)
 {
     _backupDir    = backupDir;
     _passPhrase   = passPhrase;
     _tempFilePath = GetTemporaryDirectory();
     _repository   = new ManifestRepository(_tempFilePath);
 }
        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 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 FrayteUserManifest IsManifestSupprt(int userId)
        {
            FrayteUserManifest IsManifestSupport = new ManifestRepository().IsManifestSupprt(userId);

            if (IsManifestSupport.Services != null && IsManifestSupport.Services.Count > 0)
            {
                IsManifestSupport.Services.OrderBy(p => p.OrderNumber);
            }
            return(IsManifestSupport);
        }
 public List <FrayteManifest> GetManifests(TrackManifest trackManifest)
 {
     try
     {
         var list = new ManifestRepository().GetManifests(trackManifest);
         return(list);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
 public MainfestDetailModel GetNonManifestedShipments(int OperationZoneId, int UserId, int CreatedBy, string moduleType, string subModuleType)
 {
     try
     {
         var list = new ManifestRepository().GetNonManifestedShipments(OperationZoneId, UserId, CreatedBy, moduleType, subModuleType);
         return(list);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Beispiel #8
0
        public void Repository_MetadataVersionIsSaved()
        {
            var file       = Guid.NewGuid().ToString();
            var repository = new ManifestRepository((File)file);

            repository.Save(Manifest);
            var loadedMetadata = repository.Load();

            Assert.AreEqual((string)Manifest.Version, (string)loadedMetadata.Version);

            System.IO.File.Delete(file);
        }
        public FrayteViewManifest GetManifestDetail(int ManifestId, string moduleType, string subModuleType)
        {
            try
            {
                var list = new ManifestRepository().GetManifestDetail(ManifestId, moduleType);
                return(list);
            }

            catch (Exception ex)
            {
                return(null);
            }
        }
        public List <CustomManifestDetail> GetCustomManifests(TrackCustomManifest trackManifest)
        {
            try
            {
                var list = new ManifestRepository().GetCustomManifests(trackManifest);
                return(list);
            }

            catch (Exception ex)
            {
                return(null);
            }
        }
 public FrayteResult SetETAETD(ETAETDManifest manifestETAETD)
 {
     try
     {
         FrayteResult result = new ManifestRepository().SetETAETD(manifestETAETD);
         return(result);
     }
     catch (Exception ex)
     {
         return(new FrayteResult()
         {
             Status = false
         });
     }
 }
Beispiel #12
0
        public void Repository_MetadataPackageIsSaved()
        {
            var file       = Guid.NewGuid().ToString();
            var repository = new ManifestRepository((File)file);

            repository.Save(Manifest);
            var loadedMetadata = repository.Load();

            for (var i = 0; i < Manifest.Packages.Count; i++)
            {
                Assert.AreEqual(Manifest.Packages[i].Name.Value, loadedMetadata.Packages[i].Name.Value);
            }

            System.IO.File.Delete(file);
        }
        public fileName GenerateCustomManifest(int ManifestId, string ManifestName)
        {
            if (ManifestName != null && !ManifestName.Contains(".csv"))
            {
                ManifestName = ManifestName + ".csv";
            }

            TrackCustomManifest TCM = new TrackCustomManifest();
            fileName            fN  = new fileName();
            var flag      = true;
            var filePaths = Directory.GetFiles(AppSettings.ManifestFolderPath);
            var filePath  = AppSettings.WebApiPath + "Manifestedshipments/" + ManifestName;

            if (ManifestName != null && ManifestName != "")
            {
                for (int i = 0; i < filePaths.Length; i++)
                {
                    var filePathLength   = filePaths[i].Length;
                    var FileName         = filePaths[i].Split('\\');
                    var FileNameLength   = FileName.Length;
                    var ManifestFileName = FileName[FileNameLength - 1];

                    if (ManifestFileName == ManifestName)
                    {
                        flag        = false;
                        fN.FileName = ManifestName;
                        fN.FilePath = filePath;
                        break;
                    }
                }
            }
            if (flag == true && ManifestName != null && ManifestName != "")
            {
                var gmd = new ManifestRepository().GetMainfestDataUI(ManifestId, ManifestName);

                fN.FileName = new ManifestRepository().ManifestExcelWriteFromUI(gmd, ManifestName);
                if (fN.FileName.Contains(".csv"))
                {
                    fN.FileName = fN.FileName;
                }
                else
                {
                    fN.FileName = fN.FileName + ".csv";
                }
                fN.FilePath = filePath;
            }
            return(fN);
        }
Beispiel #14
0
        private async Task <IEnumerable <DesiredState> > GetDesiredStateData()
        {
            if (IsValidJson(DesiredStateSource))
            {
                return(new[] { JsonSerializer.Deserialize <DesiredState>(DesiredStateSource) });
            }

            if (!Path.IsPathFullyQualified(DesiredStateSource))
            {
                DesiredStateSource = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, DesiredStateSource));
            }

            if (!Directory.Exists(DesiredStateSource))
            {
                return(File.Exists(DesiredStateSource)
                                        ? new[] { JsonSerializer.Deserialize <DesiredState>(File.ReadAllText(DesiredStateSource)) }
                                        : null);
            }

            var manifestRepository = new ManifestRepository <DesiredState>(new DirectoryInfo(DesiredStateSource));

            return(await manifestRepository.GetDesiredStatesByIdAsync(Guid.Parse(EnvironmentId)));
        }
Beispiel #15
0
        /// <summary>
        ///     Verifies the map lengths by comparing them to the lengths defined in the manifest.
        /// </summary>
        /// <exception cref="NullReferenceException">
        ///     Maps package not found in the manifest.
        /// </exception>
        /// <exception cref="MapDataException">
        ///     Map length mismatches the expected one.
        /// </exception>
        /// <exception cref="FileNotFoundException">
        ///     Map does not exist in the maps folder.
        ///     - or -
        ///     Manifest binary does not exist in working directory.
        /// </exception>
        private void VerifyMapLengths()
        {
            if (_configuration.SkipMapVerification)
            {
                return;
            }

            Notify("----------------------------");
            Notify("Initiated maps data check...");
            Notify("----------------------------");

            var manifestFile = (File)Manifest.Name.Value;

            /**
             * The maps are retrieved from the manifest binary, which should be present in the working directory along
             * with the loader. The manifest, conventionally, is installed to the directory. If it's not present, you
             * must create a manifest binary using the SPV3.Compiler. Alternatively, enable the SkipMapVerification
             * option in the LoaderConfiguration.
             */
            IEnumerable <Entry> GetMaps()
            {
                var manifest = new ManifestRepository(manifestFile).Load();
                var packages = manifest.Packages;

                foreach (var package in packages)
                {
                    if (package.Directory == null)
                    {
                        continue;
                    }
                    if (package.Directory.Name == "maps")
                    {
                        return(package.Entries);
                    }
                }

                throw new NullReferenceException("No maps package found in the manifest.");
            }

            foreach (var map in GetMaps())
            {
                var mapFile = Path.Combine("maps", map.Name);
                var mapName = (string)map.Name;
                var mapSize = (int)map.Size;

                /**
                 * Makes the output more symmetrical, to satisfy the Yumi.
                 */
                var padding = new string(' ', 32 - mapName.Length);

                /**
                 * Checks the existence & sizes for the length.
                 */
                if (System.IO.File.Exists(mapFile))
                {
                    Notify($"Checking {mapName} {padding} <= " + mapSize);

                    if (new FileInfo(mapFile).Length == map.Size)
                    {
                        Notify($"Verified {mapName} {padding} <= " + mapSize);
                    }
                    else
                    {
                        throw new MapDataException($"Map '{mapName}' length mismatches the expected one.");
                    }
                }
                else
                {
                    throw new FileNotFoundException($"Map '{mapName}' does not exist in the maps folder.");
                }
            }

            Notify("----------------------------");
            Notify("Completed maps data check...");
            Notify("----------------------------");
        }
Beispiel #16
0
 public ManifestsController()
 {
     manifestRepository = ManifestRepository.Instance;
 }
        public FrayteManifestName GenerateManifestReport(int ManifestId, string moduleType, int UserId, int RoleId)
        {
            FrayteManifestName result = new FrayteManifestName();

            try
            {
                var manifestlist = new ManifestRepository().DownLoadManifest(ManifestId, moduleType, UserId, RoleId);
                if (manifestlist != null && manifestlist.Count > 0 && moduleType == FrayteShipmentServiceType.DirectBooking)
                {
                    if (manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].LogisticType == "DHL Export" || manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].LogisticType == "DHL UKShipment")
                    {
                        ReportTemplate.Other.ManifestDHLReport rp = new ReportTemplate.Other.ManifestDHLReport();
                        if (RoleId == (int)FrayteUserRole.UserCustomer)
                        {
                            rp.Parameters["lblNote"].Value = "MEX Logistics Ltd is not responsible for any parcel lost with expired labels.";
                        }
                        else
                        {
                            rp.Parameters["lblNote"].Value = "FRAYTE GLOBAL is not responsible for any parcel lost with expired labels.";
                        }
                        rp.DataSource = manifestlist;

                        if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf"))
                        {
                            File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            result.FileName = "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                            result.FilePath = AppSettings.WebApiPath + "ReportFiles/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                        }
                        else
                        {
                            rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            result.FileName = "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                            result.FilePath = AppSettings.WebApiPath + "ReportFiles/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                        }
                    }
                    else
                    {
                        ReportTemplate.Other.ManifestReport rp = new ReportTemplate.Other.ManifestReport();
                        if (RoleId == (int)FrayteUserRole.UserCustomer)
                        {
                            rp.Parameters["lblNote"].Value = "MEX Logistics Ltd is not responsible for any parcel lost with expired labels.";
                        }
                        else
                        {
                            rp.Parameters["lblNote"].Value = "FRAYTE Logistics Ltd is not responsible for any parcel lost with expired labels.";
                        }
                        rp.DataSource = manifestlist;

                        if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf"))
                        {
                            File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            result.FileName = "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                            result.FilePath = AppSettings.WebApiPath + "ReportFiles/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                        }
                        else
                        {
                            rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf");
                            result.FileName = "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                            result.FilePath = AppSettings.WebApiPath + "ReportFiles/" + "DBK - " + manifestlist[0].CompanyName + " - " + manifestlist[0].Collection[0].LogisticCompany + " " + manifestlist[0].Collection[0].RateTypeDisplay + " - " + manifestlist[0].ManifestFileName + ".pdf";
                        }
                    }
                }
                else if (manifestlist != null && manifestlist.Count > 0 && moduleType == FrayteShipmentServiceType.eCommerce)
                {
                    ReportTemplate.Other.eCommerceManifestReport rp = new ReportTemplate.Other.eCommerceManifestReport();
                    rp.DataSource = manifestlist;
                    if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder) + "/" + manifestlist[0].ManifestName + ".pdf"))
                    {
                        File.Delete(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder) + "/" + manifestlist[0].ManifestName + ".pdf");
                        rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder) + "/" + manifestlist[0].ManifestName + ".pdf");
                        result.FileName = manifestlist[0].ManifestName + ".pdf";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/eCommerce/" + manifestlist[0].ManifestName + ".pdf";
                    }
                    else
                    {
                        if (!Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder)))
                        {
                            Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder));
                        }
                        rp.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.eCommerceReportFolder) + "/" + manifestlist[0].ManifestName + ".pdf");
                        result.FileName = manifestlist[0].ManifestName + ".pdf";
                        result.FilePath = AppSettings.WebApiPath + "ReportFiles/eCommerce/" + manifestlist[0].ManifestName + ".pdf";
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
        public IHttpActionResult RemoveShipmentFromManifest(int shipmentId, string moduleType)
        {
            FrayteResult result = new ManifestRepository().RemoveShipmentFromManifest(shipmentId, moduleType);

            return(Ok(result));
        }