private FileStreamResult BadgesResult(List <ApplicationUser> users) { Stream stream = new MemoryStream(); BadgeGenerator bg = GetBadgeGenerator(stream); bg.FillPages(users); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "badges.pdf")); }
private void Awake() { loadTime = -1f; bg = gameObject.GetComponent <BadgeGenerator>(); PlayerBadges = new Dictionary <string, Sprite>(); }
public void Initialize() { _sampleBadge1 = BadgeGenerator.GenerateBadge1(); _sampleBadge2 = BadgeGenerator.GenerateBadge2(); _manyBadges = BadgeGenerator.GenerateManyBadges(); }
public async Task <IActionResult> GetBadge(Guid teamProject, int buildDefinitionId, string type, string title, string titlefg, string titlebg, string value, string valuefg, string valuebg, string subType) { try { // http://localhost:50573/_apis/infos/c4f86f26-1bf4-4452-bd7e-67db7a5c1486/335/buildnumber/badge // http://localhost:50573/_apis/infos/c4f86f26-1bf4-4452-bd7e-67db7a5c1486/335/custom/badge?title=hello&value=33773 titlebg = GetValue(titlebg, "#f1f1f1"); titlefg = GetValue(titlefg, "#000"); valuebg = GetValue(valuebg, "#08298A"); valuefg = GetValue(valuefg, "#fff"); if (type == "custom") { value = value ?? "-"; } else { using (var client = m_tfsOptions.GetBuildClient()) { var result = await client.GetBuildsAsync(teamProject, new[] { buildDefinitionId }); if (!result.Any()) { return(new JsonResult($"Build definition {buildDefinitionId} was not found.")); } var build = result.First(); switch (type.ToLowerInvariant()) { case "buildnumber": title = title ?? "number"; value = build.BuildNumber; break; case "result-age": title = title ?? "build"; value = GetResultAge(subType, build, ref valuebg, ref valuefg, ref title); break; case "duration": title = title ?? "duration"; value = GetDuration(build); break; case "finishdate": title = title ?? "finished"; value = GetFinishDate(build); break; case "best-coverage": title = title ?? "coverage"; value = await GetBestCoverageAsync(teamProject, build); break; case "coverage": title = title ?? "coverage"; value = await GetCoverageAsync(teamProject, subType, build); break; default: // Use title, value, etc. as passed. value = value ?? "-"; break; } } } var doc = BadgeGenerator.CreateSvgBadge(title, titlefg, titlebg, value, valuefg, valuebg); return(Content(doc.ToString(), "image/svg+xml")); } catch (Exception ex) { m_logger.LogError($"Request failed: {Request.GetDisplayUrl()}: {ex}"); throw; } }