Exemplo n.º 1
0
        //public ActionResult Upgrade(string packageId, string source)
        //{
        //    try {

        //        var projectManager = GetProjectManagers().Where(p => p.SourceRepository.Source == source).First();

        //        projectManager.addLog("Starting update...");

        //        IPackage installedPackage = GetInstalledPackage(projectManager, packageId);

        //        IPackage update = projectManager.GetUpdate(installedPackage);

        //        projectManager.UpdatePackage(update);

        //        projectManager.addLog("Waiting to Reload Site");

        //        var logger = (string)System.Web.HttpContext.Current.Application["NugetLogger"];

        //        return Json(new {
        //            msg = "Updated " + packageId + " to " + update.Version.ToString() + "!",
        //            updated = true, NugetLog = logger
        //        }, JsonRequestBehavior.AllowGet);
        //    } catch (Exception exc) {
        //        ErrorHandler.Publish(LogLevel.Error, exc);

        //        return Json(new {
        //            msg = "Error updating " + packageId,
        //            updated = false
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //}


        //public ActionResult DelayedUpgrade(string packageId, string source, string version)
        //{
        //    SelfUpdaterEntities context = new SelfUpdaterEntities();

        //    var entity = context.SelfUpdatingPackages.Where(d => d.PackageId == packageId).FirstOrDefault();
        //    if (entity == default(SelfUpdatingPackages)) {

        //        entity = new SelfUpdatingPackages() {
        //            PackageId = packageId,
        //            Source = source,
        //            PackageVersion = version
        //        };

        //        context.SelfUpdatingPackages.AddObject(entity);
        //        context.SaveChanges();
        //    }

        //    return Json(new {
        //        msg = "Package " + packageId + " scheduled to update!",
        //        res = true
        //    }, JsonRequestBehavior.AllowGet);

        //}

        //public ActionResult RemoveDelayedUpgrade(string packageId)
        //{
        //    SelfUpdaterEntities context = new SelfUpdaterEntities();

        //    var entity = context.SelfUpdatingPackages.Where(d => d.PackageId == packageId).FirstOrDefault();
        //    if (entity != default(SelfUpdatingPackages)) {
        //        context.SelfUpdatingPackages.DeleteObject(entity);
        //        context.SaveChanges();


        //        return Json(new {
        //            msg = "Package " + packageId + " unscheduled!",
        //            res = true
        //        }, JsonRequestBehavior.AllowGet);
        //    } else {
        //        return Json(new {
        //            msg = "Package " + packageId + " unscheduled!",
        //            res = false
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //}

        //[AcceptVerbs(HttpVerbs.Post)]
        //public void RestartSite()
        //{
        //    if (PortalSecurity.IsInRole("Admins")) {
        //        /*Forcing site restart*/
        //        var doc = new XmlDocument();
        //        doc.PreserveWhitespace = true;
        //        var configFile = Server.MapPath("~/web.config");
        //        doc.Load(configFile);

        //        var writer = new XmlTextWriter(configFile, Encoding.UTF8) { Formatting = Formatting.Indented };
        //        doc.Save(writer);
        //        writer.Flush();
        //        writer.Close();
        //        /*....................*/
        //    }
        //}

        //public ActionResult Status()
        //{
        //    var logger = (string)System.Web.HttpContext.Current.Application["NugetLogger"];
        //    if (logger == null || logger.Equals(string.Empty)) {
        //        return Json(true);
        //    }
        //    else {
        //        return Json(false);
        //    }
        //}

        private IPackage GetInstalledPackage(WebProjectManager projectManager, string packageId)
        {
            IPackage package = projectManager.GetInstalledPackages(false).Where(d => d.Id == packageId).FirstOrDefault();

            if (package == null)
            {
                throw new InvalidOperationException(string.Format("The package for package ID '{0}' is not installed in this website. Copy the package into the App_Data/packages folder.", packageId));
            }
            return(package);
        }
