internal void Load(DataManager data)
{
if (_loaded)
{
return;
}
if (data.Resolver != null)
{
string fullPath = data.ResolvePath(FileName);
string oldPath = data.ResolvePath(DateLocalTime.ToString("yyyy-MM-dd") + ".dayextra.xml");
if (UpgradeFilesToUtc && File.Exists(oldPath))
{
LoadDayExtra(oldPath);
// backup the old file
try
{
DirectoryInfo backup = new DirectoryInfo(Path.Combine(data.ResolvePath(""), "backup"));
if (!backup.Exists)
{
backup.Create();
}
FileInfo f = new FileInfo(oldPath);
f.MoveTo(Path.Combine(backup.FullName, f.Name));
}
catch (Exception e)
{
ErrorTrace.Trace(TraceLevel.Error, e);
}
// now write the new file
this.Save(data);
}
else if (File.Exists(fullPath))
{
LoadDayExtra(fullPath);
}
}
_loaded = true;
}