private void EnqueueDocuments(string warehouseID) { Tracing.TraceEvent(TraceEventType.Verbose, 0, "Creating print job in print queue..."); if (_receivedDocuments.Count > 0) { _printQueue.Createprintjob(warehouseID, null); } Tracing.TraceEvent(TraceEventType.Verbose, 0, "Adding documents to print queue..."); try { foreach (GenericReport d in _receivedDocuments) { if (string.IsNullOrEmpty(d.Data)) { Tracing.TraceEvent(TraceEventType.Verbose, 0, string.Format("Empty document data - document type: {0} Nothing to add.", d.MetaData.documentType)); } else { Tracing.TraceEvent(TraceEventType.Verbose, 0, string.Format("Document type = {0}.", d.MetaData.documentType)); UTF8Encoding utf8 = new UTF8Encoding(); StringWriterWithEncoding sw = new StringWriterWithEncoding(utf8); _genericReportSerializer.Serialize(sw, d); string almid = ""; try { _printQueue.Enqueuedocument(sw.ToString(), ref almid, d.MetaData.documentType, d.MetaData.documentSubType, d.MetaData.terminalIdentity, d.MetaData.printerIdentity, d.MetaData.userIdentity, d.MetaData.numberOfCopies); } catch (Exception ex) { Tracing.TraceData(TraceEventType.Error, 0, ex); throw; } } } Tracing.TraceEvent(TraceEventType.Verbose, 0, "Done adding documents."); Tracing.TraceEvent(TraceEventType.Verbose, 0, "Compleating print job in print queue..."); _printQueue.Completeprintjob(); } finally { _receivedDocuments.Clear(); } }