Exemple #1
0
 public void Execute(IConversationFile conversation, IErrorCheckerUtilities <IConversationNode> util)
 {
     using (SaveFileDialog sfd = new SaveFileDialog())
     {
         sfd.DefaultExt   = "ssv";
         sfd.AddExtension = true;
         if (sfd.ShowDialog() == DialogResult.OK)
         {
             Stream stream = null;
             try
             {
                 stream = sfd.OpenFile();
                 using (StreamWriter sw = new StreamWriter(stream))
                 {
                     stream = null;
                     CsvData.WriteTitle(Separator, sw, false);
                     WriteConversation(conversation, sw, false, util);
                 }
             }
             finally
             {
                 if (stream != null)
                 {
                     stream.Dispose();
                 }
             }
         }
     }
 }
Exemple #2
0
        public void Export(IProject2 project, ConfigParameterString exportPath, Func <Id <LocalizedStringType>, Id <LocalizedText>, Tuple <string, DateTime> > localize, IErrorCheckerUtilities <IConversationNode> util)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }
            if (exportPath == null)
            {
                throw new ArgumentNullException(nameof(exportPath));
            }

            using (var sfd = new SaveFileDialog())
            {
                sfd.DefaultExt       = "*.ssv";
                sfd.AddExtension     = true;
                sfd.CreatePrompt     = false;
                sfd.InitialDirectory = exportPath.Value;
                sfd.OverwritePrompt  = true;
                sfd.ValidateNames    = true;
                sfd.Title            = "Export to C# source file";
                sfd.DefaultExt       = ".ssv";
                if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    exportPath.Value = Path.GetDirectoryName(sfd.FileName);
                    FileStream stream = null;
                    try
                    {
                        stream = new FileStream(sfd.FileName, FileMode.OpenOrCreate, FileAccess.Write);
                        stream.SetLength(0);
                        using (var sw = new StreamWriter(stream))
                        {
                            stream = null;
                            ExportAsSsv ssv = new ExportAsSsv((type, textId) => localize(type, textId).Item1);
                            CsvData.WriteTitle(";", sw, true);
                            foreach (var con in project.ConversationFilesCollection)
                            {
                                ssv.WriteConversation(con, sw, true, util);
                            }
                        }
                    }
                    finally
                    {
                        if (stream != null)
                        {
                            stream.Dispose();
                        }
                    }
                }
            }
        }