Пример #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(txtMessageText.Text))
         {
             return;
         }
         saveFileDialog.Title      = SaveAsTitle;
         saveFileDialog.DefaultExt = JsonExtension;
         saveFileDialog.Filter     = JsonFilter;
         saveFileDialog.FileName   = CreateFileName();
         if (saveFileDialog.ShowDialog() != DialogResult.OK ||
             string.IsNullOrWhiteSpace(saveFileDialog.FileName))
         {
             return;
         }
         if (File.Exists(saveFileDialog.FileName))
         {
             File.Delete(saveFileDialog.FileName);
         }
         using (var writer = new StreamWriter(saveFileDialog.FileName))
         {
             writer.Write(MessageSerializationHelper.Serialize(eventData, txtMessageText.Text));
         }
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
 }
Пример #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtMessageText.Text))
     {
         return;
     }
     saveFileDialog.Title      = SaveAsTitle;
     saveFileDialog.DefaultExt = JsonExtension;
     saveFileDialog.Filter     = JsonFilter;
     saveFileDialog.FileName   = CreateFileName();
     if (saveFileDialog.ShowDialog() != DialogResult.OK ||
         string.IsNullOrWhiteSpace(saveFileDialog.FileName))
     {
         return;
     }
     if (File.Exists(saveFileDialog.FileName))
     {
         File.Delete(saveFileDialog.FileName);
     }
     using (var writer = new StreamWriter(saveFileDialog.FileName))
     {
         writer.Write(MessageSerializationHelper.Serialize(brokeredMessage, txtMessageText.Text, doNotSerializeBody: true));
     }
 }