BIRT extension for execute after each generation - birt

I need to create an extesion to "cleanup" some things after each report generation, the output format does not matter.
I need this because I created a script function extension to obtain a JDBC connection inside the scripts.
If the programmer forget to close this connection the "Cleanup Extension" must do the dirty work (like a garbage collector).
What extension I need to extend to do this?

You could use a invisible layout element at the very end of your report and add the cleanup code to its onCreate event (if you are using RunAndRenderTask).

Related

Does the VB6 compiler actually run the ActiveX during the Build process? [duplicate]

I am trying to compile a VB6 application, but it fails with the error, "Run-time error '91': Object variable or With block variable not set". It turns out the Resize event of a user control is firing during compilation and calling code that attempts to access an object that has not been instantiated yet.
Why is an event firing during compilation and is there any way to stop it?
Edit: I had some code here, but it's not relevant. The problem results from the fact that UserControl code (namely the Initialize, ReadProperties, Resize, and WriteProperties events) can execute at unexpected times. If the code in these events relies on other code to initialize any of its data structures, there's a good chance it's going to fail because that initialization code may not have executed. Especially during compilation when nothing is supposed to be executing! I'd call this a bug, but I'm sure Microsoft can rationalize it somehow.
Here's is a good article on the lifecyle of user control events
Understanding Control Lifetime and Key Events
Here is one snippet
Compiling the Project
When the project is compiled into an
application or component, Visual Basic
loads all the form files invisibly,
one after another, in order to write
the information they contain into the
compiled file. A control instance gets
the Initialize, ReadProperties, and
WriteProperties events. The control's
property settings are compiled into
the finished executable.
It doesn't mention resize (which happens during run-time or when you physically resize the usercontrol on a container in design-time). Maybe your Initialize event is resizing the user control?
To avoid the error you can check if the offending object has been created before doing anything:
If Not Object Is Nothing then
do something
I think some events for user controls get executed during design time, at least for the purpose of rendering them in a consistent way.

Remove Error handler code from vb6 codes auto

I have used one error handler code in my all vb6 projects,
Now I have to remove that error handler code which is in all sub procedures, functions.
I have to remove it manually all the time can it be removed automatically
I approached a task similar to this one time by writing a small program that would
1) read the project's vbp file and retrieve the names of all the files in a project
and
2) would then edit each of these files and make the desired changes.

VB run code on start of the application

I am a Java programmer and don't know much about VB.
My task:
Create an exe. When I run the exe it will read a text file, and after that it will display the content. After that the application code ends.
What i have done:
I have created a project and created a button on the form. On click of the button I have given the option to read.
Problem
I am not able to find the event which has to be used to run code on start up and code to end the application when my task completes.
Please help me with the process which I have to follow. If the code is provided, it's best, but if somebody knows any web resources it will also be a great help.
You can create a Visual Basic 6 program to run without any form.
You need to create a module. Put a Public Sub Main inside of it.
Then in under Project Properties, General Tab; change the startup object to be Sub Main.
To do something at form's start up, use Form_Load() event.
To close a form, use unload me.
To close your application, use end.
Hope this solves your problem. If not, you are welcome for further queries.

VB6 - Inet hangs - multiple form instances

Here is my app status:
Purpose - download multiple list files from internet
Approach - created a simple "download form". After a while, I just needed more forms because I had more than one list of files to download. Just solved that by adding a MDIform to my project, add a button to create another "download form" instance and voilĂ . Apparently, my problem was solved. But no :(
When I press my "download" button in my form-instance3, the other form instances (2 and 1) hangs on downloading the contents (I get a timeout sometimes) until the form-instance3 terminates all the downloads and so on, for all the other forms. So, even though I know my app is not multi-threaded, the multiple instances of the same form are in conflict (Inet component, presumably) and I can't download multiple files at the same time.
Inet and my download function are defined in the form.
What can I do to solve this? how can I download multiple files at the same time?
edit:
I'm trying to use the "wqw" suggestion, but I'm facing some problems:
In the download_form, I have a MSHFlexgrid, with 2 columns: one with the URL and the other with the file destiny. I was iterating throw all rows to download the files and save them. With the approach suggested by "wqw", how can I distinguish each download so that I can save it with the properly name indicated in the grid?
What do you use for the actual http download? I would try Simple Asynchronous Downloads and forget about the MDIForm. Really!
VB6, on its own, is single threaded. So breaking out downloading to different forms won't help you.
What I've used in the past is the Timer object in conjunction with an ActiveX EXE. This approach will give you an ability to localize all the downloading logic in one place, control it like you control a regular object and have it run in a separate EXE, thus by default making it multi-threaded.
So the way this works is like so:
You call the Download method on the ActiveX EXE object
In the download method, you instantiate the Timer and have it kick off almost immediately.
You get out of the Download method, thus giving control back to the entity that called it.
Then you communicate back to the main app via Events (e.g. DownloadProgress or DownloadComplete, etc...)

Why is an event firing during compilation of a VB6 app?

I am trying to compile a VB6 application, but it fails with the error, "Run-time error '91': Object variable or With block variable not set". It turns out the Resize event of a user control is firing during compilation and calling code that attempts to access an object that has not been instantiated yet.
Why is an event firing during compilation and is there any way to stop it?
Edit: I had some code here, but it's not relevant. The problem results from the fact that UserControl code (namely the Initialize, ReadProperties, Resize, and WriteProperties events) can execute at unexpected times. If the code in these events relies on other code to initialize any of its data structures, there's a good chance it's going to fail because that initialization code may not have executed. Especially during compilation when nothing is supposed to be executing! I'd call this a bug, but I'm sure Microsoft can rationalize it somehow.
Here's is a good article on the lifecyle of user control events
Understanding Control Lifetime and Key Events
Here is one snippet
Compiling the Project
When the project is compiled into an
application or component, Visual Basic
loads all the form files invisibly,
one after another, in order to write
the information they contain into the
compiled file. A control instance gets
the Initialize, ReadProperties, and
WriteProperties events. The control's
property settings are compiled into
the finished executable.
It doesn't mention resize (which happens during run-time or when you physically resize the usercontrol on a container in design-time). Maybe your Initialize event is resizing the user control?
To avoid the error you can check if the offending object has been created before doing anything:
If Not Object Is Nothing then
do something
I think some events for user controls get executed during design time, at least for the purpose of rendering them in a consistent way.

Resources