//private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; public override async Task <InstallSetupResult> ExecuteAsync(Guid?starterKitId) { //if there is no value assigned then use the default starter kit if (starterKitId.HasValue == false) { var starterKits = _installHelper.GetStarterKits().FirstOrDefault(); if (starterKits != null) { starterKitId = starterKits.Id; } else { return(null); } } else if (starterKitId.Value == Guid.Empty) { //if the startkit id is an empty GUID then it means the user has decided not to install one // so we'll just exit return(null); } var(packageFile, packageId) = await DownloadPackageFilesAsync(starterKitId.Value); UmbracoApplication.Restart(); return(new InstallSetupResult(new Dictionary <string, object> { { "packageId", packageId }, { "packageFile", packageFile } })); }
public ServerResponse RestartAppPool() { try { UmbracoApplication.Restart(); return(new ServerResponse("Restarting the application pool - hold tight...", ServerResponseType.Success)); } catch (Exception ex) { return(new ServerResponse("Error restarting the application pool: " + ex.Message, ServerResponseType.Error)); } }
public override Task <InstallSetupResult> ExecuteAsync(object model) { var installSteps = InstallStatusTracker.GetStatus().ToArray(); var previousStep = installSteps.Single(x => x.Name == "StarterKitDownload"); var packageId = Convert.ToInt32(previousStep.AdditionalData["packageId"]); InstallBusinessLogic(packageId); UmbracoApplication.Restart(_httContext); return(Task.FromResult <InstallSetupResult>(null)); }
private static void ThrowModelBindingException(bool sourceContent, bool modelContent, Type sourceType, Type modelType) { var msg = new StringBuilder(); // prepare message msg.Append("Cannot bind source"); if (sourceContent) { msg.Append(" content"); } msg.Append(" type "); msg.Append(sourceType.FullName); msg.Append(" to model"); if (modelContent) { msg.Append(" content"); } msg.Append(" type "); msg.Append(modelType.FullName); msg.Append("."); // raise event, to give model factories a chance at reporting // the error with more details, and optionally request that // the application restarts. var args = new ModelBindingArgs(sourceType, modelType, msg); ModelBindingException?.Invoke(Instance, args); // TODO: with all of the tests I've done i don't think restarting the app here is required anymore, // when I don't have this code enabled and i get a model binding error and just refresh, it fixes itself. // We'll leave this for now though. if (args.Restart) { msg.Append(" The application is restarting now."); var context = HttpContext.Current; if (context == null) { AppDomain.Unload(AppDomain.CurrentDomain); } else { UmbracoApplication.Restart(new HttpContextWrapper(context)); } } throw new ModelBindingException(msg.ToString()); }
private static void ThrowModelBindingException(bool sourceContent, bool modelContent, Type sourceType, Type modelType) { var msg = new StringBuilder(); // prepare message msg.Append("Cannot bind source"); if (sourceContent) { msg.Append(" content"); } msg.Append(" type "); msg.Append(sourceType.FullName); msg.Append(" to model"); if (modelContent) { msg.Append(" content"); } msg.Append(" type "); msg.Append(modelType.FullName); msg.Append("."); // raise event, to give model factories a chance at reporting // the error with more details, and optionally request that // the application restarts. var args = new ModelBindingArgs(sourceType, modelType, msg); ModelBindingException?.Invoke(Instance, args); if (args.Restart) { msg.Append(" The application is restarting now."); var context = HttpContext.Current; if (context == null) { AppDomain.Unload(AppDomain.CurrentDomain); } else { UmbracoApplication.Restart(new HttpContextWrapper(context)); } } throw new ModelBindingException(msg.ToString()); }
public PackageInstallModel InstallFiles(PackageInstallModel model) { var definition = Services.PackagingService.GetInstalledPackageById(model.Id); if (definition == null) { throw new InvalidOperationException("Not package definition found with id " + model.Id); } var zipFile = new FileInfo(definition.PackagePath); var installedFiles = Services.PackagingService.InstallCompiledPackageFiles(definition, zipFile, Security.GetUserId().ResultOr(0)); //set a restarting marker and reset the app pool UmbracoApplication.Restart(Request.TryGetHttpContext().Result); model.IsRestarting = true; return(model); }