Exemple #1
0
        public void SaveAndRenameItem(SyncItem renamedItem, string oldName)
        {
            var oldRootPath = renamedItem.ItemPath.Substring(0, renamedItem.ItemPath.LastIndexOf('/') + 1) + oldName;
            var newRootPath = renamedItem.ItemPath;

            var descendantItems = _index.GetDescendants(renamedItem.GetSitecoreId());

            // write the moved sync item to its new destination
            SaveItem(renamedItem);

            MoveDescendants(oldRootPath, newRootPath, renamedItem.DatabaseName, descendantItems);
        }
Exemple #2
0
        public void DeleteItem(SyncItem syncItem)
        {
            Assert.ArgumentNotNull(syncItem, "syncItem");

            var path      = GetPhysicalSyncItemPath(syncItem);
            var directory = PathUtils.StripPath(path);

            using (new WatcherDisabler(_watcher))
            {
                if (File.Exists(path))
                {
                    File.Delete(path);                                    // remove the file
                }
                if (Directory.Exists(directory))
                {
                    Directory.Delete(directory, true);                                              // remove the directory that held child items, if it exists
                }
            }

            _index.ClearIndexes(syncItem.GetSitecoreId());             // remove from indexes
        }
Exemple #3
0
        public void MoveItem(SyncItem syncItem, ID newParent)
        {
            Assert.ArgumentNotNull(syncItem, "syncItem");
            Assert.ArgumentNotNullOrEmpty(newParent, "newParent");

            var newParentItem = _index.GetItem(newParent);

            Assert.IsNotNull(newParentItem, "New parent item {0} did not exist!", newParent);

            var oldRootPath = syncItem.ItemPath;
            var newRootPath = string.Concat(newParentItem.ItemPath, "/", syncItem.Name);

            var descendantItems = _index.GetDescendants(syncItem.GetSitecoreId());

            // update the path and parent IDs to the new location
            syncItem.ParentID = newParent.ToString();
            syncItem.ItemPath = string.Concat(newParentItem.ItemPath, "/", syncItem.Name);

            // write the moved sync item to its new destination
            SaveItem(syncItem);

            MoveDescendants(oldRootPath, newRootPath, syncItem.DatabaseName, descendantItems);
        }
Exemple #4
0
		public void SaveAndRenameItem(SyncItem renamedItem, string oldName)
		{
			var oldRootPath = renamedItem.ItemPath.Substring(0, renamedItem.ItemPath.LastIndexOf('/') + 1) + oldName;
			var newRootPath = renamedItem.ItemPath;

			var descendantItems = _index.GetDescendants(renamedItem.GetSitecoreId());

			// write the moved sync item to its new destination
			SaveItem(renamedItem);

			MoveDescendants(oldRootPath, newRootPath, renamedItem.DatabaseName, descendantItems);
		}
Exemple #5
0
		public void MoveItem(SyncItem syncItem, ID newParent)
		{
			Assert.ArgumentNotNull(syncItem, "syncItem");
			Assert.ArgumentNotNullOrEmpty(newParent, "newParent");

			var newParentItem = _index.GetItem(newParent);

			Assert.IsNotNull(newParentItem, "New parent item {0} did not exist!", newParent);

			var oldRootPath = syncItem.ItemPath;
			var newRootPath = string.Concat(newParentItem.ItemPath, "/", syncItem.Name);

			var descendantItems = _index.GetDescendants(syncItem.GetSitecoreId());

			// update the path and parent IDs to the new location
			syncItem.ParentID = newParent.ToString();
			syncItem.ItemPath = string.Concat(newParentItem.ItemPath, "/", syncItem.Name);

			// write the moved sync item to its new destination
			SaveItem(syncItem);

			MoveDescendants(oldRootPath, newRootPath, syncItem.DatabaseName, descendantItems);
		}
Exemple #6
0
		public void DeleteItem(SyncItem syncItem)
		{
			Assert.ArgumentNotNull(syncItem, "syncItem");

			var path = GetPhysicalSyncItemPath(syncItem);
			var directory = PathUtils.StripPath(path);

			using (new WatcherDisabler(_watcher))
			{
				if (File.Exists(path)) File.Delete(path); // remove the file
				if (Directory.Exists(directory)) Directory.Delete(directory, true); // remove the directory that held child items, if it exists
			}

			_index.ClearIndexes(syncItem.GetSitecoreId()); // remove from indexes
		}