some fix
This commit is contained in:
parent
54dba1b009
commit
4686902b54
@ -39,20 +39,61 @@ namespace ResoursesManager.Controllers
|
||||
{
|
||||
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());
|
||||
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.ByTypeCircle = db.Statistic.GroupBy(l => l.StatisticType).ToDictionary(j => j.Key, j => j.Count());
|
||||
var today = DateTime.Today.AddDays(-30.0);
|
||||
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.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 allUsers = db.Users.Count();
|
||||
model.Subscribe = new Dictionary<string, int>();
|
||||
model.Subscribe.Add("Subscribed user", subscibedUser);
|
||||
model.Subscribe.Add("Unsubscibed user", allUsers - subscibedUser);
|
||||
model.Subscribe = new List<Subscribe>();
|
||||
model.Subscribe.Add(new Subscribe() { Name = "Subscribed user", Value = subscibedUser });
|
||||
model.Subscribe.Add(new Subscribe() { Name = "Unsubscibed user", Value = allUsers - subscibedUser });
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
if (disposing)
|
||||
|
@ -12,10 +12,30 @@ namespace ResoursesManager.ViewModels
|
||||
}
|
||||
public class StatisticViewModel
|
||||
{
|
||||
public Dictionary<DateTime,int> ByType { get; set; }
|
||||
public Dictionary<int, int> ByResource{ get; set; }
|
||||
public Dictionary<StatisticType, int> ByTypeCircle { get; set; }
|
||||
public Dictionary<string, int> Subscribe { get; set; }
|
||||
public List<ByType> ByType { get; set; }
|
||||
public List<ByResource> ByResource { get; set; }
|
||||
public List<ByTypeCircle> ByTypeCircle { get; set; }
|
||||
public List<Subscribe> Subscribe { 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>
|
||||
<!-- Chart code -->
|
||||
<script>
|
||||
var chart = AmCharts.makeChart( "chartdiv", {
|
||||
"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 data = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "MMM-dd" }));
|
||||
|
||||
} );
|
||||
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>
|
||||
var chart2 = AmCharts.makeChart( "chartdiv2", {
|
||||
"type": "serial",
|
||||
"theme": "light",
|
||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource))],
|
||||
"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 data2 = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.Converters.IsoDateTimeConverter() { DateTimeFormat = "MMM-dd" }));
|
||||
var chart2 = AmCharts.makeChart( "chartdiv2", {
|
||||
"type": "serial",
|
||||
"theme": "light",
|
||||
"dataProvider": data2,
|
||||
"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>
|
||||
var chart3 = AmCharts.makeChart( "chartdiv3", {
|
||||
"type": "pie",
|
||||
"theme": "light",
|
||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByTypeCircle))],
|
||||
"valueField": "litres",
|
||||
"titleField": "country",
|
||||
"balloon":{
|
||||
"fixedPosition":true
|
||||
},
|
||||
"export": {
|
||||
"enabled": false
|
||||
}
|
||||
} );
|
||||
var chart3 = AmCharts.makeChart( "chartdiv3", {
|
||||
"type": "pie",
|
||||
"theme": "light",
|
||||
"dataProvider": @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByTypeCircle)),
|
||||
"valueField": "Value",
|
||||
"titleField": "Name",
|
||||
"balloon":{
|
||||
"fixedPosition":true
|
||||
},
|
||||
"export": {
|
||||
"enabled": false
|
||||
}
|
||||
} );
|
||||
</script>
|
||||
<script>
|
||||
var chart4 = AmCharts.makeChart( "chartdiv4", {
|
||||
"type": "pie",
|
||||
"theme": "light",
|
||||
"dataProvider": [@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Subscribe))],
|
||||
"valueField": "litres",
|
||||
"titleField": "country",
|
||||
"dataProvider": @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Subscribe)),
|
||||
"valueField": "Value",
|
||||
"titleField": "Name",
|
||||
"balloon":{
|
||||
"fixedPosition":true
|
||||
},
|
||||
@ -128,15 +133,15 @@ var chart3 = AmCharts.makeChart( "chartdiv3", {
|
||||
|
||||
<h2>Statisztika</h2>
|
||||
<!-- HTML -->
|
||||
<h3>Tevékenységek száma erőforrás szerint</h3>
|
||||
<h3>Műveletek száma</h3>
|
||||
<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>
|
||||
<h3>Tevékenységek aránya</h3>
|
||||
<div id="chartdiv3"></div>
|
||||
<h3>Felíratkozások aránya</h3>
|
||||
<div id="chartdiv4"></div>
|
||||
|
||||
|
||||
<h2>Napló</h2>
|
||||
<table class="table">
|
||||
<tr>
|
||||
@ -157,28 +162,29 @@ var chart3 = AmCharts.makeChart( "chartdiv3", {
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model.Log) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.UserId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ResourceId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ReservationId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.StatisticType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateTime)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
@foreach (var item in Model.Log)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.UserId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ResourceId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ReservationId)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.StatisticType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateTime)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<p>json</p>
|
||||
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType)
|
||||
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByType)
|
||||
<p>-</p>
|
||||
@Newtonsoft.Json.JsonConvert.SerializeObject(Model.ByResource)
|
||||
<p>-</p>
|
||||
|
Loading…
Reference in New Issue
Block a user