📄 dxdatabaseservercore.pas
字号:
unit DXDatabaseServerCore;
interface
///////////////////////////////////////////////////////////////////////////////
// Component: TDXDatabaseServerCore
// Author: G.E. Ozz Nixon Jr. (onixon@dxsock.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: *Example* One way you could implement a Database Server.
// ========================================================================
// This allows you to develop TDatabase Servers - this is a proprietary
// solutions from Brain Patchwork DX, LLC. It has been designed to allow you
// to make your own hooks at the server for the database connectivity. Later
// we will develop a TDatabase Client and a common TDatabase interface. The
// goal of the interface will be to make this component work seamlessly with
// any Data-Aware component that knows how to talk to Borland's TDatabase.
///////////////////////////////////////////////////////////////////////////////
uses
Classes,
DXServerCore;
{$I DXSock.def}
type
{$IFDEF VER100}
Longword=Cardinal;
{$ENDIF}
DatabaseTBasicEvent = procedure(ClientThread: TDXClientThread) of object;
DatabaseTSimpleEvent = procedure(ClientThread: TDXClientThread;Parm1:String) of object;
DatabaseTComplexEvent = procedure(ClientThread: TDXClientThread;Parm1,Parm2:String) of object;
DatabaseTOtherEvent = procedure(ClientThread: TDXClientThread; Command: string; Parm: string;Var Handled:Boolean) of object;
// specifications:
//
// AUTH UserName Password
// Verifies username and password, can be encoded if you implement your own encoding!
//
// USER UserName
// Part 1 of authentication, when doing in multiple parts versus AUTH is both parts
//
// PASS Password
// Part 2 of authentication, when doing in multiple parts versus AUTH is both parts
//
// CREATEDATASET MAGIC_WORD
// magic word is up to you to implement, the CreateDataset event lets your server
// know which database the client wishes to interact with. The magic_word can be
// a database name, alias, or if you want a connection string for another database
// server.
//
// DISPOSEDATASET MAGIC_WORD
// magic word is up to you to implement, the DisposeDataset event lets your server
// know which database instance the client is finished working with.
//
// Do not confuse OPEN/CLOSE with CREATEDATASET/DISPOSEDATASET. Your have to issue
// the CREATEDATASET before you can open/close the database, and DISPOSEDATASET
// is used usually when the client is disconnecting. Make sure you design your
// OnNewConnect to also check if your instance has been disposed or not, incase
// the client dropped carrier!!!
//
// OPEN
// opens the currently selected database
//
// CLOSE
// closes the currently selected database
//
// SETACTIVE TRUE|FALSE
// issues internally OPEN when parm1=TRUE or CLOSE when parm1=FALSE
//
// FIRST
// tells the open database to seek to the first row.
//
// NEXT
// tells the open database to seek to the next available row.
//
// PRIOR
// tells the open database to seek to the previous available row.
//
// LAST
// tells the open database to seek to the last row.
//
// MOVEBY +#|-#
// tells the open database to seek +# of rows or -# rows.
//
// ISBOF
// asks the open database if it is on the first row (beginning of file)
//
// ISEOF
// asks the open database if it is on the last row (end of file)
//
// GETFIELDLIST
// asks the open database to turned the field list sturcture.
//
// LOCATECASEINSENSITIVE TRUE|FALSE
// enables or disables Case Sensitive flag for searching.
//
// LOCATEPARTIALKEY TRUE|FALSE
// enables or disables PARTIAL COMPARES on "key" field.
//
// LOCATENOOPTIONS
// short-circuit - sets both of the previous to FALSE.
//
// LOCATEBOTHOPTIONS
// short-circuit - sets noth of the previous to TRUE.
//
// LOCATE "KeyField(s)" "Keyvalue(s)"
// performs the low-level "Locate" command.
//
// FINDFIRST
// asks the open database to seek to the first available row.
//
// FINDLAST
// asks the open database to seek to the last available row.
//
// FINDNEXT
// asks the open database to seek to the next available row.
//
// FINDPRIOR
// asks the open database to seek to the previous available row.
//
// FINDFIELD
// asks the open database to return the specified field if it exists.
//
// FOUND
// returns true if any of the above FIND commands were successful. You should
// use the result from the FIND command, but this is available incase you
// forgot to save the result in your code. And asks the server to return
// the status of the last FIND.
//
// CANMODIFY
// asks the open database if it can be modified.
//
// FIELDCOUNT
// asks the open database for the number of available fields (0=none, 1 based)
//
// RECORDCOUNT
// asks the open database for the number of available rows (0=none, 1 based)
//
// RECORDSIZE
// asks the open database for the size of each row.
//
// MODIFIED
// asks the open database if the current row has changed, and requires a POST
// command, or CANCEL command.
//
// APPEND
// asks the open database to create a new row. Unindexed files this is faster
// than INSERT.
//
// INSERT
// asks the open database to create a new row. Unindexed files *usually*
// attempt to physically insert the new row at the current cursor position!
//
// EDIT
// asks the open database to put the current row into EDIT mode.
//
// DELETE
// asks the open database to delete the current row.
//
// POST
// asks the open database to commit any changes that have not been committed.
//
// CANCEL
// asks the open database to rollback any changes that have not been committed.
//
// REFRESH
// Refresh ensures that an application has the latest data from a database.
// For example, when an application turns off filtering for a dataset, it
// should immediately call Refresh to display all records in the dataset,
// not just those that used to meet the filter condition.
//
// FIELDBYNAME "FieldName" "AsType"
// asks the open database to return the specified field, as the specified
// field type. This is probably the most "tricky" implementation in the
// database server.
//
// 2001 additions:
// ISEMPTY
// basically returns true if RecordCount=0
//
TDXDatabaseServerCore = class(TDXServerCore)
private
// CONNECTION COMMANDS
fOnCommandUSER: DatabaseTSimpleEvent;
fOnCommandPASS: DatabaseTSimpleEvent;
fOnCommandAUTH: DatabaseTComplexEvent;
// DATASET INFORMATION COMMANDS
fOnCommandSETACTIVE: DatabaseTSimpleEvent;
fOnCommandISBOF: DatabaseTBasicEvent;
fOnCommandISEOF: DatabaseTBasicEvent;
fOnCommandISEMPTY: DatabaseTBasicEvent;
fOnCommandCANMODIFY: DatabaseTBasicEvent;
fOnCommandFIELDCOUNT: DatabaseTBasicEvent;
fOnCommandRECORDCOUNT: DatabaseTBasicEvent;
fOnCommandRECORDSIZE: DatabaseTBasicEvent;
fOnCommandFOUND: DatabaseTBasicEvent;
fOnCommandMODIFIED: DatabaseTBasicEvent;
// DATASET COMMANDS
fOnCommandCREATEDATASET: DatabaseTSimpleEvent;
fOnCommandDISPOSEDATASET: DatabaseTSimpleEvent;
// fOnCommandISLINKEDTODATASET: DatabaseTSimpleEvent;
// DATASET NAVIGATION COMMANDS
fOnCommandOPEN: DatabaseTBasicEvent;
fOnCommandCLOSE: DatabaseTBasicEvent;
fOnCommandFIRST: DatabaseTBasicEvent;
fOnCommandNEXT: DatabaseTBasicEvent;
fOnCommandPRIOR: DatabaseTBasicEvent;
fOnCommandLAST: DatabaseTBasicEvent;
fOnCommandMOVEBY: DatabaseTSimpleEvent;
fOnCommandFINDFIRST: DatabaseTBasicEvent;
fOnCommandFINDLAST: DatabaseTBasicEvent;
fOnCommandFINDNEXT: DatabaseTBasicEvent;
fOnCommandFINDPRIOR: DatabaseTBasicEvent;
fOnCommandFINDFIELD: DatabaseTSimpleEvent;
fOnCommandGETFIELDLIST: DatabaseTBasicEvent;
fOnCommandLOCATECaseInsensitive: DatabaseTSimpleEvent;
fOnCommandLOCATEPartialKey: DatabaseTSimpleEvent;
fOnCommandLOCATENoOptions: DatabaseTBasicEvent;
fOnCommandLOCATEBothOptions: DatabaseTBasicEvent;
fOnCommandLOCATE: DatabaseTComplexEvent;
// DATASET DATA MANIPULATION COMMANDS
fOnCommandAPPEND: DatabaseTBasicEvent;
fOnCommandINSERT: DatabaseTBasicEvent;
fOnCommandEDIT: DatabaseTBasicEvent;
fOnCommandDELETE: DatabaseTBasicEvent;
fOnCommandPOST: DatabaseTBasicEvent;
fOnCommandCANCEL: DatabaseTBasicEvent;
fOnCommandREFRESH: DatabaseTBasicEvent;
// DATASET DATA COMMANDS
fOnCommandFIELDBYNAME: DatabaseTComplexEvent;
fOnCommandOther: DatabaseTOtherEvent; //COMMAND parameters...
protected
Procedure SetOnCommandUSER(value:DatabaseTSimpleEvent);
Procedure SetOnCommandPASS(value:DatabaseTSimpleEvent);
Procedure SetOnCommandAUTH(value:DatabaseTComplexEvent);
Procedure SetOnCommandSETACTIVE(value:DatabaseTSimpleEvent);
Procedure SetOnCommandISBOF(value:DatabaseTBasicEvent);
Procedure SetOnCommandISEOF(value:DatabaseTBasicEvent);
Procedure SetOnCommandISEMPTY(value:DatabaseTBasicEvent);
Procedure SetOnCommandCANMODIFY(value:DatabaseTBasicEvent);
Procedure SetOnCommandFIELDCOUNT(value:DatabaseTBasicEvent);
Procedure SetOnCommandRECORDCOUNT(value:DatabaseTBasicEvent);
Procedure SetOnCommandRECORDSIZE(value:DatabaseTBasicEvent);
Procedure SetOnCommandFOUND(value:DatabaseTBasicEvent);
Procedure SetOnCommandMODIFIED(value:DatabaseTBasicEvent);
Procedure SetOnCommandCREATEDATASET(value:DatabaseTSimpleEvent);
Procedure SetOnCommandDISPOSEDATASET(value:DatabaseTSimpleEvent);
Procedure SetOnCommandOPEN(value:DatabaseTBasicEvent);
Procedure SetOnCommandCLOSE(value:DatabaseTBasicEvent);
Procedure SetOnCommandFIRST(value:DatabaseTBasicEvent);
Procedure SetOnCommandNEXT(value:DatabaseTBasicEvent);
Procedure SetOnCommandPRIOR(value:DatabaseTBasicEvent);
Procedure SetOnCommandLAST(value:DatabaseTBasicEvent);
Procedure SetOnCommandMOVEBY(value:DatabaseTSimpleEvent);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -