1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| /// <summary>
/// Export journal (génération contenu cote serveur
/// </summary>
/// <returns>Flux Pdf</returns>
public Stream ExportJournal ()
{
try
{
Byte[] flux = srvFicNet.ImpressionJournal(
"STE TEST DEMONSTRATION",
"00123456601",
new DateTime( 2008, 2, 1 ),
new DateTime( 2009, 1, 31 ),
vue.CheminApplication + @"\rptJournal.rdlc",
string.Empty,
"AC", 2, 2008 );
string mimeType = "Content-type: application/pdf\r\n";
string attachement = "Content-Disposition: attachment; filename=Journal_AC_022008_02008_WCF.pdf\r\n";
UTF8Encoding encodage = new UTF8Encoding();
MemoryStream memStream = new MemoryStream();
//
// Ecriture de l'entete PDF
Debug.WriteLine( string.Format( "mimeType.Length : {0}", mimeType.Length.ToString() ) );
Byte[] tbMimeType = encodage.GetBytes( mimeType );
memStream.Write( tbMimeType, 0, tbMimeType.Length );
Byte[] tbattachement = encodage.GetBytes( attachement );
Debug.WriteLine( string.Format( "(int)memStream.Position : {0}", ( (int) memStream.Position ).ToString() ) );
memStream.Write( tbattachement, 0, tbattachement.Length );
//
// Ecrire les bits de donnees
Debug.WriteLine( string.Format( "(int)memStream.Position : {0}", ( (int) memStream.Position ).ToString() ) );
memStream.Write( flux, 0, flux.Length );
memStream.Position = 0;
//
memStream.Flush();
memStream.Seek( 0, SeekOrigin.Begin );
//
return memStream;
}
catch ( Exception ex )
{
Debug.WriteLine( ex );
throw ex;
}
} |
Partager