public override void Run() { StatusLogger.UpdateMessage(StatusMessage); List <PwGroup> touchedGroups = new List <PwGroup>(); List <PwGroup> permanentlyDeletedGroups = new List <PwGroup>(); Android.Util.Log.Debug("KP2A", "Calling PerformDelete.."); PerformDelete(touchedGroups, permanentlyDeletedGroups); _onFinishToRun = new ActionOnFinish(ActiveActivity, (success, message, activity) => { if (success) { foreach (var g in touchedGroups) { Db.Dirty.Add(g); } foreach (var g in permanentlyDeletedGroups) { //remove groups from global lists if present there Db.Dirty.Remove(g); Db.Groups.Remove(g.Uuid); } } else { // Let's not bother recovering from a failure to save. It is too much work. App.LockDatabase(false); } }, OnFinishToRun); // Commit database SaveDb save = new SaveDb(Ctx, App, OnFinishToRun, false); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { //check if we will run into problems. Then finish with error before we start doing anything. foreach (var _elementToMove in _elementsToMove) { PwGroup pgParent = _elementToMove.ParentGroup; if (pgParent != _targetGroup) { if (pgParent != null) { PwGroup group = _elementToMove as PwGroup; if (group != null) { if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group))) { Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere)); return; } } } } } foreach (var elementToMove in _elementsToMove) { _app.GetDb().Dirty.Add(elementToMove.ParentGroup); PwGroup pgParent = elementToMove.ParentGroup; if (pgParent != _targetGroup) { if (pgParent != null) // Remove from parent { PwEntry entry = elementToMove as PwEntry; if (entry != null) { pgParent.Entries.Remove(entry); _targetGroup.AddEntry(entry, true, true); } else { PwGroup group = (PwGroup)elementToMove; if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group))) { Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere)); return; } pgParent.Groups.Remove(group); _targetGroup.AddGroup(group, true, true); } } } } _onFinishToRun = new ActionOnFinish(ActiveActivity, (success, message, activity) => { if (!success) { // Let's not bother recovering from a failure. _app.LockDatabase(false); } }, OnFinishToRun); // Save SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, false); save.SetStatusLogger(StatusLogger); save.Run(); }