Ejemplo n.º 1
0
        public ActionResult Dashboard()
        {
            HttpClient Client = new HttpClient();

            Client.BaseAddress = new Uri("http://localhost:8089");
            Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


            DateTime            toDay         = DateTime.Now;
            HttpResponseMessage responseToday = Client.GetAsync("Epione-web/rest/analytics/next/3/day/" + toDay.ToString("yyyy-MM-dd")).Result;
            HttpResponseMessage responseDay1  = Client.GetAsync("Epione-web/rest/analytics/next/3/day/" + toDay.AddDays(1).ToString("yyyy-MM-dd")).Result;
            HttpResponseMessage responseDay2  = Client.GetAsync("Epione-web/rest/analytics/next/3/day/" + toDay.AddDays(2).ToString("yyyy-MM-dd")).Result;

            var resultToday = responseToday.Content.ReadAsAsync <IEnumerable <JObject> >().Result;
            var resultDay1  = responseDay1.Content.ReadAsAsync <IEnumerable <JObject> >().Result;
            var resultDay2  = responseDay2.Content.ReadAsAsync <IEnumerable <JObject> >().Result;

            foreach (var r in resultToday)
            {
                double rr = Convert.ToDouble(r.value, new CultureInfo("en-US"));
                ViewBag.vacationToday = rr;
            }
            foreach (var r in resultDay1)
            {
                double rr = Convert.ToDouble(r.value, new CultureInfo("en-US"));
                ViewBag.vacationDay1 = rr;
            }
            foreach (var r in resultDay2)
            {
                double rr = Convert.ToDouble(r.value, new CultureInfo("en-US"));
                ViewBag.vacationDay2 = rr;
            }
            ViewBag.toDay = toDay.ToString("yyyy-MM-dd");
            ViewBag.Day1  = toDay.AddDays(1).ToString("yyyy-MM-dd");
            ViewBag.Day2  = toDay.AddDays(2).ToString("yyyy-MM-dd");


            ViewBag.classSuccess = "success";
            ViewBag.classDanger  = "danger";
            ViewBag.classWarning = "warning";

            HttpResponseMessage responseMostDay = Client.GetAsync("Epione-web/rest/analytics/most/3").Result;
            var resultMostDay = responseMostDay.Content.ReadAsAsync <IEnumerable <JObject> >().Result;


            List <int> numbersOccured = new List <int>();

            foreach (var d in resultMostDay)
            {
                numbersOccured.Add(Convert.ToInt32(d.value));
            }
            List <SplineSeriesData> DataOccured = new List <SplineSeriesData>();


            foreach (double value in numbersOccured)
            {
                SplineSeriesData data = new SplineSeriesData();
                data.Y = value;
                if (value == 26.5)
                {
                    data.Marker.Symbol = "url(http://www.highcharts.com/demo/gfx/sun.png)";
                }
                data.Drilldown = "time";
                DataOccured.Add(data);
            }

            ViewData["numbersOccured"] = DataOccured;

            DateTime date        = new DateTime();
            var      resultTimes = Enumerable.Repeat(date, 24)
                                   .Select((x, i) => x.AddHours(i).ToString("HH:tt"));

            ViewBag.listTimes = resultTimes;

            HttpResponseMessage responseNextPatient = Client.GetAsync("Epione-web/rest/analytics/next5Patient/3").Result;
            var resultNextPatient = responseNextPatient.Content.ReadAsAsync <IEnumerable <JObjectPatient> >().Result;

            ViewBag.resultNextPatient = resultNextPatient;

            return(View());
        }
Ejemplo n.º 2
0
        // GET: hasils/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            hasil hasil = db.hasils.Find(id);

            TempData["id_perusahaan"] = db.hasils.Find(id).id_perusahaan;
            if (hasil == null)
            {
                return(HttpNotFound());
            }

            //string nama_perusahaan = db.perusahaans.Find(id).nama_perusahaan;


            var IDPerusahaan = db.hasils.Find(id).id_perusahaan;

            var selectedHasil = (from hasil_ in db.hasils
                                 join perusahaan in db.perusahaans on hasil_.id_perusahaan equals perusahaan.IDPerusahaan
                                 join tahun in db.tahuns on hasil_.id_tahun equals tahun.IDTahun
                                 where hasil_.id_perusahaan == IDPerusahaan
                                 select new { hasil_.IDHasil, perusahaan.nama_perusahaan, tahun.tahun1, hasil_.target_2, tahun.IDTahun })
                                .OrderByDescending(x => x.IDTahun).Take(5);

            string nama_perusahaan = "PT Nama Perusahaan";

            string[] KodeTahun   = new string[5];
            double[] NilaiTarget = new double[5];
            int      i           = 4;

            foreach (var temp in selectedHasil)
            {
                nama_perusahaan = temp.nama_perusahaan;
                KodeTahun[i]    = temp.tahun1.ToString();
                NilaiTarget[i]  = Math.Round((double)temp.target_2 * 100, 0);
                i--;
            }

            List <string> KodeTahunValues  = KodeTahun.ToList();
            List <double> TargetValues     = NilaiTarget.ToList();
            List <double> BatasKurangSehat = new List <double> {
                70, 70, 70, 70, 70
            };
            List <double> BatasTidakSehat = new List <double> {
                40, 40, 40, 40, 40
            };

            List <SplineSeriesData> TargetData      = new List <SplineSeriesData>();
            List <SplineSeriesData> DataKurangSehat = new List <SplineSeriesData>();
            List <SplineSeriesData> DataTidakSehat  = new List <SplineSeriesData>();


            foreach (double value in TargetValues)
            {
                SplineSeriesData data = new SplineSeriesData();
                data.Y = value;
                //if (value == 86)
                //{
                //    data.Marker.Symbol = "url(http://www.highcharts.com/demo/gfx/sun.png)";
                //    //kasi warna
                //}

                TargetData.Add(data);
            }

            foreach (double value in BatasKurangSehat)
            {
                SplineSeriesData data = new SplineSeriesData();
                data.Y = value;

                DataKurangSehat.Add(data);
            }

            foreach (double value in BatasTidakSehat)
            {
                SplineSeriesData data = new SplineSeriesData();
                data.Y = value;

                DataTidakSehat.Add(data);
            }

            ViewData["Tahun"]           = KodeTahunValues;
            ViewData["TargetData"]      = TargetData;
            ViewData["DataKurangSehat"] = DataKurangSehat;
            ViewData["DataTidakSehat"]  = DataTidakSehat;
            ViewData["NamaPerusahaan"]  = nama_perusahaan;//db.hasils.Find(IDPerusahaan).nama_perusahaan;

            return(View(hasil));
        }