W
wksdgy
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Umanger_thread;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, Grids, DBGrids,StrUtils, ActiveX,
ComCtrls, OoMisc, AdPort,Registry,Buttons,DBCtrls,ImgList, Mask, CRGrid,MsgExch,
Ora, Tel_DM,
OraSmart, MemDS, DBAccess,IdUDPServer,Ubwfy_tread,OraProvider,DBClient,Provider;
type
Tmanger_thread = class(TThread)
private
{ Private declarations }
my_memo1:tmemo;
local_OraSession: TOraSession;
cur_bw_dataset:TOraQuery;
protected
procedure resolve_data;
procedure create_orasession;
procedure Execute;
override;
public
constructor create(memo1:tmemo);
destructor Destroy;
override;
end;
var
manger_thread_session: Tmanger_thread;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure Tmanger_thread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end;
}
{ Tmanger_thread }
constructor Tmanger_thread.create(memo1: tmemo);
begin
my_memo1:= memo1;
create_orasession;
freeonterminate:=true;
inherited Create(False);
end;
procedure Tmanger_thread.create_orasession;
begin
CoInitialize(nil);
local_OraSession:=TOraSession.Create(nil);
local_OraSession.ConnectString:='bwxx/bwxx@127.0.0.1:1521:bwxx';
local_OraSession.Options.Net:=true;
local_OraSession.ConnectPrompt:=false;
local_OraSession.AutoCommit:=true;
local_OraSession.Connected := false;
cur_bw_dataset:=TOraQuery.Create(nil);
cur_bw_dataset.Session:=local_OraSession;
end;
destructor Tmanger_thread.Destroy;
begin
try
freeandnil(cur_bw_dataset);
local_OraSession.Connected:=false;
freeandnil(local_OraSession);
CoUnInitialize;
inherited;
except
end;
end;
procedure Tmanger_thread.Execute;
var
str1,xh,m_ysbw:string;
mysql:string;
begin
try
while truedo
begin
if (cur_bw_dataset.Eof) then
begin
cur_bw_dataset.Close;
cur_bw_dataset.SQL.Clear;
mysql:='select myid,mybwxx from bwxx where rownum<30 order by myid';
cur_bw_dataset.SQL.Add(mysql) ;
cur_bw_dataset.Open;
end ;
cur_bw_dataset.First;
while not cur_bw_dataset.Eofdo
begin
m_ysbw:= cur_bw_dataset.fieldbyname('mybwxx').AsString;
xh:= cur_bw_dataset.fieldbyname('myid').AsString;
if (cur_tread_num<max_tread) then
begin
if manager_list.IndexOf(xh)<0 then
begin
bwfy_session:=TBWFY_TREAD.create(m_ysbw,my_memo1,xh);
end;
cur_bw_dataset.Next;
end;
sleep(1);
application.ProcessMessages;
end;
sleep(1000);
application.ProcessMessages;
end;
except
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, Grids, DBGrids,StrUtils, ActiveX,
ComCtrls, OoMisc, AdPort,Registry,Buttons,DBCtrls,ImgList, Mask, CRGrid,MsgExch,
Ora, Tel_DM,
OraSmart, MemDS, DBAccess,IdUDPServer,Ubwfy_tread,OraProvider,DBClient,Provider;
type
Tmanger_thread = class(TThread)
private
{ Private declarations }
my_memo1:tmemo;
local_OraSession: TOraSession;
cur_bw_dataset:TOraQuery;
protected
procedure resolve_data;
procedure create_orasession;
procedure Execute;
override;
public
constructor create(memo1:tmemo);
destructor Destroy;
override;
end;
var
manger_thread_session: Tmanger_thread;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure Tmanger_thread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end;
}
{ Tmanger_thread }
constructor Tmanger_thread.create(memo1: tmemo);
begin
my_memo1:= memo1;
create_orasession;
freeonterminate:=true;
inherited Create(False);
end;
procedure Tmanger_thread.create_orasession;
begin
CoInitialize(nil);
local_OraSession:=TOraSession.Create(nil);
local_OraSession.ConnectString:='bwxx/bwxx@127.0.0.1:1521:bwxx';
local_OraSession.Options.Net:=true;
local_OraSession.ConnectPrompt:=false;
local_OraSession.AutoCommit:=true;
local_OraSession.Connected := false;
cur_bw_dataset:=TOraQuery.Create(nil);
cur_bw_dataset.Session:=local_OraSession;
end;
destructor Tmanger_thread.Destroy;
begin
try
freeandnil(cur_bw_dataset);
local_OraSession.Connected:=false;
freeandnil(local_OraSession);
CoUnInitialize;
inherited;
except
end;
end;
procedure Tmanger_thread.Execute;
var
str1,xh,m_ysbw:string;
mysql:string;
begin
try
while truedo
begin
if (cur_bw_dataset.Eof) then
begin
cur_bw_dataset.Close;
cur_bw_dataset.SQL.Clear;
mysql:='select myid,mybwxx from bwxx where rownum<30 order by myid';
cur_bw_dataset.SQL.Add(mysql) ;
cur_bw_dataset.Open;
end ;
cur_bw_dataset.First;
while not cur_bw_dataset.Eofdo
begin
m_ysbw:= cur_bw_dataset.fieldbyname('mybwxx').AsString;
xh:= cur_bw_dataset.fieldbyname('myid').AsString;
if (cur_tread_num<max_tread) then
begin
if manager_list.IndexOf(xh)<0 then
begin
bwfy_session:=TBWFY_TREAD.create(m_ysbw,my_memo1,xh);
end;
cur_bw_dataset.Next;
end;
sleep(1);
application.ProcessMessages;
end;
sleep(1000);
application.ProcessMessages;
end;
except
end;
end;
end.