public IEnumerable<VersionCompatibility> GetCompatibilityReport(int projectId) { var uVersions = UVersion.GetAllVersions(); var projectProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider(); var project = projectProvider.GetListing(projectId, true); var compatList = new List<VersionCompatibility>(); var projectCompatibilities = _databaseContext.Database.Fetch<dynamic>( "SELECT * FROM DeliVersionCompatibility WHERE projectId = @projectId", new {projectId = projectId}); foreach (var ver in uVersions) { var ver1 = ver; var reports = projectCompatibilities.Where(x => x.version == ver1.Name && x.projectId == project.Id).ToArray(); if (reports.Any()) { float compats = reports.Count(x => x.isCompatible); float numReps = reports.Count(); var perc = Convert.ToInt32(((compats / numReps) * 100)); var smiley = "unhappy"; if (perc >= 95) { smiley = "joyous"; } else if (perc < 95 && perc >= 80) { smiley = "happy"; } else if (perc < 80 && perc >= 65) { smiley = "neutral"; } else if (perc < 65 && perc >= 50) { smiley = "unhappy"; } else { smiley = "superUnhappy"; } compatList.Add(new VersionCompatibility() { Percentage = perc, Smiley = smiley, Version = ver.Name }); } else { compatList.Add(new VersionCompatibility() { Percentage = 0, Smiley = "untested", Version = ver.Name }); } } return compatList; }
public void ProcessRequest(HttpContext context) { HttpPostedFile file = context.Request.Files["Filedata"]; string userguid = context.Request.Form["USERGUID"]; string projectguid = context.Request.Form["NODEGUID"]; string nodeId = context.Request.Form["id"]; string fileType = context.Request.Form["FILETYPE"]; string fileName = context.Request.Form["FILENAME"]; string umbraoVersion = (context.Request.Form["UMBRACOVERSION"] != null) ? context.Request.Form["UMBRACOVERSION"] : "nan"; string dotNetVersion = (context.Request.Form["DOTNETVERSION"] != null) ? context.Request.Form["DOTNETVERSION"] : "nan"; string trustLevel = (context.Request.Form["TRUSTLEVEL"] != null) ? context.Request.Form["TRUSTLEVEL"] : "nan"; List <OurUmbraco.Wiki.BusinessLogic.UmbracoVersion> v = new List <OurUmbraco.Wiki.BusinessLogic.UmbracoVersion>() { OurUmbraco.Wiki.BusinessLogic.UmbracoVersion.DefaultVersion() }; if (!string.IsNullOrEmpty(umbraoVersion)) { v.Clear(); v = WikiFile.GetVersionsFromString(umbraoVersion); } bool trust = false; if (trustLevel == "Medium") { trust = true; } if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(projectguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName)) { var nodeListingProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider(); var p = nodeListingProvider.GetListing(new Guid(projectguid)); Member mem = new Member(new Guid(userguid)); if (p.VendorId == mem.Id || Utils.IsProjectContributor(mem.Id, p.Id)) { var mediaProvider = new OurUmbraco.MarketPlace.Providers.MediaProvider(); var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType, true); // TODO: Don't know how else to get the bloody version var version = UmbracoContext.Current.Application.Services.ContentService.GetById(p.Id).Version; mediaProvider.CreateFile(fileName, version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust); } else { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner"); } } }
public void ProcessRequest(HttpContext context) { HttpPostedFile file = context.Request.Files["Filedata"]; string userguid = context.Request.Form["USERGUID"]; string projectguid = context.Request.Form["NODEGUID"]; string nodeId = context.Request.Form["id"]; string fileType = context.Request.Form["FILETYPE"]; string fileName = context.Request.Form["FILENAME"]; string umbraoVersion = (context.Request.Form["UMBRACOVERSION"] != null) ? context.Request.Form["UMBRACOVERSION"] : "nan"; string dotNetVersion = (context.Request.Form["DOTNETVERSION"] != null) ? context.Request.Form["DOTNETVERSION"] : "nan"; string trustLevel = (context.Request.Form["TRUSTLEVEL"] != null) ? context.Request.Form["TRUSTLEVEL"] : "nan"; List<OurUmbraco.Wiki.BusinessLogic.UmbracoVersion> v = new List<OurUmbraco.Wiki.BusinessLogic.UmbracoVersion>() { OurUmbraco.Wiki.BusinessLogic.UmbracoVersion.DefaultVersion() }; if (!string.IsNullOrEmpty(umbraoVersion)) { v.Clear(); v = WikiFile.GetVersionsFromString(umbraoVersion); } bool trust = false; if(trustLevel == "Medium"){ trust = true; } if (!string.IsNullOrEmpty(userguid) && !string.IsNullOrEmpty(projectguid) && !string.IsNullOrEmpty(fileType) && !string.IsNullOrEmpty(fileName)) { var nodeListingProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider(); var p = nodeListingProvider.GetListing(new Guid(projectguid)); Member mem = new Member(new Guid(userguid)); if (p.VendorId == mem.Id || Utils.IsProjectContributor(mem.Id, p.Id)) { var mediaProvider = new OurUmbraco.MarketPlace.Providers.MediaProvider(); var packageFileType = (FileType)Enum.Parse(typeof(FileType), (string)fileType , true); // TODO: Don't know how else to get the bloody version var version = ApplicationContext.Current.Services.ContentService.GetById(p.Id).Version; mediaProvider.CreateFile(fileName, version, mem.UniqueId, file, packageFileType, v, dotNetVersion, trust); } else { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, 0, "wrong type or not a owner"); } } }
public IEnumerable <VersionCompatibility> GetCompatibilityReport(int projectId) { var versions = new UVersion(); var uVersions = versions.GetAllVersions(); var projectProvider = new OurUmbraco.MarketPlace.NodeListing.NodeListingProvider(); var project = projectProvider.GetListing(projectId, true); var compatList = new List <VersionCompatibility>(); var projectCompatibilities = _databaseContext.Database.Fetch <dynamic>( "SELECT * FROM DeliVersionCompatibility WHERE projectId = @projectId", new { projectId = projectId }); foreach (var ver in uVersions) { var ver1 = ver; var reports = projectCompatibilities.Where(x => x.version == ver1.Name.Replace("Version ", string.Empty) && x.projectId == project.Id).ToArray(); if (reports.Any()) { float compats = reports.Count(x => x.isCompatible); float numReps = reports.Count(); var perc = Convert.ToInt32(((compats / numReps) * 100)); var smiley = "unhappy"; if (perc >= 95) { smiley = "joyous"; } else if (perc < 95 && perc >= 80) { smiley = "happy"; } else if (perc < 80 && perc >= 65) { smiley = "neutral"; } else if (perc < 65 && perc >= 50) { smiley = "unhappy"; } else { smiley = "superUnhappy"; } compatList.Add(new VersionCompatibility() { Percentage = perc, Smiley = smiley, Version = ver.Name }); } else { compatList.Add(new VersionCompatibility() { Percentage = 0, Smiley = "untested", Version = ver.Name }); } } return(compatList); }