2dust 1 day ago
parent
commit
80f840a7c2
  1. 14
      v2rayN/ServiceLib/Handler/ConfigHandler.cs
  2. 19
      v2rayN/ServiceLib/Handler/StatisticsHandler.cs

14
v2rayN/ServiceLib/Handler/ConfigHandler.cs

@ -1296,6 +1296,20 @@ namespace ServiceLib.Handler
}
}
//Keep the last traffic statistics
if (lstOriSub != null)
{
var lstSub = await AppHandler.Instance.ProfileItems(subid);
foreach (var item in lstSub)
{
var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true));
if (existItem != null)
{
await StatisticsHandler.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId);
}
}
}
return counter;
}

19
v2rayN/ServiceLib/Handler/StatisticsHandler.cs

@ -65,6 +65,25 @@
}
}
public async Task CloneServerStatItem(string indexId, string toIndexId)
{
if (_lstServerStat == null)
{
return;
}
var stat = _lstServerStat.FirstOrDefault(t => t.IndexId == indexId);
if (stat == null)
{
return;
}
var toStat = JsonUtils.DeepCopy(stat);
toStat.IndexId = toIndexId;
await SQLiteHelper.Instance.ReplaceAsync(toStat);
_lstServerStat.Add(toStat);
}
private async Task InitData()
{
await SQLiteHelper.Instance.ExecuteAsync($"delete from ServerStatItem where indexId not in ( select indexId from ProfileItem )");

Loading…
Cancel
Save