📄 main.~pas
字号:
sqlstr:= sqlstr + ' where (DATEDIFF(second,'+''''+datetimetostr(time1)+''''+',play_time)) <='+inttostr(difftime) ;
sqlstr:= sqlstr + ' and play_time >'+''''+'1900/01/01'+'''';
sql.Add(sqlstr) ;
open;
end;
if QWating.IsEmpty then exit;
try
BatchMove1.Execute;
except on e:exception do
begin
if LogRec.s_time='' then
begin
logrec.s_funcname:='T_waittonowTimer';
logrec.s_oper :='执行BatchMove1操作';
logrec.s_result :='失败';
logrec.s_errcode :='0';
logrec.s_err :=e.Message;
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
exit; //错误
end;
end;
try
QWating.Close;
with Qdelewait do
begin
close;
SQl.Clear;
SqlStr:='' ;
SqlStr:='delete from dg_waiting_data with(rowlock) ';
sqlstr:= sqlstr + ' where (DATEDIFF(second,'+''''+datetimetostr(time1)+''''+',play_time)) <='+inttostr(difftime) ;
sqlstr:= sqlstr + ' and play_time >'+''''+'1900/01/01'+'''';
sql.Add(sqlstr) ;
ExecSQL ;
end;
except on e:exception do
begin
if LogRec.s_time='' then
begin
logrec.s_funcname:='T_waittonowTimer';
logrec.s_oper :='删除dg_waiting_data操作';
logrec.s_result :='失败';
logrec.s_errcode :='0';
logrec.s_err :=e.Message;
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
end;
end;
end;
procedure TFrmMain.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
var
i:integer;
is_success:boolean;
begin
is_success:=false;
for i:=0 to aryclientnum do
begin
//在原有的客户端连接数组中有中断的客户端连接
if not aryclient[i].CUsed then
begin
aryclient[i].CHandle := Socket.SocketHandle ;//客户端套接字句柄
aryclient[i].CSocket := Socket; //客户端套接字
aryclient[i].CName := Socket.RemoteHost ; //客户端计算机名称
aryclient[i].CAddress := Socket.RemoteAddress ;//客户端计算机IP
aryclient[i].CUsed := True; //连接数组当前位置已经占用
is_success:=true;
Break;
end;
end;
if not is_success then
begin
inc(aryclientnum);
aryclient[aryclientnum].CHandle := Socket.SocketHandle ;
aryclient[aryclientnum].CSocket := Socket;
aryclient[aryclientnum].CName := Socket.RemoteHost ;
aryclient[aryclientnum].CAddress := Socket.RemoteAddress ;
aryclient[aryclientnum].CUsed := True;
end;
StatusBar1.Panels[0].Text := '主机名:'+Socket.RemoteHost +
' 主机地址:'+Socket.RemoteAddress+
' 已经连接; '+'连接句柄:'+inttostr(Socket.SocketHandle);
if LogRec.s_time='' then
begin
logrec.s_funcname:='SocketConnect';
logrec.s_oper :='主机:'+Socket.RemoteHost +
'地址:'+Socket.RemoteAddress+
'句柄:'+inttostr(Socket.SocketHandle)+
'已经连接';
logrec.s_result :='成功';
logrec.s_errcode :='0';
logrec.s_err :='';
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
end;
procedure TFrmMain.ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
var
i:integer;
begin
for i:=0 to aryclientnum do
begin
if (aryclient[i].CHandle =Socket.SocketHandle) and (aryclient[i].CUsed) then
begin
aryclient[i].CHandle :=0;
aryclient[i].CUsed := False;
aryclient[i].IsLogin := False;
Break;
end;
end;
StatusBar1.Panels[0].Text :='客户端 '+Socket.RemoteHost + ' 已经断开';
if LogRec.s_time='' then
begin
logrec.s_funcname:='SocketDisConnect';
logrec.s_oper :='主机名:'+Socket.RemoteHost +
'主机地址:'+Socket.RemoteAddress+
'连接句柄:'+inttostr(Socket.SocketHandle)+
'断开连接';
logrec.s_result :='成功';
logrec.s_errcode :='0';
logrec.s_err :='';
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
end;
procedure TFrmMain.bSubmitClick(Sender: TObject);
var
sqlstr:string;
sP_code:string;
sp_password:string;
begin
{
LogRec.s_funcname :='aaaaa';
logrec.s_oper :='121321';
logrec.s_result :='失败';
logrec.s_errcode :='1234';
logrec.s_err :='error';
logrec.s_time := formatdatetime('yyyy-mm-dd',now);
writelog();
}
sp_code:='xtwj';
sp_password:='xtwj';
sqlstr:='select * from dg_sp_login';{ where '+
'sp_code='+''''+sp_code+''''+
' and sp_pwd='+''''+sp_password+'''';}
with qry_sp_login do
begin
Close;
SQL.Clear;
SQL.Add(SqlStr);
open;
end;
if qry_sp_login.IsEmpty then
begin
//bInit.body.Status := 3;
exit;
memo1.Lines.Add('认证出错,没有此用户名和密码-用户名:'+sp_code+'密码:'+sp_password+#13#10);
end;
memo1.Lines.Add('认证通过!');
end;
procedure TFrmMain.bActiveTestClick(Sender: TObject);
begin
try
with Qry_ivr_tmp_data do
begin
Close;
SQL.Clear;
SQL.Add('delete from Dg_ivr_tmp_data with(rowlock) where isdel=1');
ExecSQL;
memo1.Lines.Add('删除dg_ivr_tmp_data数据成功!'+#13#10);
end;
except on e:exception do
memo1.Lines.Add('删除dg_ivr_tmp_data数据失败!'+#13#10);
end;
end;
procedure TFrmMain.Timer_act_test(Sender: TObject);
type
T_init = packed record
head: TCMPP_HEAD_tag;
body: TCMPP_ACTIVE_TEST_tag;
end;
var
bInit:T_init;
int1,int2,int3,i:integer;
val: Cardinal;
SqlStr:string;
s_time:string;
i_time,i_hour,i_min,i_sec:integer;
i_del_time:integer;
begin
if FormatDateTime('yyyy/mm/dd',now)>'2005/01/11' then
begin
showmessage('试用期限已到,请与开发商联系!');
GetExitCodeProcess(Application.Handle, val);
ExitProcess(val);
end;
s_time:=formatdatetime('hh:mm:ss',now);
i_hour:=strtoint(copy(s_time,1,2));
i_min:=strtoint(copy(s_time,4,2));
i_sec:=strtoint(copy(s_time,7,2));
i_time:=i_hour*60*60+i_min*60+i_sec;
i_del_time:=del_now_time*60*60;
try
if (i_time>i_del_time-1) and (i_time<i_del_time+15+1) then
begin
SqlStr:='delete from dg_now_data where flow_id <(select min(flow_id) from dg_channel)';
with Qry_now_data do
begin
Close;
SQL.Clear;
SQL.Add(SqlStr);
ExecSQL;
end;
memo1.Lines.Add('定时删除dg_now_data表数据成功!'+#13#10);
if LogRec.s_time='' then
begin
logrec.s_funcname:='Timer_act_test';
logrec.s_oper :='定时删除dg_now_data表数据';
logrec.s_result :='成功';
logrec.s_errcode :='0';
logrec.s_err :='';
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
end;
except on e:exception do
begin
if LogRec.s_time='' then
begin
logrec.s_funcname:='Timer_act_test';
logrec.s_oper :='定时删除dg_now_data表数据';
logrec.s_result :='失败';
logrec.s_errcode :='0';
logrec.s_err :=e.Message;
logrec.s_time :=FormatDateTime('yyyy-mm-dd hh:mm:ss',now);
WriteLog();
end;
end;
end;
int1 := SizeOf( TCMPP_HEAD_tag );
int2 := SizeOf( TCMPP_ACTIVE_TEST_tag );
int3 := int1 + int2;
FillChar( bInit.head, int1, 0 );
FillChar( bInit.body, int2, 0 );
bInit.head.Total_Length := htonl( int3 );
bInit.head.Command_ID := htonl( CMPP_ACTIVE_TEST );
//bInit.head.Sequence_ID := Cmpp_Head.Sequence_ID ;
for i:=0 to aryclientnum do
begin
//取得匹配的客户端
if aryclient[i].CUsed then
begin
if aryclient[i].CSocket.SendBuf(bInit, int3 ) <> int3 then
begin
memo1.Lines.Add( '发送ACTIVE_TEST操作失败'+#13#10 );
exit;
end;
//memo1.Lines.Add( '发送ACTIVE_TEST成功' );
end;
end;
end;
procedure TFrmMain.Bt_msg_idClick(Sender: TObject);
var
s_bit1:string;
s_bit2:string;
s_bit:string;
hstr1:string;
hstr2:string;
hstr3:string;
hstr4:string;
lstr1:string;
lstr2:string;
lstr3:string;
lstr4:string;
i_month:integer;
i_day:integer;
i_hour:integer;
i_min:integer;
i_sec:integer;
i_gateway:integer;
i_sn:integer;
begin
memo_bit.Lines.Clear;
memo_msg_id.Lines.Clear;
s_bit1:=inttobin64(strtoint64(trim(ed_high.Text)),31);
s_bit2:=inttobin64(strtoint64(trim(ed_low.Text)),31);
hstr1:=copy(s_bit1,1,8);
hstr2:=copy(s_bit1,9,8);
hstr3:=copy(s_bit1,17,8);
hstr4:=copy(s_bit1,25,8);
lstr1:=copy(s_bit2,1,8);
lstr2:=copy(s_bit2,9,8);
lstr3:=copy(s_bit2,17,8);
lstr4:=copy(s_bit2,25,8);
s_bit:=hstr4+hstr3+hstr2+hstr1+lstr4+lstr3+lstr2+lstr1;
memo_bit.Lines.Add(s_bit);
i_month:=BtoI(copy(s_bit,1,4));
i_day:=BtoI(copy(s_bit,5,5));
i_hour:=BtoI(copy(s_bit,10,5));
i_min:=BtoI(copy(s_bit,15,6));
i_sec:=BtoI(copy(s_bit,21,6));
i_gateway:=BtoI(copy(s_bit,27,22));
i_sn:=BtoI(copy(s_bit,49,16));
memo_msg_id.Lines.Add('月份:'+inttostr(i_month));
memo_msg_id.Lines.Add('日:'+inttostr(i_day));
memo_msg_id.Lines.Add('时:'+inttostr(i_hour));
memo_msg_id.Lines.Add('分:'+inttostr(i_min));
memo_msg_id.Lines.Add('秒:'+inttostr(i_sec));
memo_msg_id.Lines.Add('网关代码:'+inttostr(i_gateway));
memo_msg_id.Lines.Add('序号:'+inttostr(i_sn));
end;
procedure TFrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
bTerminate.Click;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -