Ejemplo n.º 1
0
        public string RenderReportPreview(string rdlc, string moduleName, string key)
        {
            // CheckBox to see if there is any data
            try
            {
                DataTable Data = new DataTable();
                Data = LoadData(key, moduleName);

                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());

                if (Data != null)
                {
                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Donnee chargéé");
                }

                if (Data.Rows.Count > 0)
                {
                    List <ReportParameter> listeParam = new List <ReportParameter>();

                    if (parameter != null && parameter.Count != 0)
                    {
                        foreach (KeyValuePair <string, string> pair in parameter)
                        {
                            ReportParameter param = new ReportParameter(pair.Key, pair.Value);
                            listeParam.Add(param);
                        }
                    }

                    report.ReportPath = p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc");
                    ReportDataSource reportDataSource = new ReportDataSource(rdlc, Data);

                    if (listeParam != null & listeParam.Count > 0)
                    {
                        report.SetParameters(listeParam);
                    }
                    report.DataSources.Add(reportDataSource);

                    // save report in static PreviewPrinting class
                    printError.SetErrorsFromSilverlightWebPrinting(p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc"), "Terminer");


                    Random random = new Random();
                    keyPreview = random.Next(2013, 3000).ToString() + "_" + random.Next(1986, 2013).ToString() + "_" + DateTime.Now.Second + "_" + DateTime.Now.Millisecond;
                    PrintingPrieview.reportDataSource.Add(keyPreview, reportDataSource);
                    PrintingPrieview.reportParameter.Add(keyPreview, listeParam);
                    PrintingPrieview.reportPath.Add(keyPreview, p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc"));
                    PrintingPrieview.datasourceName.Add(keyPreview, rdlc);

                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Terminer");
                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), keyPreview);
                }
                return(keyPreview);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 2
0
        //public List<object> getCollectionToPrint_Image(string key)
        //{
        //    try
        //    {

        //        EndpointAddress lePoint = EndPointPrinting(SessionObject.machine, SessionObject.portService);

        //        Galatee.Silverlight.Web.ServiceAccueil.AcceuilServiceClient print = new Galatee.Silverlight.Web.ServiceAccueil.AcceuilServiceClient(ProtocoleFacturation(), lePoint);
        //        List<Galatee.Silverlight.Web.ServicePrintings.CsPrint> connex = new List<Galatee.Silverlight.Web.ServicePrintings.CsPrint>();

        //        List<object> connexO = new List<object>();
        //        var resultatAImprimer = print.GetCsPrintFromWebPart(key);
        //        if (resultatAImprimer ==null )
        //            print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Aucune valeur");

        //        connex.AddRange(resultatAImprimer);
        //        connexO.AddRange(connex);

        //        print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), key);

        //        if (connexO.Count == 0 )
        //            print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Aucune données");
        //        else
        //            print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "données trouve");

        //        parameter = print.getParameters(key);

        //        if (param.Count != 0)
        //            print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Parametre trouvé");
        //        else
        //            print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Parametre non trouvé");

        //        return connexO;
        //    }
        //    catch (Exception ex)
        //    {
        //        PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
        //        printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
        //        throw ex;
        //    }

        //}

        // Func delegate test CHK 15/02/2013
        /* CHK - 01/03/2013 - retrait du delegué func */
        //private DataTable LoadData(string key, Func<string, List<object>> GetDataFromModule)
        //{
        //    try
        //    {
        //        List<object> data = new List<object>();
        //        /data.AddRange(GetDataFromModule(key));
        //        List<object> liste = getCollectionToPrint(key);
        //        data.AddRange(liste);
        //        return Galatee.Tools.Utility.ListToDataTable(data);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        /* CHK - 01/03/2013 - retrait du delegué func */
        private DataTable LoadData(string key, string moduleName)
        {
            try
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());

                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "loadData");
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), key);

                List <object> data  = new List <object>();
                List <object> liste = getCollectionToPrint(key);
                data.AddRange(liste);

                if (data.Count == 0)
                {
                    printError.SetErrorsFromSilverlightWebPrinting("data", "data Aucun");
                }
                else
                {
                    printError.SetErrorsFromSilverlightWebPrinting("data", "data trouve");
                }

                return(Galatee.Tools.Utility.ListToDataTable(data));
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            int bytelength = context.Request.ContentLength;

            byte[] inputbytes = context.Request.BinaryRead(bytelength);
            string message    = System.Text.Encoding.UTF8.GetString(inputbytes);



            string[] parameters = message.Split('|');

            SessionObject.machine     = parameters[3];
            SessionObject.port        = parameters[4];
            SessionObject.portService = parameters[4];

            PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());

            printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "ProcessRequest");

            try
            {
                Utilitys objetUtil  = new Utilitys();
                string   keypreview = objetUtil.LaunchPrintingPreview(false, parameters[0], parameters[1], parameters[2]);
                context.Response.Write(keypreview);
            }
            catch (Exception)
            {
                context.Response.Write(string.Empty);
            }
        }
