public static void Clean()
 {
     OnlyInIndexing1     = new List <IndexingNode>();
     OnlyInIndexing2     = new List <IndexingNode>();
     UpdateNodeIn1       = new List <IndexingNode>();
     UpdateNodeIn2       = new List <IndexingNode>();
     ResultIndexingNodes = new List <IndexingNode>();
     ResultTree          = null;
 }
        public static IndexingTree Merge(IndexingTree indexingTree1, IndexingTree indexingTree2)
        {
            OnlyInIndexing1     = new List <IndexingNode>();
            OnlyInIndexing2     = new List <IndexingNode>();
            UpdateNodeIn1       = new List <IndexingNode>();
            UpdateNodeIn2       = new List <IndexingNode>();
            ResultIndexingNodes = new List <IndexingNode>();
            ResultTree          = new IndexingTree(indexingTree1.Project, "000000000000");

            if (!indexingTree1.GetRoot().Equals(indexingTree2.GetRoot()))
            {
                throw new Exception("Not same root!");
            }
            foreach (IndexingNode n in indexingTree1.GetAllNodes())
            {
                bool isFind = false;
                foreach (IndexingNode m in indexingTree2.GetAllNodes())
                {
                    if (n.Equals(m))
                    {
                        isFind = true;
                        break;
                    }
                }
                if (!isFind)
                {
                    OnlyInIndexing1.Add(n);
                }
            }

            foreach (IndexingNode n in indexingTree2.GetAllNodes())
            {
                bool isFind = false;
                foreach (IndexingNode m in indexingTree1.GetAllNodes())
                {
                    if (n.Equals(m))
                    {
                        isFind = true;
                        break;
                    }
                }
                if (!isFind)
                {
                    OnlyInIndexing2.Add(n);
                }
            }

            CopyFromTree1(null, indexingTree1.GetRoot());

            foreach (IndexingNode n in OnlyInIndexing2)
            {
                Insert(ResultTree.GetRoot(), n);
            }

            ResultTree.SetAllNodes(ResultIndexingNodes);
            return(ResultTree);
        }
Example #3
0
 public void LoadIndexingTrees()
 {
     _indexingTrees.Clear();
     foreach (var f in new DirectoryInfo(_project.IndexingFolderPath).GetFiles())
     {
         IndexingTree temp = new IndexingTree(_project, f.Name.Substring(0, 12), "000000000000");
         temp.ImportTreeFromIndexing();
         AddIndexingTree(temp);
     }
 }
        public static IEnumerable <string> CompareTwoIndexing(IndexingTree indexingTree1, IndexingTree indexingTree2)
        {
            if (indexingTree1 == null)
            {
                return(new List <string>());
            }
            if (indexingTree2 == null)
            {
                List <string> result = JsonConvert.DeserializeObject <Indexing>(indexingTree1.ToJSON()).ProjectContents.ToList();
                result.RemoveAt(0);
                return(result);
            }
            var indexing1 = JsonConvert.DeserializeObject <Indexing>(indexingTree1.ToJSON()).ProjectContents;
            var indexing2 = JsonConvert.DeserializeObject <Indexing>(indexingTree2.ToJSON()).ProjectContents;

            indexing1[0] = indexing2[0];  //Ignore the line about time
            return(indexing1.Where(a => !indexing2.Contains(a)));
        }
Example #5
0
        public IndexingTree GetNewestTree()
        {
            IndexingTree temp = null;

            for (int i = 0; i < _indexingTrees.Count; i++)
            {
                if (i == 0)
                {
                    temp = _indexingTrees.Values[i];
                    continue;
                }
                if (_indexingTrees.Values[i].SubmitTime.CompareTo(temp.SubmitTime) > 0)
                {
                    temp = _indexingTrees.Values[i];
                }
            }
            return(temp);
        }
Example #6
0
 public void ShowDiff()
 {
     for (var i = 0; i < _indexingTrees.Count - 1; i++)
     {
         var oldIndexingTree = _indexingTrees.Values[i];
         var newIndexingTree = _indexingTrees.Values[i + 1];
         var addedNodes      = IndexingTree.CompareTwoIndexing(newIndexingTree.IndexFilePath, oldIndexingTree.IndexFilePath);
         var deletedNodes    = IndexingTree.CompareTwoIndexing(oldIndexingTree.IndexFilePath, newIndexingTree.IndexFilePath);
         Console.WriteLine(newIndexingTree.ID.Substring(0, 8) + " Compares To " + oldIndexingTree.ID.Substring(0, 8));
         Console.WriteLine("Added: ");
         foreach (var a in addedNodes)
         {
             Console.WriteLine(a);
         }
         Console.WriteLine("Deleted: ");
         foreach (var d in deletedNodes)
         {
             Console.WriteLine(d);
         }
     }
 }
Example #7
0
 public void AddIndexingTree(IndexingTree newIndexingTree)
 {
     _indexingTrees.Add(newIndexingTree.SubmitTime, newIndexingTree);
 }