Example #1
0
        public IActionResult GetOperationsCount(string datefrom, string dateto)
        {
            var layerNameList = GetLayers().Select(o => $"{o.Table_schema}.{o.Table_name}");


            DateTime DateFrom = DateTime.ParseExact(datefrom, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture);
            DateTime DateTo   = DateTime.ParseExact(dateto, "yyyy-MM", System.Globalization.CultureInfo.InvariantCulture).AddMonths(1);

            var logList = _loggerService.GetAllLogByPeriod(DateFrom, DateTo);
            var inserts = logList.Where(o => o.Action == "INSERT" && layerNameList.Contains($"{o.Tableschema}.{o.Tablename}")).Count();
            var updates = logList.Where(o => o.Action == "UPDATE" && layerNameList.Contains($"{o.Tableschema}.{o.Tablename}")).Count();
            var deletes = logList.Where(o => o.Action == "DELETE" && layerNameList.Contains($"{o.Tableschema}.{o.Tablename}")).Count();

            string[] labels = new string[3] {
                $"INSERTS({inserts})", $"UPDATES({updates})", $"DELETES({deletes})"
            };
            int[] dataset = new int[3] {
                inserts, updates, deletes
            };
            string[] colors = new string[3] {
                "rgb(227, 26, 28, 0.5)", "rgb(31, 120, 180, 0.5)", "rgb(255, 177, 0, 0.5)"
            };

            var datefrom_string = DateFrom.ToString("MM.yyyy");
            var dateto_string   = DateTo.ToString("MM.yyyy");

            ViewBag.StatOperations_labels  = JsonConvert.SerializeObject(labels, _jsonSetting);
            ViewBag.StatOperations_dataset = JsonConvert.SerializeObject(dataset, _jsonSetting);
            ViewBag.StatOperations_colors  = JsonConvert.SerializeObject(colors, _jsonSetting);
            ViewBag.Periodstring           = $"{datefrom_string} - {dateto_string}";

            return(PartialView());
        }