Plugin SQL intercept  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Plugin SQL intercept

Postby neil.interactit » Mon Mar 04, 2024 2:50 pm

Hey guys,

James just hit me with a question that I thought best to raise with you. When he upgrades a client Jiwa 6 to Jiwa 7, he ends up - on a case by case basis - with an extensive list of changes to be made, each time he runs through the upgrade. This is essentially a OneNote list he reads through and repeats in Jiwa. Inevitably, at 3am when doing the actual upgrade, a silly mistake snowballs into huge issues.

So his question "can you sniff the SQL updates as I make changes in Jiwa so that I can compile these into a script to re-run each test run".

While I can do this SQL-side, independently of Jiwa, the SQL is pretty noisy, and complicated by multiuser access. Better, if possible to do this Jiwa-side.

So my question - would it be possible, from a plugin, to intercept ALL database calls in order to log these? If so, then I can filter out INSERT/UPDATE/DELETE/EXECs and probably even annotate with the calling form. I would probably also work out some way of providing a logging on/off control, so that only specific UI-generated changes of interest are logged.

Is this at all possible, or am I barking up the wrong tree?

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Plugin SQL intercept

Postby SBarnes » Mon Mar 04, 2024 6:11 pm

You can get reads from the readerexecuted event on the database property the manager its signature is below


Code: Select all
 public delegate void ReaderExecutedEventHandler(SqlCommand SQLCommand, CommandBehavior CommandBehaviour);



Given all business objects inherit from the same maintenance object that implements IJiwaSaveable which is below, you can latch onto the save events and use the lcient property on maintenace to get you the form but that won't actually get you the SQLs, but you could serailise out the objects and work from there.

Code: Select all
namespace JiwaFinancials.Jiwa.JiwaApplication
{
    [CLSCompliant(true)]
    public interface IJiwaSaveable
    {
        bool ChangeFlag
        {
            get;
            set;
        }

        void iSave();

        void Save();

        event IJiwaCommonInterfaces.SaveEndDelegate SaveEnd;

        event IJiwaSaveable.SaveEndingEventHandler SaveEnding;

        event IJiwaSaveable.SaveStartEventHandler SaveStart;

        public delegate void SaveEndingEventHandler(object sender, EventArgs e);

        public delegate void SaveStartEventHandler(object sender, EventArgs e);
    }
}


If you can get the SQLs you need to run one other option would be to add these to the scripts database and have Jiwa run them for you as part of the upgrade process.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Plugin SQL intercept  Topic is solved

Postby Mike.Sheen » Fri Mar 22, 2024 10:50 am

neil.interactit wrote:While I can do this SQL-side, independently of Jiwa, the SQL is pretty noisy, and complicated by multiuser access. Better, if possible to do this Jiwa-side.


Nonsense - I do this all the time on very busy live customer environments using SQL Profiler and using the ClienProcessID filter to limit the sql captured to be ONLY what is run in my Jiwa session.

You get the client process ID from the Jiwa About dialog accessible from any form in the application, and then when you launch a profile trace add a filter to only include SQL commands for that specific ClientProcessID.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Plugin SQL intercept

Postby neil.interactit » Fri Mar 22, 2024 10:54 am

Thanks Stuart.
Thanks Mike.

I'll sort something for James on this basis.

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 14 guests

cron