private void ActionDelete(FileExtended sourceFileExtended, FileExtended destFileExtended, Direction actionDirection) { FileExtended fileToDelete = null; switch (actionDirection) { case Direction.SourceToDestination: fileToDelete = destFileExtended; FileMappingFromCsv.Remove(destFileExtended); break; case Direction.DestinationToSource: fileToDelete = sourceFileExtended; FileMappingFromCsv.Remove(sourceFileExtended); break; } if (fileToDelete != null) { string pathForArchival = Path.Combine(SyncConfig.Parameters["ArchiveFolder"], DateTime.Now.ToString("yyyy-MM-dd")); string logFile = SyncConfig.SyncLog; WorkingWithFiles.ArchiveFile(fileToDelete, logFile, pathForArchival, "deletion"); } }
//internal bool ActionListContainsFilePairAction(KeyValuePair<FileExtended,FileExtended> filePair) //{ // bool res = false; // foreach (var action in actionList) // { // if ( // action.ActionType == filePair. // ((action.File1 == filePair.Key && action.File2 == filePair.Value) // || // (action.File1 == filePair.Value && action.File2 == filePair.Key) // ) // ) // { // res = true; // break; // } // } // return res; //} internal void UpdateFileInMapping(FileExtended oldFile, FileExtended newFile) { FileExtended counterpartFile; if (FileMappingFromCsv.ContainsKey(oldFile)) { counterpartFile = FileMappingFromCsv[oldFile]; FileMappingFromCsv.Remove(oldFile); FileMappingFromCsv.Add(newFile, counterpartFile); } else if (FileMappingFromCsv.ContainsValue(oldFile)) { counterpartFile = FileMappingFromCsv.FirstOrDefault(x => x.Value == oldFile).Key; FileMappingFromCsv[counterpartFile] = newFile; } else { throw new Exception("Could not find specified file in mapping: \n" + oldFile.fullPath); } }