Ejemplo n.º 4
0
        } /// <summary>

        private void Export(LocalReport report, float PageWidth, float PageHeight, float MarginTop, float MarginLeft, float MarginRight, float MarginBottom)
        {
            try
            {
                StringBuilder deviceInfosb = new StringBuilder();
                deviceInfosb.Append("<DeviceInfo>");
                deviceInfosb.Append("<OutputFormat>EMF</OutputFormat>");
                deviceInfosb.Append(string.Format("<PageWidth>{0}in</PageWidth>", PageWidth));
                deviceInfosb.Append(string.Format("<PageHeight>{0}in</PageHeight>", PageHeight));
                deviceInfosb.Append(string.Format("<MarginTop>{0}in</MarginTop>", MarginTop));
                deviceInfosb.Append(string.Format("<MarginLeft>{0}in</MarginLeft>", MarginLeft));
                deviceInfosb.Append(string.Format("<MarginRight>{0}in</MarginRight>", MarginRight));
                deviceInfosb.Append(string.Format("<MarginBottom>{0}in</MarginBottom>", MarginBottom));
                deviceInfosb.Append(string.Format("</DeviceInfo>"));
                string deviceInfo = deviceInfosb.ToString();
                Microsoft.Reporting.WebForms.Warning[] warnings;
                m_streams = new List <System.IO.Stream>();
                report.Render("Image", deviceInfo, CreateStream, out warnings);


                foreach (System.IO.Stream stream in m_streams)
                {
                    stream.Position = 0;
                }

                //PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                // printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Export(LocalReport report, float PageWidth,");
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 5
0
        } /// <summary>

        ///
        private void PrintToLocalPrinter(string pPrinter, string port, string machine)
        {
            string GetPrintServiceAddress = string.Empty;

            try
            {
                if (m_streams == null || m_streams.Count == 0)
                {
                    return;
                }
                // sending stream to local machine
                MemoryStream ms = new MemoryStream();
                m_streams[0].CopyTo(ms);
                byte[] bytes = ms.ToArray();

                // CHK - 18/07/2013 - la methode "PrintReceipt" ne se trouve pas dans le service d'authentification
                // mais plutot dans celui de caisse. J'ai donc remplacé cette ligne par la suivante
                GetPrintServiceAddress = "http://" + machine + ":" + port + "/AuthentInitialize/AuthentInitializeService.svc";
                //GetPrintServiceAddress = "http://" + machine + ":" + port + "/Caisse/CaisseService.svc";
                InvokePrinter(GetPrintServiceAddress, bytes, pPrinter);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message + " url : " + GetPrintServiceAddress);
                throw ex;
            }
        } /// <summary>
        //private void SendMail(string address, string filePath)
        //{
        //    //string MonAdresse = "*****@*****.**";
        //    string MonAdresse = "*****@*****.**";
        //    MailAddress from = new MailAddress(MonAdresse);
        //    MailAddress to = new MailAddress(address);
        //    MailMessage mailMsg = new MailMessage(from, to);

        //    mailMsg.Subject = "Votre facture d'electricité";
        //    mailMsg.Attachments.Add(new Attachment(filePath));
        //    mailMsg.Body = "Bonjour, vous trouverez ci-joint votre facture, merci de ne plus fraudez et de payer regulièrement \nAu plaisir.";

        //    ////SmtpClient client = new SmtpClient("iv-srv-003");
        //    ////SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
        //    //SmtpClient smtp = new SmtpClient();
        //    //smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
        //    //smtp.Port = 587;

        //    //smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "kouakouasso");
        //    ////smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "algoman03");
        //    //smtp.EnableSsl = true;
        //    //smtp.Send(mailMsg);



        //    //SmtpClient stpc = new SmtpClient("smtp.gmail.com", 587);
        //    SmtpClient stpc = new SmtpClient("smtp.gmail.com", 465);
        //    stpc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "algoman03");
        //    stpc.DeliveryMethod = SmtpDeliveryMethod.Network;
        //    stpc.EnableSsl = true;
        //    stpc.UseDefaultCredentials = true;
        //    stpc.Send(mailMsg);

        //    //client.Send(mailMsg);
        //}
        //public string SendMail(string address, string filePath)
        //{
        //    MailMessage msg = new MailMessage();

        //    msg.From = new MailAddress("*****@*****.**");
        //    msg.To.Add(address);
        //    msg.Subject = "Hello world! " + DateTime.Now.ToString();
        //    msg.Body = "hi to you ... :)";
        //    msg.Attachments.Add(new Attachment(filePath));

        //    SmtpClient client = new SmtpClient();
        //    client.UseDefaultCredentials = true;
        //    client.Host = "smtp.live.com";
        //    client.Port = 465;
        //    client.EnableSsl = false;
        //    client.DeliveryMethod = SmtpDeliveryMethod.Network;
        //    //client.Credentials = new NetworkCredential("*****@*****.**", "algoman03");
        //    client.Timeout = 20000;
        //    try
        //    {
        //        client.Send(msg);
        //        return "Mail has been successfully sent!";
        //    }
        //    catch (Exception ex)
        //    {
        //        return "Fail Has error" + ex.Message;
        //    }
        //    finally
        //    {
        //        msg.Dispose();
        //    }
        //}
        private void SendMail(string address, string filePath)
        {
            PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());

            try
            {
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Envoi Mail debut");

                //String userName = "******";
                //String password = "******";

                String userName = "******";
                String password = "******";

                MailMessage msg = new MailMessage();
                msg.To.Add(new MailAddress(address));
                msg.From       = new MailAddress(userName);
                msg.Subject    = "Votre facture d'electricité";
                msg.Body       = "Bonjour, vous trouverez ci-joint votre facture, merci de ne plus fraudez et de payer regulièrement \nAu plaisir.";
                msg.IsBodyHtml = true;

                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Fichier joint debut");
                msg.Attachments.Add(new Attachment(filePath));
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Fichier joint fin");


                //msg.Subject = "Test Office 365 Account";
                //msg.Body = "Testing email using Office 365 account.";


                //SmtpClient smtpServer = new SmtpClient("10.100.2.56");
                //smtpServer.Port = 25;
                //smtpServer.DeliveryMethod = SmtpDeliveryMethod.Network;
                //smtpServer.UseDefaultCredentials = true;
                //smtpServer.Credentials = new System.Net.NetworkCredential(userName, password);
                //smtpServer.Timeout = 900;
                //smtpServer.EnableSsl = false;

                SmtpClient client = new SmtpClient();
                client.Host        = "smtp.office365.com";
                client.Credentials = new System.Net.NetworkCredential(userName, password);
                client.Port        = 587;
                client.EnableSsl   = true;
                client.Timeout     = 300;
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Envoi Mail ok Debut");

                client.Send(msg);
                //smtpServer.Send(msg);
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Envoi Mail ok Fin");
            }
            catch (Exception ex)
            {
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
            }
        }
