|
发表于 2007-3-6 13:47:19
|
显示全部楼层
日志资源集代码:
unit SystemLogLib;
interface
uses
Business.System, Business.Model, CommonComponentLibrary;
type
TSystemLogLib = class(TBizLibrary)
private
{private declarations}
public
{public declarations}
end;
TSystemLog = class(TSQLDataSet)
private
public
constructor Create(AOwner: TComponent);
function SaveLog(context: TContext): boolean; overload;
function SaveLog(strWhat: string): boolean; overload;
function SaveLog(strWho: string; strWhen: string; strWhat: string): boolean;
overload;
static function Instance(AOwner: TComponent): TSystemLog;
static procedure FreeInstanceA;
end;
var
FSystemLog: TSystemLog;
const
C_tblSystemLogSelect = 'select * from TSystemLog ';
C_tblSystemLogDelete = 'Delete from TSystemLog ';
C_tblSystemLogInsert = 'Insert into TSystemLog ';
implementation
static function TSystemLog.Instance(AOwner: TComponent): TSystemLog;
begin
if FSystemLog = nil then
FSystemLog := TSystemLog.Create(AOwner);
result := FSystemLog;
end;
static procedure TSystemLog.FreeInstanceA;
begin
if FSystemLog <> nil then
FSystemLog.Free;
end;
constructor TSystemLog.Create(AOwner: TComponent);
begin
inherited;
Database.URL := 'Biz:\SYSTEM\System.DataBase';
end;
function TSystemLog.SaveLog(context: TContext): boolean;
var
a: TContextCurrent;
begin
result := true;
a := TContextCurrent.Create(context);
with a do
begin
try
SQL.Text := C_tblSystemLogInsert + 'values('
+ '''' + JSCommon.CreateGUIDStr + ''','
+ '''' + PersonMember.DisplayName + ''','
+ '''' + SysUtils.DateTimeToStr
(SysUtils.Now) + ''','
+ '''' + GetDefaultFunc.DisplayName +
''')';
Execute;
except
result := false;
end;
end;
end;
function TSystemLog.SaveLog(strWho: string; strWhen: string; strWhat: string):
boolean;
begin
result := true;
try
SQL.Text := C_tblSystemLogInsert + 'values('
+ '''' + JSCommon.CreateGUIDStr + ''','
+ '''' + strWho + ''','
+ '''' + strWhen + ''','
+ '''' + strWhat + ''')';
Execute;
except
result := false;
end;
end;
function TSystemLog.SaveLog(strWhat: string): boolean;
begin
result := true;
try
SQL.Text := C_tblSystemLogInsert + 'values('
+ '''' + JSCommon.CreateGUIDStr + ''','
+ '''' +
TCommonComponentLibrary.UserSystem.CurrentPersonMember.DisplayName + ''','
+ '''' + SysUtils.DateTimeToStr
(SysUtils.Now) + ''','
+ '''' + strWhat + ''')';
Execute;
except
result := false;
end;
end;
end.
附件是相关的资源,可以使用studio的业务资源管理器拷贝到系统中。 |
|