static public void Preload() { try { EmpiriaLog.Info($"Application preloading starts at {DateTime.Now}."); StandardAccount.Preload(); AccountsChart.Preload(); SubsidiaryLedger.Preload(); SubsidiaryAccount.Preload(); EmpiriaLog.Info($"Application preloading ends at {DateTime.Now}."); } catch (Exception e) { EmpiriaLog.Error(e); } }
internal ProjectItem ChangeParentAndPosition(ProjectItem item, ProjectItem newParent, int newPosition) { EmpiriaLog.Debug($"ChangeParent of {item.Name} to new parent {newParent.Name}"); if (item.Equals(newParent)) { EmpiriaLog.Info($"Trying to change the parent of a tree item to itself {item.Name} ({item.UID})."); return(item); } var branchToMove = this.GetBranch(item); Assertion.Require(!branchToMove.Contains(newParent), $"Can't change the parent of '{item.Name}' because it is a branch " + $"and '{newParent.Name}' is one of its children."); // Then remove the whole branch an reinsert it in the new position foreach (var branchItem in branchToMove) { ItemsList.Remove(branchItem); } item.SetParentAndPosition(newParent, newPosition); int insertionIndex = newPosition - 1; // insertionIndex is zero-based foreach (var branchItem in branchToMove) { ItemsList.Insert(insertionIndex, branchItem); insertionIndex++; } this.RefreshPositions(); EmpiriaLog.Info($"ChangeParentAndPosition of {item.Name} to {newParent.Name} at position {newParent.Position + 1}."); return(item); }
internal ProjectItem ChangeParentKeepingPosition(ProjectItem item, ProjectItem newParent) { EmpiriaLog.Debug($"ChangeParent of {item.Name} to new parent {newParent.Name} keeping current position."); if (item.Equals(newParent)) { EmpiriaLog.Info($"Trying to change the parent of a tree item to itself {item.Name} ({item.UID})."); return(item); } var branchToMove = this.GetBranch(item); Assertion.Require(!branchToMove.Contains(newParent), $"Can't change the parent of '{item.Name}' because it is a branch " + $"and '{newParent.Name}' is one of its children."); item.SetParent(newParent); item.Save(); return(item); }