void SyncFileThread(string DirectoryToSync, bool recoursive, string userName, int SyncBy) { try { int count = 0; FileData[] files = FastDirectoryEnumerator.GetFiles(DirectoryToSync, "*.Bin", recoursive == true ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); ulong g360Index; using (UploadHistoryLogApi m = new UploadHistoryLogApi(_writeListDir, false)) { m.LoadLogToMemoryDic(); string fileToAdd = string.Empty; Dictionary <string, bool> list = m.DicFileList; for (int i = 0; i < files.Length; i++) { if (list.ContainsKey(files[i].Path) == false) { switch (SyncBy) { case 0: q.AddFile(files[i].Path, m_startTime, files[i].CreationTime, out g360Index, userName); break; case 1: q.AddFile(files[i].Path, m_startTime, files[i].LastAccesTime, out g360Index, userName); break; case 2: q.AddFile(files[i].Path, m_startTime, files[i].LastWriteTime, out g360Index, userName); break; } count++; } } } pCallback(133, m_clientIpAddress, count.ToString(), string.Empty, "ok", 0, DateTime.Now, 0, m_FileOwnerUserName); } catch (Exception err) { pCallback(133, m_clientIpAddress, "0", string.Empty, err.Message, 0, DateTime.Now, 0, m_FileOwnerUserName); } }
void CallbackMessage(int code, string ipAdress, string fileName, string FullPath, string msg, int Hash, DateTime startTime, ulong g360Index, string userName) { //Console.WriteLine("code: {0} ipadress {1} fileName: {2} , fullPath{3} msg: {4}", code, ipAdress, fileName, FullPath, msg, startTime.ToString()); string line = ipAdress + "," + fileName + "," + FullPath + "," + msg + "," + startTime.ToString() + "," + g360Index; int r = BroadcastMessage(code, line, startTime, userName); if (r == 0 && code == 18) { q.AddFile(FullPath, startTime, DateTime.Now, g360Index, userName); } }