Ejemplo n.º 7
0
        void RenderReport(string rdlc, string moduleName, string key)
        {
            // CheckBox to see if there is any data
            try
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());

                DataTable Data = new DataTable();
                Data = LoadData(key, moduleName);
                if (Data == null)
                {
                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Collection vide");
                }



                if (Data.Rows.Count > 0)
                {
                    List <ReportParameter> listeParam = new List <ReportParameter>();

                    if (parameter != null && parameter.Count != 0)
                    {
                        foreach (KeyValuePair <string, string> pair in parameter)
                        {
                            ReportParameter param = new ReportParameter(pair.Key, pair.Value);
                            listeParam.Add(param);
                        }
                    }

                    report.ReportPath = p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc");
                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod() + " | " + "~/Reports/" + moduleName + @"/" + rdlc + ".rdlc", "Chemin du fichier rdlc");

                    ReportDataSource reportDataSource = new ReportDataSource(rdlc, Data);

                    if (listeParam != null & listeParam.Count > 0)
                    {
                        report.SetParameters(listeParam);
                        printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod() + " | " + listeParam.First().Name + " : " + listeParam.First().Values + "  " + listeParam.Last().Name + " : " + listeParam.Last().Values, "Set Parameters");
                    }

                    report.DataSources.Add(reportDataSource);
                    printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Add DataSources ok");
                }
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 8
0
        public List <object> getCollectionToPrintAccueil(string key)
        {
            try
            {
                EndpointAddress lePoint = EndPointPrinting(SessionObject.machine, SessionObject.portService);

                PrintingsServiceClient print = new PrintingsServiceClient(ProtocoleFacturation(), lePoint);
                List <Galatee.Silverlight.Web.ServicePrintings.CsPrint> connex = new List <Galatee.Silverlight.Web.ServicePrintings.CsPrint>();

                List <object> connexO           = new List <object>();
                var           resultatAImprimer = print.GetCsPrintFromWebPartBalanceAgee(key);
                if (resultatAImprimer == null)
                {
                    print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "BalanceAucune valeur");
                }

                connex.AddRange(resultatAImprimer);
                connexO.AddRange(connex);

                print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), key);

                if (connexO != null && connexO.Count == 0)
                {
                    print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "BalanceAucune données");
                }
                else
                {
                    print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Balance données trouve");
                }

                parameter = print.getParameters(key);

                if (parameter != null && parameter.Count != 0)
                {
                    print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Parametre trouvé");
                }
                else
                {
                    print.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Parametre non trouvé");
                }

                return(connexO);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 9
