📄 dxdispatchdatasetservercore.pas
字号:
unit DXDispatchDatasetServerCore;
interface
///////////////////////////////////////////////////////////////////////////////
// Component: TDXDispatchDatasetServerCore
// Author: G.E. Ozz Nixon Jr. (staff@bpdx.com)
// ========================================================================
// Source Owner: DX, Inc. 1995-2003
// Copyright: All code is the property of DX, Inc. Licensed for
// resell by Brain Patchwork DX (tm) and part of the
// DX (r) product lines, which are (c) 1999-2003
// DX, Inc. Source may not be distributed without
// written permission from both Brain Patchwork DX,
// and DX, Inc.
// License: (Reminder), None of this code can be added to other
// developer products without permission. This includes
// but not limited to DCU's, DCP's, DLL's, OCX's, or
// any other form of merging our technologies. All of
// your products released to a public consumer be it
// shareware, freeware, commercial, etc. must contain a
// license notification somewhere visible in the
// application.
// Example is Internet Explorer - Help->About screen
// shows the licensed code contained in the application.
// Code Version: (4th Generation Code)
// ========================================================================
// Description: Custom DXServerCore for Police Dispatch Systems
// ========================================================================
// Transaction Flow:
// HELO USER_NAME PASSWORD
// CONNECT SERVER_INFO OPTIONAL_CONNECT_STRING
// SQL SQL_STATEMENT
// OPEN
// CLOSE
// FIELDS
// FETCH ROW_NUMBER
// FETCHROWS COUNT STARTING_ROW
// POST FIELD# DATA
// FIRST
// LAST
// DETAILSQL TABLENAME:SQL_STATEMENT
// DETAILOPEN TABLENAME:
// DETAILCLOSE TABLENAME:
// DETAILFIELDS TABLENAME:
// DETAILFETCH TABLENAME:ROW_NUMBER
//
// Results from Server:
// 200 ACK
// 205 <FIELDS STRUCTURE>
// 206 <FETCH STRUCTURE>
// 500 COMMAND ERROR
///////////////////////////////////////////////////////////////////////////////
uses
DB,
Classes,
DXServerCore;
{$I DXSock.def}
type
DISPATCHTSimpleEvent = procedure(ClientThread: TDXClientThread) of object;
DISPATCHTBasicEvent = procedure(ClientThread: TDXClientThread; Parm: string) of object;
DISPATCHTComplexEvent = procedure(ClientThread: TDXClientThread; Parm1, Parm2: string) of object;
DISPATCHTOtherEvent = procedure(ClientThread: TDXClientThread; Command: string; Parm: string;Var Handled:Boolean) of object;
TDXDispatchDatasetServerCore = class(TDXServerCore)
private
fOnCommandHELO: DISPATCHTComplexEvent;
fOnCommandCONNECT: DISPATCHTComplexEvent;
fOnCommandSQL: DISPATCHTBasicEvent;
fOnCommandSQLEXEC: DISPATCHTBasicEvent;
fOnCommandACKD: DISPATCHTSimpleEvent;
fOnCommandNACK: DISPATCHTSimpleEvent;
fOnCommandOPEN: DISPATCHTSimpleEvent;
fOnCommandCLOSE: DISPATCHTSimpleEvent;
fOnCommandFIELDS: DISPATCHTSimpleEvent;
fOnCommandFETCH: DISPATCHTBasicEvent;
fOnCommandFETCHROWS: DISPATCHTComplexEvent;
fOnCommandQUIT: DISPATCHTSimpleEvent;
fOnCommandPOST: DISPATCHTComplexEvent;
fOnCommandFIRST: DISPATCHTSimpleEvent;
fOnCommandLAST: DISPATCHTSimpleEvent;
fOnCommandDETAILSQL: DISPATCHTBasicEvent;
fOnCommandDETAILOPEN: DISPATCHTBasicEvent;
fOnCommandDETAILCLOSE: DISPATCHTBasicEvent;
fOnCommandDETAILFIELDS: DISPATCHTBasicEvent;
fOnCommandDETAILFETCH: DISPATCHTBasicEvent;
fOnCommandOther: DISPATCHTOtherEvent; {COMMAND parameters...}
fEventArray:TList;
fiTimeout:Cardinal;
fDataSet:TDataSet;
protected
Procedure SetOnCommandHELO(value:DISPATCHTComplexEvent);
Procedure SetOnCommandCONNECT(value:DISPATCHTComplexEvent);
Procedure SetOnCommandSQL(value:DISPATCHTBasicEvent);
Procedure SetOnCommandSQLEXEC(value:DISPATCHTBasicEvent);
Procedure SetOnCommandACKD(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandNACK(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandOPEN(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandCLOSE(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandFIELDS(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandFETCH(value:DISPATCHTBasicEvent);
Procedure SetOnCommandFETCHROWS(value:DISPATCHTComplexEvent);
Procedure SetOnCommandQUIT(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandPOST(value:DISPATCHTComplexEvent);
Procedure SetOnCommandFIRST(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandLAST(value:DISPATCHTSimpleEvent);
Procedure SetOnCommandDETAILSQL(value:DISPATCHTBasicEvent);
Procedure SetOnCommandDETAILOPEN(value:DISPATCHTBasicEvent);
Procedure SetOnCommandDETAILCLOSE(value:DISPATCHTBasicEvent);
Procedure SetOnCommandDETAILFIELDS(value:DISPATCHTBasicEvent);
Procedure SetOnCommandDETAILFETCH(value:DISPATCHTBasicEvent);
public
constructor Create(AOwner:TComponent); {$IFNDEF OBJECTS_ONLY} override; {$ENDIF}
destructor Destroy; override;
procedure ProcessSession(ClientThread: TDXClientThread);
Function WriteResult(ClientThread:TDXClientThread;StatusCode:Integer;Rslt:String):Boolean;
Function Writeln(ClientThread:TDXClientThread;Rslt:String):Boolean;
Procedure AddBasicEvent(Command:String;EventProc:DISPATCHTBasicEvent);
Procedure AddSimpleEvent(Command:String;EventProc:DISPATCHTSimpleEvent);
Procedure AddComplexEvent(Command:String;EventProc:DISPATCHTComplexEvent);
published
property DataSet:TDataSet read fDataSet
write fDataSet;
property Timeout:Cardinal read fiTimeout
write fiTimeout;
property OnCommandHELO: DISPATCHTComplexEvent read fOnCommandHELO
write SetOnCommandHELO;
property OnCommandCONNECT: DISPATCHTComplexEvent read fOnCommandCONNECT
write SetOnCommandCONNECT;
property OnCommandSQL: DISPATCHTBasicEvent read fOnCommandSQL
write SetOnCommandSQL;
property OnCommandSQLEXEC: DISPATCHTBasicEvent read fOnCommandSQLEXEC
write SetOnCommandSQLEXEC;
property OnCommandACKD: DISPATCHTSimpleEvent read fOnCommandACKD
write SetOnCommandACKD;
property OnCommandNACK: DISPATCHTSimpleEvent read fOnCommandNACK
write SetOnCommandNACK;
property OnCommandOPEN: DISPATCHTSimpleEvent read fOnCommandOPEN
write SetOnCommandOPEN;
property OnCommandCLOSE: DISPATCHTSimpleEvent read fOnCommandCLOSE
write SetOnCommandCLOSE;
property OnCommandFIELDS: DISPATCHTSimpleEvent read fOnCommandFIELDS
write SetOnCommandFIELDS;
property OnCommandFETCH: DISPATCHTBasicEvent read fOnCommandFETCH
write SetOnCommandFETCH;
property OnCommandFETCHROWS: DISPATCHTComplexEvent read fOnCommandFETCHROWS
write SetOnCommandFETCHROWS;
property OnCommandQUIT: DISPATCHTSimpleEvent read fOnCommandQUIT
write SetOnCommandQUIT;
property OnCommandPOST: DISPATCHTComplexEvent read fOnCommandPOST
write SetOnCommandPOST;
property OnCommandFIRST: DISPATCHTSimpleEvent read fOnCommandFIRST
write SetOnCommandFIRST;
property OnCommandLAST: DISPATCHTSimpleEvent read fOnCommandLAST
write SetOnCommandLAST;
property OnCommandDETAILSQL: DISPATCHTBasicEvent read fOnCommandDETAILSQL
write SetOnCommandDETAILSQL;
property OnCommandDETAILOPEN: DISPATCHTBasicEvent read fOnCommandDETAILOPEN
write SetOnCommandDETAILOPEN;
property OnCommandDETAILCLOSE: DISPATCHTBasicEvent read fOnCommandDETAILCLOSE
write SetOnCommandDETAILCLOSE;
property OnCommandDETAILFIELDS: DISPATCHTBasicEvent read fOnCommandDETAILFIELDS
write SetOnCommandDETAILFIELDS;
property OnCommandDETAILFETCH: DISPATCHTBasicEvent read fOnCommandDETAILFETCH
write SetOnCommandDETAILFETCH;
property OnCommandOther: DISPATCHTOtherEvent read fOnCommandOther
write fOnCommandOther;
end;
procedure Register;
implementation
Uses
DXSock,
DXString;
Type
PDISPATCHBasicEvent=^TDISPATCHBasicEvent;
TDISPATCHBasicEvent=record
Tag:Integer;
Command:String;
EventProcedure:DISPATCHTBasicEvent;
End;
PDISPATCHSimpleEvent=^TDISPATCHSimpleEvent;
TDISPATCHSimpleEvent=record
Tag:Integer;
Command:String;
EventProcedure:DISPATCHTSimpleEvent;
End;
PDISPATCHComplexEvent=^TDISPATCHComplexEvent;
TDISPATCHComplexEvent=record
Tag:Integer;
Command:String;
EventProcedure:DISPATCHTComplexEvent;
End;
constructor TDXDispatchDatasetServerCore.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
ServerPort:=15220;
fEventArray:=TList.Create;
fiTimeout:=120000;
SocketOutputBufferSize:=bsfNormal;
end;
destructor TDXDispatchDatasetServerCore.Destroy;
Var
PBasicEvent:PDISPATCHBasicEvent;
PSimpleEvent:PDISPATCHSimpleEvent;
PComplexEvent:PDISPATCHComplexEvent;
begin
If Assigned(fEventArray) then Begin
While fEventArray.Count>0 do Begin
Case PDISPATCHBasicEvent(fEventArray[0]).Tag of
1:Begin
PBasicEvent:=fEventArray[0];
Dispose(PBasicEvent);
End;
2:Begin
PSimpleEvent:=fEventArray[0];
Dispose(PSimpleEvent);
End;
3:Begin
PComplexEvent:=fEventArray[0];
Dispose(PComplexEvent);
End;
End;
fEventArray.Delete(0);
End;
fEventArray.Free;
fEventArray:=Nil;
End;
inherited Destroy;
end;
Procedure TDXDispatchDatasetServerCore.AddBasicEvent(Command:String;EventProc:DISPATCHTBasicEvent);
Var
PBasicEvent:PDISPATCHBasicEvent;
Loop:Integer;
Begin
Command:=Uppercase(Command);
Loop:=0;
While Loop<fEventArray.Count do Begin
If PDISPATCHBasicEvent(fEventArray[Loop]).Command=Command then Begin
PDISPATCHBasicEvent(fEventArray[Loop]).EventProcedure:=EventProc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -