private void MoveHandler(Event currentEvent) { // Have to stop and consider what if the file is not in the database? Should first send the request. // If the server says it's unimportant we can skip it String originalTransientFolderPath = FileSystemUtilities.GetTransientFolderPath(currentEvent.File.Path); Console.WriteLine("Original Path: " + originalTransientFolderPath); String newTransientFolderPath = FileSystemUtilities.GetTransientFolderPath(currentEvent.File.NewPath); Console.WriteLine("New Path: " + newTransientFolderPath); // If the original file existed then move it and send a put request otherwise do nothing if (!SystemFile.Exists(originalTransientFolderPath)) return; // Create the directories of destination if doesn't exist String directories = newTransientFolderPath.Substring(0, newTransientFolderPath.LastIndexOf(@"\")); System.IO.Directory.CreateDirectory(directories); FileSystemUtilities.MoveFile(originalTransientFolderPath, newTransientFolderPath); SendMoveRequest(currentEvent.File); }
private void OpenHandler(Event currentEvent) { SendOpenRequest(currentEvent.File); }
private void ModifyHandler(Event currentEvent) { FileSystemUtilities.PutFileInTransientFolder(currentEvent.File); SendModifyRequest(currentEvent.File); }
private void DeleteHandler(Event currentEvent) { // No delete events are forwarded to the server because server manages deletions based on expiration date }
private void RenameHandler(Event currentEvent) { // Have to stop and consider what if the file is not in the database? String originalTransientFolderPath = FileSystemUtilities.GetTransientFolderPath(currentEvent.File.Path); Console.WriteLine("Original Path: " + originalTransientFolderPath); // If file never existed, don't need to do anything if (!SystemFile.Exists(originalTransientFolderPath)) return; String newTransientFolderPath = FileSystemUtilities.GetTransientFolderPath(currentEvent.File.NewPath); FileSystemUtilities.MoveFile(originalTransientFolderPath, newTransientFolderPath); SendRenameRequest(currentEvent.File); }
private void ProcessEvent(Event currentEvent) { switch (currentEvent.Action) { case FileSystemUtilities.EVENT_ACTIONS.open: OpenHandler(currentEvent); break; case FileSystemUtilities.EVENT_ACTIONS.delete: break; case FileSystemUtilities.EVENT_ACTIONS.rename: RenameHandler(currentEvent); break; case FileSystemUtilities.EVENT_ACTIONS.move: MoveHandler(currentEvent); break; case FileSystemUtilities.EVENT_ACTIONS.modify: ModifyHandler(currentEvent); break; } }