private void backgroundWorkerMigrate_DoWork(object sender, DoWorkEventArgs e) { PwUuid RecycleBinUuid = this.host.Database.RecycleBinUuid; List <PwEntry> entries = new List <PwEntry>(); entries = this.host.MainWindow.ActiveDatabase.RootGroup.GetEntries(true).ToList(); int count = entries.Count; int counter = 0; int succeeded = 0; labelStatus.Text = String.Format(KeeOtp2Statics.SettingsLoadedNEntries, count); foreach (PwEntry entry in entries) { if (entry.ParentGroup.Uuid != RecycleBinUuid) { if (checkEntryMigratable(entry, currentMigrationProfile.migrationMode)) { OtpAuthData data = OtpAuthUtils.loadData(entry); if (data != null) { entry.CreateBackup(this.host.Database); switch (currentMigrationProfile.migrationMode) { case MigrationMode.KeeOtp1ToBuiltIn: if (!data.isForcedKeeOtp1Mode()) { OtpAuthUtils.migrateToBuiltInOtp(data, entry); if (OtpAuthUtils.loadDataFromKeeOtp1String(entry) != null) { if (removeAfterMigration) { OtpAuthUtils.purgeLoadedFields(data, entry); } } } else { encounteredForcedKeeOtp1Entries = true; } break; case MigrationMode.BuiltInToKeeOtp1: OtpAuthUtils.migrateToKeeOtp1String(data, entry); if (OtpAuthUtils.loadDataFromKeeOtp1String(entry) != null) { if (removeAfterMigration) { OtpAuthUtils.purgeLoadedFields(data, entry); } } break; default: break; } if (migrateAutoType) { foreach (string currentPlaceholder in currentMigrationProfile.findPlaceholder.Values) { OtpAuthUtils.replacePlaceholder(entry, currentPlaceholder, currentMigrationProfile.replacePlaceholder[data.Type]); } } entry.Touch(true); succeeded++; } else { this.Invoke((Action)(() => { if (MessageBox.Show(String.Format(KeeOtp2Statics.MessageBoxCantParseEntry, entry.ParentGroup.Name, entry.Strings.ReadSafe(PwDefs.TitleField), entry.Strings.ReadSafe(PwDefs.UserNameField)), KeeOtp2Statics.Migration, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { backgroundWorkerMigrate.CancelAsync(); } })); } } } counter++; labelStatus.Text = String.Format(KeeOtp2Statics.SettingsDoneNofNEntries, counter, count); } if (succeeded > 0) { this.host.MainWindow.ActiveDatabase.Modified = true; this.host.MainWindow.UpdateUI(false, null, false, null, false, null, true); } }