internal void DeclinePackage(string name) { if (_packageDictionary.ContainsKey(name)) { InstallationPackage pkgToDecline = _packageDictionary[name]; pkgToDecline.InstallationState = InstallationPackage.State.Skipped; } }
public PackageDownloaderBits(InstallationPackage installationPackage) : base(installationPackage) { _aTimer = new Timer { Interval = TIMER_INTERVAL_MS, Enabled = false }; _aTimer.Elapsed += new ElapsedEventHandler(TimerElapsed); }
internal void DiscardPackage(string name, string errorMessage) { if (_packageDictionary.ContainsKey(name)) { InstallationPackage pkgToDiscard = _packageDictionary[name]; pkgToDiscard.ErrorMessage = errorMessage; pkgToDiscard.InstallationState = InstallationPackage.State.Discard; } }
private void SetPackageStateToDisplayed(string name, int index) { InstallationPackage pkg = _packageDictionary[name]; if (pkg == null) { return; } pkg.InstallationState = InstallationPackage.State.Displayed; }
internal void ConfirmPackage(string name) { if (_packageDictionary.ContainsKey(name)) { _pkgConfirmedCounter++; InstallationPackage pkgToConfirm = _packageDictionary[name]; pkgToConfirm.InstallationState = InstallationPackage.State.Confirmed; } if (_pkgConfirmedCounter >= _maxConfirmedPackages) { #if DEBUG Logger.GetLogger().Info($"{_pkgConfirmedCounter} packages were confirmed which is the maximal number. going to skip all other packages..."); #endif SkipAll(""); } }
public PackageDownloaderWebClient(InstallationPackage installationPackage) : base(installationPackage) { _isDownloading = false; }
internal void HandleProgressUpdate(InstallationPackage pkg) { lock (progressLock) { if (pkg.InstallationState >= InstallationPackage.State.DownloadStart && pkg.DwnldBytesOffset > 0) { if (!pkg.hasUpdatedTotal) { dwnldBytesTotal += pkg.DwnldBytesTotal; pkg.hasUpdatedTotal = true; pkgRunningCounter++; } dwnldBytesReceived += pkg.DwnldBytesOffset; currentProgress = Math.Round(100.0 * dwnldBytesReceived / dwnldBytesTotal); } if (pkg.isProgressCompleted && !pkg.isUpdatedProgressCompleted) { pkgCompletedCounter++; if (pkg.hasUpdatedTotal) { pkgRunningCounter--; } pkg.isUpdatedProgressCompleted = true; #if DEBUG Logger.GetLogger().Info($"[{pkg.Name}] Package progress completed"); #endif } if (_packageDictionary.Count > pkgRunningCounter + pkgCompletedCounter) { return; } if (currentProgress > 100 || _packageDictionary.Count == pkgCompletedCounter) { currentProgress = 100; } if ((DateTime.Now - progressSampleTime).TotalMilliseconds < 100 && currentProgress != 100) { return; } progressSampleCnt = progressSampleCnt < 50 ? progressSampleCnt + 1 : 1; avgDwnldSpeed = avgDwnldSpeed * (progressSampleCnt - 1) / progressSampleCnt + CalcCurrentDownloadSpeed(dwnldBytesReceived) / progressSampleCnt; progressSampleTime = DateTime.Now; string errorMessage = string.Empty; if (pkg.InstallationState == InstallationPackage.State.Error && !pkg.isOptional) { errorMessage = pkg.ErrorMessage; } ProgressEventArgs progressEvent = new ProgressEventArgs(errorMessage, Convert.ToInt32(currentProgress), dwnldBytesReceived, dwnldBytesTotal, avgDwnldSpeed, _packageDictionary.Count == pkgCompletedCounter); ProgressBarUpdater.HandleProgress(progressEvent); } }
internal void SetProductsSettings(List <ProductSettings> productsSettings) { int maxOptionalProducts = ConfigParser.GetConfig().GetIntValue("//RemoteConfiguration/FlowSettings/MaxProducts", int.MaxValue); maxOptionalProducts = maxOptionalProducts == -1 ? int.MaxValue : maxOptionalProducts; int optionalProducts = 0; _maxConfirmedPackages = ConfigParser.GetConfig().GetIntValue("//RemoteConfiguration/FlowSettings/MaxAcceptedProducts", int.MaxValue); _maxConfirmedPackages = _maxConfirmedPackages == -1 ? int.MaxValue : _maxConfirmedPackages; _pkgConfirmedCounter = 0; foreach (ProductSettings prodSettings in productsSettings) { if (_packageDictionary.ContainsKey(prodSettings.Name)) { continue; } if (prodSettings.IsOptional && optionalProducts >= maxOptionalProducts) { #if DEBUG Logger.GetLogger().Info($"[{prodSettings.Name}] product will not be shown since the limit of optional products to show is: {maxOptionalProducts}"); #endif continue; } InstallationPackage pkg = CreatePackage(prodSettings); pkg.InstallationState = InstallationPackage.State.CheckStart; if (prodSettings.PreInstall.RequirementList != null && prodSettings.PreInstall.RequirementsList != null) { RequirementHandlers reqHandlers = new RequirementHandlers(); #if DEBUG Logger.GetLogger().Info($"[{prodSettings.Name}] Checking requirements for product:"); #endif ProductSettings tmpProdSettings = prodSettings; bool res = false; if (tmpProdSettings.Exclusive && optionalProducts > 0) { string dictionaryString = "{"; foreach (KeyValuePair <string, InstallationPackage> keyValues in _packageDictionary) { if (keyValues.Value.isOptional) { dictionaryString += keyValues.Key + ", "; } } dictionaryString = dictionaryString.TrimEnd(',', ' ') + "}"; #if DEBUG Logger.GetLogger().Info($"Exclusive {dictionaryString} <Equal> [] => False"); #endif tmpProdSettings.PreInstall.UnfulfilledRequirementType = "Exclusive"; tmpProdSettings.PreInstall.UnfulfilledRequirementDelta = dictionaryString; } else if (!string.IsNullOrEmpty(_passedExclusive)) { #if DEBUG Logger.GetLogger().Info($"Exclusive ({_passedExclusive}) <Exists> [] => False"); #endif tmpProdSettings.PreInstall.UnfulfilledRequirementType = "Exclusive"; tmpProdSettings.PreInstall.UnfulfilledRequirementDelta = $"Exclusive product {_passedExclusive} already passed"; } else if (productClasses.Contains(tmpProdSettings.Class)) { #if DEBUG Logger.GetLogger().Info($"Class ({tmpProdSettings.Class}) <Exists> [{string.Join(", ", productClasses)}] => False"); #endif tmpProdSettings.PreInstall.UnfulfilledRequirementType = "Class"; tmpProdSettings.PreInstall.UnfulfilledRequirementDelta = $"product of class {_passedExclusive} already passed"; } else { res = reqHandlers.HandlersResult(ref tmpProdSettings.PreInstall); } if (!res) { ConfigParser.GetConfig().SetProductSettingsXml(tmpProdSettings, "StaticData/PreInstall/UnfulfilledRequirement/Type", tmpProdSettings.PreInstall.UnfulfilledRequirementType); ConfigParser.GetConfig().SetProductSettingsXml(tmpProdSettings, "StaticData/PreInstall/UnfulfilledRequirement/Delta", tmpProdSettings.PreInstall.UnfulfilledRequirementDelta); pkg.ProdSettings = tmpProdSettings; pkg.InstallationState = InstallationPackage.State.Discard; continue; } } // if we got here, all requirements passed pkg.InstallationState = InstallationPackage.State.CheckPassed; if (!string.IsNullOrEmpty(prodSettings.Class)) { productClasses.Add(prodSettings.Class); } if (prodSettings.IsOptional) { optionalProducts++; } if (prodSettings.Exclusive) { _passedExclusive = prodSettings.Name; } _packageDictionary.Add(pkg.Name, pkg); pkg.HandleProgress = HandleProgressUpdate; productLayoutManager.AddProductSettings(prodSettings); } productLayoutManager.WaitForProductsSettingsControlsResources(ConfigParser.GetConfig().GetIntValue("//Config/" + ConfigConsts.REMOTE_LAYOUTS_RESOURCES_MAX_GRACETIME_MS, 0)); }
public virtual InstallationPackage CreatePackage(ProductSettings settings) { InstallationPackage pkg = new InstallationPackage(settings); return(pkg); }
public PackageDownloader(InstallationPackage installationPackage) { this.installationPackage = installationPackage; //ServicePointManager.Expect100Continue = true; //ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xF00; // Allow variety of protocols to support different clients }
public PackageExtractor(InstallationPackage installationPackage) { this.installationPackage = installationPackage; }
public PackageRunner(InstallationPackage installationPackage) { _installationPackage = installationPackage; BitsEnabled = false; _waitForRunner = false; }