⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 urdmerrorserver.pas

📁 就是这本书的随书代码。包括《实战Delphi 5.x-分布式多层应用系统篇》
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -