private static void ChangeLocks(string sourcePath, bool isSourceFolder, IFolder target, string newName, LockCollection locks) { string targetPath = target.Href.AbsolutePath.TrimEnd('/') + '/' + newName; if (isSourceFolder) { List <string> toChange = new List <string>(); foreach (KeyValuePair <string, string> pair in locks) { if (pair.Key.StartsWith(sourcePath)) { toChange.Add(pair.Key); } } foreach (string path in toChange) { string token = locks[path]; locks.Remove(path); string newPath = path.Remove(0, sourcePath.Length); newPath = targetPath + '/' + newPath; locks.Add(newPath, token); } } else { string token = locks[sourcePath]; locks.Remove(sourcePath); locks.Add(targetPath, token); } }
public static bool Move(IHierarchyItem item, IFolder target, string newName, bool overwrite, LockCollection locks) { string sourcePath = item.Href.AbsolutePath; bool isSourceFolder = item is IFolder; List <LockUriTokenPair> lockPairs = GetLockPairs(item, locks); try { item.MoveTo(target, newName, overwrite, (lockPairs != null) ? lockPairs.ToArray() : null); ChangeLocks(sourcePath, isSourceFolder, target, newName, locks); return(true); } catch (WebDavException ex) { WebDavHttpException exept = ex as WebDavHttpException; if (exept == null || exept.Multistatus.Responses.Length == 0) { Informator.ShowError(item.DisplayName + ": " + ex.Message); } else { return(false); } return(false); } catch (Exception) { return(false); } }
public static object PutUnderVersionControl(IResource resource, bool enable, LockCollection locks) { try { resource.PutUnderVersionControl(enable, locks[resource]); return(null); } catch (Exception e) { return(e); } }
private static List <LockUriTokenPair> GetLockPairs(IHierarchyItem item, LockCollection locks) { List <LockUriTokenPair> lockPairs = new List <LockUriTokenPair>(); if (locks != null) { lockPairs = new List <LockUriTokenPair>(); foreach (KeyValuePair <string, string> pair in locks) { if (!string.IsNullOrEmpty(pair.Value)) { if (pair.Key.StartsWith(item.Href.AbsolutePath)) { lockPairs.Add( new LockUriTokenPair( new Uri(item.Href.OriginalString + pair.Key.Remove(0, item.Href.AbsolutePath.Length)), pair.Value)); } } } } return(lockPairs); }
public static object SetAutoVersionMode(IResource resource, AutoVersion autoVersionMode, LockCollection locks) { try { resource.SetAutoVersion(autoVersionMode, locks[resource]); return(null); } catch (Exception e) { return(e); } }
public static bool Move(IHierarchyItem item, IFolder target, bool overwrite, LockCollection locks) { return(Move(item, target, item.DisplayName, overwrite, locks)); }
public static object DeleteFolder(IFolder folder, LockCollection locks) { List <LockUriTokenPair> lockPairs = GetLockPairs(folder, locks); return(Delete(folder, lockPairs.ToArray())); }
public static object Delete(IHierarchyItem item, LockCollection locks) { return(Delete(item, locks[item])); }