コード例 #1
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 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;
 }
コード例 #2
0
ファイル: SystemLogicLayer.cs プロジェクト: sr3dna/big5sync
 /// <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);
     }
 }
コード例 #3
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 /// <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);
 }
コード例 #4
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 /// <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;
     }
 }
コード例 #5
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 /// <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();
 }
コード例 #6
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 /// <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;
     }
 }
コード例 #7
0
ファイル: Tag.cs プロジェクト: sr3dna/big5sync
 /// <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;
 }
コード例 #8
0
ファイル: TagUnitTestDriver.cs プロジェクト: sr3dna/big5sync
 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;
     }
 }
コード例 #9
0
ファイル: TagUnitTestDriver.cs プロジェクト: sr3dna/big5sync
 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;
     }
 }
コード例 #10
0
ファイル: TaggingLayer.cs プロジェクト: sr3dna/big5sync
 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;
 }
コード例 #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;
 }
コード例 #12
0
ファイル: TaggingLayer.cs プロジェクト: sr3dna/big5sync
 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;
 }
コード例 #13
0
ファイル: TaggingXMLHelper.cs プロジェクト: sr3dna/big5sync
 /// <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;
 }
コード例 #14
0
ファイル: TaggingXMLHelper.cs プロジェクト: sr3dna/big5sync
 /// <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;
 }
コード例 #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);
 }
コード例 #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;
 }