Replace 'clear all server statistic' function from Flag to Method

将清除统计数据提取成方法
pull/1233/head
Li 4 years ago
parent e6fc9e4783
commit 63411c5978

@ -663,9 +663,9 @@ namespace v2rayN.Forms
private void menuClearStatistic_Click(object sender, EventArgs e)
{
if (statistics != null && statistics.Enable)
if (statistics != null)
{
statistics.ClearStatistic = true;
statistics.ClearAllServerStatistics();
}
}

@ -30,10 +30,6 @@ namespace v2rayN.Handler
get; set;
}
public bool ClearStatistic
{
get; set;
}
public List<ServerStatItem> Statistic
{
@ -65,7 +61,6 @@ namespace v2rayN.Handler
config_ = config;
Enable = config.enableStatistics;
UpdateUI = false;
ClearStatistic = false;
updateFunc_ = update;
exitFlag_ = false;
@ -132,21 +127,6 @@ namespace v2rayN.Handler
serverStatItem.totalUp += up;
serverStatItem.totalDown += down;
if (ClearStatistic)
{
foreach (ServerStatItem item in serverStatistics_.server)
{
item.todayUp = 0;
item.todayDown = 0;
item.totalUp = 0;
item.totalDown = 0;
updateFunc_(up, down, new List<ServerStatItem> { item });
}
ClearStatistic = false;
}
if (UpdateUI)
{
updateFunc_(up, down, new List<ServerStatItem> { serverStatItem });
@ -212,6 +192,25 @@ namespace v2rayN.Handler
}
}
public void ClearAllServerStatistics()
{
if (serverStatistics_ != null)
{
foreach (var item in serverStatistics_.server)
{
item.todayUp = 0;
item.todayDown = 0;
item.totalUp = 0;
item.totalDown = 0;
// update ui display to zero
updateFunc_(0, 0, new List<ServerStatItem> { item });
}
// update statistic json file
SaveToFile();
}
}
private ServerStatItem GetServerStatItem(string itemId)
{
long ticks = DateTime.Now.Date.Ticks;

Loading…
Cancel
Save