IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Template d'impression en réseau


Sujet :

ASP.NET

  1. #1
    Membre actif
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Avril 2011
    Messages : 89
    Par défaut Template d'impression en réseau
    Bonjour,

    je viens vers vous car je suis devant un probleme casse-tete... peut etre l'avez vous deja resolu?

    J'ai developpé un appli web en asp.net(C#) et je donne la possibilité à mes utilisateurs d'imprimer le document ce qu'ils voient à l'écran. Sur mon poste ca marche tres bien.

    Lorsque je porte l'appli en réseau et que une personne veut imprimer ca fonctionne nickel. Si une deuxieme personne veut imprimer ca coince.

    En effet, pour imprimer j'utilise un fichier template.pdf que je modifie en fonction de l'écran à imprimer.

    Ma question est la suivante : comment faire pour que deux personne puisses accéder à ce fichier simultanément, et le modifier...

    Pour ceux que ca peut aider voici comment je fais mon impression :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    protected string strPagesPdf;
     
        protected void Page_Load(object sender, EventArgs e)
        {
            EcritTitre();
            // step 1: Création du document
            Document document = new Document();
            try
            {
                //récupération du template et effacement du contenu (FileMode.Create)
                PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "Impressions/Template/Template.pdf", FileMode.Create));
     
                // step 2: Métadonnées
                document.AddTitle("Liste des Lieux physiques");
                document.AddSubject("Liste extraite depuis l'interface");
                document.AddAuthor("Toto");
                document.AddCreationDate();
     
                // step 2: Ouverture du document
                document.Open();
     
                // step 3: Création du contenu du document
     
                //Titre du pdf
                PdfPTable table = new PdfPTable(6);
                Paragraph titre = new Paragraph(new Chunk("Liste des lieux physiques", FontFactory.GetFont(FontFactory.TIMES_BOLD, 20)));
                PdfPCell cell = new PdfPCell(titre);
                cell.Colspan = 6;
                cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
                cell.BorderWidthBottom = 0;
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase("", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell.Colspan = 6;
                cell.BorderWidthTop = 0;
                table.AddCell(cell);
                document.Add(table);
     
     
                //Header du tableau
                // Definir ici nombre de colonnes
                PdfPTable table2 = new PdfPTable(5);
                table2.SpacingBefore = 10;
                table2.WidthPercentage = 100f;
     
                // definir ici le pourcentage de chaque colonne
                float[] widths = new float[] { 10f, 40f, 20f,15f, 15f };
                table2.SetWidths(widths);
                table2.HorizontalAlignment = 1;
     
                PdfPCell cell2 = new PdfPCell(new Phrase("Code", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell2.BackgroundColor = new BaseColor(187, 187, 187);
                table2.AddCell(cell2);
     
                cell2 = new PdfPCell(new Phrase("Libellé", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell2.BackgroundColor = new BaseColor(187, 187, 187);
                table2.AddCell(cell2);
     
                cell2 = new PdfPCell(new Phrase("Code postal", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell2.BackgroundColor = new BaseColor(187, 187, 187);
                table2.AddCell(cell2);
     
                cell2 = new PdfPCell(new Phrase("Derniere mise à jour", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell2.BackgroundColor = new BaseColor(187, 187, 187);
                table2.AddCell(cell2);
     
                cell2 = new PdfPCell(new Phrase("Actif?", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10)));
                cell2.BackgroundColor = new BaseColor(187, 187, 187);
                table2.AddCell(cell2);
     
                // Remplissage du tableau
                DataSet dtsLieuxPh = LieuPh.ListerLieuPh();
                if (dtsLieuxPh.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < dtsLieuxPh.Tables[0].Rows.Count; i++)
                    {
                        cell2 = new PdfPCell(new Phrase(dtsLieuxPh.Tables[0].Rows[i]["C_LIEUPH"].ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8)));
                        table2.AddCell(cell2);
     
                        cell2 = new PdfPCell(new Phrase(dtsLieuxPh.Tables[0].Rows[i]["L_LIEUPH"].ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8)));
                        table2.AddCell(cell2);
     
                        cell2 = new PdfPCell(new Phrase(dtsLieuxPh.Tables[0].Rows[i]["CP_LIEUPH"].ToString(), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8)));
                        table2.AddCell(cell2);
     
                        string laDate = DateTime.Parse(dtsLieuxPh.Tables[0].Rows[i]["D_DER_MAJ"].ToString()).ToShortDateString();
                        cell2 = new PdfPCell(new Phrase(laDate, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8)));
                        table2.AddCell(cell2);
     
     
                        string Actif = "";
                        if (dtsLieuxPh.Tables[0].Rows[i]["ACTIF"].ToString().Equals("O"))
                            Actif = "OUI";
                        else
                            Actif = "NON";
                        cell2 = new PdfPCell(new Phrase(Actif, FontFactory.GetFont(FontFactory.TIMES_ROMAN, 8)));
                        table2.AddCell(cell2);
                    }
                }
     
                //affichage du tableau
                document.Add(table2);
            }
            catch (DocumentException de)
            {
                throw (de);            
            }
            // step 4: fermeture du document
            document.Close();
     
            GetEdition();
        }
     
        private void EcritTitre()
        {
            lblTitre.Text = "Edition de la liste des lieux physiques";
        }
     
        private void GetEdition()
        {
            try
            {
                strPagesPdf = "";
                strPagesPdf += "<table cellpadding='0' cellspacing='5' width='100%' align='center' class='bordersolidfondgris'>";
                DirectoryInfo di = new DirectoryInfo(ConfigurationManager.AppSettings["cheminPhysiquePdf"].ToString());
                FileInfo[] fi = di.GetFiles("*.pdf");
                if (fi.Length > 0)
                {
                    strPagesPdf += "<tr height='15'><td class='td'>&nbsp;</td></tr>";
                    strPagesPdf += "<tr height='15'><td align='center' class='titreProfil'>Document(s) généré(s) </td></tr>";
                    strPagesPdf += "<tr><td class='td'></td></tr>";
                    for (int i = 0; i < fi.Length; i++)
                    {
                        strPagesPdf += "<tr>";
                        strPagesPdf += "<td class='td'align='center'>";
                        strPagesPdf += "<a href='#' style='cursor:pointer' onclick='window.open(\"" + ConfigurationManager.AppSettings["cheminWebPdf"].ToString() + "/" + fi[i].Name.Replace("'", "@") + "\");'>" + "Liste des lieux physiques</a>";
                        strPagesPdf += "</td>";
                        strPagesPdf += "</tr>";
                    }
                }
                strPagesPdf += "</table>";
            }
            catch (Exception ex)
            {
                Response.Redirect(Application["pageProblemeApplication"].ToString(), false);
                throw (ex);
            }
        }
    merci de vos conseils...

  2. #2
    Expert confirmé Avatar de Graffito
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    5 993
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2006
    Messages : 5 993
    Par défaut
    Chaque requête s'exécute dans un thread different et donc potentiellement concurrent.
    Il faudra donc gérer un fichier de nom différent à chaque requête et penser à la suppression automatique des fichiers obsolètes.

Discussions similaires

  1. Réponses: 6
    Dernier message: 27/11/2014, 21h27
  2. Template d'impression ?
    Par Legenyes dans le forum Général Dotnet
    Réponses: 2
    Dernier message: 16/02/2012, 09h42
  3. impression en réseau
    Par longuard dans le forum Développement
    Réponses: 0
    Dernier message: 13/01/2010, 04h40
  4. Impression imprimante réseau
    Par Alga007 dans le forum C++Builder
    Réponses: 4
    Dernier message: 01/04/2008, 12h02
  5. Problème d'impression en réseau
    Par saxo MAX dans le forum Administration
    Réponses: 3
    Dernier message: 12/02/2008, 07h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo