Exemple #1
0
 /// <summary>
 /// Reads a <see cref="Conversation"/> from the input file path and exports it to as JSON file.
 /// </summary>
 /// <exception cref="ArgumentException">
 /// Thrown when there is a problem with the any of the arguments.
 /// </exception>
 /// <exception cref="IOException">
 /// Thrown when something with the IO went wrong.
 /// </exception>
 public bool ExportConversation(ConversationFilters filters)
 {
     try
     {
         Conversation conversation = this.ReadConversation();
         if (conversation == null)
         {
             return(false);
         }
         Conversation filteredConversation = filters.ApplyFilters(conversation);
         return(this.WriteConversation(filteredConversation));
     }
     catch (ArgumentException e)
     {
         Console.WriteLine("Something went wrong while exporting the conversation. Please restart the appliction and try again.");
         Console.WriteLine(e.Message);
         return(false);
     }
     catch (OutOfMemoryException e)
     {
         Console.WriteLine("The application ran out of memory while exporting the conversation. Please restart the appliction and try again.");
         Console.WriteLine(e.Message);
         return(false);
     }
     catch (RegexMatchTimeoutException e)
     {
         Console.WriteLine("Appying the iflters is taking too long. Please restart the appliction and try again.");
         Console.WriteLine(e.Message);
         return(false);
     }
     catch (IOException e)
     {
         Console.WriteLine("Something went wrong in the IO while exporting the conversation. Please restart the appliction and try again.");
         Console.WriteLine(e.Message);
         return(false);
     }
 }