C# C从keepass数据库中删除组
我正在构建一个C插件,一旦通过web验证,它就会创建一个密码组。我的问题是,一旦我在plugins Terminate方法中关闭应用程序,我似乎无法让组删除自己。是否有人遇到过删除KeePass的条目或组的问题?我可以很好地添加它们,并且在我当前的终止方法上没有收到任何错误。这是我到目前为止所拥有的。非常感谢您的帮助,谢谢C# C从keepass数据库中删除组,c#,plugins,C#,Plugins,我正在构建一个C插件,一旦通过web验证,它就会创建一个密码组。我的问题是,一旦我在plugins Terminate方法中关闭应用程序,我似乎无法让组删除自己。是否有人遇到过删除KeePass的条目或组的问题?我可以很好地添加它们,并且在我当前的终止方法上没有收到任何错误。这是我到目前为止所拥有的。非常感谢您的帮助,谢谢 public override void Terminate() { // Remove event handlers for opening a database
public override void Terminate()
{
// Remove event handlers for opening a database
m_host.MainWindow.FileOpened -= OnFileOpened;
PwGroup RootGroup = m_host.Database.RootGroup.FindCreateGroup("Test", false);
foreach(PwGroup group in RootGroup.Groups)
{
RootGroup.Groups.Remove(group);
group.DeleteAllObjects(m_host.Database);
PwDeletedObject pdo = new PwDeletedObject(group.Uuid, DateTime.Now);
m_host.Database.DeletedObjects.Add(pdo);
}
// Update the main window to reflect changes (only update from the root folder)
m_host.MainWindow.UpdateUI(false, null, true, m_host.Database.RootGroup, true, null, true);
}
我认为您缺少一个.MergeIn语句,它应该应用您的删除。至少这对我来说对单个条目有效
private static bool DeleteKeePassEntry(PwDatabase pwDatabase, PwEntry pwEntry)
{
try
{
PwDeletedObject pwDeletedObject = new PwDeletedObject(pwEntry.Uuid, DateTime.Now);
pwDatabase.DeletedObjects.Add(pwDeletedObject);
pwDatabase.MergeIn(pwDatabase, PwMergeMethod.Synchronize);
pwDatabase.Save(new CoutLogger());
}
catch (Exception e)
{
Log.UpdateLog(e.Message);
if (e.InnerException != null)
Log.UpdateLog(e.InnerException.Message);
return Global.ERROR;
}
/* success */
return Global.OK;
}