public ILocationModel Any(UpdateLocation request) { return(workflow.Update(request)); }
// // PrepareSyncDesktop(string sourcePath, string destinationPath, ref Queue<UpdateLocation> UpdateFiles) // Scans the Desktop, removes unnecessary files and folders, and determines what new files need to be copied // public double PrepareSyncDesktop(string sourcePath, string destinationPath, ref Queue<UpdateLocation> UpdateFiles) { double size = 0; //size of all files in this directory that will need to be copied bool dirExisted = DirExisted(destinationPath); if (!Directory.Exists(destinationPath)) return size; //the directory could not be accessed //get the source files string[] sourceFiles = null; try { sourceFiles = Directory.GetFiles(sourcePath); } catch (Exception ex) { Console.WriteLine(ex); return size; } foreach (string sourceFile in sourceFiles) { FileInfo sourceInfo = new FileInfo(sourceFile); string destinationFile = Path.Combine(destinationPath, sourceInfo.Name); if (dirExisted && File.Exists(destinationFile)) { FileInfo destinationInfo = new FileInfo(destinationFile); if (sourceInfo.LastWriteTime > destinationInfo.LastWriteTime) { //file is newer, so add it to the queue of files that need to be copied UpdateLocation update = new UpdateLocation(); update.SourceFile = sourceFile; update.DestinationFile = Path.Combine(destinationPath, sourceInfo.Name); UpdateFiles.Enqueue(update); FileInfo info = new FileInfo(sourceFile); size += info.Length; //get the file's size } } else { //add it to the queue of files that need to be copied UpdateLocation update = new UpdateLocation(); update.SourceFile = sourceFile; update.DestinationFile = Path.Combine(destinationPath, sourceInfo.Name); UpdateFiles.Enqueue(update); FileInfo info = new FileInfo(sourceFile); size += info.Length; //get the file's size } } //now process the directories if exist string[] dirs = null; try { dirs = Directory.GetDirectories(sourcePath); } catch (Exception ex) { Console.WriteLine(ex); return size; } foreach (string dir in dirs) { DirectoryInfo dirInfo = new DirectoryInfo(dir); //recursive do the directories size += PrepareSyncDesktop(dir, Path.Combine(destinationPath, dirInfo.Name), ref UpdateFiles); } return size; }
// // PrepareSyncPMP(string sourcePath, string destinationPath, ref Queue<UpdateLocation> UpdateFiles) // Scans the PMP, removes unnecessary files and folders, and determines what new files need to be copied // public double PrepareSyncPMP(string sourcePath, string destinationPath, ref Queue<UpdateLocation> UpdateFiles) { double size = 0; //size of all files in this directory that will need to be copied bool dirExisted = DirExisted(destinationPath); if (!Directory.Exists(destinationPath)) return size; //the directory could not be accessed //get the source files string[] sourceFiles = null; try { sourceFiles = Directory.GetFiles(sourcePath); } catch (Exception ex) { Console.WriteLine(ex); return size; } foreach (string sourceFile in sourceFiles) { string correctFile = sourceFile; if (Path.GetExtension(sourceFile) == ".flac") { try { Luminescence.Xiph.FlacTagger flacTag = new FlacTagger(correctFile); //get the flac's tag if (flacTag.BitsPerSample > 16 || flacTag.SampleRate > 48000) { if (File.Exists(DownscaledLibrary + sourceFile.Substring(MusicLibrary.Length))) correctFile = DownscaledLibrary + sourceFile.Substring(MusicLibrary.Length); //redirect to downscaled file else if (PreventSynchingUpscaled) continue; } } catch (Exception ex) { Console.WriteLine(ex); } } FileInfo sourceInfo = new FileInfo(correctFile); string destinationFile = Path.Combine(destinationPath, sourceInfo.Name); if (dirExisted && File.Exists(destinationFile)) { FileInfo destinationInfo = new FileInfo(destinationFile); if (sourceInfo.LastWriteTime > destinationInfo.LastWriteTime) { //file is newer, so add it to the queue of files that need to be copied UpdateLocation update = new UpdateLocation(); update.SourceFile = correctFile; update.DestinationFile = Path.Combine(destinationPath, sourceInfo.Name); UpdateFiles.Enqueue(update); FileInfo info = new FileInfo(correctFile); size += info.Length; //get the file's size } } else { //add it to the queue of files that need to be copied UpdateLocation update = new UpdateLocation(); update.SourceFile = correctFile; update.DestinationFile = Path.Combine(destinationPath, sourceInfo.Name); UpdateFiles.Enqueue(update); FileInfo info = new FileInfo(correctFile); size += info.Length; //get the file's size } } DeleteOldDestinationFiles(sourceFiles, destinationPath); //now process the directories if exist string[] dirs = null; try { dirs = Directory.GetDirectories(sourcePath); } catch (Exception ex) { Console.WriteLine(ex); return size; } DeleteOldDestinationDirectories(dirs, destinationPath); foreach (string dir in dirs) { if (dir == DownscaledLibrary.Substring(0, DownscaledLibrary.Length - 1)) continue; //skip downscaled folder if (EnableChiptunes && dir == ChiptunesLibrary.Substring(0, ChiptunesLibrary.Length - 1)) continue; //skip chiptunes folder DirectoryInfo dirInfo = new DirectoryInfo(dir); //recursive do the directories size += PrepareSyncPMP(dir, Path.Combine(destinationPath, dirInfo.Name), ref UpdateFiles); } return size; }
private void HandleUpdateLocation(UpdateLocation x) { Broadcast(x); }
public Task <Response> UpdateLocation(UpdateLocation command) { return(_appLayer.Execute(command)); }