Exemplo n.º 1
0
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Http_Request> addOn = await FetchDataService.getData <Http_Request>(oldStamp, newStamp); // Get data

            foreach (Http_Request h in addOn)
            {
                // When there is start event, create a new Client_Http_Request object and add it to httpTracker
                if (h.type.Equals("Start"))
                {
                    Client_Http_Request clientH = new Client_Http_Request(h);
                    httpTracker[h.activityID] = clientH;
                    http.Add(clientH);
                }
                // When there is a stop event, remove associated http request (by looking at id) from httpTracker,
                // update the Client_Http_Request to include stop event and update http list
                else if (h.type.Equals("Stop"))
                {
                    if (httpTracker.ContainsKey(h.activityID))
                    {
                        Client_Http_Request clientH = httpTracker[h.activityID];
                        http.Remove(clientH);
                        clientH.updateEndTimestamp(h.timestamp);
                        http.Add(clientH);
                    }
                }
            }

            http.OrderBy(h => h.StartTimestamp).ToList(); // Updating http so that is sorted by time
            http.Reverse();                               // Updating http so that the most current http requests are shown first

            totalHttpRequest = http.Count;
            updateAvg();
        }
Exemplo n.º 2
0
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Contention> addOn = await FetchDataService.getUpdatedData <Contention>(oldStamp, newStamp);

            foreach (Contention c in addOn)
            {
                if (c.type.Equals("Start"))
                {
                    Client_Contention clientC = new Client_Contention(c);
                    contentionTracker[c.id] = clientC;
                    contentions.Add(clientC);
                }
                else if (c.type.Equals("Stop"))
                {
                    Client_Contention clientC = contentionTracker[c.id];
                    contentions.Remove(clientC);
                    clientC.updateEndTimestamp(c.timestamp);
                    contentions.Add(clientC);
                }
            }

            contentions.OrderBy(c => c.StartTimestamp).ToList(); // updating http so that is sorted by time
            contentions.Reverse();                               // updating http so that the most current http requests are shown first

            totalContentions = contentions.Count;
            updateAvg();
        }
        public DateTime newStamp = DateTime.Now.ToUniversalTime(); // Gets current time

        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime(); // Updating newStamp

            // Getting cpu and mem data based off of dates (oldStamp and newStamp)
            List <CPU_Usage> cpu_addOn = await FetchDataService.getUpdatedData <CPU_Usage>(oldStamp, newStamp);

            List <Mem_Usage> mem_addOn = await FetchDataService.getUpdatedData <Mem_Usage>(oldStamp, newStamp);

            double totalCPU = avgCPU * timeAccounted; // Weighting previous avgCPU
            double totalMem = avgMem * timeAccounted; // Weighting previous avgMem

            // Updates CPU_Usage list and totalCPU to calculate new average
            foreach (CPU_Usage c in cpu_addOn)
            {
                totalCPU += c.usage;
                cpu.Add(c);
            }

            // Calculating new avgCPUs
            this.timeAccounted += cpu_addOn.Count;
            this.avgCPU         = totalCPU / (double)timeAccounted;

            // Updates Mem_Usage list and totalMem to calculate new average
            foreach (Mem_Usage m in mem_addOn)
            {
                totalMem += m.usage;
                mem.Add(m);
            }

            // Calculating new avgMem
            this.timeAccounted += mem_addOn.Count;
            this.avgMem         = totalMem / (double)timeAccounted;
        }
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();

            // Geting new data
            List <Contention> addOn = await FetchDataService.getData <Contention>(oldStamp, newStamp);

            foreach (Contention c in addOn)
            {
                // When there is start event, create a new Client_Contention object and add it to contentionTracker
                if (c.type.Equals("Start"))
                {
                    Client_Contention clientC = new Client_Contention(c);
                    contentionTracker[c.id] = clientC;
                    contentions.Add(clientC);
                }
                // When there is a stop event, remove associated contention (by looking at id) from contentionTracker,
                // update the Client_Contention to include stop event and update contentions list
                else if (c.type.Equals("Stop"))
                {
                    Client_Contention clientC = contentionTracker[c.id];
                    contentions.Remove(clientC);
                    clientC.updateEndTimestamp(c.timestamp);
                    contentions.Add(clientC);
                }
            }

            contentions.OrderBy(c => c.StartTimestamp).ToList(); // Updating contentions so that is sorted by time
            contentions.Reverse();                               // Updating contentions so that the most current contentions are shown first

            totalContentions = contentions.Count;
            updateAvg();
        }
