Subject | Re: createing and using events |
---|---|
Author | mikcaau |
Post date | 2005-07-13T03:41:37Z |
--- In firebird-support@yahoogroups.com, Grant Brown <grant@s...> wrote:
Here are some simple things to do.
1) Use a client dataset for you list
2) Make an after insert trigger in your database for the table that
supplies your list like
set term ^ ;
create Trigger Lu_List_Table_An for Lu_list_Table
active
after insert
position 50 /*put events at end of trigger run */
as
begin
Post_Event 'NEW_LOOKUP_ITEM' /*events are case sensitive */
end
^
set term ; ^
Now go back to your program
Drop a TSIBEventAlerter on to your datamodule.
add the value NEW_LOOKUP_ITEM to Events list
create a TSIBAlertEvent procedure for OnEventAlert
like
procedure TForm1.MainLertOnEventAlert(Sender: TObject; EventName:
string; EventCount: Longint);
begin
if EventName = 'NEW_LOOKUP_ITEM' then begin
//now you need to find your list
//and repopulate it
if you are using a TClientSet to populate your list do something like
Select Id, ItemName
from Lu_list_Table;
ExecSql;
while not eof do begin
if not FindIdInList(fieldByName('Id').asInteger) then begin
with ClientDs do begin
insert new row, and set values from your query.
end;
end;
end;
Events are easy to use.
I have a passenger dispatch system running. There are several vehicles
which represent themselves as bus queues TListViews (a bit like M$
print queues).
Passengers can be dragged from one vehicle and dropped in another.
When that happens passenger objects call an update sql that changes
their vehicle id.
This causes an event to fire and any user with dispatch open receives
the event.
I delay a response by random(10 seconds) to avoid overloading the server.
When a queue gets around to responding to the event it just runs a
select that returns all passengers assigned to it. It removes those it
found in the view but not in the select and adds those it found in the
select and not in the view.
All this happens in an idle moment.
I have observed dispatchers playing something like passenger ping pong
(when they thought I wasn't looking).
ListViews enable me to do quite a bit behind the scene without
distracting users.
mick
> Hi all,edit as
>
> Using Delphi 5, FB 1.5 (ss mode) and FIBPlus
>
> We have an app that has custom drop down lists that any user can
> required ie they can edit the contents of the drop down lists to suitthey
> there own needs.
>
> A problem has arisen in that when one user changes the contents of the
> drop down list the other users dont see the new list contents until
> re-log in to the database.<<snip>>
>
> Product Development ManagerGrant,
Here are some simple things to do.
1) Use a client dataset for you list
2) Make an after insert trigger in your database for the table that
supplies your list like
set term ^ ;
create Trigger Lu_List_Table_An for Lu_list_Table
active
after insert
position 50 /*put events at end of trigger run */
as
begin
Post_Event 'NEW_LOOKUP_ITEM' /*events are case sensitive */
end
^
set term ; ^
Now go back to your program
Drop a TSIBEventAlerter on to your datamodule.
add the value NEW_LOOKUP_ITEM to Events list
create a TSIBAlertEvent procedure for OnEventAlert
like
procedure TForm1.MainLertOnEventAlert(Sender: TObject; EventName:
string; EventCount: Longint);
begin
if EventName = 'NEW_LOOKUP_ITEM' then begin
//now you need to find your list
//and repopulate it
if you are using a TClientSet to populate your list do something like
Select Id, ItemName
from Lu_list_Table;
ExecSql;
while not eof do begin
if not FindIdInList(fieldByName('Id').asInteger) then begin
with ClientDs do begin
insert new row, and set values from your query.
end;
end;
end;
Events are easy to use.
I have a passenger dispatch system running. There are several vehicles
which represent themselves as bus queues TListViews (a bit like M$
print queues).
Passengers can be dragged from one vehicle and dropped in another.
When that happens passenger objects call an update sql that changes
their vehicle id.
This causes an event to fire and any user with dispatch open receives
the event.
I delay a response by random(10 seconds) to avoid overloading the server.
When a queue gets around to responding to the event it just runs a
select that returns all passengers assigned to it. It removes those it
found in the view but not in the select and adds those it found in the
select and not in the view.
All this happens in an idle moment.
I have observed dispatchers playing something like passenger ping pong
(when they thought I wasn't looking).
ListViews enable me to do quite a bit behind the scene without
distracting users.
mick