Exemplo n.º 2
0
        //public ActionResult Upgrade(string packageId, string source)
        //{
        //    try {
        //        var projectManager = GetProjectManagers().Where(p => p.SourceRepository.Source == source).First();
        //        projectManager.addLog("Starting update...");
        //        IPackage installedPackage = GetInstalledPackage(projectManager, packageId);
        //        IPackage update = projectManager.GetUpdate(installedPackage);
        //        projectManager.UpdatePackage(update);
        //        projectManager.addLog("Waiting to Reload Site");
        //        var logger = (string)System.Web.HttpContext.Current.Application["NugetLogger"];
        //        return Json(new {
        //            msg = "Updated " + packageId + " to " + update.Version.ToString() + "!",
        //            updated = true, NugetLog = logger
        //        }, JsonRequestBehavior.AllowGet);
        //    } catch (Exception exc) {
        //        ErrorHandler.Publish(LogLevel.Error, exc);
        //        return Json(new {
        //            msg = "Error updating " + packageId,
        //            updated = false
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //}
        //public ActionResult DelayedUpgrade(string packageId, string source, string version)
        //{
        //    SelfUpdaterEntities context = new SelfUpdaterEntities();
        //    var entity = context.SelfUpdatingPackages.Where(d => d.PackageId == packageId).FirstOrDefault();
        //    if (entity == default(SelfUpdatingPackages)) {
        //        entity = new SelfUpdatingPackages() {
        //            PackageId = packageId,
        //            Source = source,
        //            PackageVersion = version
        //        };
        //        context.SelfUpdatingPackages.AddObject(entity);
        //        context.SaveChanges();
        //    }
        //    return Json(new {
        //        msg = "Package " + packageId + " scheduled to update!",
        //        res = true
        //    }, JsonRequestBehavior.AllowGet);
        //}
        //public ActionResult RemoveDelayedUpgrade(string packageId)
        //{
        //    SelfUpdaterEntities context = new SelfUpdaterEntities();
        //    var entity = context.SelfUpdatingPackages.Where(d => d.PackageId == packageId).FirstOrDefault();
        //    if (entity != default(SelfUpdatingPackages)) {
        //        context.SelfUpdatingPackages.DeleteObject(entity);
        //        context.SaveChanges();
        //        return Json(new {
        //            msg = "Package " + packageId + " unscheduled!",
        //            res = true
        //        }, JsonRequestBehavior.AllowGet);
        //    } else {
        //        return Json(new {
        //            msg = "Package " + packageId + " unscheduled!",
        //            res = false
        //        }, JsonRequestBehavior.AllowGet);
        //    }
        //}
        //[AcceptVerbs(HttpVerbs.Post)]
        //public void RestartSite()
        //{
        //    if (PortalSecurity.IsInRole("Admins")) {
        //        /*Forcing site restart*/
        //        var doc = new XmlDocument();
        //        doc.PreserveWhitespace = true;
        //        var configFile = Server.MapPath("~/web.config");
        //        doc.Load(configFile);
        //        var writer = new XmlTextWriter(configFile, Encoding.UTF8) { Formatting = Formatting.Indented };
        //        doc.Save(writer);
        //        writer.Flush();
        //        writer.Close();
        //        /*....................*/
        //    }
        //}
        //public ActionResult Status()
        //{
        //    var logger = (string)System.Web.HttpContext.Current.Application["NugetLogger"];
        //    if (logger == null || logger.Equals(string.Empty)) {
        //        return Json(true);
        //    }
        //    else {
        //        return Json(false);
        //    }
        //}
        private IPackage GetInstalledPackage(WebProjectManager projectManager, string packageId)
        {
            IPackage package = projectManager.GetInstalledPackages(false).Where(d => d.Id == packageId).FirstOrDefault();

            if (package == null) {
                throw new InvalidOperationException(string.Format("The package for package ID '{0}' is not installed in this website. Copy the package into the App_Data/packages folder.", packageId));
            }
            return package;
        }
Exemplo n.º 3
0
        private IEnumerable<IPackage> GetInstalledPackages(WebProjectManager projectManager)
        {
            var packages = projectManager.GetInstalledPackages(true);

            return packages;
        }
Exemplo n.º 4
0
        protected List<IPackage> GetInstalledPackages(WebProjectManager projectManager)
        {
            var packages = projectManager.GetInstalledPackages(false).ToList();

            return packages;
        }
        public static List<IPackage> GetInstalledPackages(WebProjectManager projectManager, bool filterTags)
        {
            var packages = projectManager.GetInstalledPackages(filterTags).ToList();

            return packages;
        }
Exemplo n.º 6
0
        protected List <IPackage> GetInstalledPackages(WebProjectManager projectManager)
        {
            var packages = projectManager.GetInstalledPackages(false).ToList();

            return(packages);
        }