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