예제 #1
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;
            }
        }