Exemple #1
0
        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 WebStatusExport Status(string id = null)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest,
                                                                 $"Web nenalezen"
                                                                 ));
            }

            ZabHost host = ZabTools.Weby().Where(w => w.hostid == id.ToString() & w.itemIdResponseTime != null).FirstOrDefault();

            if (host == null)
            {
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest,
                                                                 $"Web nenalezen"
                                                                 ));
            }

            try
            {
                ZabHostAvailability data   = ZabTools.GetHostAvailabilityLong(host);
                ZabHostSslStatus    webssl = ZabTools.SslStatusForHostId(host.hostid);
                var ssldata = new WebStatusExport.SslData()
                {
                    Grade       = webssl?.Status().ToNiceDisplayName(),
                    LatestCheck = webssl?.Time,
                    Copyright   = "(c) © Qualys, Inc. https://www.ssllabs.com/",
                    FullReport  = "https://www.ssllabs.com/ssltest/analyze.html?d=" + webssl?.Host?.UriHost()
                };
                if (webssl == null)
                {
                    ssldata = null;
                }
                return
                    (new WebStatusExport()
                {
                    Availability = data,
                    SSL = ssldata
                });
            }
            catch (Exception e)
            {
                HlidacStatu.Util.Consts.Logger.Error($"_DataHost id ${id}", e);
                throw new HttpResponseException(new ErrorMessage(System.Net.HttpStatusCode.BadRequest,
                                                                 $"Interní chyba při načítání systému."
                                                                 ));
            }
        }
Exemple #3
0
        private ActionResult _DataHost(int id, string h)
        {
            ZabHost host = ZabTools.Weby().Where(w => w.hostid == id.ToString() & w.itemIdResponseTime != null).FirstOrDefault();

            if (host == null)
            {
                return(Json(ApiResponseStatus.StatniWebNotFound, JsonRequestBehavior.AllowGet));
            }

            if (host.ValidHash(h))
            {
                try
                {
                    var data    = ZabTools.GetHostAvailabilityLong(host);
                    var webssl  = ZabTools.SslStatusForHostId(host.hostid);
                    var ssldata = new
                    {
                        grade      = webssl?.Status().ToNiceDisplayName(),
                        time       = webssl?.Time,
                        copyright  = "(c) © Qualys, Inc. https://www.ssllabs.com/",
                        fullreport = "https://www.ssllabs.com/ssltest/analyze.html?d=" + webssl?.Host?.UriHost()
                    };
                    if (webssl == null)
                    {
                        ssldata = null;
                    }
                    return(Content(Newtonsoft.Json.JsonConvert.SerializeObject(
                                       new
                    {
                        availability = data,
                        ssl = ssldata
                    })
                                   , "text/json"));
                }
                catch (Exception e)
                {
                    HlidacStatu.Util.Consts.Logger.Error($"_DataHost id ${id}", e);
                    return(Json(ApiResponseStatus.GeneralExceptionError, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(ApiResponseStatus.StatniWebNotFound, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #4
0
        public ActionResult Info(int id, string h)
        {
            ZabHost host = ZabTools.Weby().Where(w => w.hostid == id.ToString() & w.itemIdResponseTime != null).FirstOrDefault();

            if (host == null)
            {
                return(RedirectToAction("Index", "Weby"));
            }

            if (host.ValidHash(h))
            {
                return(View(host));
            }
            else
            {
                return(RedirectToAction("Index", "Weby"));
            }
        }
Exemple #5
0
        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"));
        }