修改监控

This commit is contained in:
zpc 2024-12-02 20:00:24 +08:00
parent 5c2ecf0936
commit d39d798bb5
5 changed files with 95 additions and 3 deletions

View File

@ -26,4 +26,15 @@ public class MonitorController : CloudGamingControllerBase
{
return new MonitorBLL(ServiceProvider).GetAppMonitorInfo();
}
/// <summary>
/// 获取用户登录数据
/// </summary>
/// <param name="startTimeStamp"></param>
/// <param name="endTimeStamp"></param>
/// <returns></returns>
[HttpGet]
public async Task<dynamic> GetActiveUserCount([FromQuery] long startTimeStamp = 0, [FromQuery] long endTimeStamp = 0)
{
return await new MonitorBLL(ServiceProvider).GetActiveUserCount(startTimeStamp, endTimeStamp);
}
}

View File

@ -3,6 +3,7 @@ using CloudGaming.Code.DataAccess.MultiTenantUtil;
using CloudGaming.Code.Filter;
using CloudGaming.Code.Game;
using CloudGaming.Code.Monitor;
using CloudGaming.GameModel.Db.Db_Ext;
using HuanMeng.DotNetCore.CustomExtension;
using HuanMeng.DotNetCore.MiddlewareExtend;
@ -40,6 +41,20 @@ builder.Services.AddSingleton(typeof(ILogger<ExceptionMiddleware>), serviceProvi
return loggerFactory.CreateLogger<ExceptionMiddleware>();
});
#endregion
#region automap
var mapperDomain = AppDomain.CurrentDomain.GetAssemblies().Where(it => it.FullName.Contains("HuanMeng") || it.FullName.Contains("CloudGaming.")).ToList();
Type type = typeof(T_App_Config);
if (type != null)
{
Assembly assembly = Assembly.GetAssembly(type);
if (!mapperDomain.Any(it => it.FullName == assembly.FullName))
{
mapperDomain.Add(assembly);
}
}
builder.Services.AddAutoMapper(mapperDomain);
#endregion
#region
var _myAllowSpecificOrigins = "_myAllowSpecificOrigins";
builder.Services.AddCustomCors(_myAllowSpecificOrigins);

View File

@ -10,7 +10,7 @@
"secret": "95BB717C61D1ECB0E9FB82C932CC77FF",
"nodes": "http://124.220.55.158:94", //使
"url": "http://124.220.55.158:94",
"env": "DEV",
"env": "TEST",
"name": "payClient",
"UserName": "admin",
"Password": "dbt@com@1234"

View File

@ -1,5 +1,7 @@
using CloudGaming.DtoModel.Other;
using Microsoft.Win32;
using System;
using System.Collections;
using System.Collections.Generic;
@ -7,6 +9,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.CreateNewTaxControlFapiaoApplicationRequest.Types.Fapiao.Types;
namespace CloudGaming.Code.Monitor;
/// <summary>
@ -31,7 +35,7 @@ public class MonitorBLL : CloudGamingBase
/// 获取近一月活跃人数统计
/// </summary>
/// <returns></returns>
public async Task GetActiveUserCount(long startTimeStamp = 0, long endTimeStamp = 0)
public async Task<dynamic> GetActiveUserCount(long startTimeStamp = 0, long endTimeStamp = 0)
{
if (endTimeStamp == 0)
{
@ -47,12 +51,50 @@ public class MonitorBLL : CloudGamingBase
DateOnly endDate = DateOnly.FromDateTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(endTimeStamp));
DateOnly curr = startDate;
var userStatisticsList = await Dao.DaoExt.Context.T_Statistics_User.Where(it => it.LoginDate > startDate && it.LoginDate < endDate).ToListAsync();
var channels = userStatisticsList.GroupBy(it => it.Channel).Select(it => it.Key).ToList();
List<StatisticsDto> userLogin = new List<StatisticsDto>();
List<StatisticsDto> userRegistr = new List<StatisticsDto>();
List<StatisticsDto> userActive = new List<StatisticsDto>();
while (curr <= endDate)
{
int day = int.Parse(curr.ToString("yyyyMMdd"));
var _Statistics_Users = userStatisticsList.Where(it => it.LoginDate == curr).OrderBy(it => it.Channel).ToList();
var statisticsDtoUserList = new List<StatisticsDto>();
var statisticsDtoRegistrList = new List<StatisticsDto>();
var statisticsDtoActiveList = new List<StatisticsDto>();
curr.AddDays(1);
var currDateStr = curr.ToString("MM月dd号");
StatisticsDto _UserLogin = new StatisticsDto(currDateStr, 0, "全部");
StatisticsDto _userRegistr = new StatisticsDto(currDateStr, 0, "全部");
StatisticsDto _userActive = new StatisticsDto(currDateStr, 0, "全部");
foreach (var _channel in channels)
{
var item = _Statistics_Users.FirstOrDefault(it => it.Channel == _channel);
if (item == null)
{
item = new T_Statistics_User();
}
_UserLogin.Value += item.LoginCount;
_userRegistr.Value += item.RegistrCount;
_userActive.Value += item.ActiveCount;
//item.ActiveCount
statisticsDtoUserList.Add(new StatisticsDto(currDateStr, item.LoginCount, item.Channel));
statisticsDtoRegistrList.Add(new StatisticsDto(currDateStr, item.RegistrCount, item.Channel));
statisticsDtoActiveList.Add(new StatisticsDto(currDateStr, item.ActiveCount, item.Channel));
}
userLogin.Add(_UserLogin);
userLogin.AddRange(statisticsDtoUserList);
userRegistr.Add(_userRegistr);
userRegistr.AddRange(statisticsDtoRegistrList);
userActive.Add(_userActive);
userActive.AddRange(statisticsDtoActiveList);
curr = curr.AddDays(1);
}
return new { Login = userLogin, Registr = userRegistr, Active = userActive };
}
/// <summary>
@ -72,3 +114,4 @@ public class MonitorBLL : CloudGamingBase
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudGaming.DtoModel.Other;
public class StatisticsDto
{
public string TimeStamp { get; set; }
public int Value { get; set; }
public string Category { get; set; }
public StatisticsDto() { }
public StatisticsDto(string timeStamp, int value, string category)
{
TimeStamp = timeStamp;
Value = value;
Category = category;
}
}