public IPrintResult Print(IPrintData printData)
 {
     this.printServiceNotificationProvider.AddSubscription(printData.PrintJobIInfo, this.printManagerNotificationHandler);
     IPrintManager printManager = this.printManagerChannelFactory.CreateManager(printData.PrintJobIInfo.Key);
     try
     {
         printManager.Print(printData.PrintJobIInfo, printData.Source, printData.Settings, printData.GetDatasource());
         return null;
     }
     catch (CommunicationException communicationException)
     {
         this.printServiceNotificationProvider.RemoveSubscription(printData.PrintJobIInfo);
         return new PrintErrorResult(printData.PrintJobIInfo) { Reason = FailReason.ServiceUnavailable, ReasonCode = communicationException.GetExceptionMessage() };
     }
 }
 public IPrintResult Print(IPrintData printData)
 {
     AutoResetEvent autoResetEvent = this.printServiceNotificationProvider.AddNotification(printData.PrintJobIInfo);
     IPrintManager printManager = this.printManagerChannelFactory.CreateManager(printData.PrintJobIInfo.Key);
     try
     {
         printManager.Print(printData.PrintJobIInfo, printData.Source, printData.Settings, printData.GetDatasource());
         if (autoResetEvent.WaitOne(printData.Settings.Timeout))
         {
             return this.printServiceNotificationProvider.GetResponse(printData.PrintJobIInfo);
         }
         else
         {
             return new PrintErrorResult(printData.PrintJobIInfo) { Reason = FailReason.Timeout, ReasonCode = "Service Timeout. No Response returned after given time" };
         }
     }
     catch (CommunicationException communicationException)
     {
         return new PrintErrorResult(printData.PrintJobIInfo) { Reason = FailReason.ServiceUnavailable, ReasonCode = communicationException.GetExceptionMessage() };
     }
 }
Example #3
0
        public IPrintResult Print(IPrintData printData)
        {
            AutoResetEvent autoResetEvent = this.printServiceNotificationProvider.AddNotification(printData.PrintJobIInfo);
            IPrintManager  printManager   = this.printManagerChannelFactory.CreateManager(printData.PrintJobIInfo.Key);

            try
            {
                printManager.Print(printData.PrintJobIInfo, printData.Source, printData.Settings, printData.GetDatasource());
                if (autoResetEvent.WaitOne(printData.Settings.Timeout))
                {
                    return(this.printServiceNotificationProvider.GetResponse(printData.PrintJobIInfo));
                }
                else
                {
                    return(new PrintErrorResult(printData.PrintJobIInfo)
                    {
                        Reason = FailReason.Timeout, ReasonCode = "Service Timeout. No Response returned after given time"
                    });
                }
            }
            catch (CommunicationException communicationException)
            {
                return(new PrintErrorResult(printData.PrintJobIInfo)
                {
                    Reason = FailReason.ServiceUnavailable, ReasonCode = communicationException.GetExceptionMessage()
                });
            }
        }
        public IPrintResult Print(IPrintData printData)
        {
            this.printServiceNotificationProvider.AddSubscription(printData.PrintJobIInfo, this.printManagerNotificationHandler);
            IPrintManager printManager = this.printManagerChannelFactory.CreateManager(printData.PrintJobIInfo.Key);

            try
            {
                printManager.Print(printData.PrintJobIInfo, printData.Source, printData.Settings, printData.GetDatasource());
                return(null);
            }
            catch (CommunicationException communicationException)
            {
                this.printServiceNotificationProvider.RemoveSubscription(printData.PrintJobIInfo);
                return(new PrintErrorResult(printData.PrintJobIInfo)
                {
                    Reason = FailReason.ServiceUnavailable, ReasonCode = communicationException.GetExceptionMessage()
                });
            }
        }