/// <summary> /// Create a Folder Tag of tagname /// </summary> /// <param name="tagname">The name of the Tag to be created</param> /// <param name="lastupdated">The last updated time of the Tag to be created</param> /// <returns>The created Tag, else raise TagAlreadyExistsException</returns> public FolderTag CreateFolderTag(string tagname) { if (!CheckFolderTagExists(tagname)) { long created = DateTime.Now.Ticks; FolderTag tag = new FolderTag(tagname, created); _folderTagList.Add(tag); UpdateTaggingProfileDate(created); return tag; } else { throw new TagAlreadyExistsException(); } }
public bool DeleteTag(FolderTag tag) { FolderTag folderTag = TaggingLayer.Instance.RemoveFolderTag(tag.TagName); if (folderTag != null) { return true; } return false; }
public int UntagFolder(FolderTag tag, DirectoryInfo folder) { string path = ProfilingLayer.Instance.ConvertPhysicalToLogical(folder.FullName, true); return TaggingLayer.Instance.UntagFolder(path, tag.TagName); }
public FolderTag TagFolder(FolderTag tag, DirectoryInfo folder) { return TagFolder(tag.TagName, folder); }
public CompareResult PreviewSync(FolderTag tag) { return null; }
public bool SetTagBidirectional(FolderTag tag) { return false; }
public bool StartManualSync(FolderTag tagname) { return false; }
private bool CheckFolderID(FolderTag tag, string ID) { foreach (TaggedPath path in tag.PathList) { if (path.LogicalDriveId.Equals(ID)) { return true; } } return false; }
private void AddFolderTag(FolderTag tag) { if (!CheckFolderTagExists(tag.TagName)) { _folderTagList.Add(tag); } }
private FolderTag RetrieveFolderTag(string tagname, bool create, long lastupdated) { FolderTag tag = GetFolderTag(tagname); if (tag == null) { if (create) { tag = new FolderTag(tagname, lastupdated); } } return tag; }
private bool CheckRecursiveDirectory(FolderTag folderTag, string path) { foreach (TaggedPath p in folderTag.PathList) { if (p.Path.StartsWith(path) || path.StartsWith(p.Path)) { return true; } } return false; }
private static XmlElement CreateFolderTagElement(XmlDocument TaggingDataDocument, FolderTag folderTag) { XmlElement folderTagElement = TaggingDataDocument.CreateElement("folderTag"); folderTagElement.SetAttribute("name", folderTag.TagName); folderTagElement.SetAttribute("created", folderTag.Created.ToString()); folderTagElement.SetAttribute("lastUpdated", folderTag.LastUpdated.ToString()); foreach (TaggedPath path in folderTag.PathList) { folderTagElement.AppendChild(CreateTaggedFolderElement(TaggingDataDocument, path)); } return folderTagElement; }
private static FolderTag CreateFolderTagFromXml(XmlElement tag) { string tagname = tag.GetAttribute("name"); long created = long.Parse(tag.GetAttribute("created")); long lastupdated = long.Parse(tag.GetAttribute("lastUpdated")); FolderTag folderTag = new FolderTag(tagname, created); folderTag.LastUpdated = lastupdated; XmlNodeList pathList = tag.ChildNodes; foreach (XmlElement path in pathList) { TaggedPath taggedPath = CreatePath(path); folderTag.PathList.Add(taggedPath); } return folderTag; }
/// <summary> /// Tag a folder with a tagname /// </summary> /// <param name="path">The path to be tagged.</param> /// <param name="tagname">The name of the Tag</param> /// <returns>The FolderTag that contains the path, else raise PathAlreadyExistsException</returns> public FolderTag TagFolder(string path, string tagname) { long lastupdated = DateTime.Now.Ticks; Tag tag = FindTag(tagname); if (tag == null) { tag = new FolderTag(tagname, lastupdated); } Debug.Assert(tag != null); if (tag is FileTag) { throw new TagTypeConflictException(); } else { Debug.Assert(tag is FolderTag); if (!tag.Contain(path)) { if (!CheckRecursiveDirectory((FolderTag)tag, path)) { tag.AddPath(path, lastupdated); AddFolderTag((FolderTag)tag); UpdateTaggingProfileDate(lastupdated); return (FolderTag)tag; } else { throw new RecursiveDirectoryException(); } } else { throw new PathAlreadyExistsException(); } } }