public void MakePlotTest() { CleanTestBase.RunAutomatically(false); var cs = new OxyCalculationSetup(Utili.GetCurrentMethodAndClass()); cs.StartHousehold(1, GlobalConsts.CSVCharacter, configSetter: x => x.Enable(CalcOption.LocationsFile)); //cs.Wd.InputDataLogger.AddSaver(new HouseholdKeyLogger(cs.Wd.SqlResultLoggingService)); using (FileFactoryAndTracker fft = new FileFactoryAndTracker(cs.DstDir, "1", cs.Wd.InputDataLogger)) { fft.ReadExistingFilesFromSql(); Logger.Info("Making picture"); var di = new DirectoryInfo(cs.DstDir); var files = FileFinder.GetRecursiveFiles(di, "LocationStatistics.HH1.csv"); files.Count.Should().BeGreaterOrEqualTo(1); CalculationProfiler cp = new CalculationProfiler(); ChartCreationParameters ccps = new ChartCreationParameters(300, 4000, 2500, false, GlobalConsts.CSVCharacter, new DirectoryInfo(cs.DstDir)); var locationStatistics = new LocationStatistics(ccps, fft, cp); var rfe = cs.GetRfeByFilename("LocationStatistics.HH1.csv"); locationStatistics.MakePlot(rfe); Logger.Info("finished picture"); // OxyCalculationSetup.CopyImage(resultFileEntries[0].FullFileName); var imagefiles = FileFinder.GetRecursiveFiles(di, "LocationStatistics.*.png"); imagefiles.Count.Should().BeGreaterOrEqualTo(1); } cs.CleanUp(); CleanTestBase.RunAutomatically(true); }
private static double GetRawValue(LocationStatisticsMode mode, LocationStatistics stats) { if (mode == LocationStatisticsMode.MaxSimultaneousCalls) { return(stats.MaxSimultaneousCalls); } if (mode == LocationStatisticsMode.TotaltTimeForCalls) { return(stats.TotaltTimeForCalls); } return(stats.NumberOfCalls); }
public ActionResult Statistics() { var model = new LocationStatistics(); var locations = _locationsRepository.GetAll(); // Count model.Count = locations.Count(); // Latest model.Latest = locations.OrderByDescending(c => c.Id).Take(3).Select(i => new { name = i.Name, image = _imageService.BuildUrl(i.ImageBlob?.Name, i.Name, 40, 40), creationDate = Globalization.GetLocalDateTime(i.UTCCreation).DateTime.ToLongDateString(), navigationPath = Url.Action(nameof(LocationsController.Edit), nameof(LocationsController).RemoveControllerSuffix(), new { @id = i.Id }) }).Cast <object>().ToList(); // Weekly data var maxDate = DateTime.UtcNow; var minDate = maxDate.AddDays(-7); locations = locations.Where(c => c.UTCCreation.Date >= minDate.Date); locations = locations.Where(c => c.UTCCreation.Date <= maxDate.Date); var items = new List <object>(); for (DateTime date = minDate.Date; date <= maxDate.Date; date = date.AddDays(1)) { var dayName = date.ToString("MMM/dd"); var dayValue = locations.Where(c => c.UTCCreation.Date.Equals(date)).Count(); items.Add(new List <object>() { dayName, dayValue }); } model.WeeklyRegistrations = items; return(Json(model)); }
private static string GetToolTip(LocationStatisticsMode mode, LocationStatistics stats) { if (mode != LocationStatisticsMode.MaxSimultaneousCalls) { return(string.Empty); } if (stats.MaxSimultaneousCalls <= 1) { return(string.Empty); } var dates = stats.MaxSimultaneousEventDates.ToList(); var sb = new StringBuilder(); var format = dates.Count > 1 ? Resources.Stats_SimultaneousCallsToolTipM : Resources.Stats_SimultaneousCallsToolTip1; sb.AppendFormat(format, stats.MaxSimultaneousCalls, dates.Count); dates.ForEach(d => sb.AppendLine().AppendFormat("{0:yyyy-MM-dd}", d)); return(sb.ToString()); }
private static string GetValue(LocationStatisticsMode mode, LocationStatistics stats) { return(string.Format(SvCulture, "{0}", Math.Round(GetRawValue(mode, stats), MidpointRounding.ToEven))); }
private static string GetWidth(LocationStatisticsMode mode, LocationStatistics stats, double multiplier) { return(string.Format(CultureInfo.InvariantCulture, "{0:0.#}", Math.Max(0.1, GetRawValue(mode, stats) * multiplier * 50))); }