public void SendAllPhotos(object sender, System.EventArgs e) { ClientCommunication client = (ClientCommunication)sender; PhotoUpdate.MessageRecieved += client.WriteMessage; client.WriteMessage(this, PhotoExtractor.GetAllPhotos()); }
/// <summary> /// when file created /// </summary> /// <param name="source">event caller</param> /// <param name="e">the created file</param> public void OnChanged(object source, FileSystemEventArgs e) { // check if file is an image // if it is, backup string path = e.FullPath; logger.Log("New file detected in \"" + dirPath + "\"", MessageTypeEnum.L_INFO); if (!filters.Contains(Path.GetExtension(path))) { logger.Log("File \"" + Path.GetFileName(path) + "\" isnt an image", MessageTypeEnum.L_INFO); return; } logger.Log("Backup \"" + Path.GetFileName(path) + "\" is an image", MessageTypeEnum.L_INFO); string[] output = { "", "" }; ExitCode status = controller.ExecuteCommand(Command.BackupFile, new string[] { path }, output); if (status != ExitCode.Success) { logger.Log("Failed to back up \"" + Path.GetFileName(path) + "\" reson of failuer: " + GetFailedReson(status), MessageTypeEnum.L_FAIL); } else { logger.Log("Successfully Backup \"" + Path.GetFileName(path) + "\" and created thumbnail", MessageTypeEnum.L_INFO); MessageRecievedEventArgs message = PhotoExtractor.GetPhotos(output[0], output[1]); if (message != null) { photoUpdate.Log(message.Message, message.Status); } Settings settings = Settings.Instance; settings.PicturesCounter++; } }