コード例 #1
0
        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"));
            }
        }
コード例 #2
0
        public ActionResult Backup(string id, int?rok = null)
        {
            if (!Framework.HtmlExtensions.ShowKIndex(this.User) ||
                string.IsNullOrWhiteSpace(id))
            {
                return(Redirect("/"));
            }

            Backup backup = KIndexData.GetPreviousVersion(id);

            rok = Consts.FixKindexYear(rok);
            ViewBag.SelectedYear  = rok;
            ViewBag.BackupCreated = backup.Created.ToString("dd.MM.yyyy");
            ViewBag.BackupComment = backup.Comment;

            return(View(backup.KIndex));
        }
コード例 #3
0
        public ActionResult Porovnat(string id, int?rok = null)
        {
            if (!Framework.HtmlExtensions.ShowKIndex(this.User))
            {
                //todo: přidat base view, kde pokud nebude žádná hodnota v id, tak zobrazíme základní porovnání
                return(Redirect("/"));
            }

            rok = Consts.FixKindexYear(rok);
            ViewBag.SelectedYear = rok;

            var results = new List <SubjectWithKIndexAnnualData>();

            if (string.IsNullOrWhiteSpace(id))
            {
                return(View(results));
            }


            foreach (var i in id.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var f = Firmy.Get(Util.ParseTools.NormalizeIco(i));
                if (f.Valid)
                {
                    SubjectWithKIndexAnnualData data = new SubjectWithKIndexAnnualData()
                    {
                        Ico   = f.ICO,
                        Jmeno = f.Jmeno
                    };
                    try
                    {
                        data.PopulateWithAnnualData(rok.Value);
                    }
                    catch (Exception)
                    {
                        // chybí ičo v objeku data
                        continue;
                    }
                    results.Add(data);
                }
            }


            return(View(results));
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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"));
        }
コード例 #7
0
        public ActionResult Zebricek_child(string id, int?rok = null, string group = null, string kraj = null, string part = null)
        {
            if (!Framework.HtmlExtensions.ShowKIndex(this.User))
            {
                return(Redirect("/"));
            }

            rok = Consts.FixKindexYear(rok);
            ViewBag.SelectedYear   = rok;
            ViewBag.SelectedLadder = id;
            ViewBag.SelectedGroup  = group;
            ViewBag.SelectedKraj   = kraj;

            KIndexData.KIndexParts?selectedPart = null;
            if (Enum.TryParse <KIndexData.KIndexParts>(part, out KIndexData.KIndexParts ePart))
            {
                selectedPart = (KIndexData.KIndexParts)ePart;
            }
            ViewBag.SelectedPart = selectedPart;

            IEnumerable <SubjectWithKIndex> result = null;

            Lib.Data.Firma.Zatrideni.StatniOrganizaceObor oborFromId;
            if (Enum.TryParse <Firma.Zatrideni.StatniOrganizaceObor>(id, true, out oborFromId))
            {
                id = "obor";
            }

            switch (id?.ToLower())
            {
            case "obor":
                if (selectedPart.HasValue)
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListPartsCompanyAsc(selectedPart.Value, Firma.Zatrideni.Subjekty(oborFromId), showNone: true);
                }
                else
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListKIndexCompanyAsc(Firma.Zatrideni.Subjekty(oborFromId), showNone: true);
                }
                ViewBag.LadderTopic = oborFromId.ToNiceDisplayName();
                ViewBag.LadderTitle = oborFromId.ToNiceDisplayName() + " podle K–Indexu";
                break;

            case "nejlepsi":
                if (selectedPart.HasValue)
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListPartsCompanyAsc(selectedPart.Value)
                             .Take(100);
                }
                else
                {
                    result = Statistics.GetStatistics(rok.Value).SubjektOrderedListKIndexCompanyAsc()
                             //.Where(s => s.KIndex > 0)
                             .Take(100);
                }
                ViewBag.LadderTopic = "Top 100 nejlepších subjektů";
                ViewBag.LadderTitle = "Top 100 nejlepších subjektů podle K–Indexu";
                break;

            case "nejhorsi":
                if (selectedPart.HasValue)
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListPartsCompanyAsc(selectedPart.Value)
                             .OrderByDescending(k => k.KIndex)
                             .Take(100);
                }
                else
                {
                    result = Statistics.GetStatistics(rok.Value).SubjektOrderedListKIndexCompanyAsc()
                             .OrderByDescending(k => k.KIndex)
                             .Take(100);
                }
                ViewBag.LadderTopic = "Nejhůře hodnocené úřady a organizace";
                ViewBag.LadderTitle = "Nejhůře hodnocené úřady a organizace podle K–Indexu";
                break;

            case "celkovy":
                if (selectedPart.HasValue)
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListPartsCompanyAsc(selectedPart.Value);
                }
                else
                {
                    result = Statistics.GetStatistics(rok.Value)
                             .SubjektOrderedListKIndexCompanyAsc()
                             .Select(subj => {
                        subj.Kraj = Util.CZ_Nuts.Nace2Kraj(subj.KrajId, "(neznamý)");
                        return(subj);
                    });
                }
                ViewBag.LadderTopic = "Kompletní žebříček úřadů a organizací";
                ViewBag.LadderTitle = "Kompletní žebříček úřadů a organizací podle K–Indexu";
                break;

            case "skokani":
                ViewBag.LadderTitle = "Úřady a organizace, kterým se hodnocení K-Indexu meziročně nejvíce změnilo";
                return(View("Zebricek.Skokani", Statistics.GetJumpersFromBest(rok.Value).Take(200)));

            default:
                return(View("Zebricek.Index"));
            }

            return(View(result));
        }