Exemplo n.º 5
0
        //[Required]
        //[BindProperty]
        //[Display(Name = "userReqNum")]
        //public int userReqNum { get; set; }

        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Exceptions> addOn = await FetchDataService.getData <Exceptions>(oldStamp, newStamp); // Get data

            foreach (Exceptions e in addOn)
            {
                exceptions.Add(e);
                string typeOfException = e.type;

                // If exceptionTracker contains the type of exception, update the value
                if (exceptionTracker.ContainsKey(typeOfException))
                {
                    exceptionTracker[typeOfException] = exceptionTracker[typeOfException] + 1;
                }
                // If exceptionTracker does not contain that type of exception, create a new key value pair
                else
                {
                    exceptionTracker.Add(typeOfException, 1);
                }
            }

            // In order to sort the dictionary, first need to put into list
            exceptionSorted = exceptionTracker.ToList();
            // Ordering list by frequency of exception
            exceptionSorted.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));
            // Reverse list so most frequent exceptions are at the front of the list
            exceptionSorted.Reverse();

            totalExceptions = exceptions.Count; // Update totalExceptions
        }
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Exceptions> addOn = await FetchDataService.getUpdatedData <Exceptions>(oldStamp, newStamp);

            foreach (Exceptions e in addOn)
            {
                exceptions.Add(e);
                string typeOfException = e.type;

                if (exceptionTracker.ContainsKey(typeOfException))
                {
                    exceptionTracker[typeOfException] = exceptionTracker[typeOfException] + 1;
                }
                else
                {
                    exceptionTracker.Add(typeOfException, 1);
                }
            }

            exceptionSorted = exceptionTracker.ToList();
            exceptionSorted.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));

            exceptionSorted.Reverse();

            totalExceptions = exceptions.Count;
        }
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Http_Request> addOn = await FetchDataService.getUpdatedData <Http_Request>(oldStamp, newStamp);

            foreach (Http_Request h in addOn)
            {
                if (h.type.Equals("Start"))
                {
                    Client_Http_Request clientH = new Client_Http_Request(h);
                    httpTracker[h.activityID] = clientH;
                    http.Add(clientH);
                }
                else if (h.type.Equals("Stop"))
                {
                    if (httpTracker.ContainsKey(h.activityID))
                    {
                        Client_Http_Request clientH = httpTracker[h.activityID];
                        http.Remove(clientH);
                        clientH.updateEndTimestamp(h.timestamp);
                        http.Add(clientH);
                    }
                }
            }

            http.OrderBy(h => h.StartTimestamp).ToList(); // updating http so that is sorted by time
            http.Reverse();                               // updating http so that the most current http requests are shown first

            totalHttpRequest = http.Count;
            updateAvg();
        }
Exemplo n.º 8
0
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <DataTransfer.GC> addOn = await FetchDataService.getData <DataTransfer.GC>(oldStamp, newStamp); // Get data

            foreach (DataTransfer.GC g in addOn)
            {
                gc.Add(g);
            }
        }
Exemplo n.º 9
0
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Jit> addOn = await FetchDataService.getData <Jit>(oldStamp, newStamp); // Get data

            foreach (Jit j in addOn)
            {
                jit.Add(j);
            }
        }
Exemplo n.º 10
0
 public StockRegistry()
 {
     // 每天执行一次(这里是在每天的下午 15:40 分执行),可以不用类,直接虚拟方法
     Schedule(() =>
     {
         logger.Info($"定时任务开始运行");
         Task t = FetchDataService.FetchDataAsync();
         Task.WhenAny(t);
         logger.Info($"定时任务结束运行");
     }
              ).ToRunNow().AndEvery(1).Minutes();
 }
Exemplo n.º 11
0
        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime();
            List <Jit> addOn = await FetchDataService.getUpdatedData <Jit>(oldStamp, newStamp);

            foreach (Jit j in addOn)
            {
                jit.Add(j);
            }

            totalJit = jit.Count;
        }
Exemplo n.º 12
0
        public static async Task <string> TemperatureResponse(string dateParam)
        {
            var blobDataTemperature = await FetchDataService.CallBlobAPI(blobURI + "/temperature/" + dateParam + ".csv");

            var outgoingObjAsList = new List <TemperatureObj>();

            var listofTemperatures = blobDataTemperature.Split("\r\n").ToList();

            foreach (var temperature in listofTemperatures)
            {
                if (!string.IsNullOrEmpty(temperature))
                {
                    var            temperatureLine = temperature.Split(";");
                    TemperatureObj outgoingJson    = new TemperatureObj()
                    {
                        PointInTime = temperatureLine[0],
                        Temperature = temperatureLine[1]
                    };
                    outgoingObjAsList.Add(outgoingJson);
                }
            }
            return(JsonSerializer.Serialize(outgoingObjAsList));
        }
