public KIndexDTO Detail(string ico) { if (string.IsNullOrEmpty(ico)) { throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest, $"Hodnota ico chybí.")); } var kindex = KIndex.Get(ico); if (kindex == null) { throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.NotFound, $"Kindex pro ico [{ico}] nenalezen.")); } var limitedKindex = new KIndexDTO { Ico = kindex.Ico, Name = kindex.Jmeno, LastChange = kindex.LastSaved, AnnualCalculations = kindex.roky.Select(annual => new KIndexYearsDTO { KIndex = annual.KIndex, Calculation = annual.KIndexVypocet }) }; return(limitedKindex); }
public ActionResult PercentileBanner(string id, int?part = null, int?rok = null) { rok = Consts.FixKindexYear(rok); var kidx = KIndex.Get(id); if (kidx != null) { Statistics stat = Statistics.GetStatistics(rok.Value); KIndexData.KIndexParts?kpart = (KIndexData.KIndexParts?)part; if (kpart.HasValue) { var val = kidx.ForYear(rok.Value).KIndexVypocet.Radky.FirstOrDefault(m => m.VelicinaPart == kpart.Value)?.Hodnota ?? 0; return(Content( new HlidacStatu.KIndexGenerator.PercentileBanner( val, stat.Percentil(1, kpart.Value), stat.Percentil(10, kpart.Value), stat.Percentil(25, kpart.Value), stat.Percentil(50, kpart.Value), stat.Percentil(75, kpart.Value), stat.Percentil(90, kpart.Value), stat.Percentil(99, kpart.Value), Lib.StaticData.App_Data_Path).Svg() , "image/svg+xml")); } else { var val = kidx.ForYear(rok.Value).KIndex; return(Content( new HlidacStatu.KIndexGenerator.PercentileBanner( val, stat.Percentil(1), stat.Percentil(10), stat.Percentil(25), stat.Percentil(50), stat.Percentil(75), stat.Percentil(90), stat.Percentil(99), Lib.StaticData.App_Data_Path).Svg() , "image/svg+xml")); } } else { return(Content("", "image/svg+xml")); } }
public KIndexData FullDetail(string ico) { if (string.IsNullOrEmpty(ico)) { throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest, $"Hodnota ico chybí.")); } var kindex = KIndex.Get(ico); if (kindex == null) { throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.NotFound, $"Kindex pro ico [{ico}] nenalezen.")); } return(kindex); }
//todo: What are we going to do with this? public ActionResult Debug(string id, string ico = "", int?rok = null) { if (!Framework.HtmlExtensions.ShowKIndex(this.User)) { return(Redirect("/")); } if ( !(this.User.IsInRole("Admin") || this.User.IsInRole("KIndex")) ) { return(Redirect("/")); } if (string.IsNullOrEmpty(id)) { return(View("Debug.Start")); } if (Util.DataValidators.CheckCZICO(Util.ParseTools.NormalizeIco(id))) { KIndexData kdata = KIndex.Get(Util.ParseTools.NormalizeIco(id)); ViewBag.ICO = id; return(View("Debug", kdata)); } else if (id?.ToLower() == "porovnat") { List <KIndexData> kdata = new List <KIndexData>(); foreach (var i in ico.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries)) { var f = Firmy.Get(Util.ParseTools.NormalizeIco(i)); if (f.Valid) { var kidx = KIndex.Get(Util.ParseTools.NormalizeIco(i)); if (kidx != null) { kdata.Add(kidx); } } } return(View("Debug.Porovnat", kdata)); } else { return(NotFound()); } }
public ActionResult Detail_child(string id, int?rok = null) { if (!Framework.HtmlExtensions.ShowKIndex(this.User) || string.IsNullOrWhiteSpace(id)) { return(Redirect("/")); } if (Util.DataValidators.CheckCZICO(Util.ParseTools.NormalizeIco(id))) { KIndexData kdata = KIndex.Get(Util.ParseTools.NormalizeIco(id)); ViewBag.ICO = id; rok = Consts.FixKindexYear(rok); ViewBag.SelectedYear = rok; return(View(kdata)); } return(View()); }
public JsonResult KindexForIco(string id, int?rok = null) { rok = Consts.FixKindexYear(rok); var f = Firmy.Get(Util.ParseTools.NormalizeIco(id)); if (f.Valid) { var kidx = KIndex.Get(Util.ParseTools.NormalizeIco(id)); if (kidx != null) { var radky = kidx.ForYear(rok.Value).KIndexVypocet.Radky .Select(r => new { VelicinaName = r.VelicinaName, Label = KIndexData.KindexImageIcon(KIndexData.DetailInfo.KIndexLabelForPart(r.VelicinaPart, r.Hodnota), "height: 25px", showNone: true, KIndexData.KIndexCommentForPart(r.VelicinaPart, kidx.ForYear(rok.Value))), Value = r.Hodnota.ToString("F2") }).ToList(); var result = new { UniqueId = Guid.NewGuid(), Ico = kidx.Ico, Jmeno = Devmasters.TextUtil.ShortenText(kidx.Jmeno, 55), Kindex = KIndexData.KindexImageIcon(kidx.ForYear(rok.Value).KIndexLabel, "height: 40px", showNone: true), Radky = radky, KindexReady = kidx.ForYear(rok.Value).KIndexReady }; return(Json(result, JsonRequestBehavior.AllowGet)); } } return(Json(null, JsonRequestBehavior.AllowGet)); }
public ActionResult Banner(string id, int?rok = null) { var kidx = KIndex.Get(id); byte[] data = null; if (kidx != null) { KIndexData.KIndexLabelValues label; Util.InfoFact[] infoFacts; int year; if (rok is null) { label = kidx.LastKIndexLabel(out int?y); year = y.Value; infoFacts = kidx.InfoFacts(); } else { year = Consts.FixKindexYear(rok); label = kidx.ForYear(year)?.KIndexLabel ?? KIndexData.KIndexLabelValues.None; infoFacts = kidx.InfoFacts(year); } KIndexGenerator.IndexLabel img = new KIndexGenerator.IndexLabel(Lib.StaticData.App_Data_Path); data = img.GenerateImageByteArray(kidx.Jmeno, Util.InfoFact.RenderInfoFacts(infoFacts, 3, takeSummary: (label == KIndexData.KIndexLabelValues.None), shuffle: false, " "), label.ToString(), year.ToString()); } return(File(data, "image/png")); }