protected void exportSessions(List<Session> selectedSessions, ExportSessionEventArgs se)
        {
            String filetype;
            String filedescription;

            if (selectedSessions.Count == 0)
            {
                MessageBox.Show("You must select some sessions to export!"
                    , "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (se.type == ExportSessionEventArgs.ExportType.CLIP_TYPE)
            {
                int copiedCount = sc.copyHostnamesToClipboard(selectedSessions);
                if (copiedCount != selectedSessions.Count)
                {
                    MessageBox.Show("Only copied "+ copiedCount +" sessions"
                         , "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Successfully copied " + copiedCount + " hostnames"
                        , "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
                return;
            }
            else
            {
                filetype = sc.getExportFileTypeExtension(se.type);
                filedescription = sc.getExportFileDescription(se.type);

                saveFileDialog1.Filter = filedescription + "|*." + filetype + "|All files|*.*";

                saveFileDialog1.Title = SAVE_FILE_DIALOG_TITLE + filetype + " file: " +
                                        selectedSessions.Count + " sessions selected";
                saveFileDialog1.DefaultExt = filetype;
            }

            if (DialogResult.OK == saveFileDialog1.ShowDialog(this))
            {

                bool result = true;
                String errorMessage = "Unknown Error";
                int savedCount = -1;
                try
                {
                    savedCount = sc.saveSessionsToFile(
                                         selectedSessions,
                                         saveFileDialog1.FileName,
                                         se.type);
                    if (savedCount != selectedSessions.Count)
                    {
                        result = false;
                        errorMessage = "Only exported " + savedCount
                                       + " out of " + selectedSessions.Count + " sessions.";
                    }
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                    result = false;

                }
                if ( result == false )
                    MessageBox.Show("Failed to export sessions:\n" +
                                errorMessage
                    , "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                    MessageBox.Show("Successfully exported " + savedCount + " sessions"
                    , "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Export the sessions to a file
 /// This method may throw an exception if there are File I/O issues
 /// </summary>
 /// <param name="sessionList">The list of sessions to export</param>
 /// <param name="fileName">The file name to save to</param>
 /// <param name="type">The type of export</param>
 /// <returns>Count of sessions successfully exported</returns>
 public int saveSessionsToFile(List<Session> sessionList, String fileName, ExportSessionEventArgs.ExportType type)
 {
     switch (type)
     {
         case ExportSessionEventArgs.ExportType.REG_TYPE:
             return regExportProvider.saveSessionsToFile(sessionList, fileName);
         case ExportSessionEventArgs.ExportType.CSV_TYPE:
             return csvExportProvider.saveSessionsToFile(sessionList, fileName);
     }
     return -1;
 }
 private void sessionTreeControl1_ExportSessions(object sender, ExportSessionEventArgs se)
 {
     exportSessions(currentSessionControl.getSelectedSessions(),se);
 }
 /// <summary>
 /// Get the file extensions for the supported export types
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public string getExportFileTypeExtension(ExportSessionEventArgs.ExportType type)
 {
     switch (type)
     {
         case ExportSessionEventArgs.ExportType.REG_TYPE:
             return regExportProvider.getFileTypeExtension();
         case ExportSessionEventArgs.ExportType.CSV_TYPE:
             return csvExportProvider.getFileTypeExtension();
     }
     return "";
 }
 protected virtual void OnExportSessions(ExportSessionEventArgs e)
 {
     if (ExportSessions != null)
     {
         ExportSessions(this, e);
     }
 }