Summary
We have an ASP.NET application that allows users to query a SQL Server Database through a middle layer (pretty standard stuff). When the user attempts to generate a PDF for the rows that were returned to them. Each set of rows with a common identifier will “turn into” a separate page in the resulting PDF.
Originally, I assumed that the number of rows would be of an order of magnitude that was conducive to piping the end PDF into the ASP Response stream and letting the user download the file to their machine, but newer requirements indicate that the number of rows is very large and vastly outside of the scale for which I had designed this.
My current solution is as follows:
-
If the returned row count is larger than a configured
thresholdvalue, the user gets a message that asks whether or not they want to generate the PDF’s in the background and be notified by email with a URL when its done, so they can download them. -
If acceptable to the user, I create two
DataTables: One with the actual data, and one with MetaData such as where to save the resulting PDF, the name, and other meta-type information. -
I can then use
DataTable.WriteXMLto generate a “job” file in a particular folder. -
This is all done in a separate Thread, so the User can continue doing what they want.
Problem:
I really want to store the job xml file on a machine inside our firewall (shared network folder), but It seems I cannot for security reasons. I have been told I might want to use Impersonation and have tried but could not get it to work.
The other part of this application is something that “listens in” to the “input” folder, and processes these “job” files once every hour (or similar schedule), moves the generated PDF file to the requisite location and emails the user.
I have gotten the part that reads job files and generates the PDF working, and the part that creates the job files works (when I run it inside the firewall), but when I run it outside the firewall, even attempting impersonation, it does not work. (keeps saying “Network location not found”.
Question(s):
Am I going about this the right way?
How do I write these files across the firewall?
Any design ideas or suggestions?
Thanks in advance.
How I solved this was to create a table called PDFJobs on our database.
This table contained the Criteria used to run the report as well as the desired template folder and file, the target folder and filename for the resulting PDF.
I then wrote a command line tool (PDFGenerator) which reads from this table, and for each row, creates a separate thread which performs the PDF generation. Once the PDF is generated, it sends an email out to an email address (also contained in the table).
Then I have a windows scheduled task which runs that PDFGenerator tool every hour.
It’s not idea, but it does the job.
A recent update is that they want something that will trigger the PDFGenerator whenever a job row is created…I guess I will have to do some more thinking about that one.