public void DetectingEnded(SyncElementInfo sei) { if (typeof(SyncFileInfo) == sei.GetType()) { _filesDetectedCount++; } else { _dirsDetectedCount++; } }
public void SyncElementStatusChanged(SyncElementInfo sei) { bool isFile = typeof(SyncFileInfo) == sei.GetType(); switch (sei.SyncStatus) { case SyncElementStatus.ElementFound: if (isFile) { _filesFoundCount++; DirTree.AddFile((MyFileInfo)sei.ElementInfo); } else { _dirsFoundCount++; DirTree.AddDir((MyDirInfo)sei.ElementInfo); } break; case SyncElementStatus.ChangeDetectingStarted: break; case SyncElementStatus.NoChangeFound: break; case SyncElementStatus.ChangeFound: if (isFile) { SyncFileExecutionInfos.Add((SyncFileExecutionInfo)sei.SyncExecutionInfo); if (sei.SyncExecutionInfo.Remove) { _filesToRemoveCount++; _filesTotalSizeToRemove += ((MyFileInfo)sei.ElementInfo).Size; } else { _filesToCopyCount++; _filesTotalSizeToCopy += ((MyFileInfo)sei.ElementInfo).Size; } } else { SyncDirExecutionInfos.Add((SyncDirExecutionInfo)sei.SyncExecutionInfo); if (sei.SyncExecutionInfo.Remove) _dirsToRemoveCount++; else _dirsToCreateCount++; } break; case SyncElementStatus.ChangeApplied: if (isFile) { if (sei.SyncExecutionInfo.Remove) { _fileSizeRemoved += ((SyncFileInfo)sei).FileInfo.Size; _filesRemovedCount++; } else { _fileSizeCopied += ((SyncFileInfo)sei).FileInfo.Size; _filesCopiedCount++; } } else { if (sei.SyncExecutionInfo.Remove) _dirsRemovedCount++; else _dirsCreatedCount++; } break; case SyncElementStatus.Conflicted: ConflictInfos.Add(sei.ConflictInfo); break; } _listener?.OnSyncElementStatusChanged(sei); }
public void DetectingEnded(SyncElementInfo sei) { if (typeof(SyncFileInfo) == sei.GetType()) _filesDetectedCount++; else _dirsDetectedCount++; }
public void OnSyncElementStatusChanged(SyncElementInfo sei) { bool isFile = typeof(SyncFileInfo) == sei.GetType(); switch (sei.SyncStatus) { case SyncElementStatus.ElementFound: //update treeview TreeNodeCollection tnc = treeView1.Nodes; TreeNode treeNode; for (int i = 0; i < sei.ElementInfo.TreePath.Count; i++) { treeNode = tnc[sei.ElementInfo.TreePath[i].Info.Name]; if (treeNode == null) return; tnc = treeNode.Nodes; } treeView1.Invoke(new Action(() => { if (isFile) AddFileTreeNode(tnc, (MyFileInfo)sei.ElementInfo); else AddDirTreeNode(tnc, (MyDirInfo)sei.ElementInfo); })); break; case SyncElementStatus.ChangeDetectingStarted: Console.WriteLine("Start detecting file:" + sei.ElementInfo.FullPath); break; case SyncElementStatus.NoChangeFound: break; case SyncElementStatus.ChangeFound: TreeNode tn1 = getTreeNode(sei.ElementInfo); if (tn1 == null) break; tn1.ForeColor = Color.Blue; if (tn1 != null) treeView1.Invoke( new Action(() => { foreach (TreeNode ptn in NextParentNode(tn1)) ptn.Text = ptn.Text + " - #cf"; })); if (isFile) { Console.WriteLine("file change detected:" + sei.SyncExecutionInfo.AbsoluteDestPath); } else { Console.WriteLine("directory change detected:" + sei.SyncExecutionInfo.AbsoluteDestPath); } break; case SyncElementStatus.ChangeApplied: TreeNode tn2 = getTreeNode(sei.ElementInfo); if (tn2 != null) treeView1.Invoke(new Action(() => { foreach (TreeNode ptn in NextParentNode(tn2)) ptn.Text = ptn.Text + " - #ca"; })); if (isFile) { if (sei.SyncExecutionInfo.Remove) Console.WriteLine("file deleted:" + sei.SyncExecutionInfo.AbsoluteDestPath); else Console.WriteLine("file copied:" + sei.SyncExecutionInfo.AbsoluteDestPath); } else { if (sei.SyncExecutionInfo.Remove) Console.WriteLine("directory removed:" + sei.SyncExecutionInfo.AbsoluteDestPath); else Console.WriteLine("Directory created:" + sei.SyncExecutionInfo.AbsoluteDestPath); } break; case SyncElementStatus.Conflicted: string elementType = isFile ? "file" : "dir"; string conflictType = ""; switch (sei.ConflictInfo.Type) { case ConflictType.IO: conflictType = "IO"; break; case ConflictType.UA: conflictType = "Access Denied"; break; case ConflictType.Unknown: conflictType = "Unknown"; break; } AddLogLine($"Conflict ({conflictType}) at {elementType}: {sei.ConflictInfo.GetAbsolutePath()}"); break; } }
public void SyncElementStatusChanged(SyncElementInfo sei) { bool isFile = typeof(SyncFileInfo) == sei.GetType(); switch (sei.SyncStatus) { case SyncElementStatus.ElementFound: if (isFile) { _filesFoundCount++; DirTree.AddFile((MyFileInfo)sei.ElementInfo); } else { _dirsFoundCount++; DirTree.AddDir((MyDirInfo)sei.ElementInfo); } break; case SyncElementStatus.ChangeDetectingStarted: break; case SyncElementStatus.NoChangeFound: break; case SyncElementStatus.ChangeFound: if (isFile) { SyncFileExecutionInfos.Add((SyncFileExecutionInfo)sei.SyncExecutionInfo); if (sei.SyncExecutionInfo.Remove) { _filesToRemoveCount++; _filesTotalSizeToRemove += ((MyFileInfo)sei.ElementInfo).Size; } else { _filesToCopyCount++; _filesTotalSizeToCopy += ((MyFileInfo)sei.ElementInfo).Size; } } else { SyncDirExecutionInfos.Add((SyncDirExecutionInfo)sei.SyncExecutionInfo); if (sei.SyncExecutionInfo.Remove) { _dirsToRemoveCount++; } else { _dirsToCreateCount++; } } break; case SyncElementStatus.ChangeApplied: if (isFile) { if (sei.SyncExecutionInfo.Remove) { _fileSizeRemoved += ((SyncFileInfo)sei).FileInfo.Size; _filesRemovedCount++; } else { _fileSizeCopied += ((SyncFileInfo)sei).FileInfo.Size; _filesCopiedCount++; } } else { if (sei.SyncExecutionInfo.Remove) { _dirsRemovedCount++; } else { _dirsCreatedCount++; } } break; case SyncElementStatus.Conflicted: ConflictInfos.Add(sei.ConflictInfo); break; } _listener?.OnSyncElementStatusChanged(sei); }