/// <summary> /// Confirm the grouping based on the arguments passed. /// </summary> /// <param name="files"></param> /// <param name="arguments"></param> /// <returns></returns> private async Task <bool> ConfirmPrompt(IPhotoCollection files, Arguments arguments) { await ListFiles(files, arguments); Console.WriteLine("Confirm moving {0} files?" , files.Count()); Console.Write("[Y] Yes (default), [N] No: "); string key = Console.ReadLine(); return(key.StartsWith("Y") || key.StartsWith("y")); }
/// <summary> /// Creates PhotoMail Images using the MSNPubSend Interface from piorg.dll. The images are created in the %TEMP% directory. /// The images include WebReady, Thumbnail, and Hi-Res for each of the images and also the Pinky Strip for whole PhotoMail /// </summary> /// <returns>IPhotoCollection a collection of photos</returns> internal IPhotoCollection CreatePhotoMailImages() { IPhotoCollection photos = null; try { Logger.AddComment(PhotomailMessages.MsgCreatingImage, Logger.CommentType.Message); // Creating a Photos Collection Object. photos = this.msnPubSend.CreatePhotoCollection(null); // Delete the Previous Photomail Files if exists in the target location. this.DeletePhotoMailFiles(); // Directory to create new photos collection. DirectoryInfo dir = Directory.CreateDirectory(System.Environment.GetEnvironmentVariable("TEMP")); dir = dir.CreateSubdirectory(PhotomailMessages.PhotosDirectory); string imagesDirectory = dir.ToString(); //// Create First photo file temp1.jpg in the target directory. string fileName1 = Path.Combine(dir.FullName, PhotomailMessages.Photo1); ImageCreator.CreateImage(1000, 1000, fileName1); //// Create Second photo file temp2.jpg in the target directory. string fileName2 = Path.Combine(dir.FullName, PhotomailMessages.Photo2); ImageCreator.CreateImage(800, 800, fileName2); //// Add the above created photos to the Photos Collection. photos.AddPhoto(fileName1, PhotomailMessages.PhotoTitle1, PhotomailMessages.PhotoDescription1); photos.AddPhoto(fileName2, PhotomailMessages.PhotoTitle2, PhotomailMessages.PhotoDescription2); //// Sucess message for image creation Logger.AddComment(PhotomailMessages.MsgCreatingImageSuccessfull, Logger.CommentType.Message); } catch (PhotomailException fe) { Logger.AddComment(PhotomailMessages.MsgCreatingImageUnsuccessfull, Logger.CommentType.Message); Logger.AddComment(PhotomailMessages.TextReasonForFailure + fe.Message, Logger.CommentType.Message); } catch (Exception fe) { Logger.AddComment(PhotomailMessages.MsgCreatingImageUnsuccessfull, Logger.CommentType.Error); Logger.AddComment(PhotomailMessages.TextReasonForFailure + fe.Message, Logger.CommentType.Message); } return(photos); }
/// <summary> /// Lists the files out to the user. /// </summary> /// <param name="arguments"></param> /// <param name="files"></param> /// <returns></returns> private async Task ListFiles(IPhotoCollection files, Arguments arguments) { //files = await files.UnGroup(); if (arguments.Json) { Console.WriteLine(await files.ToJson()); } else { StringBuilder br = new StringBuilder(); foreach (var file in files) { br.AppendLine(file.FilePath); } Console.WriteLine(br.ToString()); } }
/// <summary> /// Confirm the grouping based on the arguments passed. /// </summary> /// <param name="files"></param> /// <param name="arguments"></param> /// <returns></returns> private async Task <IPhotoCollection> HandleConfirm(IPhotoCollection files, Arguments arguments) { IProgress <int> updateProgress = new Progress <int>(percentage => { Console.Write("\rProgress: {0}%", percentage); }); int fileCount = files.Count(); if (!arguments.ConfirmPrompt || await ConfirmPrompt(files, arguments)) { Console.Write("Progress: 0%"); files = await files.Confirm(updateProgress); Console.WriteLine("\nSuccessfully moved {0} files.", fileCount); } return(files); }
/// <summary> /// Simulates the sending of a PhotoMail from the client. It uploads the Pinky and other required Images depending on the list of fingerprints it recieves from the server /// </summary> internal void SendPhotoMail() { try { //// Creating Photomail Images. IPhotoCollection photos = this.msnPubSend.CreatePhotoCollection(null); photos = this.CreatePhotoMailImages(); //// Uploading Photomail. for (uint i = 0; i < photos.GetCount(); i++) { photos.GetPhotoData(i, out this.picName, out this.picTitle, out this.picDesc, out this.u); this.UploadPhotoMail(); } Logger.AddComment(PhotomailMessages.MsgSendingPhotoMail + PhotomailMessages.MsgSuccess, Logger.CommentType.Message); Logger.AddComment(string.Empty, Logger.CommentType.Pass); } catch (PhotomailException pex) { Logger.AddComment(PhotomailMessages.TextSendPhotomailTCName + PhotomailMessages.MsgFailedTag, Logger.CommentType.Message); Logger.AddComment(PhotomailMessages.TextReasonForFailure + pex.Message, Logger.CommentType.Message); Logger.AddComment(string.Empty, Logger.CommentType.Fail); } catch (WebException we) { Logger.AddComment(PhotomailMessages.TextSendPhotomailTCName + PhotomailMessages.MsgFailedTag, Logger.CommentType.Message); Logger.AddComment(PhotomailMessages.TextReasonForFailure + we.Message, Logger.CommentType.Message); Logger.AddComment(string.Empty, Logger.CommentType.Fail); } catch (Exception ex) { Logger.AddComment(PhotomailMessages.TextSendPhotomailTCName + PhotomailMessages.MsgFailedTag, Logger.CommentType.Message); Logger.AddComment(PhotomailMessages.TextReasonForFailure + ex.Message, Logger.CommentType.Message); Logger.AddComment(string.Empty, Logger.CommentType.Fail); } }