Example #1
0
        /// <summary>
        /// see if any patches are missing; is there a direct line between FCurrentlyInstalledVersion and FLatestAvailablePatch?
        /// </summary>
        /// <returns>return a list of all patches that should be applied. empty list if there is a problem</returns>
        public SortedList CheckPatchesConsistent(SortedList AOrderedListOfAllPatches)
        {
            SortedList       ResultPatchList = new SortedList();
            TFileVersionInfo testPatchVersion;

            // get the latest patch that is available
            FLatestAvailablePatch = new TFileVersionInfo(FCurrentlyInstalledVersion);

            foreach (string patch in AOrderedListOfAllPatches.GetValueList())
            {
                testPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch);

                if (testPatchVersion.Compare(FLatestAvailablePatch) > 0)
                {
                    FLatestAvailablePatch = testPatchVersion;
                }
            }

            // drop unnecessary patch files
            // ie. patch files leading to the same version, eg. 2.2.11-1 and 2.2.12-2 to 2.2.12-3
            // we only want the biggest step
            testPatchVersion = new TFileVersionInfo(FCurrentlyInstalledVersion);
            bool patchesAvailable = true;

            while (patchesAvailable)
            {
                StringCollection applyingPatches = new StringCollection();

                foreach (string patch in AOrderedListOfAllPatches.GetValueList())
                {
                    if (TPatchFileVersionInfo.PatchApplies(testPatchVersion, patch))
                    {
                        applyingPatches.Add(patch);
                    }
                }

                patchesAvailable = (applyingPatches.Count > 0);

                if (applyingPatches.Count > 0)
                {
                    // see which of the applying patches takes us further
                    string           highestPatch        = applyingPatches[0];
                    TFileVersionInfo highestPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(highestPatch);

                    foreach (string patch in applyingPatches)
                    {
                        if (TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch).Compare(highestPatchVersion) > 0)
                        {
                            highestPatch        = patch;
                            highestPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(highestPatch);
                        }
                    }

                    ResultPatchList.Add(highestPatch, highestPatch);
                    testPatchVersion = highestPatchVersion;
                }
            }

            if (FLatestAvailablePatch.Compare(testPatchVersion) != 0)
            {
                // check for a generic patch file, starting from version 0.0.99.99
                foreach (string patch in AOrderedListOfAllPatches.GetValueList())
                {
                    if (patch.Contains("0.0.99.99"))
                    {
                        testPatchVersion = TPatchFileVersionInfo.GetLatestPatchVersionFromDiffZipName(patch);
                        ResultPatchList.Clear();
                        ResultPatchList.Add(patch, patch);
                    }
                }
            }

            if (FLatestAvailablePatch.Compare(testPatchVersion) != 0)
            {
                TLogging.Log("missing patchfile from version " + testPatchVersion.ToString() + " to " + FLatestAvailablePatch.ToString());
                return(new SortedList());
            }

            return(ResultPatchList);
        }
Example #2
0
 /// <summary>
 /// would this patch file apply to the current installed version
 /// </summary>
 /// <param name="APatchZipFile"></param>
 /// <returns></returns>
 public Boolean PatchApplies(String APatchZipFile)
 {
     return(TPatchFileVersionInfo.PatchApplies(this, APatchZipFile));
 }