Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Report Listener Data Session Problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de rapports & Rapports
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01355732
Message ID:
01357015
Vues:
29
Ok, here's what I have. It's a bit long, but here goes....

I am using Lisa Nicholls' PDF Listener class found here http://msdn.microsoft.com/en-us/library/ms947696.aspx

I wrote a small wrapper around it:
DEFINE CLASS ReportExtender AS Custom

	** Hidden/ protected properties
	HIDDEN _oPDFListener	&& Object reference to the PDFListener class
	HIDDEN _oHTMLListener	&& Object reference to the HTMLListener class

	** Public properties
	sGSLocation = ADDBS(FULLPATH(".\GS"))	&& Location of the GhostScript files (PDF only)

	PROCEDURE RunReport(oReportParams AS Object)

		LOCAL oListener AS Object
		LOCAL sExtension AS String
		LOCAL sFileName AS String
		oListener = NULL
		sExtension = ""

		WITH This
		
			** Set the data session to ensure that the report's data is avaialble
			SET DATASESSION TO (oReportParams.iDataSession)
		
			** Determine which listener to call into 
			DO CASE
				
				CASE oReportParams.iReportType = REPORT_TYPE_PDF
					oListener  = ._oPDFListener
					sExtension = "pdf"
					
				CASE oReportParams.iReportType = REPORT_TYPE_HTML
					oListener  = ._oHTMLListener 
					sExtension = "html"
			ENDCASE

			** If no destination file name was passed in...
			IF EMPTY(oReportParams.sFileName)
				** Create a file name located in the user's temp folder
				sFileName = GETENV("TEMP")
				sFileName = ADDBS(sFileName) + SYS(2015) + "." + sExtension
			ELSE
				** Use the name passed on the params object
				sFileName = oReportParams.sFileName
			ENDIF
		
			** Set the file destination file name on the report listener class
			oListener.TargetFileName = sFileName 
			oListener.QuietMode = TRUE
			
			** Add the report to the listener class' reports collection
			oListener.AddReport(oReportParams.sReportFile)
			
			** Call into the PDFListener class's RunReport method
** EXECUTING THIS LINE WILL CAUSE THE DATA SESSION TO CHANGE
			oListener.RunReports()

	ENDPROC
The Init of my wrapper has:
** Create an instance of the listener class
._oPDFListener = CREATEOBJECT("PDFListener")

** Set up needed properties on the listener class
._oPDFListener.GSLocation  = .sGSLocation 
._oPDFListener.PSDriverSetupName = DRIVER_NAME
._oPDFListener.GenerateNewStyleOutput = .F.
Lisa has overwritten the RunReport method in her class:
   PROCEDURE RunReports(tlRemoveReportsAfterRun, tlOmitListenerReferences)
      IF (NOT ISNULL(THIS.ReportFileNames)) AND ;
         (NOT EMPTY(THIS.ReportFileNames[1])) AND ;
         THIS.LoadPrinterInfo()
         IF EMPTY(JUSTEXT(THIS.TargetFileName))
            THIS.TargetFileName = FORCEEXT(THIS.TargetFileName,THIS.TargetFileExt)
         ENDIF   
         THIS.verifyTargetFile()
         IF PCOUNT() = 2 OR VARTYPE(THIS.generateNewStyleOutput) # "L"
            DODEFAULT(.F., tlOmitListenerReferences)
         ELSE
            DODEFAULT(.F.,NOT THIS.generateNewStyleOutput)
         ENDIF   
         THIS.UnloadPrinterInfo()
         RETURN THIS.ProcessPDF(tlRemoveReportsAfterRun)
      ELSE
         RETURN .F.   
      ENDIF   
   ENDPROC
So, the moment the debugger steps into the line:
PROCEDURE RunReports(tlRemoveReportsAfterRun, tlOmitListenerReferences)
the datasession changes.

Sorry for the long post, but I'm not sure how else to explain what I'm seeing.

Thanks
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform