Skip to content

Commit

Permalink
Change Time Offset is very slow fix #1769
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Aug 25, 2023
1 parent 6d0746a commit ddf19fd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 371 deletions.
12 changes: 2 additions & 10 deletions Analogy.CommonControls/Managers/PagingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public DataRow AppendMessage(IAnalogyLogMessage message, string dataSource)
try
{
lockSlim.EnterWriteLock();
DataRow dtr = Utils.CreateRow(table, message, dataSource,Settings.TimeOffsetType,Settings.TimeOffset);
DataRow dtr = Utils.CreateRow(table, message, dataSource, Settings.TimeOffsetType, Settings.TimeOffset);
table.Rows.Add(dtr);
return dtr;

Expand Down Expand Up @@ -357,15 +357,7 @@ public void UpdateOffsets()
lockSlim.EnterWriteLock();
foreach (DataTable dataTable in pages)
{
dataTable.BeginLoadData();
foreach (DataRow dataTableRow in dataTable.Rows)
{
dataTableRow.BeginEdit();
AnalogyLogMessage m = (AnalogyLogMessage)dataTableRow[Common.CommonUtils.AnalogyMessageColumn];
dataTableRow["Date"] = Utils.GetOffsetTime(m.Date, Settings.TimeOffsetType, Settings.TimeOffset);
dataTableRow.EndEdit();
}
dataTable.EndLoadData();
Utils.ChangeOffset(dataTable, Settings);
}
lockSlim.ExitWriteLock();
}
Expand Down
8 changes: 1 addition & 7 deletions Analogy.CommonControls/UserControls/LogMessagesUC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,13 +1034,7 @@ private void GridView_ShownEditor(object sender, System.EventArgs e)
private void RefreshTimeOffset()
{
PagingManager.UpdateOffsets();
foreach (DataRow dataTableRow in _bookmarkedMessages.Rows)
{
dataTableRow.BeginEdit();
AnalogyLogMessage m = (AnalogyLogMessage)dataTableRow[Common.CommonUtils.AnalogyMessageColumn];
dataTableRow["Date"] = Utils.GetOffsetTime(m.Date, Settings.TimeOffsetType, Settings.TimeOffset);
dataTableRow.EndEdit();
}
Utils.ChangeOffset(_bookmarkedMessages, Settings);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,7 @@ private void GridView_ShownEditor(object sender, System.EventArgs e)
private void RefreshTimeOffset()
{
PagingManager.UpdateOffsets();
foreach (DataRow dataTableRow in _bookmarkedMessages.Rows)
{
dataTableRow.BeginEdit();
AnalogyLogMessage m = (AnalogyLogMessage)dataTableRow[Common.CommonUtils.AnalogyMessageColumn];
dataTableRow["Date"] = Utils.GetOffsetTime(m.Date, Settings.TimeOffsetType, Settings.TimeOffset);
dataTableRow.EndEdit();
}
Utils.ChangeOffset(_bookmarkedMessages, Settings);
}


Expand Down
15 changes: 15 additions & 0 deletions Analogy.CommonControls/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Analogy.Common.DataTypes;
using Analogy.Common.Interfaces;
using Analogy.CommonControls.DataTypes;
using Analogy.Interfaces;
using Analogy.Interfaces.DataTypes;
Expand Down Expand Up @@ -114,6 +115,20 @@ public static DateTime GetOffsetTime(DateTime time, TimeOffsetType timeOffsetTyp
_ => time
};
}

public static void ChangeOffset(DataTable dataTable, IUserSettingsManager settings)
{
dataTable.BeginLoadData();
foreach (DataRow row in dataTable.Rows)
{
row.BeginEdit();
AnalogyLogMessage m = (AnalogyLogMessage)row[Common.CommonUtils.AnalogyMessageColumn];
row["Date"] = Utils.GetOffsetTime(m.Date, settings.TimeOffsetType, settings.TimeOffset);
row.EndEdit();
row.AcceptChanges();
}
dataTable.EndLoadData();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static DataTable DataTableConstructor()
{
Expand Down
3 changes: 2 additions & 1 deletion Analogy/CommonChangeLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public static class CommonChangeLog
public static IEnumerable<AnalogyChangeLog> GetChangeLog()
{
return new List<AnalogyChangeLog>
{
{
new ("V5.0.0 - Change Time Offset is very slow #1769", AnalogChangeLogType.Bug,"Lior Banai",new DateTime(2023,08,25),"5.0.0.0"),
new ("V5.0.0 - Message viewer doesn't understand Linux-style new lines #1770", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,08,25),"5.0.0.0"),
new ("V5.0.0 - Add Search everywhere checkbox #1812",AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,07,18), "5.0.0.0"),
new ("V5.0.0 - Add NET8 initial Support #1814",AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,07,18), "5.0.0.0"),
Expand Down
Loading

0 comments on commit ddf19fd

Please sign in to comment.