0
        } /// <summary>

        bool InvokePrinter(string ServiceUrl, byte[] bytes, string pPrinter)
        {
            string m = string.Empty;

            try
            {
                string         _service = string.Empty;
                ServiceInvoker invoker  = new ServiceInvoker(new Uri(ServiceUrl));
                foreach (string service in invoker.AvailableServices)
                {
                    _service = service;
                    break;
                }
                List <string> methods = invoker.EnumerateServiceMethods(_service);

                foreach (string p in methods)
                {
                    m += p + " || ";
                }
                string method = "PrintReceipt";

                byte[]   args            = bytes;
                string[] argsPrinterName = new[] { pPrinter };
                bool?    result          = invoker.InvokeMethod <bool?>(_service, method, args);


                if ((result != null))
                {
                    if ((result.Value == true))
                    {
                        return(true);
                    }
                    else
                    {
                        PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                        printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), m + " service : " + _service);
                        throw new Exception("Erreur dans l'appel du service d'impression");
                    }
                }
                return(true);
                //throw new Exception("Erreur dans l'appel du service d'impression");
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initialise le telechargement des données et lance
        /// l'impression de données
        /// </summary>
        /// <param name="orientation">determine l'orientation portrait ou paysage</param>
        /// <param name="modulename">nom du module dans lequel se fera l'impression</param>
        /// <param name="printer">nom de l'imprimante choisie</param>
        /// <param name="rdlc">fichier de rapport dans le module </param>
        /// <param name="key">clé servant d'entrée pour le téléchargement des données coté service</param>
        /// <param name="GetDataFromModule">methode à invoquer pour le chargement des données</param>
        /// <returns></returns>
        //public bool LaunchPrinting(bool orientation, string modulename, string printer, string rdlc, string key, Func<string, List<object>> GetDataFromModule)
        //{
        //    try
        //    {

        //        RenderReport(rdlc, modulename, key, GetDataFromModule);
        //        PrintPDF(rdlc, printer, orientation);
        //        return true;
        //    }
        //    catch (Exception ex)
        //    {
        //        string error = ex.Message;
        //        return false;
        //    }
        //}

        /// <summary>
        /// Initialise le telechargement des données et lance
        /// l'impression de données
        /// </summary>
        /// <param name="orientation">determine l'orientation portrait ou paysage</param>
        /// <param name="modulename">nom du module dans lequel se fera l'impression</param>
        /// <param name="printer">nom de l'imprimante choisie</param>
        /// <param name="rdlc">fichier de rapport dans le module </param>
        /// <param name="key">clé servant d'entrée pour le téléchargement des données coté service</param>
        /// <param name="GetDataFromModule">methode à invoquer pour le chargement des données</param>
        /// <returns></returns>
        public string LaunchPrintingPreview(bool orientation, string rdlc, string modulename, string key)
        {
            try
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "LaunchPrintingPreview");

                return(RenderReportPreview(rdlc, modulename, key));
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                return(string.Empty);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "FichierTrouve");



                    string key   = Convert.ToString(Request.QueryString["key"]);
                    string frame = Convert.ToString(Request.QueryString["frame"]);
                    hiddenframe.Value = frame;
                    try
                    {
                        printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "frame" + frame + "key" + key);


                        GalateePreview.LocalReport.ReportPath = PrintingPrieview.reportPath[key];

                        printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), GalateePreview.LocalReport.ReportPath);


                        if (PrintingPrieview.reportParameter[key].Count > 0)
                        {
                            GalateePreview.LocalReport.SetParameters(PrintingPrieview.reportParameter[key]);
                            foreach (var item in PrintingPrieview.reportParameter[key])
                            {
                                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), item.ToString());
                            }
                        }

                        GalateePreview.LocalReport.DataSources.Add(PrintingPrieview.reportDataSource[key]);
                        GalateePreview.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                        GalateePreview.LocalReport.ReportEmbeddedResource = PrintingPrieview.reportPath[key];
                    }
                    catch (Exception ex)
                    {
                        string error = ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 12
0
 private void PrintPage(object sender, PrintPageEventArgs ev)
 {
     try
     {
         Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
         ev.Graphics.DrawImage(pageImage, ev.PageBounds);
         m_currentPageIndex++;
         ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
     }
     catch (Exception ex)
     {
         PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
         printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 13
0
        public string ExportChemin(string filename, string cheminFacture, bool orientation, string rdlc, string modulename, string key, string format)
        {
            PrintingsServiceClient printErrosr = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());

            param = new Dictionary <string, string>();
            RenderReport(rdlc, modulename, key);
            PrinterSettings  ps         = new PrinterSettings();
            ImpressionDirect impression = new ImpressionDirect();

            printErrosr.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Debut RunExportFile");
            impression.RunExportFile(report, orientation, cheminFacture, filename, true, format);
            printErrosr.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Fin RunExportFile");

            // On retourne le chemin du fichier pdf
            return(cheminFacture);
        }
Ejemplo n.º 14
0
        //void RenderReport(string rdlc, string moduleName, string key, Func<string, List<object>> GetDataFromModule)
        //{
        //    // CheckBox to see if there is any data
        //    DataTable Data = new DataTable();
        //    Data = LoadData(key, GetDataFromModule);
        //    if (Data.Rows.Count > 0)
        //    {

        //        List<ReportParameter> listeParam = new List<ReportParameter>();

        //        if (parameter != null && parameter.Count != 0)
        //        {
        //            foreach (KeyValuePair<string, string> pair in parameter)
        //            {
        //                ReportParameter param = new ReportParameter(pair.Key, pair.Value);
        //                listeParam.Add(param);
        //            }
        //        }

        //        report.ReportPath = p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc");
        //        ReportDataSource reportDataSource = new ReportDataSource(rdlc, Data);

        //        if (listeParam != null & listeParam.Count > 0)
        //            report.SetParameters(listeParam);
        //        report.DataSources.Add(reportDataSource);
        //    }

        //}

        /* CHK - 01/03/2013 - retrait du delegué func pour faciliter le debogage */
        DataTable RenderReportMail(string rdlc, string moduleName, string key)
        {
            // CheckBox to see if there is any data
            try
            {
                DataTable Data = new DataTable();
                Data = LoadData(key, moduleName);
                return(Data);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 15
0
        // Export du fichier
        //private void CreateFiles(LocalReport report, string CheminFichier, string NomDuFichier,string Format)
        //{
        //    try
        //    {
        //        Warning[] warnings;
        //        string[] streamids;
        //        string mimeType;
        //        string encoding;
        //        string extension;

        //        PrintingsServiceClient printErrosr = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
        //        if(report!=null)
        //        printErrosr.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Format : " + Format + "| CheminFichier :" + CheminFichier + " | NomDuFichier" + NomDuFichier);
        //        else
        //            printErrosr.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Format : " + Format + "| CheminFichier :" + CheminFichier + " | NomDuFichier :" + NomDuFichier);

        //        if (Format == "xlsx")
        //        {
        //            byte[] bytes = report.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);
        //            FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".xls", FileMode.Create);
        //            fs.Write(bytes, 0, bytes.Length);
        //            fs.Close();
        //        }
        //        if (Format == "doc")
        //        {
        //         byte[] bytes = report.Render("WORD", null, out mimeType, out encoding, out extension, out streamids, out warnings);

        //        FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier +".doc",FileMode.Create);
        //        fs.Write(bytes, 0, bytes.Length);
        //        fs.Close();
        //        }
        //        if (Format == "pdf")
        //        {
        //            byte[] bytes = report.Render("pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings);

        //            FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".pdf", FileMode.Create);
        //            fs.Write(bytes, 0, bytes.Length);
        //            fs.Close();
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
        //        printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(),"ICIFINAL" + ex.InnerException.Message );
        //        throw ex;
        //    }

        //}


        private void CreateFiles(LocalReport report, string CheminFichier, string NomDuFichier, string Format)
        {
            try
            {
                Warning[] warnings;
                string[]  streamids;
                string    mimeType;
                string    encoding;
                string    extension;
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), CheminFichier + "|" + NomDuFichier + "|" + Format);
                if (Format == "xlsx")
                {
                    byte[] bytes = report.Render("Excel", null, out mimeType, out encoding, out extension, out streamids, out warnings);
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Générer byte");
                    FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".xls", FileMode.Create);
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Initialiser le filsStream");
                    fs.Write(bytes, 0, bytes.Length);
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "Création du fichier");

                    fs.Close();
                }
                if (Format == "doc")
                {
                    byte[] bytes = report.Render("WORD", null, out mimeType, out encoding, out extension, out streamids, out warnings);

                    FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".doc", FileMode.Create);
                    fs.Write(bytes, 0, bytes.Length);
                    fs.Close();
                }
                if (Format == "pdf")
                {
                    byte[] bytes = report.Render("pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings);

                    FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".pdf", FileMode.Create);
                    fs.Write(bytes, 0, bytes.Length);
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "ICIFINAL" + ex.InnerException.Message);
                throw ex;
            }
        }