Exemplo n.º 13
0
        public static async Task <string> HumidityResponse(string dateParam)
        {
            var blobDataHumidity = await FetchDataService.CallBlobAPI(blobURI + "/humidity/" + dateParam + ".csv");

            var outgoingObjAsList = new List <HumidityObj>();

            var listofHumidities = blobDataHumidity.Split("\r\n").ToList();

            foreach (var humidity in listofHumidities)
            {
                if (!string.IsNullOrEmpty(humidity))
                {
                    var         humidityLine = humidity.Split(";");
                    HumidityObj outgoingJson = new HumidityObj()
                    {
                        PointInTime = humidityLine[0],
                        Humidity    = humidityLine[1]
                    };
                    outgoingObjAsList.Add(outgoingJson);
                }
            }
            return(JsonSerializer.Serialize(outgoingObjAsList));
        }
Exemplo n.º 14
0
        public static async Task <string> RainfallResponse(string dateParam)
        {
            var blobDataRainfall = await FetchDataService.CallBlobAPI(blobURI + "/rainfall/" + dateParam + ".csv");

            var outgoingObjAsList = new List <RainfallObj>();

            var listofRainfalls = blobDataRainfall.Split("\r\n").ToList();

            foreach (var Rainfall in listofRainfalls)
            {
                if (!string.IsNullOrEmpty(Rainfall))
                {
                    var         rainfallLine = Rainfall.Split(";");
                    RainfallObj outgoingJson = new RainfallObj()
                    {
                        PointInTime = rainfallLine[0],
                        Rainfall    = rainfallLine[1]
                    };
                    outgoingObjAsList.Add(outgoingJson);
                }
            }
            return(JsonSerializer.Serialize(outgoingObjAsList));
        }
Exemplo n.º 15
0
 public HomeController()
 {
     _fetchDataService = new FetchDataService();
 }
Exemplo n.º 16
0
        public async Task OnGet() // Method that gets called as page is loaded and refreshed
        {
            sessions = await FetchDataService.getSessionData();

            sortSessionsByApp();
        }
Exemplo n.º 17
0
        public DateTime newStamp; // Represents current time

        public async Task OnGet()
        {
            newStamp = DateTime.Now.ToUniversalTime(); // Updating newStamp

            // Getting cpu and mem data based off of dates (oldStamp and newStamp)
            List <CPU_Usage> cpu_addOn = await FetchDataService.getUpdatedData <CPU_Usage>(oldStamp, newStamp);

            List <Mem_Usage> mem_addOn = await FetchDataService.getUpdatedData <Mem_Usage>(oldStamp, newStamp);

            double totalCPU = avgCPU * timeAccounted; // Weighting previous avgCPU
            double totalMem = avgMem * timeAccounted; // Weighting previous avgMem

            // Updates CPU_Usage list and totalCPU to calculate new average
            foreach (CPU_Usage c in cpu_addOn)
            {
                totalCPU += c.usage;
                cpu.Add(c);
                String dateString = c.timestamp.ToString("yyyyMMddHHmmssFFF");
                if (dataByTime.ContainsKey(dateString))
                {
                    Tuple <CPU_Usage, Mem_Usage> val = dataByTime[dateString];
                    val = new Tuple <CPU_Usage, Mem_Usage>(c, val.Item2);

                    dataByTime.Remove(dateString);
                    dataByTime.Add(dateString, val);
                }
                else
                {
                    Tuple <CPU_Usage, Mem_Usage> val = new Tuple <CPU_Usage, Mem_Usage>(c, null);
                    dataByTime.Add(dateString, val);
                }
            }

            // Updates Mem_Usage list and totalMem to calculate new average
            foreach (Mem_Usage m in mem_addOn)
            {
                totalMem += m.usage;
                mem.Add(m);
                String dateString = m.timestamp.ToString("yyyyMMddHHmmssFFF");
                if (dataByTime.ContainsKey(dateString))
                {
                    Tuple <CPU_Usage, Mem_Usage> val = dataByTime[dateString];
                    val = new Tuple <CPU_Usage, Mem_Usage>(val.Item1, m);

                    dataByTime.Remove(dateString);
                    dataByTime.Add(dateString, val);
                }
                else
                {
                    Tuple <CPU_Usage, Mem_Usage> val = new Tuple <CPU_Usage, Mem_Usage>(null, m);
                    dataByTime.Add(dateString, val);
                }
            }

            // Calculating new avgMem
            this.timeAccounted += mem_addOn.Count;
            this.avgMem         = totalMem / (double)timeAccounted;
            // Calculating new avgCPUs
            this.timeAccounted += cpu_addOn.Count;
            this.avgCPU         = totalCPU / (double)timeAccounted;

            foreach (KeyValuePair <String, Tuple <CPU_Usage, Mem_Usage> > p in dataByTime)
            {
                string   format = "yyyyMMddHHmmssFFF";
                DateTime d      = DateTime.ParseExact(p.Key, format, CultureInfo.InvariantCulture);
                dataByTimeSorted.Add(new KeyValuePair <DateTime, Tuple <CPU_Usage, Mem_Usage> >(d, p.Value));
            }
            dataByTimeSorted.Sort((pair1, pair2) => pair1.Key.CompareTo(pair2.Key));
        }