Beispiel #1
0
 /// <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();
     }
 }
Beispiel #2
0
 public bool DeleteTag(FolderTag tag)
 {
     FolderTag folderTag =  TaggingLayer.Instance.RemoveFolderTag(tag.TagName);
     if (folderTag != null)
     {
         return true;
     }
     return false;
 }
Beispiel #3
0
 public int UntagFolder(FolderTag tag, DirectoryInfo folder)
 {
     string path = ProfilingLayer.Instance.ConvertPhysicalToLogical(folder.FullName, true);
     return TaggingLayer.Instance.UntagFolder(path, tag.TagName);
 }
Beispiel #4
0
 public FolderTag TagFolder(FolderTag tag, DirectoryInfo folder)
 {
     return TagFolder(tag.TagName, folder);
 }
Beispiel #5
0
 public CompareResult PreviewSync(FolderTag tag)
 {
     return null;
 }
Beispiel #6
0
 public bool SetTagBidirectional(FolderTag tag)
 {
     return false;
 }
Beispiel #7
0
 public bool StartManualSync(FolderTag tagname)
 {
     return false;
 }
Beispiel #8
0
 private bool CheckFolderID(FolderTag tag, string ID)
 {
     foreach (TaggedPath path in tag.PathList)
     {
         if (path.LogicalDriveId.Equals(ID))
         {
             return true;
         }
     }
     return false;
 }
Beispiel #9
0
 private void AddFolderTag(FolderTag tag)
 {
     if (!CheckFolderTagExists(tag.TagName))
     {
         _folderTagList.Add(tag);
     }
 }
Beispiel #10
0
 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;
 }
Beispiel #11
0
 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;
 }
Beispiel #12
0
 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;
 }
Beispiel #13
0
 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;
 }
Beispiel #14
0
 /// <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();
         }
     }
 }