Ejemplo n.º 16
0
        void PrintPDF(string filename, bool orientation)
        {
            try
            {
                PrinterSettings  ps         = new PrinterSettings();
                ImpressionDirect impression = new ImpressionDirect();
                impression.Run(report, orientation, p.Server.MapPath("~") + @"PDF", filename, true);

                impression.Run(report, orientation, p.Server.MapPath("~") + @"PDF", filename, true);
                impression.Run(report, orientation, ps.PrinterName);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 17
0
        private void Print(bool landscape, string NomDocument, string CheminImpression)
        {
            try
            {
                if (m_streams == null || m_streams.Count == 0)
                {
                    return;
                }

                PrintDocument   printDoc = new PrintDocument();
                PrinterSettings ps       = new PrinterSettings();
                ps.PrinterName = CheminImpression;
                ps.DefaultPageSettings.Landscape = landscape;
                ps.DefaultPageSettings.PrinterSettings.DefaultPageSettings.Landscape = landscape;
                printDoc.PrinterSettings = ps;

                if (!printDoc.PrinterSettings.IsValid)
                {
                    string msg = String.Format("Can't find printer \"{0}\".", ps.PrinterName);

                    PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), msg);
                    throw new Exception(msg);
                }
                printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
                printDoc.Print();

                foreach (System.IO.Stream stream in m_streams)
                {
                    stream.Flush();
                    stream.Close();
                }

                // sending stream to local machine
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
                throw ex;
            }
        } /// <summary>
