H
hedadt
Unregistered / Unconfirmed
GUEST, unregistred user!
现在只要客户端超过10个服务器程序就自动退出,请问如何解决?
if (AThread.Connection.Connected) and (not Athread.Terminated) then
begin
Msg := AThread.Connection.ReadLn;
Client := Pointer(AThread.Data);
if Client.Name = 'Logging In' then
begin
FullStr := Copy(Msg,Pos('#N:',Msg)+3,Length(Msg));
sName := Copy(FullStr,1,Pos('#Pwd:',FullStr)-1);
FullStr := Copy(FullStr,Pos('#Pwd:',FullStr)+5,Length(Msg));
sPWD := Copy(FullStr,1,Pos('#Hrd:',FullStr)-1);
sHardDiskid := Trim(Copy(FullStr,Pos('#Hrd:',FullStr)+5,Length(Msg)));
if (sName = 'guest') and (sPWD = 'guest') then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(30));
AThread.Connection.WriteLn('#~~#'+'00000000'+' '+'0000001');
Client.Name := sName;
UpdateClientList;
exit;
end;
CoInitializeex( nil, COINIT_MULTITHREADED);
Query := TADOQuery.Create(Nil);
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select * from zcm_user where name='+#39+sName+#39+' and pwd1='+#39+sPWD+#39;
Query.Open;
if Query.IsEmpty then
begin
AThread.Connection.WriteLn('#' + 'N');
Exit;
end;
if StrToDatetime(Query.fieldbyname('enddt').asstring)< now then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+'0');
Exit;
end;
if Query.FieldByName('suo').AsInteger = 1 then
begin
AThread.Connection.WriteLn('Locked');
Exit;
end;
/////////
hardid := Query.FieldByName('hardid').AsString;
enddt := Query.fieldbyname('enddt').asstring;
tel := Query.fieldbyname('tel').asstring;
tel1 := Query.fieldbyname('tel1').asstring;
query.Close;
freeandNil(query);
CoUninitialize;
////////////
if hardid='' then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(1+daysbetween(now,StrToDateTime(enddt))));
AThread.Connection.WriteLn('#~~#'+tel+' '+tel1);
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'doutao_updateDiskID;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@name').Value := sname;
parameters.ParamByName('@pwd').Value := spwd;
parameters.ParamByName('@hardid').Value := sHardDiskid;
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
getLastDT(sname);
Client.Name := sName;
UpdateClientList;
Exit;
end;
if (Trim(hardid)<>Trim(sharddiskid)) then
begin
AThread.Connection.WriteLn('#' + 'D');
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'doutao_Locked;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@name').Value := sname;
parameters.ParamByName('@pwd').Value := spwd;
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
end
else
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(1+daysbetween(now,StrToDateTime(enddt))));
AThread.Connection.WriteLn('#~~#'+tel+' '+tel1);
getLastDT(sname);
Client.Name := sName;
UpdateClientList;
end;
Exit;
end;
if (Msg[1] = '&') and (Msg[2] = '&') then
begin
Try
CoInitializeex( nil, COINIT_MULTITHREADED);
FullStr := Copy(Msg,4,pos('$E',Msg)-4);
Query := TADOQuery.Create(Nil);
Query.Close;
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select * from zcm_msg where id>'+FullStr;
Query.Open;
if Query.RecordCount = 0 then
exit;
Query.first;
While not Query.Eofdo
begin
AThread.Connection.WriteLn('*Data:'+Query.FieldByName('memo').asstring+'['+Query.FieldByName('dt').asstring+']'+'*Id:'+ Query.FieldByName('id').asstring);
Query.Next;
end;
Finally
//Athread.Connection.Disconnect;
FreeAndNil(Query);
CoUninitialize;
end;
end;
/////////////
if (Msg[1] = '^') and (Msg[2] = '^') then
begin
try
CoInitializeex( nil, COINIT_MULTITHREADED);
FullStr := Copy(Msg,4,pos('$E',Msg)-4);
Query := TADOQuery.Create(Nil);
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select min(id) as ccd from zcm_msg';
Query.Open;
SQLServer_MinID := Query.fieldbyname('ccd').AsInteger;
AThread.Connection.WriteLn('MinID:'+IntToStr(SQLServer_MinID));
Query.SQL.Text := 'select * from zcm_msg where id>'+FullStr;
Query.Open;
if Query.RecordCount = 0 then
begin
Query.SQL.Text := 'select * from BoradCast';
Query.Open;
if Query.IsEmpty = false then
begin
query.First;
while not query.Eofdo
begin
AThread.Connection.WriteLn('Broad:'+Query.FieldByName('Msg').asstring);
query.Next;
end;
end;
AThread.Connection.WriteLn('^^!:');
exit;
end;
Query.first;
While not Query.Eofdo
begin
AThread.Connection.WriteLn('*Data:'+Query.FieldByName('memo').asstring+'['+Query.FieldByName('dt').asstring+']'+'*Id:'+ Query.FieldByName('id').asstring);
Query.Next;
end;
Query.SQL.Text := 'select * from BoradCast';
Query.Open;
if Query.IsEmpty = false then
begin
query.First;
while not query.Eofdo
begin
AThread.Connection.WriteLn('Broad:'+Query.FieldByName('Msg').asstring);
query.Next;
end;
end;
////
AThread.Connection.WriteLn('^^!:');
// Athread.Connection.Disconnect;
finally
FreeAndNil(Query);
CoUninitialize;
end;
end;
if (Msg[1]= '@') and (Msg[2] = '@') then
begin
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'zcm_Addmsg;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@uid').Value := 0;
parameters.ParamByName('@cls').Value := 1;
parameters.ParamByName('@memo').Value := Copy(Msg,4,length(Msg));
parameters.ParamByName('@umemo').Value := Copy(Msg,4,length(Msg));
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
end;
end;
if (AThread.Connection.Connected) and (not Athread.Terminated) then
begin
Msg := AThread.Connection.ReadLn;
Client := Pointer(AThread.Data);
if Client.Name = 'Logging In' then
begin
FullStr := Copy(Msg,Pos('#N:',Msg)+3,Length(Msg));
sName := Copy(FullStr,1,Pos('#Pwd:',FullStr)-1);
FullStr := Copy(FullStr,Pos('#Pwd:',FullStr)+5,Length(Msg));
sPWD := Copy(FullStr,1,Pos('#Hrd:',FullStr)-1);
sHardDiskid := Trim(Copy(FullStr,Pos('#Hrd:',FullStr)+5,Length(Msg)));
if (sName = 'guest') and (sPWD = 'guest') then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(30));
AThread.Connection.WriteLn('#~~#'+'00000000'+' '+'0000001');
Client.Name := sName;
UpdateClientList;
exit;
end;
CoInitializeex( nil, COINIT_MULTITHREADED);
Query := TADOQuery.Create(Nil);
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select * from zcm_user where name='+#39+sName+#39+' and pwd1='+#39+sPWD+#39;
Query.Open;
if Query.IsEmpty then
begin
AThread.Connection.WriteLn('#' + 'N');
Exit;
end;
if StrToDatetime(Query.fieldbyname('enddt').asstring)< now then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+'0');
Exit;
end;
if Query.FieldByName('suo').AsInteger = 1 then
begin
AThread.Connection.WriteLn('Locked');
Exit;
end;
/////////
hardid := Query.FieldByName('hardid').AsString;
enddt := Query.fieldbyname('enddt').asstring;
tel := Query.fieldbyname('tel').asstring;
tel1 := Query.fieldbyname('tel1').asstring;
query.Close;
freeandNil(query);
CoUninitialize;
////////////
if hardid='' then
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(1+daysbetween(now,StrToDateTime(enddt))));
AThread.Connection.WriteLn('#~~#'+tel+' '+tel1);
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'doutao_updateDiskID;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@name').Value := sname;
parameters.ParamByName('@pwd').Value := spwd;
parameters.ParamByName('@hardid').Value := sHardDiskid;
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
getLastDT(sname);
Client.Name := sName;
UpdateClientList;
Exit;
end;
if (Trim(hardid)<>Trim(sharddiskid)) then
begin
AThread.Connection.WriteLn('#' + 'D');
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'doutao_Locked;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@name').Value := sname;
parameters.ParamByName('@pwd').Value := spwd;
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
end
else
begin
AThread.Connection.WriteLn('#' + 'P'+'$'+IntToStr(1+daysbetween(now,StrToDateTime(enddt))));
AThread.Connection.WriteLn('#~~#'+tel+' '+tel1);
getLastDT(sname);
Client.Name := sName;
UpdateClientList;
end;
Exit;
end;
if (Msg[1] = '&') and (Msg[2] = '&') then
begin
Try
CoInitializeex( nil, COINIT_MULTITHREADED);
FullStr := Copy(Msg,4,pos('$E',Msg)-4);
Query := TADOQuery.Create(Nil);
Query.Close;
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select * from zcm_msg where id>'+FullStr;
Query.Open;
if Query.RecordCount = 0 then
exit;
Query.first;
While not Query.Eofdo
begin
AThread.Connection.WriteLn('*Data:'+Query.FieldByName('memo').asstring+'['+Query.FieldByName('dt').asstring+']'+'*Id:'+ Query.FieldByName('id').asstring);
Query.Next;
end;
Finally
//Athread.Connection.Disconnect;
FreeAndNil(Query);
CoUninitialize;
end;
end;
/////////////
if (Msg[1] = '^') and (Msg[2] = '^') then
begin
try
CoInitializeex( nil, COINIT_MULTITHREADED);
FullStr := Copy(Msg,4,pos('$E',Msg)-4);
Query := TADOQuery.Create(Nil);
Query.ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
Query.SQL.Text := 'select min(id) as ccd from zcm_msg';
Query.Open;
SQLServer_MinID := Query.fieldbyname('ccd').AsInteger;
AThread.Connection.WriteLn('MinID:'+IntToStr(SQLServer_MinID));
Query.SQL.Text := 'select * from zcm_msg where id>'+FullStr;
Query.Open;
if Query.RecordCount = 0 then
begin
Query.SQL.Text := 'select * from BoradCast';
Query.Open;
if Query.IsEmpty = false then
begin
query.First;
while not query.Eofdo
begin
AThread.Connection.WriteLn('Broad:'+Query.FieldByName('Msg').asstring);
query.Next;
end;
end;
AThread.Connection.WriteLn('^^!:');
exit;
end;
Query.first;
While not Query.Eofdo
begin
AThread.Connection.WriteLn('*Data:'+Query.FieldByName('memo').asstring+'['+Query.FieldByName('dt').asstring+']'+'*Id:'+ Query.FieldByName('id').asstring);
Query.Next;
end;
Query.SQL.Text := 'select * from BoradCast';
Query.Open;
if Query.IsEmpty = false then
begin
query.First;
while not query.Eofdo
begin
AThread.Connection.WriteLn('Broad:'+Query.FieldByName('Msg').asstring);
query.Next;
end;
end;
////
AThread.Connection.WriteLn('^^!:');
// Athread.Connection.Disconnect;
finally
FreeAndNil(Query);
CoUninitialize;
end;
end;
if (Msg[1]= '@') and (Msg[2] = '@') then
begin
try
CoInitializeex( nil, COINIT_MULTITHREADED);
ADOStoredProc1 := TADOStoredProc.Create(Nil);
with ADOStoredProc1do
begin
ConnectionString := 'Provider=SQLOLEDB.1;Password=zcm;Persist Security Info=True;User ID=sa;Initial Catalog=ldt';
close;
parameters.clear;
procedurename := 'zcm_Addmsg;1';
prepared:=true;
parameters.Refresh;
parameters.ParamByName('@uid').Value := 0;
parameters.ParamByName('@cls').Value := 1;
parameters.ParamByName('@memo').Value := Copy(Msg,4,length(Msg));
parameters.ParamByName('@umemo').Value := Copy(Msg,4,length(Msg));
ExecProc;
end;
finally
FreeAndNil(ADOStoredProc1);
CoUninitialize;
end;
end;
end;