urdmerrorserver.pas

来自「delphi多层应用系统 delphi多层应用系统」· PAS 代码 · 共 72 行

PAS
72
字号
unit urdmErrorServer;

interface

uses
  Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  DBClient, PErrorServer_TLB, StdVcl, Provider, DBTables, Db, Dialogs;

type
  TErrorServer = class(TRemoteDataModule, IErrorServer)
    Database1: TDatabase;
    Query1: TQuery;
    Session1: TSession;
    DataSetProvider1: TDataSetProvider;
    procedure DataSetProvider1UpdateError(Sender: TObject;
      DataSet: TClientDataSet; E: EUpdateError; UpdateKind: TUpdateKind;
      var Response: TResolverResponse);
  private
    { Private declarations }
  protected
    class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
  public
    { Public declarations }
  end;

implementation

uses fErrorServerMain;

{$R *.DFM}

class procedure TErrorServer.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
  if Register then
  begin
    inherited UpdateRegistry(Register, ClassID, ProgID);
    EnableSocketTransport(ClassID);
    EnableWebTransport(ClassID);
  end else
  begin
    DisableSocketTransport(ClassID);
    DisableWebTransport(ClassID);
    inherited UpdateRegistry(Register, ClassID, ProgID);
  end;
end;

procedure TErrorServer.DataSetProvider1UpdateError(Sender: TObject;
  DataSet: TClientDataSet; E: EUpdateError; UpdateKind: TUpdateKind;
  var Response: TResolverResponse);
var
  eDBError : EDBEngineError;
  iCount : Integer;
begin
  frmErrorServer.Edit1.Text := IntToStr(E.ErrorCode);
  frmErrorServer.Edit2.Text := E.Context;

  if (E.ErrorCode <> 0) then
    if (E.OriginalException is EDBEngineError) then
    begin
      eDBError := E.OriginalException  as EDBEngineError;
      ShowMessage(IntToStr(eDBError.ErrorCount));
      for iCount := 0 to eDBError.ErrorCount - 1 do
      begin
        frmErrorServer.ListBox1.Items.Add(IntToStr(eDBError.Errors[iCount].NativeError));
      end;
    end;end;

initialization
  TComponentFactory.Create(ComServer, TErrorServer,
    Class_ErrorServer, ciMultiInstance, tmApartment);
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?