Skip to content

Document generation, preview, distribution and print

DocumentServiceProxy wraps the Document SOAP service (clsGenerateSoapClient) to preview a PDF, list categories/packages, and distribute or print a document package, mapping SAIF.Core document, mail, and fax contract types to the wire types on every call.

Field Value
Operation ID OP-WP-02
Trigger SAIF.Services.Utilities.Documents.DocumentService (constructed at DocumentService.cs:35), or package consumers
Inputs Package/profile/category names; DocumentGenerationConfig; MailMessage; FaxInfoClass; DeferredPrintConfig; PrintConfig
Outputs PDF bytes, sorted category/package arrays, or a distribution/print side effect
Primary components DocumentServiceProxy.PreviewPdf, GetCategories, GetPackages, DistributeDocument, DistributeDocumentDocCenter, PrintDocument
Entry point Services/SAIF.Services.Web.Proxies/DocumentServiceProxy.cs

Steps

  1. Construct DocumentServiceProxy(serviceUrl): guard serviceUrl (WP-BR-001), then build a BasicHttpBinding with MaxReceivedMessageSize and MaxArrayLength set to int.MaxValue.
  2. PreviewPdf(package, xml, profile): guard package and xml are not null/whitespace (WP-BR-001), then call wire previewDocument(package, xml, profile, inApplication: "xPression Design") (WP-BR-004) and return the PDF bytes.
  3. GetCategories(): call wire categoriesForUser(ref "xPression Design") and return the categories sorted ascending (WP-BR-005).
  4. GetPackages(category): call wire documentsForCategory(ref category, ref "xPression Design") and return the result sorted ascending (WP-BR-005).
  5. DistributeDocument(docConfig, printer, copies, plexMode, scaleMode, paperTray, imageImportSettings, mailMessage, faxInfo, deferredPrintConfig, imagePath):
  6. Guard docConfig.
  7. Map PlexMode, ScaleMode, and PaperTray by name via Helpers.MapEnumByName (WP-BR-006).
    • On failure: an unmatched enum name throws ArgumentNullException.
  8. Map MailMessage to EmailInfoClass, setting BCC/CC only when non-empty; a null message produces a null result (WP-BR-007).
  9. Map DeferredPrintConfig to DeferredPrintInfoClass, copying SortField0–SortField9 into Sort0Value–Sort9Value; a null config produces null.
  10. Call wire distributeDocument(inPackage, inXML, inPrinter, inMode, inCopies, inScaleMode, inOutputProfile, inImportInfo, inEmailInfo, inFaxInfo, inIDMPath, inTray, inDeferredInfo, inApplication) with docConfig.OutputProfile, fax info forced to null (WP-BR-008), and application "xPression Design".
    • Note: the faxInfo string parameter is ignored; it is suppressed via CA1801.
  11. DistributeDocumentDocCenter(docConfig, printer, copies, plexMode, scaleMode, paperTray, imageImportSettings, mailMessage, faxInfo, deferredPrintConfig, imagePath): the same mapping as step 5, with these differences:
  12. Uses docConfig.OutputProfileOverride.
  13. Maps FaxInfoClass to the wire FaxInfoClass only when ToFaxNumber is non-empty; otherwise fax is null (WP-BR-009).
  14. Uses docConfig.ApplicationName when set, falling back to "xPression Design" (WP-BR-004).
  15. On failure: a null faxInfo argument throws NullReferenceException, because MapFaxMessage dereferences it without a guard.
  16. PrintDocument(docConfig, printConfig): guard both arguments, then call wire distributeDocument with the printer, plex, copies, scale, and tray taken from printConfig, docConfig.OutputProfile, empty import info and IDM path, null email/fax/deferred info, and application "xPression Design".

Process flow

The following diagram visualizes the branch between preview/catalog reads and the distribution/print write path.

flowchart TD
    Start([Caller invokes wrapper method]) --> Which{Which method?}
    Which -->|PreviewPdf| Guard1[Guard package/xml] --> Preview[Call previewDocument] --> RetPdf([Return PDF bytes])
    Which -->|GetCategories/GetPackages| Cat[Call wire operation] --> Sort["Sort result ascending"] --> RetSorted([Return sorted array])
    Which -->|Distribute or Print| MapEnums["Map Plex/Scale/Tray by name"] --> MapMail["Map MailMessage,<br>DeferredPrintConfig, FaxInfoClass"] --> Dist[Call distributeDocument] --> RetDist([Distribution side effect])

Failure and edge-case behavior

  • A null/whitespace package, xml, or serviceUrl throws an argument exception before the wire call.
  • An unmatched enum name in Helpers.MapEnumByName throws ArgumentNullException.
  • DistributeDocumentDocCenter throws NullReferenceException on a null faxInfo argument.
  • DistributeDocument's faxInfo string parameter is always ignored, which is a documented parameter-mismatch finding rather than a defect in this operation's contract.

Sources

  • Services/SAIF.Services.Web.Proxies/DocumentServiceProxy.cs
  • Services/SAIF.Services.Web.Proxies/Helpers.cs