protected bool RenameIfNeeded(IItemData serializedItemData, Item targetItem) { if (targetItem.Name.Equals(serializedItemData.Name, StringComparison.Ordinal)) { return(false); } string oldName = targetItem.Name; targetItem.Editing.BeginEdit(); targetItem.RuntimeSettings.ReadOnlyStatistics = true; targetItem.Name = serializedItemData.Name; targetItem.Editing.EndEdit(); ClearCaches(targetItem.Database, targetItem.ID); targetItem.Reload(); if (oldName != serializedItemData.Name) { _logger.RenamedItem(targetItem, oldName); return(true); } return(false); }
protected void RenameIfNeeded(IItemData serializedItemData, Item targetItem) { if (targetItem.Name == serializedItemData.Name && targetItem.BranchId.Guid.Equals(serializedItemData.BranchId)) { return; } string oldName = targetItem.Name; Guid oldBranchId = targetItem.BranchId.Guid; using (new EditContext(targetItem)) { targetItem.RuntimeSettings.ReadOnlyStatistics = true; targetItem.Name = serializedItemData.Name; targetItem.BranchId = ID.Parse(serializedItemData.BranchId); } ClearCaches(targetItem.Database, targetItem.ID); targetItem.Reload(); if (oldName != serializedItemData.Name) { _logger.RenamedItem(targetItem, oldName); } if (oldBranchId != serializedItemData.BranchId) { _logger.ChangedBranchTemplate(targetItem, new ID(oldBranchId).ToString()); } }