From 88795b86fd4ce85bc59cdb82a49953f77e686892 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Thu, 18 Apr 2013 21:16:00 +0600 Subject: [PATCH] Updated merge issue, and removed the call to refreshXmlSortOrder since we are already republishing which already writes the updated xml --- .../umbraco/webservices/nodeSorter.asmx.cs | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs index 73b406d713..e79747534f 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/webservices/nodeSorter.asmx.cs @@ -75,6 +75,9 @@ namespace umbraco.presentation.webservices [WebMethod] public void UpdateSortOrder(int ParentId, string SortOrder) { + //TODO: The amount of processing this method takes is HUGE. We should look at + // refactoring this to use purely the new APIs and see how much faster we can make it! + try { if (AuthorizeRequest() == false) return; @@ -90,29 +93,23 @@ namespace umbraco.presentation.webservices for (var i = 0; i < ids.Length; i++) { if (ids[i] == "" || ids[i].Trim() == "") continue; - + if (isContent) { var document = new Document(int.Parse(ids[i])) { sortOrder = i }; - - //TODO: Theoretically we should be calling this too but it will show up as an unpublished - // revision which is not what we want, otherwise we should call Publish() on each node but this - // will be even worse performance! We'll wait till version 6 to fix up. - //document.Save(); - + if (document.Published) { - // update the sort order of the xml in the database - document.refreshXmlSortOrder(); + document.Publish(BusinessLogic.User.GetCurrent()); //TODO: WE don't want to have to republish the entire document !!!! library.UpdateDocumentCache(document); } } - // to update the sortorder of the media node in the XML, re-save the node.... + // to update the sortorder of the media node in the XML, re-save the node.... else if (isMedia) { var media = new cms.businesslogic.media.Media(int.Parse(ids[i])) @@ -120,35 +117,35 @@ namespace umbraco.presentation.webservices sortOrder = i }; media.Save(); - { - new cms.businesslogic.CMSNode(int.Parse(tmp[i])).sortOrder = i; + { + new cms.businesslogic.CMSNode(int.Parse(ids[i])).sortOrder = i; + } } - } - // Refresh sort order on cached xml - if (isContent) - { - XmlNode parentNode = ParentId == -1 - ? content.Instance.XmlContent.DocumentElement - : content.Instance.XmlContent.GetElementById(ParentId.ToString()); + // Refresh sort order on cached xml + if (isContent) + { + XmlNode parentNode = ParentId == -1 + ? content.Instance.XmlContent.DocumentElement + : content.Instance.XmlContent.GetElementById(ParentId.ToString()); - //only try to do the content sort if the the parent node is available... - if (parentNode != null) - content.SortNodes(ref parentNode); + //only try to do the content sort if the the parent node is available... + if (parentNode != null) + content.SortNodes(ref parentNode); - // Load balancing - then refresh entire cache - if (UmbracoSettings.UseDistributedCalls) - library.RefreshContent(); + // Load balancing - then refresh entire cache + if (UmbracoSettings.UseDistributedCalls) + library.RefreshContent(); - // fire actionhandler, check for content - BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance); - } + // fire actionhandler, check for content + BusinessLogic.Actions.Action.RunActionHandlers(new Document(ParentId), ActionSort.Instance); + } + } } catch (Exception ex) { LogHelper.Error("Could not update sort order", ex); } - } }