some fix
This commit is contained in:
parent
54dba1b009
commit
4686902b54
@ -39,20 +39,61 @@ namespace ResoursesManager.Controllers
|
|||||||
{
|
{
|
||||||
Log = db.Statistic.ToList()
|
Log = db.Statistic.ToList()
|
||||||
};
|
};
|
||||||
model.ByType = db.Statistic.Where(k => k.StatisticType == byTypeType /*&& k.DateTime > DateTime.Today.AddDays(-30.0)*/).GroupBy(l => DbFunctions.TruncateTime(l.DateTime)).ToDictionary(j => (DateTime)j.Key, j => j.Count());
|
var today = DateTime.Today.AddDays(-30.0);
|
||||||
model.ByResource = db.Statistic.Where(k => k.ResourceId == byResourceId /*&& k.DateTime > DateTime.Today.AddDays(-30.0)*/).GroupBy(l => l.ResourceId).ToDictionary(j => j.Key, j => j.Count());
|
model.ByType = db.Statistic.Where(k => k.StatisticType == byTypeType && k.DateTime > today).GroupBy(l => DbFunctions.TruncateTime(l.DateTime)).Select(j => new ByType() { Name = (DateTime)j.Key, Value = j.Count() }).ToList();
|
||||||
model.ByTypeCircle = db.Statistic.GroupBy(l => l.StatisticType).ToDictionary(j => j.Key, j => j.Count());
|
model.ByResource = db.Statistic.Where(k => k.ResourceId == byResourceId & k.DateTime > today).GroupBy(l => DbFunctions.TruncateTime(l.DateTime)).Select(j => new ByResource() { Name = (DateTime)j.Key, Value = j.Count() }).ToList();
|
||||||
|
model.ByTypeCircle = db.Statistic.GroupBy(l => l.StatisticType).Select(j => new ByTypeCircle() { Name = ((StatisticType)j.Key).ToString(), Value = j.Count() }).ToList();
|
||||||
var subscibedUser = db.Resources.FirstOrDefault(k => k.Id == subscribeId).Users.Count;
|
var subscibedUser = db.Resources.FirstOrDefault(k => k.Id == subscribeId).Users.Count;
|
||||||
var allUsers = db.Users.Count();
|
var allUsers = db.Users.Count();
|
||||||
model.Subscribe = new Dictionary<string, int>();
|
model.Subscribe = new List<Subscribe>();
|
||||||
model.Subscribe.Add("Subscribed user", subscibedUser);
|
model.Subscribe.Add(new Subscribe() { Name = "Subscribed user", Value = subscibedUser });
|
||||||
model.Subscribe.Add("Unsubscibed user", allUsers - subscibedUser);
|
model.Subscribe.Add(new Subscribe() { Name = "Unsubscibed user", Value = allUsers - subscibedUser });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string getResourceName(int id)
|
||||||
|
{
|
||||||
|
return db.Resources.FirstOrDefault(k => k.Id == id).Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string getStatisticTypeName(StatisticType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case StatisticType.ResourceCreate:
|
||||||
|
return "Create resource";
|
||||||
|
case StatisticType.ResourceModified:
|
||||||
|
return "Modify resource";
|
||||||
|
case StatisticType.ResourceDelete:
|
||||||
|
return "Delete resource";
|
||||||
|
case StatisticType.Reserv:
|
||||||
|
return "Reservation";
|
||||||
|
case StatisticType.ReservartionModified:
|
||||||
|
return "Reservation modify";
|
||||||
|
case StatisticType.ReservationDelete:
|
||||||
|
return "Reservation delete";
|
||||||
|
case StatisticType.Subscribe:
|
||||||
|
return "Subscribe";
|
||||||
|
case StatisticType.Unsubscirbe:
|
||||||
|
return "Unsubscirbe";
|
||||||
|
case StatisticType.SubscribeAll:
|
||||||
|
return "Subscribe all resource";
|
||||||
|
case StatisticType.UnsubscirbeAll:
|
||||||
|
return "Unsubscribe all resource";
|
||||||
|
case StatisticType.Register:
|
||||||
|
return "New registration";
|
||||||
|
case StatisticType.Login:
|
||||||
|
return "Log in";
|
||||||
|
case StatisticType.Logout:
|
||||||
|
return "Log out";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
|
@ -12,10 +12,30 @@ namespace ResoursesManager.ViewModels
|
|||||||
}
|
}
|
||||||
public class StatisticViewModel
|
public class StatisticViewModel
|
||||||
{
|
{
|
||||||
public Dictionary<DateTime,int> ByType { get; set; }
|
public List<ByType> ByType { get; set; }
|
||||||
public Dictionary<int, int> ByResource{ get; set; }
|
public List<ByResource> ByResource { get; set; }
|
||||||
public Dictionary<StatisticType, int> ByTypeCircle { get; set; }
|
public List<ByTypeCircle> ByTypeCircle { get; set; }
|
||||||
public Dictionary<string, int> Subscribe { get; set; }
|
public List<Subscribe> Subscribe { get; set; }
|
||||||
public List<StatisticModel> Log { get; set; }
|
public List<StatisticModel> Log { get; set; }
|
||||||
}
|
}
|
||||||
|
public class ByType
|
||||||
|
{
|
||||||
|
public DateTime Name { get; set; }
|
||||||
|
public int Value { get; set; }
|
||||||
|
}
|
||||||
|
public class ByResource
|
||||||
|
{
|
||||||
|
public DateTime Name { get; set; }
|
||||||
|
public int Value { get; set; }
|
||||||
|
}
|
||||||
|
public class ByTypeCircle
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Value { get; set; }
|
||||||
|
}
|
||||||
|
public class Subscribe
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Value { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
@ -22,101 +22,106 @@
|
|||||||
<script src="~/amcharts/themes/light.js"></script>
|
<script src="~/amcharts/themes/light.js"></script>
|
||||||
<!-- Chart code -->
|
<!-- Chart code -->
|
||||||
<script>
|
<script>
|
||||||
var chart = AmCharts.makeChart( "chartdiv", {
|
var data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "MMM-dd" }));
|
||||||
"type": "serial",
|
|
||||||
"theme": "light",
|
|
||||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType))],
|
|
||||||
"valueAxes": [ {
|
|
||||||
"gridColor": "#FFFFFF",
|
|
||||||
"gridAlpha": 0.2,
|
|
||||||
"dashLength": 0
|
|
||||||
} ],
|
|
||||||
"gridAboveGraphs": true,
|
|
||||||
"startDuration": 1,
|
|
||||||
"graphs": [ {
|
|
||||||
"balloonText": "[[category]]: <b>[[value]]</b>",
|
|
||||||
"fillAlphas": 0.8,
|
|
||||||
"lineAlpha": 0.2,
|
|
||||||
"type": "column",
|
|
||||||
"valueField": "visits"
|
|
||||||
} ],
|
|
||||||
"chartCursor": {
|
|
||||||
"categoryBalloonEnabled": false,
|
|
||||||
"cursorAlpha": 0,
|
|
||||||
"zoomable": false
|
|
||||||
},
|
|
||||||
"categoryField": "country",
|
|
||||||
"categoryAxis": {
|
|
||||||
"gridPosition": "start",
|
|
||||||
"gridAlpha": 0,
|
|
||||||
"tickPosition": "start",
|
|
||||||
"tickLength": 20
|
|
||||||
},
|
|
||||||
"export": {
|
|
||||||
"enabled": false
|
|
||||||
}
|
|
||||||
|
|
||||||
} );
|
var chart = AmCharts.makeChart( "chartdiv", {
|
||||||
|
"type": "serial",
|
||||||
|
"theme": "light",
|
||||||
|
"dataProvider": data,
|
||||||
|
"valueAxes": [ {
|
||||||
|
"gridColor": "#FFFFFF",
|
||||||
|
"gridAlpha": 0.2,
|
||||||
|
"dashLength": 0
|
||||||
|
} ],
|
||||||
|
"gridAboveGraphs": true,
|
||||||
|
"startDuration": 1,
|
||||||
|
"graphs": [ {
|
||||||
|
"balloonText": "[[category]]: <b>[[value]]</b>",
|
||||||
|
"fillAlphas": 0.8,
|
||||||
|
"lineAlpha": 0.2,
|
||||||
|
"type": "column",
|
||||||
|
"valueField": "Value"
|
||||||
|
} ],
|
||||||
|
"chartCursor": {
|
||||||
|
"categoryBalloonEnabled": false,
|
||||||
|
"cursorAlpha": 0,
|
||||||
|
"zoomable": false
|
||||||
|
},
|
||||||
|
"categoryField": "Name",
|
||||||
|
"categoryAxis": {
|
||||||
|
"gridPosition": "start",
|
||||||
|
"gridAlpha": 0,
|
||||||
|
"tickPosition": "start",
|
||||||
|
"tickLength": 20,
|
||||||
|
"labelRotation": 45
|
||||||
|
},
|
||||||
|
"export": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
|
||||||
|
} );
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var chart2 = AmCharts.makeChart( "chartdiv2", {
|
var data2 = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "MMM-dd" }));
|
||||||
"type": "serial",
|
var chart2 = AmCharts.makeChart( "chartdiv2", {
|
||||||
"theme": "light",
|
"type": "serial",
|
||||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource))],
|
"theme": "light",
|
||||||
"valueAxes": [ {
|
"dataProvider": data2,
|
||||||
"gridColor": "#FFFFFF",
|
"valueAxes": [ {
|
||||||
"gridAlpha": 0.2,
|
"gridColor": "#FFFFFF",
|
||||||
"dashLength": 0
|
"gridAlpha": 0.2,
|
||||||
} ],
|
"dashLength": 0
|
||||||
"gridAboveGraphs": true,
|
} ],
|
||||||
"startDuration": 1,
|
"gridAboveGraphs": true,
|
||||||
"graphs": [ {
|
"startDuration": 1,
|
||||||
"balloonText": "[[category]]: <b>[[value]]</b>",
|
"graphs": [ {
|
||||||
"fillAlphas": 0.8,
|
"balloonText": "[[category]]: <b>[[value]]</b>",
|
||||||
"lineAlpha": 0.2,
|
"fillAlphas": 0.8,
|
||||||
"type": "column",
|
"lineAlpha": 0.2,
|
||||||
"valueField": "visits"
|
"type": "column",
|
||||||
} ],
|
"valueField": "Value"
|
||||||
"chartCursor": {
|
} ],
|
||||||
"categoryBalloonEnabled": false,
|
"chartCursor": {
|
||||||
"cursorAlpha": 0,
|
"categoryBalloonEnabled": false,
|
||||||
"zoomable": false
|
"cursorAlpha": 0,
|
||||||
},
|
"zoomable": false
|
||||||
"categoryField": "country",
|
},
|
||||||
"categoryAxis": {
|
"categoryField": "Name",
|
||||||
"gridPosition": "start",
|
"categoryAxis": {
|
||||||
"gridAlpha": 0,
|
"gridPosition": "start",
|
||||||
"tickPosition": "start",
|
"gridAlpha": 0,
|
||||||
"tickLength": 20
|
"tickPosition": "start",
|
||||||
},
|
"tickLength": 20,
|
||||||
"export": {
|
"labelRotation": 45
|
||||||
"enabled": false
|
},
|
||||||
}
|
"export": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var chart3 = AmCharts.makeChart( "chartdiv3", {
|
var chart3 = AmCharts.makeChart( "chartdiv3", {
|
||||||
"type": "pie",
|
"type": "pie",
|
||||||
"theme": "light",
|
"theme": "light",
|
||||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByTypeCircle))],
|
"dataProvider": @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByTypeCircle)),
|
||||||
"valueField": "litres",
|
"valueField": "Value",
|
||||||
"titleField": "country",
|
"titleField": "Name",
|
||||||
"balloon":{
|
"balloon":{
|
||||||
"fixedPosition":true
|
"fixedPosition":true
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var chart4 = AmCharts.makeChart( "chartdiv4", {
|
var chart4 = AmCharts.makeChart( "chartdiv4", {
|
||||||
"type": "pie",
|
"type": "pie",
|
||||||
"theme": "light",
|
"theme": "light",
|
||||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Subscribe))],
|
"dataProvider": @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Subscribe)),
|
||||||
"valueField": "litres",
|
"valueField": "Value",
|
||||||
"titleField": "country",
|
"titleField": "Name",
|
||||||
"balloon":{
|
"balloon":{
|
||||||
"fixedPosition":true
|
"fixedPosition":true
|
||||||
},
|
},
|
||||||
@ -128,15 +133,15 @@ var chart3 = AmCharts.makeChart( "chartdiv3", {
|
|||||||
|
|
||||||
<h2>Statisztika</h2>
|
<h2>Statisztika</h2>
|
||||||
<!-- HTML -->
|
<!-- HTML -->
|
||||||
<h3>Tevékenységek száma erőforrás szerint</h3>
|
<h3>Műveletek száma</h3>
|
||||||
<div id="chartdiv"></div>
|
<div id="chartdiv"></div>
|
||||||
<h3>Erőforrás szerint időben csoportosítva</h3>
|
<h3>Tevékenységek száma </h3>
|
||||||
<div id="chartdiv2"></div>
|
<div id="chartdiv2"></div>
|
||||||
<h3>Tevékenységek aránya</h3>
|
<h3>Tevékenységek aránya</h3>
|
||||||
<div id="chartdiv3"></div>
|
<div id="chartdiv3"></div>
|
||||||
<h3>Felíratkozások aránya</h3>
|
<h3>Felíratkozások aránya</h3>
|
||||||
<div id="chartdiv4"></div>
|
<div id="chartdiv4"></div>
|
||||||
|
|
||||||
<h2>Napló</h2>
|
<h2>Napló</h2>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
@ -157,28 +162,29 @@ var chart3 = AmCharts.makeChart( "chartdiv3", {
|
|||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@foreach (var item in Model.Log) {
|
@foreach (var item in Model.Log)
|
||||||
<tr>
|
{
|
||||||
<td>
|
<tr>
|
||||||
@Html.DisplayFor(modelItem => item.UserId)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => item.UserId)
|
||||||
<td>
|
</td>
|
||||||
@Html.DisplayFor(modelItem => item.ResourceId)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => item.ResourceId)
|
||||||
<td>
|
</td>
|
||||||
@Html.DisplayFor(modelItem => item.ReservationId)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => item.ReservationId)
|
||||||
<td>
|
</td>
|
||||||
@Html.DisplayFor(modelItem => item.StatisticType)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => item.StatisticType)
|
||||||
<td>
|
</td>
|
||||||
@Html.DisplayFor(modelItem => item.DateTime)
|
<td>
|
||||||
</td>
|
@Html.DisplayFor(modelItem => item.DateTime)
|
||||||
</tr>
|
</td>
|
||||||
}
|
</tr>
|
||||||
</table>
|
}
|
||||||
|
</table>
|
||||||
<p>json</p>
|
<p>json</p>
|
||||||
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType)
|
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType)
|
||||||
<p>-</p>
|
<p>-</p>
|
||||||
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource)
|
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource)
|
||||||
<p>-</p>
|
<p>-</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user