public void CreateSheet(KanaGroup[] kanaGroups, int pages, int questionsOnARow, bool includePageNumbers, bool includeAnswerSheets, SheetType sheetType) { var kanas = BaseFactory.Kana(kanaGroups); sheetType = sheetType == 0 ? SheetType.Alternate : sheetType; pages = pages == 0 ? 1 : (pages > 20 ? 20 : pages); questionsOnARow = questionsOnARow == 0 ? 12 : questionsOnARow; var sheet = new Sheet(kanas, pages, questionsOnARow, sheetType, includePageNumbers, includeAnswerSheets); var count = counterService.Increment(kanaType); var webPath = ConfigurationManager.AppSettings["webPath"]; var pdf = pdfExportService.ConvertHtmlToPdf("sheet", new Dictionary <string, object> { { "webPath", webPath }, { "sheet", sheet }, { "kanaType", kanaType.Capitalize() }, { "headerLeft", $"{kanaType} #{count}" }, { "headerRight", DateTime.Now.ToString("dd MMM yyyy HH:mm") }, { "footerLeft", $"Auto generated at: {webPath}" }, { "footerRight", "Created by Robin Lucassen" } }); CancelView(); Response.ContentType = "application/pdf"; Response.AppendHeader("content-disposition", $"attachment; filename={kanaType}-{count}.pdf"); Response.BinaryWrite(pdf); }
public IActionResult Index() { CounterService.Increment(); var count = CounterService.GetCount(); var msg = ImportantBusiness.GetGreetingMessage(); return(View(new GreetingViewModel(msg.Message, count))); }
public void TestIncrement() { Assert.AreEqual(0, target.CountValue); target.Increment(); Assert.AreEqual(1, target.CountValue); }
public ItemCounterPartHandler(ICounterService counters, IAuthenticationService auth, IOrchardServices services) { OnRemoved<ItemCounterPart>((ctx, part) => counters.RemoveAllCounters(part.ContentItem.Id)); OnGetDisplayShape<ItemCounterPart>((ctx, part) => { var settings = part.Settings.GetModel<ItemCounterPartTypePartSettings>(); var type = part.Record == null ? settings.Type : part.Type; // Incrementing visit counters here var user = auth.GetAuthenticatedUser(); var site = services.WorkContext.CurrentSite; var countUser = 0; var countSite = 0; var countSession = 0; if (user != null){ countUser = ctx.DisplayType != "Detail" ? counters.GetCounter(part.ContentItem.Id, user.Id, CounterType.Visits, CounterStoreType.Database) : counters.Increment(part.ContentItem.Id, user.Id, CounterType.Visits, CounterStoreType.Database); } if (site != null){ countSite = ctx.DisplayType != "Detail" ? counters.GetCounter(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Database) : counters.Increment(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Database); } if (site != null && services.WorkContext.HttpContext != null){ countSession = ctx.DisplayType != "Detail" ? counters.GetCounter(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Session) : counters.Increment(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Session); } /* Setting appropriate counter */ part.Count = (type == VisitCounterType.PerSite) ? countSite : (type == VisitCounterType.PerUser && user != null) ? countUser : countSession; }); }
public CountersHandler(ICounterService counters, IAuthenticationService auth, IOrchardServices services) { OnRemoved<AutoroutePart>((ctx, part) => counters.RemoveAllCounters(part.ContentItem.Id)); OnGetDisplayShape<AutoroutePart>((ctx, part) => { if (ctx.DisplayType != "Detail") return; // Avoiding double incrementing counter for route parts and itemcounter parts if (part.Is<ItemCounterPart>()) return; // Incrementing visit counters here var user = auth.GetAuthenticatedUser(); var site = services.WorkContext.CurrentSite; if (user != null) counters.Increment(part.ContentItem.Id, user.Id, CounterType.Visits, CounterStoreType.Database); if (site != null) counters.Increment(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Database); if (site != null && services.WorkContext.HttpContext != null) counters.Increment(part.ContentItem.Id, site.Id, CounterType.Visits, CounterStoreType.Session); }); }
public void AcceptCommand() { Console.Write("Type Command : "); var command = Console.ReadLine(); if (command.Equals("--help")) { ShowCommands(); AcceptCommand(); return; } ICounter counter = PickCounterFromCommand(command); if (counter == null) { Console.WriteLine(command + " is not command."); AcceptCommand(); return; } switch (command.Split(' ').First().First()) { case '+': counterService.Increment(counter, command.Split(' ').First().Length); break; case '-': counterService.Decrement(counter, command.Split(' ').First().Length); break; case 'a': counterService.Add(counter); break; case 'd': counterService.Delete(counter); break; default: Console.WriteLine(command + " is not command."); AcceptCommand(); return; } }
public async Task Increment(int byHowMuch) { await counterService.Increment(byHowMuch); }
public IActionResult GetIncrement() { _counterService.Increment(); return(Ok(_counterService.GetValue())); }
public async Task Invoke(HttpContext httpContext, ICounterService counterService) { counterService.Increment(); await _next.Invoke(httpContext); }
public IEnumerable <string> Get() { _counterService.Increment(); return(Enumerable.Range(1, _counterService.GetValue()).Select(x => $"value{x}")); }