private void MainForm_FileOpened(object sender, FileOpenedEventArgs e)
{
try {
var agentModeAgent = agent as Agent;
if (agentModeAgent != null && agentModeAgent.IsLocked) {
// don't do anything if agent is locked
return;
}
if (e.Database.RootGroup == null) {
return;
}
var exitFor = false;
foreach (var entry in e.Database.RootGroup.GetEntries(true)) {
if (exitFor) {
break;
}
if (e.Database.RecycleBinEnabled) {
var recylceBin = e.Database.RootGroup.FindGroup(e.Database.RecycleBinUuid, true);
if (recylceBin != null && entry.IsContainedIn(recylceBin)) {
continue;
}
}
if (entry.Expires && entry.ExpiryTime <= DateTime.Now
&& !e.Database.GetKeeAgentSettings().AllowAutoLoadExpiredEntryKey) {
continue;
}
var settings = entry.GetKeeAgentSettings();
if (settings.AllowUseOfSshKey && settings.AddAtDatabaseOpen) {
try {
AddEntry(entry, null);
} catch (Exception ex) {
if (Options.IgnoreMissingExternalKeyFiles && (ex is FileNotFoundException || ex is DirectoryNotFoundException)) {
continue;
}
if (!MessageService.AskYesNo("Do you want to attempt to load additional keys?")) {
exitFor = true;
}
}
}
}
} catch (Exception ex) {
// can't be crashing KeePass
Debug.Fail(ex.ToString());
}
}