Esempio n. 1
0
 static public void RegisterPackage(PackagesToInstall Package)
 {
     if (LocalPackages == null)
     {
         LocalPackages = new List <PackagesToInstall>();
     }
     LocalPackages.Add(Package);
     WritePackageList();
 }
Esempio n. 2
0
 static public bool HasLocalPackage(PackagesToInstall Package)
 {
     foreach (PackagesToInstall pp in LocalPackages)
     {
         if (Package == pp)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 3
0
 public static bool CanInstallOptionalPackage(PackagesToInstall pkg)
 {
     foreach (PackageIDData pp in UserPackagesToInstall)
     {
         if (pp.PackageID.ToLower() == pkg.PackageID.ToLower())
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
        static public void RemovePackage(PackagesToInstall Package, bool ForceRemove = false)
        {
            if (LocalPackages == null)
            {
                return;
            }
            string PackagesFolder = SystemInfos.ProgramData + "Packages\\";

            if (Directory.Exists(PackagesFolder) == false)
            {
                Directory.CreateDirectory(PackagesFolder);
            }

            PackagesToInstall pkg = null;

            foreach (PackagesToInstall pp in LocalPackages)
            {
                if (Package == pp)
                {
                    pkg = pp;
                    break;
                }
            }
            if (pkg == null)
            {
                return;
            }

            LocalPackageData rmlpkg = null;

            foreach (LocalPackageData lpkg in LocalPackageDataList)
            {
                if (lpkg.PackageID == pkg.PackageID && lpkg.Version == pkg.Version)
                {
                    rmlpkg = lpkg;
                    break;
                }
            }

            if (ForceRemove == false)
            {
                if (rmlpkg != null)
                {
                    if (rmlpkg.PKGRecieptFilename != null)
                    {
                        FoxEventLog.VerboseWriteEventLog("Not removing Package: " + pkg.PackageID + " V" + pkg.Version.ToString() + ". Reciept file is registred.", EventLogEntryType.Warning);
                        if (pkg.Filename != null)
                        {
                            if (File.Exists(PackagesFolder + pkg.Filename) == true)
                            {
                                CommonUtilities.SpecialDeleteFile(PackagesFolder + pkg.Filename);
                            }
                            pkg.Filename = null;
                        }
                        rmlpkg.ServerHasPackage = false;
                        return;
                    }
                }
            }

            if (pkg.MetaFilename != null)
            {
                if (File.Exists(PackagesFolder + pkg.MetaFilename) == true)
                {
                    CommonUtilities.SpecialDeleteFile(PackagesFolder + pkg.MetaFilename);
                }
            }
            if (pkg.Filename != null)
            {
                if (File.Exists(PackagesFolder + pkg.Filename) == true)
                {
                    CommonUtilities.SpecialDeleteFile(PackagesFolder + pkg.Filename);
                }
            }
            LocalPackages.Remove(pkg);
            WritePackageList();

            if (rmlpkg != null)
            {
                if (rmlpkg.PKGRecieptFilename != null)
                {
                    CommonUtilities.SpecialDeleteFile(PackagesFolder + rmlpkg.PKGRecieptFilename);
                    CommonUtilities.SpecialDeleteFile(PackagesFolder + rmlpkg.PKGRecieptFilename + ".sign");
                }
                LocalPackageDataList.Remove(rmlpkg);
                WritePackageDataList();
            }
        }