Skip to content

Commit

Permalink
* "last n stations": fixed logic bug when updating from EDDB files
Browse files Browse the repository at this point in the history
  * switched all "DateTime.Now" to "DateTime.UtcNow",
    import of EDDN messages should work again
  * date filter now also takes the time into account
  * Commander's Log: new context menu for quick filtering by cell content
  • Loading branch information
Duke-Jones committed Dec 28, 2016
1 parent c737c13 commit 00ab27c
Show file tree
Hide file tree
Showing 22 changed files with 151 additions and 106 deletions.
1 change: 1 addition & 0 deletions ED-IBE/ED-IBE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<Compile Include="Enums and Utility Classes\GradientButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Enums and Utility Classes\MessageBoxInvoked.cs" />
<Compile Include="Enums and Utility Classes\Point3Dbl.cs" />
<Compile Include="Enums and Utility Classes\sqlLikeStringExtension.cs" />
<Compile Include="Enums and Utility Classes\TextHelper.cs" />
Expand Down
50 changes: 25 additions & 25 deletions ED-IBE/EDDN/EDDNCommunicator.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ED-IBE/EDDN/EDDNDuplicateFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Boolean DataAccepted(String system, String station, String commodity, Dat
try
{
// truncate milliseconds
sampleDate = sampleDate.Truncate(TimeSpan.FromSeconds(1));
sampleDate = sampleDate.Truncate(TimeSpan.FromSeconds(1)).ToUniversalTime();

if ((sampleDate <= limit1) && (sampleDate >= limit2))
{
Expand Down Expand Up @@ -133,7 +133,7 @@ void m_Releaser_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
try
{
List<DateTime> removeStamps = new List<DateTime>();
DateTime limit = (DateTime.Now - m_ignoringPeriod).Truncate(TimeSpan.FromSeconds(1));
DateTime limit = (DateTime.UtcNow - m_ignoringPeriod).Truncate(TimeSpan.FromSeconds(1));

for (int i = 0; i < m_RecievedDataTimes.Count; i++)
{
Expand Down
18 changes: 9 additions & 9 deletions ED-IBE/Elite Dangerous Specifics/GameSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GameSettings
private AppConfig AppConfigLocal;
private EdDisplayConfig m_Display;
private SQL.DBConnector m_lDBCon;
private DateTime lastTry_Displaydata = DateTime.Now - new TimeSpan(1,0,0);
private DateTime lastTry_Displaydata = DateTime.UtcNow - new TimeSpan(1,0,0);

public GameSettings()
{
Expand Down Expand Up @@ -66,9 +66,9 @@ AppConfig CheckAndRequestVerboseLogging(String fileName, AppConfig configuration
SplashScreenForm.SetTopmost(false);

var setLog =
MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
MessageBoxInvoked.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
"Verbose logging isn't set in your Elite Dangerous AppConfig.xml, so I can't read system names. Would you like me to set it for you?",
"Set verbose logging?", MessageBoxButtons.YesNo);
"Set verbose logging?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

SplashScreenForm.SetTopmost(true);

Expand Down Expand Up @@ -111,16 +111,16 @@ AppConfig CheckAndRequestVerboseLogging(String fileName, AppConfig configuration

SplashScreenForm.SetTopmost(false);

MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
fileName + " updated. You'll need to restart Elite Dangerous if it's already running.");
MessageBoxInvoked.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
fileName + " updated. You'll need to restart Elite Dangerous if it's already running.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);

SplashScreenForm.SetTopmost(true);
}
catch (Exception ex)
{
SplashScreenForm.SetTopmost(false);

MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
MessageBoxInvoked.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
"I can't save the file (no permission). Please set the 'VorboseLogging' manually.", "Can't write", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

SplashScreenForm.SetTopmost(true);
Expand Down Expand Up @@ -224,13 +224,13 @@ void LoadDisplaySettings()
if (m_Display == null)
{
// ignore this if it was loaded short before
delta = DateTime.Now - lastTry_Displaydata;
delta = DateTime.UtcNow - lastTry_Displaydata;
if (delta.TotalMilliseconds > 1000)
{
SplashScreenForm.SetTopmost(false);

// ignore this if it was asked before
MBResult = MessageBox.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
MBResult = MessageBoxInvoked.Show(SplashScreenForm.GetPrimaryGUI(Program.MainForm),
String.Format("Error while loading ED-Displaysettings from file <{0}>", configFile), "Problem while loading data...", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);

SplashScreenForm.SetTopmost(true);
Expand All @@ -239,7 +239,7 @@ void LoadDisplaySettings()
{
CErr.processError(ex, "Error in AppData_Changed()");
}
lastTry_Displaydata = DateTime.Now;
lastTry_Displaydata = DateTime.UtcNow;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public DateTimePicker DtpAfter
/// <param name="oldHeaderCell">The DataGridViewColumnHeaderCell to copy property values from.</param>
public DataGridViewAutoFilterDateTimeColumnHeaderCell(DataGridViewColumnHeaderCell oldHeaderCell) : base(oldHeaderCell)
{
m_dtpBefore.Value = DateTime.Now.Date + new TimeSpan(23,59,59);
m_dtpBefore.Value = DateTime.UtcNow.Date + new TimeSpan(23,59,59);
m_dtpAfter.Value = new DateTime(2000, 1, 1, 0 , 0, 0);

m_dtpBefore.Checked = false;
Expand All @@ -74,7 +74,7 @@ public DataGridViewAutoFilterDateTimeColumnHeaderCell(DataGridViewColumnHeaderCe
/// </summary>
public DataGridViewAutoFilterDateTimeColumnHeaderCell() : base()
{
m_dtpBefore.Value = DateTime.Now.Date + new TimeSpan(23,59,59);
m_dtpBefore.Value = DateTime.UtcNow.Date + new TimeSpan(23,59,59);
m_dtpAfter.Value = new DateTime(2000, 1, 1, 0 , 0, 0);

m_dtpBefore.Checked = false;
Expand Down Expand Up @@ -107,7 +107,7 @@ public override string ColumnFilterString
m_dtpBefore.Checked = false;
}
else
m_dtpBefore.Value = DateTime.Now.Date + new TimeSpan(23,59,59);
m_dtpBefore.Value = DateTime.UtcNow.Date + new TimeSpan(23,59,59);

if(DateTime.TryParse(parts[2], out dtValue))
{
Expand Down
31 changes: 31 additions & 0 deletions ED-IBE/Enums and Utility Classes/MessageBoxInvoked.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Windows.Forms
{
class MessageBoxInvoked
{
public static DialogResult Show(Form parent, string message, string headline, MessageBoxButtons messageBoxButtons, MessageBoxIcon messageBoxIcon, MessageBoxDefaultButton messageBoxDefaultButton = MessageBoxDefaultButton.Button1)
{
if (parent.InvokeRequired)
{
return (DialogResult) parent.Invoke(new Func<DialogResult>(
() => { return MessageBox.Show(parent, message, headline, messageBoxButtons, messageBoxIcon, messageBoxDefaultButton); }));
}
else
{
return MessageBox.Show(parent, message, headline, messageBoxButtons, messageBoxIcon, messageBoxDefaultButton);
}
}
}
class FolderBrowserDialogInvoked
{
public DialogResult ShowDialog(Form primaryGUI)
{
throw new NotImplementedException();
}
}
}
4 changes: 2 additions & 2 deletions ED-IBE/Enums and Utility Classes/SingleThreadLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public SingleThreadLogger(ThreadLoggerType threadLoggerType, String destPath = "
if(reuseLog)
_logPathName = Path.Combine(destPath, string.Format("{0}.log", threadLoggerType));
else
_logPathName = Path.Combine(destPath, string.Format("{0}_{1:yyyy-MM-dd HH-mm-ss}.log", threadLoggerType, DateTime.Now));
_logPathName = Path.Combine(destPath, string.Format("{0}_{1:yyyy-MM-dd HH-mm-ss}.log", threadLoggerType, DateTime.UtcNow));

}

public void Log(string logMessage)
{
File.AppendAllText(_logPathName, string.Format("{0:dd.MM.yyyy HH:mm:ss} : {1}{2}", DateTime.Now, logMessage, Environment.NewLine));
File.AppendAllText(_logPathName, string.Format("{0:dd.MM.yyyy HH:mm:ss} : {1}{2}", DateTime.UtcNow, logMessage, Environment.NewLine));

if(new FileInfo(_logPathName).Length > maxFileSize)
{
Expand Down
6 changes: 3 additions & 3 deletions ED-IBE/Enums and Utility Classes/StationHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ internal void addVisit(string newStation)
if (currentIndex == 0)
{
// refresh time only
History[0].Visited = DateTime.Now;
History[0].Visited = DateTime.UtcNow;
}
else
{
// pull the existingClassification currentComboxItem up and set current time
Visit = History[currentIndex];
History.Remove(Visit);
Visit.Visited = DateTime.Now;
Visit.Visited = DateTime.UtcNow;
History.Insert(0, Visit);
}
}
else
{
History.Insert(0, new StationVisit(newStation, DateTime.Now));
History.Insert(0, new StationVisit(newStation, DateTime.UtcNow));
}

// cut to max. length
Expand Down
6 changes: 3 additions & 3 deletions ED-IBE/FileScanner/EDJournalScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void Stop()

private void FileWatcher_Created(object sender, FileSystemEventArgs e)
{
Debug.Print("get Created Event : " + DateTime.Now);
Debug.Print("get Created Event : " + DateTime.UtcNow);
m_NewFileDetected = true;
}

Expand Down Expand Up @@ -346,7 +346,7 @@ private void JournalScannerWorker()
// add every new file, but only if
// - it's "timevalue" is newer than the "timevalue" of the current file
// - it's last write time is not longer than 24 hours ago
if((GetTimeValueFromFilename(newFile) > GetTimeValueFromFilename(m_LastScan_JournalFile)) && ((DateTime.Now - File.GetLastWriteTime(newFile)).TotalHours < 24))
if((GetTimeValueFromFilename(newFile) > GetTimeValueFromFilename(m_LastScan_JournalFile)) && ((DateTime.UtcNow - File.GetLastWriteTime(newFile)).TotalHours < 24))
{
if(!newFiles.Contains(newFile))
{
Expand Down Expand Up @@ -711,7 +711,7 @@ private void JournalScannerWorker()
// while (!journalStreamReader.EndOfStream)
}
else
Debug.Print("because new files : " + DateTime.Now);
Debug.Print("because new files : " + DateTime.UtcNow);

}while (!m_Stop);

Expand Down
4 changes: 2 additions & 2 deletions ED-IBE/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 00ab27c

Please sign in to comment.