Solved

preventing paint of DbctrlGrid panel or deleting after fill

Posted on 2009-07-16
8
841 Views
Last Modified: 2013-11-23
I am developing an application which queries a db for a file/exe path, among other things.  If the application exists, the grid should be populated.  If the application does not, I need to skip the resultset row or delete/hide the filled panel.  (ex. if quickbooks exist on a client machine, paint else move to the next rs row or delete the painted panel.

For the life of me, I can't work this out.  

I'm hoping someone here may have some suggestions.

*btw, I tried an alternative in iterating through the result set for the apppath; if the exe exists, proceed; else delete/filter the resultset row -no luck here either.....


Thanks in advance,

R Davis
0
Comment
Question by:brparrish
  • 3
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:gtrifidis
Comment Utility
You could this :

1) Add a flag field into the table that stores the exe's path. Let's say APP_EXISTS type integer
    App Exists value = 1, App does not exist value = 0.
2) Write a procedure that updates the flag according to the existance of the file

3)Select from the database only the records that the application exists using the flag in the query
e.g
Select * from TABLENAME where APP_EXISTS = 1
and you will get only the records you want to display without trying to override the paint procedure of the grid.
0
 

Author Comment

by:brparrish
Comment Utility
Yep, I thought about that, trouble is 100 people will use this daily, so modifying the DB isn't really an option.  I thought about an ADOtable on the form also, drop the dataset there, then read the results to appropriate fields.....that doesn't really seem viable either, but may be my only option.  -Thanks for your input
0
 
LVL 2

Expert Comment

by:gtrifidis
Comment Utility
Well in my opinion you can implement this making a thread that will run to update the DB.
If you have to mofidy this table daily you could make a separate exe to run as a service
and make a scheduler to run on a spesific interval.

AdoTable is good but pretty slow try to do it using SQL and AdoTables this will speed up 100% the proccess specially if the DB Engine is MS SQL,MySQL generally a good DB engine.

If you could explain more the logic you want to implement maybe more ideas will appear.

0
 

Author Comment

by:brparrish
Comment Utility
Well, in a nutshell....we write a lot of software which is pushed out to our users.  Historically, we publish the shortcuts for these apps via GPO.  I'm trying to overcome that.  A db will host the name, appGroup, description and path of the exe.  Additionally, this app will also include apps like, IE, Outlook, Word, Excel etc....(in effort to clean the desktop).

So changing the DB isn't really a good option for me as up to 100 users will hit this app between 8:30 -9:00a.

What happens now (and this all works, w/exception of hiding local apps that aren't installed ex; Quickbooks).

query: select * from desktop_ui >> open dataset >> while not eof, fill panel fields w/the app name, description and group membership >> In an onpaintpanel event, take the exe path from the dataset; extract the icon or associated icon (if the object is a file, .pdf etc) and fill image1 w/it.

This all works great w/exception of the panels I'd like omitted/not-painted or skipped.

For example:  I've set an erroneous path for IE7  -however, db fields are populated -only image1 is skipped (because the icon can't be found)

I've tried checks such as fileexists()   -no dice.

For kicks, I've set silly behavior like changing the back color if the app is not found  -this works, so I know the if statement is good.  I just can't seem to find a way to remove or omit cells that don't apply to the respective user.

It is that dead end that got me focusing on a table to filter the rows prior to filling.


Hope this helps,

R Davis
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
you have a form which is prepolutated with panels for all your apps ?

why not just change the visibilty of the panel ?

this is a little obscure as to what your form looks like
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
the first time you load this thing, i agree it would take some time to find all the apps installed
why not save a TClientDataSet to a local file once processed
and then load from this local file the next time

you would use a thread to load all the possible apps from the db
and process which ones are available in this thread
within this thread you can then recreate the local file

opening the app the first time would be slow possibly
the second time, instant, and in the background it would be running the thread to check for new versions
0
 

Accepted Solution

by:
brparrish earned 0 total points
Comment Utility
I actually received some help w/this via the delphi forums.....silly how simple is was:

procedure TForm1.rsFilterRecord(DataSet: TDataSet; var Accept: Boolean);
begin
  Accept := FileExists(rs.FieldByName('AppExePath').AsString);
end;

in the form create:

rs.Filtered := True;  -crazy!


Thanks to all for your input.

R Davis
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
it will still take a while to load your dataset
and will take a time to show your form as you do this in the formcreate
you may have to add a waiting cursor or even a form displaying it's busy
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now