Ejemplo n.º 18
0
        void  ValoriserReport <T>(List <T> ListeAEditer, string modulename, string rdlc) where T : new()
        {
            // CheckBox to see if there is any data
            try
            {
                DataTable Data = new DataTable();
                Data = Galatee.Tools.Utility.ListToDataTable(ListeAEditer);
                if (Data.Rows.Count > 0)
                {
                    List <ReportParameter> listeParam = new List <ReportParameter>();

                    if (parameter != null && parameter.Count != 0)
                    {
                        foreach (KeyValuePair <string, string> pair in parameter)
                        {
                            ReportParameter param = new ReportParameter(pair.Key, pair.Value);
                            listeParam.Add(param);
                        }
                    }

                    report.ReportPath = p.Server.MapPath("~/Reports/" + modulename + @"/" + rdlc + ".rdlc");
                    ReportDataSource reportDataSource = new ReportDataSource(rdlc, Data);

                    if (report.DataSources != null)
                    {
                        report.DataSources.Clear();
                    }

                    if (listeParam != null & listeParam.Count > 0)
                    {
                        report.SetParameters(listeParam);
                    }
                    report.DataSources.Add(reportDataSource);
                }
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 19
0
 public void RunExportFile(LocalReport report, bool orientation, string CheminImpression, string NomFichier, bool ImpressionDsFichier, string format)
 {
     try
     {
         NomFichier = NomFichier +
                      System.DateTime.Now.Day +
                      System.DateTime.Now.Month +
                      System.DateTime.Now.Year +
                      System.DateTime.Now.Hour +
                      System.DateTime.Now.Minute +
                      System.DateTime.Now.Second;
         CreateFiles(report, CheminImpression, NomFichier, format);
     }
     catch (Exception ex)
     {
         PrintingsServiceClient printErrosr = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
         printErrosr.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), "exception : " + ex.InnerException.Message);
         throw ex;
     }
 }
