Exemplo n.º 1
0
        public ActionResult UpdateProjectLive(ProjectCompleteModel model)
        {
            var nodeListingProvider = new NodeListingProvider();
            var project             = GetProjectForAuthorizedMember(model.Id);

            if (model.ProjectLive == false)
            {
                project.Live = false;
                nodeListingProvider.SaveOrUpdate(project);
            }
            else
            {
                // Special exception
                if (string.Equals(model.Name, _exceptionName, StringComparison.InvariantCultureIgnoreCase))
                {
                    project.Live = true;
                    nodeListingProvider.SaveOrUpdate(project);
                }
                else
                {
                    var packages       = nodeListingProvider.GetMediaForProjectByType(project.Id, FileType.package);
                    var currentPackage = packages.FirstOrDefault(x => x.Current && x.Archived == false);

                    if (currentPackage != null && ZipFileContainsPackageXml(currentPackage))
                    {
                        project.Live = true;
                        nodeListingProvider.SaveOrUpdate(project);
                    }
                }
            }

            return(RedirectToCurrentUmbracoPage(Request.Url.Query));
        }
Exemplo n.º 2
0
        public ActionResult RenderComplete(int id)
        {
            var project = GetProjectForAuthorizedMember(id);
            var model   = new ProjectCompleteModel {
                Id = id, Name = project.Name, ProjectLive = project.Live
            };

            return(PartialView("~/Views/Partials/Project/Complete.cshtml", model));
        }
Exemplo n.º 3
0
        public ActionResult RenderComplete(int id)
        {
            var project             = GetProjectForAuthorizedMember(id);
            var nodeListingProvider = new NodeListingProvider();
            var packages            = nodeListingProvider.GetMediaForProjectByType(project.Id, FileType.package);

            var errorMessage   = string.Empty;
            var currentPackage = packages.FirstOrDefault(x => x.Current && x.Archived == false);
            var contentService = Services.ContentService;
            var content        = contentService.GetById(project.Id);
            var isNuGetFormat  = content.GetValue <bool>("isNuGetFormat");
            var nuGetUrl       = content.GetValue <string>("nuGetPackageUrl");

            // Special exception
            var isExceptionPackage = string.Equals(project.Name, _exceptionName, StringComparison.InvariantCultureIgnoreCase);

            if (isNuGetFormat == false)
            {
                if (isExceptionPackage == false && currentPackage == null)
                {
                    errorMessage =
                        "None of the package files are marked as the current package, please make one current.";
                }

                if (isExceptionPackage == false && currentPackage != null &&
                    ZipFileContainsPackageXml(currentPackage) == false)
                {
                    var projectIsLive = content.GetValue <bool>("projectLive");

                    if (projectIsLive)
                    {
                        content.SetValue("projectLive", false);
                        contentService.SaveAndPublishWithStatus(content);
                    }

                    errorMessage = string.Format(
                        "The current package file {0} is not a valid Umbraco Package, please upload a package",
                        currentPackage.Name);
                }
            }
            else
            {
                // NuGet URL needs to be provided
                if (string.IsNullOrEmpty(nuGetUrl))
                {
                    errorMessage =
                        "Please provide a NuGet URL if your package is in the v9+ NuGet format";
                }
            }

            var model = new ProjectCompleteModel {
                Id = project.Id, Name = project.Name, ProjectLive = project.Live, ErrorMessage = errorMessage
            };

            return(PartialView("~/Views/Partials/Project/Complete.cshtml", model));
        }
Exemplo n.º 4
0
        public ActionResult UpdateProjectLive(ProjectCompleteModel model)
        {
            var nodeListingProvider = new NodeListingProvider();
            var project             = GetProjectForAuthorizedMember(model.Id);

            project.Live = model.ProjectLive;
            nodeListingProvider.SaveOrUpdate(project);

            return(RedirectToCurrentUmbracoPage(Request.Url.Query));
        }
Exemplo n.º 5
0
        public ActionResult UpdateProjectLive(ProjectCompleteModel model)
        {
            var nodeListingProvider = new NodeListingProvider();
            var project             = GetProjectForAuthorizedMember(model.Id);

            if (model.ProjectLive == false)
            {
                project.Live = false;
                nodeListingProvider.SaveOrUpdate(project);
            }
            else
            {
                var packages       = nodeListingProvider.GetMediaForProjectByType(project.Id, FileType.package);
                var currentPackage = packages.FirstOrDefault(x => x.Current && x.Archived == false);

                if (currentPackage != null && ZipFileContainsPackageXml(IOHelper.MapPath(currentPackage.Path)))
                {
                    project.Live = true;
                    nodeListingProvider.SaveOrUpdate(project);
                }
            }

            return(RedirectToCurrentUmbracoPage(Request.Url.Query));
        }
Exemplo n.º 6
0
        public ActionResult RenderComplete(int id)
        {
            var project             = GetProjectForAuthorizedMember(id);
            var nodeListingProvider = new NodeListingProvider();
            var packages            = nodeListingProvider.GetMediaForProjectByType(project.Id, FileType.package);

            var errorMessage   = string.Empty;
            var currentPackage = packages.FirstOrDefault(x => x.Current && x.Archived == false);

            if (currentPackage == null)
            {
                errorMessage = "None of the package files are marked as the current package, please make one current.";
            }

            if (currentPackage != null && ZipFileContainsPackageXml(IOHelper.MapPath(currentPackage.Path)) == false)
            {
                LogHelper.Info <ProjectController>($"Checking if {currentPackage.Path} has a package.xml zipped up in there.");

                var contentService = Services.ContentService;
                var content        = contentService.GetById(project.Id);
                var projectIsLive  = content.GetValue <bool>("projectLive");

                if (projectIsLive)
                {
                    content.SetValue("projectLive", false);
                    contentService.SaveAndPublishWithStatus(content);
                }
                errorMessage = $"The current package file {currentPackage.Name} is not a valid Umbraco Package, please upload a package";
            }

            var model = new ProjectCompleteModel {
                Id = project.Id, Name = project.Name, ProjectLive = project.Live, ErrorMessage = errorMessage
            };

            return(PartialView("~/Views/Partials/Project/Complete.cshtml", model));
        }