Exemplo n.º 1
0
 public bool AddPath(string path, long created)
 {
     if (!Contain(path))
     {
         TaggedPath taggedPath = new TaggedPath();
         taggedPath.Path = path;
         taggedPath.LogicalDriveId = GetLogicalID(path);
         taggedPath.Created = created;
         taggedPath.LastUpdated = created;
         _lastupdated = created;
         _pathList.Add(taggedPath);
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Remove a Tag Path ( Notify from Merging )
 /// </summary>
 /// <param name="tag">Tag that the path was removed from</param>
 /// <param name="path">Path that is added</param>
 internal void RemoveTagPath(Tag tag, TaggedPath path)
 {
     //At the moment nothing needs to be done , just switch the tag to manual and back to seamless will do.
     if (tag.IsSeamless)
     {
         SwitchMode(tag.TagName, TagMode.Manual);
         SwitchMode(tag.TagName, TagMode.Seamless);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new tagged path with a full path name and created date that are passed as 
 /// parameters and adds to the list of tagged paths
 /// </summary>
 /// <param name="path">The string value that represents the full path name of the new tagged 
 /// path</param>
 /// <param name="created">The long value that represents the created date of the new tagged path</param>
 private void CreateNewPath(string path, long created)
 {
     TaggedPath taggedPath = new TaggedPath(path, created);
     _lastUpdatedDate = TaggingHelper.GetCurrentTime();
     _pathList.Add(taggedPath);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sets the boolean value that represents whether the tagged path is deleted to true
 /// </summary>
 /// <param name="path">The TaggedPath object to be set as deleted</param>
 /// <returns>true if some tagged paths are set as deleted; otherwise, false</returns>
 public bool RemovePath(TaggedPath path)
 {
     TaggedPath p = FindPath(path.PathName, false);
     if ((p != null) && (!p.IsDeleted))
     {
         long lastupdated = TaggingHelper.GetCurrentTime();
         p.Remove(lastupdated);
         _lastUpdatedDate = lastupdated;
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a tagged path to the list of tagged paths
 /// </summary>
 /// <param name="path">The TaggedPath object that represents the tagged path to be added</param>
 private void AddNewPath(TaggedPath path)
 {
     _pathList.Add(path);
     _lastUpdatedDate = TaggingHelper.GetCurrentTime();
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds the tagged path to the tag
 /// </summary>
 /// <param name="path">The TaggedPath object that is to be added to the tag</param>
 /// <returns>true if the tagged path is added to the tag; otherwise, false</returns>
 /// <remarks>If there already exists a tagged path whose full path name is the same as that of 
 /// the tagged path that is passed as parameter, if the boolean value that represents whether 
 /// the tagged path is deleted is true, the existing tagged path will be removed from the 
 /// list of tagged paths. The tagged path that is passed as parameter will be added to the list of 
 /// tagged paths.</remarks>
 public bool AddPath(TaggedPath path)
 {
     TaggedPath p = FindPath(path.PathName, false);
     if (p != null)
     {
         if (p.IsDeleted)
         {
             _pathList.Remove(p);
             AddNewPath(path);
             return true;
         }
         else
         {
             return false;
         }
     }
     else
     {
         AddNewPath(path);
         return true;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Sets part of the full path name, contained by one or more of the tagged paths in the list 
 /// of tagged paths, represented by the old path that is passed as parameter to the new path 
 /// that is passed as parameter
 /// </summary>
 /// <param name="oldPath">The string value that represents the old path which is part of the 
 /// full path name of the tagged path</param>
 /// <param name="newPath">The string value that represents the new path which is to replace
 /// part of the full path name of the tagged path represented by the old path that is 
 /// passed as parameter</param>
 /// <param name="updated">The long value that represents the updated date of the tag and the
 /// tagged path whose full path name is renamed</param>
 /// <returns>The number of tagged paths whose full path name represented by the old path is
 /// replaced by the new path</returns>
 /// <remarks>If the old path that is passed as parameter is not the full path name but part of 
 /// the full path name, only the matching part of the path name will be replaced with the
 /// new path that is passed as parameter</remarks>
 public int RenamePath(string oldPath, string newPath, long updated)
 {
     List<TaggedPath> newTaggedPathList = new List<TaggedPath>();
     foreach (TaggedPath p in FilteredPathList)
     {
         if (PathHelper.StartsWithIgnoreCase(p.PathName, oldPath))
         {
             p.Remove(updated);
             string combinedPath = p.PathName.Replace(oldPath, newPath);
             TaggedPath newTaggedPath = new TaggedPath(combinedPath, updated);
             if (!newTaggedPathList.Contains(newTaggedPath))
             {
                 newTaggedPathList.Add(newTaggedPath);
             }
         }
     }
     UpdateTaggedPathList(newTaggedPathList, updated);
     return newTaggedPathList.Count;
 }
Exemplo n.º 8
0
 private void TestRemovePathObject(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     TaggedPath taggedpath = new TaggedPath(path, DateTime.Now.Ticks);
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string success = tag.RemovePath(taggedpath).ToString();
         TaggedPath removedpath = tag.FindPath(path, false);
         string isdeleted = removedpath.IsDeleted.ToString();
         testcase.Actual = string.Format("{0}, {1}", success, isdeleted);
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemplo n.º 9
0
 private void TestAddPathObject(TestCase testcase)
 {
     string[] parameters = testcase.Parameters.Split(',');
     string tagname = parameters[0].Trim();
     string path = parameters[1].Trim();
     TaggedPath taggedpath = new TaggedPath(path, DateTime.Now.Ticks);
     Tag tag = FindTag(tagname);
     if (tag != null)
     {
         string success = tag.AddPath(taggedpath).ToString();
         testcase.Actual = success;
         testcase.Passed = (testcase.Expected.Equals(testcase.Actual));
     }
     else
     {
         testcase.Actual = "Invalid parameters";
         testcase.Passed = false;
     }
 }
Exemplo n.º 10
0
 private static XmlElement CreatedTaggedFileElement(XmlDocument TaggingDataDocument, TaggedPath path)
 {
     XmlElement taggedFileElement = TaggingDataDocument.CreateElement("taggedFile");
     taggedFileElement.SetAttribute("created", path.Created.ToString());
     taggedFileElement.SetAttribute("lastUpdated", path.LastUpdated.ToString());
     XmlElement filePathElement = TaggingDataDocument.CreateElement("path");
     filePathElement.InnerText = path.Path;
     taggedFileElement.AppendChild(filePathElement);
     return taggedFileElement;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initialize UnMonitorPathNotification
 /// </summary>
 /// <param name="tag">the related <see cref="Tag"/></param>
 /// <param name="path">the related <see cref="TaggedPath"/></param>
 public UnMonitorPathNotification(Tag tag, TaggedPath path):base("UnMonitor Path Notification" , NotificationCode.UnmonitorPathNotification)
 {
     TargetTag = tag;
     _targetPath = path;
 }
Exemplo n.º 12
0
 private static TaggedPath CreateTaggedPath(long pathcreated, long pathlastupdated, string pathname)
 {
     TaggedPath taggedPath = new TaggedPath();
     taggedPath.Path = pathname;
     taggedPath.Created = pathcreated;
     taggedPath.LastUpdated = pathlastupdated;
     taggedPath.LogicalDriveId = pathname.Split('\\')[0].TrimEnd(':');
     return taggedPath;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Creates a tagged path Xml element from the tagged path that is passed as parameter
 /// </summary>
 /// <param name="xmlDoc">The Xmldocument object that represents the Xml document that the
 /// Xml element to be created belongs to</param>
 /// <param name="path">The <see cref="TaggedPath">TaggedPath</see> object that
 /// represents the tagged path to be used to create the Xml element</param>
 /// <returns>the tagged path Xml element that is created</returns>
 private static XmlElement CreateTaggedFolderElement(XmlDocument xmlDoc, TaggedPath path)
 {
     XmlElement taggedFolderElement = xmlDoc.CreateElement(ELE_TAGGED_FOLDER_ROOT);
     taggedFolderElement.SetAttribute(ATTR_TAGGED_FOLDER_CREATEDDATE, path.CreatedDate.ToString());
     taggedFolderElement.SetAttribute(ATTR_TAGGED_FOLDER_LASTUPDATEDDATE, path.LastUpdatedDate.ToString());
     taggedFolderElement.SetAttribute(ATTR_TAGGED_FOLDER_ISDELETED, path.IsDeleted.ToString());
     taggedFolderElement.SetAttribute(ATTR_TAGGED_FOLDER_DELETEDDATE, path.DeletedDate.ToString());
     XmlElement folderPathElement = xmlDoc.CreateElement(ELE_TAGGED_FOLDER_PATH);
     folderPathElement.InnerText = path.PathName;
     taggedFolderElement.AppendChild(folderPathElement);
     return taggedFolderElement;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a tagged path from the created date, last updated date, path name, is deleted and deleted
 /// date attributes that are passed as parameters
 /// </summary>
 /// <param name="pathcreated">The long value that represents the created date of the tagged path</param>
 /// <param name="pathlastupdated">The long value that represents the last updated date of 
 /// the tagged path</param>
 /// <param name="pathname">The string value that represents the full path name of the 
 /// tagged path</param>
 /// <param name="isDeleted">The boolean value that represents whether the tagged path is deleted</param>
 /// <param name="deletedDate">The long value that represents the deleted date of the tagged path</param>
 /// <returns>the tagged path that is created</returns>
 private static TaggedPath CreateTaggedPath(long pathcreated, long pathlastupdated, string pathname, bool isDeleted, long deletedDate)
 {
     TaggedPath taggedPath = new TaggedPath(pathname, pathcreated);
     taggedPath.LastUpdatedDate = pathlastupdated;
     taggedPath.LogicalDriveId = TaggingHelper.GetLogicalID(pathname);
     taggedPath.IsDeleted = isDeleted;
     taggedPath.DeletedDate = deletedDate;
     return taggedPath;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a monitor path notification
 /// </summary>
 /// <param name="tag">The <see cref="Tag">Tag</see> object that represents the tag</param>
 /// <param name="path">The string value that represents the path that is monitored</param>
 /// <returns>the <see cref="MonitorPathNotification">MonitorPathNotification</see> object</returns>
 public static AbstractNotification CreateMonitorPathNotification(Tag tag, TaggedPath path)
 {
     return new MonitorPathNotification(tag, path);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Initalize the MonitorPathNotificaiton
 /// </summary>
 /// <param name="tag">The target <see cref="Tag"/></param>
 /// <param name="path">The target <see cref="TaggedPath"/></param>
 public MonitorPathNotification(Tag tag, TaggedPath path):base("Monitor Path Notification" , Syncless.Notification.NotificationCode.MonitorPathNotification)
 {
     TargetTag = tag;
     TargetPath = path;
 }