Ejemplo n.º 20
0
        private System.IO.Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
        {
            try
            {
                //Stream stream = new FileStream(@"..\..\" + name +
                //   "." + "Pdf", FileMode.Create);
                //m_streams.Add(stream);

                MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write((name + "." + "Pdf"));

                m_streams.Add(stream);
                return(stream);
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 21
0
        // Creation du fichier
        private void CreateFiles(LocalReport report, string CheminFichier, string NomDuFichier)
        {
            try
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), @CheminFichier);

                using (FileStream fs = new FileStream(@CheminFichier + "\\" + NomDuFichier + ".PDF", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                    byte[] bytes = report.Render("PDF");
                    fs.Write(bytes, 0, bytes.Length);
                    fs.Flush();
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 22
0
        void RenderReport(string rdlc, string moduleName, string key, string TypeEdition)
        {
            // CheckBox to see if there is any data
            try
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());

                DataTable Data = new DataTable();
                Data = LoadData(key, moduleName, TypeEdition);

                if (Data.Rows.Count > 0)
                {
                    List <ReportParameter> listeParam = new List <ReportParameter>();
                    if (parameter != null && parameter.Count != 0)
                    {
                        foreach (KeyValuePair <string, string> pair in parameter)
                        {
                            ReportParameter param = new ReportParameter(pair.Key, pair.Value);
                            listeParam.Add(param);
                        }
                    }

                    report.ReportPath = p.Server.MapPath("~/Reports/" + moduleName + @"/" + rdlc + ".rdlc");
                    ReportDataSource reportDataSource = new ReportDataSource(rdlc, Data);
                    report.DataSources.Add(reportDataSource);

                    if (listeParam != null & listeParam.Count > 0)
                    {
                        report.SetParameters(listeParam);
                    }
                }
            }
            catch (Exception ex)
            {
                PrintingsServiceClient printError = new PrintingsServiceClient(Protocole(), EndPoint());
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.InnerException.Message);
                throw ex;
            }
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());

                    Utilitys objetUtil       = new Utilitys(this);
                    string   rdlc            = Convert.ToString(Request.QueryString["rdlc"]);
                    string   module          = Convert.ToString(Request.QueryString["module"]);
                    string   key             = Convert.ToString(Request.QueryString["key"]);
                    string   printer         = Convert.ToString(Request.QueryString["printer"]);        //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   port            = Convert.ToString(Request.QueryString["port"]);           //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   machine         = Convert.ToString(Request.QueryString["machine"]);        //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   IscreationOnly  = Convert.ToString(Request.QueryString["IscreationOnly"]); //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    bool     _IscreationOnly = string.IsNullOrEmpty(IscreationOnly) ? false : Convert.ToBoolean(IscreationOnly);
                    string   IsLandscape     = Convert.ToString(Request.QueryString["IsLandscape"]);    //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   IsExport        = Convert.ToString(Request.QueryString["IsExport"]);       //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   FormatExport    = Convert.ToString(Request.QueryString["FormatExport"]);   //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   NomDuFichier    = Convert.ToString(Request.QueryString["NomDuFichier"]);   //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");
                    string   TypeEdition     = Convert.ToString(Request.QueryString["TypeEdition"]);    //Convert.ToString(Request.QueryString["printer"]).Replace("-_-",@"\");

                    bool _IsLandscape = string.IsNullOrEmpty(IsLandscape) ? false : Convert.ToBoolean(IsLandscape);
                    bool _IsExport    = string.IsNullOrEmpty(IsExport) ? false : Convert.ToBoolean(IsExport);

                    SessionObject.machine     = machine;
                    SessionObject.port        = port;
                    SessionObject.portService = port;

                    PrintingsServiceClient printErrosr = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                    printErrosr.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), SessionObject.machine + SessionObject.port);

                    string leChemin = printer.Replace('[', '\\');

                    if (string.IsNullOrEmpty(NomDuFichier))
                    {
                        NomDuFichier = rdlc;
                    }
                    if (!_IsExport)
                    {
                        objetUtil.CreatePDFChemin(NomDuFichier, leChemin, _IsLandscape, rdlc, module, key);
                    }
                    else
                    {
                        objetUtil.ExportChemin(NomDuFichier, leChemin, _IsLandscape, rdlc, module, key, FormatExport, TypeEdition);
                    }


                    //if ((module == "Caisse")  && !string.IsNullOrEmpty(port))
                    //    objetUtil.LaunchCashPrint(printer, module, rdlc, key, port, machine);
                    //else
                    //{
                    //    if (!_IscreationOnly)
                    //    {
                    //        string leChemin = printer.Replace('5', '\\');
                    //        objetUtil.CreatePDFChemin(rdlc, leChemin, _IsLandscape, rdlc, module, key);
                    //    }
                    //    else
                    //        objetUtil.LaunchPrinting(_IsLandscape, module, printer, rdlc, key, _IscreationOnly);
                    //}
                }
                catch (Exception ex)
                {
                    PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
                    printError.SetErrorsFromSilverlightWebPrinting(new Utilitys().GetCurrentMethod(), ex.InnerException.Message);
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());
            string retourMail = "Echec envoi mail";

            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            int bytelength = context.Request.ContentLength;

            byte[] inputbytes = context.Request.BinaryRead(bytelength);
            string message    = System.Text.Encoding.UTF8.GetString(inputbytes);

            // Toutes les clés sont concatenées dans "message",
            // il faut donc les separer et utliser chaque clé pour envoyer la facture
            string[] TousLesParametres = message.Split('/');


            foreach (string chaine in TousLesParametres)
            {
                string[] Unparametre = chaine.Split('|');
                SessionObject.machine     = Unparametre[3];
                SessionObject.portService = Unparametre[4];
                string from       = Unparametre[5];
                string subject    = Unparametre[6];
                string body       = Unparametre[7];
                string smtp       = Unparametre[8];
                string portSmtp   = Unparametre[9];
                string sslEnabled = Unparametre[10];
                string login      = Unparametre[11];
                string password   = Unparametre[12];

                Utilitys objetUtil = new Utilitys();
                string   filePath  = objetUtil.LaunchPDFgeneration(false, Unparametre[1], Unparametre[0], Unparametre[2]);
                if (objetUtil.parameter != null)
                {
                    if (objetUtil.parameter.ContainsKey("pismail"))
                    {
                        try
                        {
                            //objetUtil.LaunchPrinting(false, Unparametre[1], string.Empty, Unparametre[0], Unparametre[2], true);

                            if (!string.IsNullOrWhiteSpace(objetUtil.parameter["pismail"]))
                            {
                                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Debut lancement Mail");

                                //SendMail(objetUtil.parameter["pismail"], filePath);
                                retourMail = EnvoiMail(objetUtil.parameter["pismail"], filePath, from, subject, body, smtp, portSmtp, sslEnabled, login, password);

                                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), "Fin lancement Mail");
                            }
                        }
                        catch (Exception ex)
                        {
                            printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), retourMail + " " + ex.Message);
                            throw ex;
                        }
                    }
                }
            }
            printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), retourMail);
        }
        public string EnvoiMail(string adresse, string file, string from, string subject, string body, string smtp, string portSmtp, string sslEnabled, string login, string password)
        {
            PrintingsServiceClient printError = new PrintingsServiceClient(new Utilitys().Protocole(), new Utilitys().EndPoint());

            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  smtpServer = null;

/*                string from = System.Configuration.ConfigurationManager.AppSettings["MailSender"];
 *              string subject = System.Configuration.ConfigurationManager.AppSettings["MailSubject"];
 *              string body = System.Configuration.ConfigurationManager.AppSettings["MailBody"];
 *              string smtp = System.Configuration.ConfigurationManager.AppSettings["MailSmtp"];
 *              string port = System.Configuration.ConfigurationManager.AppSettings["MaMailPortilSmtp"];
 *              string sslEnabled = System.Configuration.ConfigurationManager.AppSettings["MailSslEnabled"];
 *              string login = System.Configuration.ConfigurationManager.AppSettings["MailLogin"];
 *              string password = System.Configuration.ConfigurationManager.AppSettings["MailPassword"];
 */

                mail.Subject = subject;
                mail.Body    = body;

                mail.IsBodyHtml      = true;
                mail.BodyEncoding    = System.Text.Encoding.UTF8;
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.From            = new MailAddress(from);


                if (IsEMailAddress(adresse))
                {
                    mail.To.Add(adresse);
                }


                Attachment maPieceJointe = new Attachment(file);
                mail.Attachments.Add(maPieceJointe);

                if (!string.IsNullOrEmpty(smtp))
                {
                    smtpServer = new SmtpClient(smtp);
                }
                if (!string.IsNullOrEmpty(portSmtp))
                {
                    smtpServer.Port = int.Parse(portSmtp);
                }
                if (!string.IsNullOrEmpty(sslEnabled))
                {
                    smtpServer.EnableSsl = bool.Parse(sslEnabled);
                }

                smtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtpServer.UseDefaultCredentials = true;
                smtpServer.Credentials           = new System.Net.NetworkCredential(login, password);

                smtpServer.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);

                smtpServer.SendAsync(mail, mail);

                return("Transmission mail OK");
            }
            catch (Exception ex)
            {
                printError.SetErrorsFromSilverlightWebPrinting(GetCurrentMethod(), ex.Message);
                return("Echec transmission mail " + ex.Message);
            }
        }