/// <summary> /// Return the UpgradeModel for a specific upgrade path/tier /// </summary> /// <param name="path"></param> /// <param name="tier"></param> public static UpgradeModel GetUpgrade(this TowerModel towerModel, int path, int tier) { if (path < 0 || tier < 0) { return(null); } int tier1 = (path == 0) ? tier : 0; int tier2 = (path == 1) ? tier : 0; int tier3 = (path == 2) ? tier : 0; TowerModel tempTower = Game.instance?.model?.GetTower(towerModel.GetBaseId(), tier1, tier2, tier3); if (tempTower is null) { return(null); } const int offset = 1; List <UpgradeModel> appliedUpgrades = tempTower.GetAppliedUpgrades(); UpgradeModel results = appliedUpgrades.FirstOrDefault(model => model.path == path && model.tier == (tier - offset)); return(null); }
public virtual UpgradeModel GetUpgradeModel() { if (upgradeModel == null) { upgradeModel = new UpgradeModel(Id, Cost, 0, GetSpriteReference(mod, Id), Path, Tier, 0, "", ""); } return(upgradeModel); }
public virtual IActionResult Index() { if (!DataSettingsHelper.DatabaseIsInstalled()) { return(RedirectToRoute("Install")); } var model = new UpgradeModel(); model.ApplicationVersion = GrandVersion.CurrentVersion; model.DatabaseVersion = _upgradeService.DatabaseVersion(); return(View(model)); }
public ActionResult Index(UpgradeModel m) { var model = new UpgradeModel(); model.ApplicationVersion = GrandVersion.CurrentVersion; model.DatabaseVersion = _upgradeService.DatabaseVersion(); if (model.ApplicationVersion != model.DatabaseVersion) { _upgradeService.UpgradeData(model.DatabaseVersion, model.ApplicationVersion); } model.ApplicationVersion = GrandVersion.CurrentVersion; model.DatabaseVersion = _upgradeService.DatabaseVersion(); return(View(model)); }
/// <summary> /// 写入升级模块信息 /// </summary> /// <param name="sectionName"></param> /// <param name="model"></param> public static void WriteModuleInfo(string sectionName, UpgradeModel model) { if (sectionName.Equals(_baseInfo)) { throw new ArgumentNullException("sectionName value is a built-in definition module"); } if (model == null) { throw new ArgumentNullException("mode is not null"); } WriteModuleUrl(sectionName, model.Url); WriteModuleDescription(sectionName, model.Description); WriteModuleFileName(sectionName, model.FileName); WriteModuleIsMainProcess(sectionName, model.IsMainProcess); }
public virtual ActionResult Upgrade() { var writer = new StringWriter(); var log = new TextLog(writer); var result = Database.PerformUpgrade(Extensions, log); UpgradeDetector.Reset(); var upgradeModel = new UpgradeModel(result, writer.ToString()); if (settingsProvider.GetSettings <SqlAuthSettings>().SqlAuthenticationEnabled&& upgradeModel.Results.All(x => x.Successful)) { // We have upgraded and now we must sign back in as as sql user! federatedAuthenticationService.Logout(); } return(View("UpgradeReport", upgradeModel)); }
public virtual IActionResult Index(UpgradeModel m, [FromServices] IWebHelper webHelper) { var model = new UpgradeModel(); model.ApplicationVersion = GrandVersion.CurrentVersion; model.DatabaseVersion = _upgradeService.DatabaseVersion(); if (model.ApplicationVersion != model.DatabaseVersion) { _upgradeService.UpgradeData(model.DatabaseVersion, model.ApplicationVersion); } //restart application webHelper.RestartAppDomain(); //Redirect to home page return(RedirectToRoute("HomePage")); }
public virtual IActionResult Index() { if (!DataSettingsHelper.DatabaseIsInstalled()) { return(RedirectToRoute("Install")); } var model = new UpgradeModel { ApplicationVersion = GrandVersion.FullVersion, ApplicationDBVersion = GrandVersion.SupportedDBVersion, DatabaseVersion = _upgradeService.DatabaseVersion() }; if (model.ApplicationDBVersion == model.DatabaseVersion) { return(RedirectToRoute("Homepage")); } return(View(model)); }
public virtual IActionResult Index(UpgradeModel m) { var model = new UpgradeModel(); model.ApplicationVersion = GrandVersion.CurrentVersion; model.DatabaseVersion = _upgradeService.DatabaseVersion(); if (model.ApplicationVersion != model.DatabaseVersion) { _upgradeService.UpgradeData(model.DatabaseVersion, model.ApplicationVersion); } //restart application var webHelper = EngineContextExperimental.Current.Resolve <IWebHelper>(); webHelper.RestartAppDomain(); //Redirect to home page return(RedirectToRoute("HomePage")); }
public virtual async Task <IActionResult> Index(UpgradeModel m, [FromServices] IWebHelper webHelper) { var model = new UpgradeModel { ApplicationDBVersion = GrandVersion.SupportedDBVersion, DatabaseVersion = _upgradeService.DatabaseVersion() }; if (model.ApplicationDBVersion != model.DatabaseVersion) { await _upgradeService.UpgradeData(model.DatabaseVersion, model.ApplicationDBVersion); } else { return(RedirectToRoute("HomePage")); } //restart application webHelper.StopApplication(); //Redirect to home page return(RedirectToRoute("HomePage")); }
/// <summary> /// 获得需要更新得模块信息 /// </summary> /// <returns></returns> public static List <UpgradeModel> GetUpgradeModule() { var resp = new List <UpgradeModel>(); try { var list = ServiceIniUpgradeHelper.ReadModuleList(); list?.ForEach(item => { var response = new UpgradeModel(); response.Url = ServiceIniUpgradeHelper.ReadModuleUrl(item); response.FileName = ServiceIniUpgradeHelper.ReadModuleFileName(item); response.Description = ServiceIniUpgradeHelper.ReadModuleDescription(item); response.IsMainProcess = ServiceIniUpgradeHelper.ReadModuleIsMainProcess(item); resp.Add(response); }); } catch (Exception ex) { TextHelper.Error("GetUpgradeModule 异常", ex); } return(resp); }
/// <summary> /// Gets the ModUpgrade associated with this UpgradeModel /// <br/> /// If there is no associated ModUpgrade, returns null /// </summary> /// <returns></returns> public static ModUpgrade GetModUpgrade(this UpgradeModel upgradeModel) { return(ModUpgrade.Cache.TryGetValue(upgradeModel.name, out var modUpgrade) ? modUpgrade : null); }
public UpgradeController(UpgradeModel model) { _model = model; }
public static void DefaultTemple(UpgradeModel upgradeModel) { upgradeModel.confirmation = "Sun Temple"; upgradeModel.cost = 100000; }
public static void ModifyTemple(UpgradeModel upgradeModel) { upgradeModel.confirmation = ""; upgradeModel.cost = Main.TempleAlternateCost; }
public IHttpActionResult CheckUpgrade(UpgradeModel model) { if (!ModelState.IsValid) { throw new HttpResponseException(Request.CreateValidationErrorResponse(ModelState)); } int revision; int.TryParse(model.VersionComment, out revision); var version = new System.Version(model.VersionMajor, model.VersionMinor, model.VersionPatch, revision); var latestVersion = GetLatestVersionFromMajor(model.VersionMajor); if (latestVersion == null) { return(Json(new UpgradeResult(UpgradeType.None, "", ""))); } // Persist the update check for our statistics, don't remove! var caller = HttpContext.Current.Request.UserHostName + "_" + HttpContext.Current.Request.UserHostAddress; var callerHashed = FormsAuthentication.HashPasswordForStoringInConfigFile(caller, "sha1"); PersistUpdateCheck(callerHashed, model.VersionMajor, model.VersionMinor, model.VersionPatch, model.VersionComment); // End of persisting the update check for our statistics, don't remove! // Special case for 4.0.4.2, apperently we never recommended them to upgrade if (version == new System.Version(4, 0, 4, 2) || version == latestVersion) { return(Json(new UpgradeResult(UpgradeType.None, "", ""))); } if (version.Major == 4) { // We had some special cases in the old updatechecker so I left them here if (version == new System.Version(4, 0, 4, 1)) { return(Json(new UpgradeResult(UpgradeType.Minor, "4.0.4.2 is out with fixes for load-balanced sites.", "http://our.umbraco.org/download"))); } if (version == new System.Version(4, 0, 4, 0)) { return(Json(new UpgradeResult(UpgradeType.Critical, "4.0.4.1 is out fixing a serious macro bug. Please upgrade!", "http://our.umbraco.org/download"))); } if (version == new System.Version(4, 7, 0, 0)) { return(Json(new UpgradeResult(UpgradeType.Critical, "This Umbraco installation needs to be upgraded. It may contain a potential security issue!", "http://our.umbraco.org/download"))); } if (version >= new System.Version(4, 10, 0, 0) && version < latestVersion) { return(Json(new UpgradeResult(UpgradeType.Major, $"{latestVersion} is released. Upgrade today - it's free!", "http://our.umbraco.org/download"))); } } if (version.Major == 6) { if ((version < latestVersion)) { return(Json(new UpgradeResult(UpgradeType.Major, $"{latestVersion} is released. Upgrade today - it's free!", "http://our.umbraco.org/download"))); } } if (version.Major == 7 || version.Major == 8 || version.Major > 8) { if (version < latestVersion) { return(Json(new UpgradeResult(UpgradeType.Minor, $"{latestVersion} is released. Upgrade today - it's free!", $"http://our.umbraco.org/contribute/releases/{latestVersion.Major}{latestVersion.Minor}{latestVersion.Build}"))); } } // If nothing matches then it's probably a nightly or a very old version, no need to send upgrade message return(Json(new UpgradeResult(UpgradeType.None, "", ""))); }
public static void DefaultGod(UpgradeModel upgradeModel) { upgradeModel.confirmation = "True Sun Temple"; upgradeModel.cost = 500000; }
/// <summary> /// If you really need to override the way that the ModUpgrade makes its UpgradeModel, go ahead /// </summary> /// <returns></returns> public virtual UpgradeModel GetUpgradeModel() { return(upgradeModel ?? (upgradeModel = new UpgradeModel(Id, Cost, XpCost, IconReference ?? DefaultIcon, Path, Tier - 1, 0, NeedsConfirmation ? Id : "", ""))); }
/// <summary> /// Change the UpgradeModel for this upgrade /// </summary> /// <param name="upgradeModel"></param> public virtual void Apply(UpgradeModel upgradeModel) { }
public static void AddUpgrade(this GameModel model, UpgradeModel upgradeModel) { model.upgrades = model.upgrades.AddTo(upgradeModel); model.upgradesByName.Add(upgradeModel.name, upgradeModel); }
public static void ModifyGod(UpgradeModel upgradeModel) { upgradeModel.confirmation = ""; upgradeModel.cost = CostForDifficulty(Main.GodAlternateCost); }
public static void DefaultGod(UpgradeModel upgradeModel) { upgradeModel.confirmation = "True Sun Temple"; upgradeModel.cost = CostForDifficulty(500000); }
public static void ModifyGod(UpgradeModel upgradeModel) { upgradeModel.confirmation = ""; upgradeModel.cost = Main.GodAlternateCost; }
/// <summary> /// Check if a specific upgrade path is being used/ has any upgrades applied to it /// </summary> /// <param name="path">Upgrade path to check</param> public static bool IsUpgradePathUsed(this TowerModel towerModel, int path) { UpgradeModel result = towerModel.GetAppliedUpgrades().FirstOrDefault(upgrade => upgrade.path == path); return(result != null); }
/// <summary> /// Check if an upgrade has been applied /// </summary> /// <param name="upgradeModel"></param> /// <returns></returns> public static bool HasUpgrade(this TowerModel towerModel, UpgradeModel upgradeModel) { return(towerModel.GetAppliedUpgrades().Contains(upgradeModel)); }
/// <summary> /// Has a specific upgrade for this TowerModel been unlocked already? /// </summary> /// <param name="path">Upgrade path</param> /// <param name="tier">Tier of upgrade</param> public static bool?IsUpgradeUnlocked(this TowerModel towerModel, int path, int tier) { UpgradeModel upgradeModel = towerModel.GetUpgrade(path, tier); return(Game.instance?.GetBtd6Player()?.HasUpgrade(upgradeModel?.name)); }
/// <summary> /// Return whether or not this upgrade has been unlocked by the player /// </summary> public static bool IsUpgradeUnlocked(this UpgradeModel upgradeModel) { return(Game.instance.GetBtd6Player().HasUpgrade(upgradeModel.name)); }
public static void DefaultTemple(UpgradeModel upgradeModel) { upgradeModel.confirmation = "Sun Temple"; upgradeModel.cost = CostForDifficulty(100000); }