public ActionResult Dalsi(string id) { ViewBag.ID = id; if (Devmasters.Core.TextUtil.IsNumeric(id)) { //priorita int iid = Convert.ToInt32(id); if (iid < 1) { return(RedirectToAction("Index", "Weby")); } if (iid > 3) { return(RedirectToAction("Index", "Weby")); } ViewBag.SubTitle = "Další státní weby"; return(View(ZabTools.WebyItems(iid.ToString()))); } else if (id?.ToLower() == "ustredni") { var list = ZabTools.WebyItems(id); if (list == null) { return(RedirectToAction("Index", "Weby")); } if (list.Count() == 0) { return(RedirectToAction("Index", "Weby")); } ViewBag.SubTitle = "Weby ústředních orgánů státní správy"; return(View(list)); } else if (id?.ToLower() == "krajske" && false) { var list = ZabTools.WebyItems(id); if (list == null) { return(RedirectToAction("Index", "Weby")); } if (list.Count() == 0) { return(RedirectToAction("Index", "Weby")); } ViewBag.SubTitle = "Weby a služby krajských úřadů"; return(View(list)); } else { return(RedirectToAction("Index", "Weby")); } }
public ActionResult ChartData(string id, string hh, long?f, long?t, int?h = 24) { id = id?.ToLower() ?? ""; string content = "{}"; DateTime fromDate = DateTime.Now.AddHours(-1 * h.Value); DateTime toDate = DateTime.Now; if (f.HasValue) { fromDate = new DateTime(f.Value); } if (t.HasValue) { toDate = new DateTime(t.Value); } IEnumerable <ZabHostAvailability> data = null; switch (id) { case "index": data = ZabTools.WebyData("0") ?.OrderBy(o => o.Host.publicname) ?.Reverse() ?.ToList(); break; case "1": data = ZabTools.WebyData(ZabTools.WebyItems("1")) ?.OrderBy(o => o.Host.publicname) ?.Reverse() ?.ToList(); break; case "2": data = ZabTools.WebyData(ZabTools.WebyItems("2")) ?.OrderBy(o => o.Host.publicname) ?.Reverse() ?.ToList(); break; case "3": //data = ZabTools.WebyData(ZabTools.WebyItems("3")) // ?.OrderBy(o => o.Host.publicname) // ?.Reverse() // ?.ToList(); break; case "ustredni": data = ZabTools.WebyData(ZabTools.WebyItems("ustredni")) ?.OrderBy(o => o.Host.publicname) ?.Reverse() ?.ToList(); break; case "krajske": break; default: break; } if (id.StartsWith("w")) { id = id.Replace("w", ""); ZabHost host = ZabTools.Weby().Where(w => w.hostid == id.ToString() & w.itemIdResponseTime != null).FirstOrDefault(); if (host != null) { if (host.ValidHash(hh)) { data = new ZabHostAvailability[] { ZabTools.GetHostAvailabilityLong(host) }; } } } if (data != null) { var dataready = new { data = data.AsEnumerable() .Select((x, l) => x.DataForChart(fromDate, toDate, l)) .SelectMany(x => x) .ToArray(), cats = data.ToDictionary(k => k.Host.hostid, d => new { host = d.Host, lastResponse = d.Data.Last() }), categories = data.Select(m => m.Host.hostid).ToArray(), colsize = data.Select(d => d.ColSize(fromDate, toDate)).Max(), }; content = Newtonsoft.Json.JsonConvert.SerializeObject(dataready); } return(Content(content, "application/json")); }