2007-05-02 22:55:35 +00:00
|
|
|
{
|
|
|
|
This unit has been produced by ws_helper.
|
|
|
|
Input unit name : "user_service_intf".
|
|
|
|
This unit name : "user_service_intf_binder".
|
2010-01-29 15:30:24 +00:00
|
|
|
Date : "29/01/2010 14:54:30".
|
2007-05-02 22:55:35 +00:00
|
|
|
}
|
|
|
|
unit user_service_intf_binder;
|
2007-06-28 23:33:38 +00:00
|
|
|
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
|
2007-05-02 22:55:35 +00:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses SysUtils, Classes, base_service_intf, server_service_intf, user_service_intf;
|
|
|
|
|
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
type
|
2007-06-28 23:33:38 +00:00
|
|
|
TUserService_ServiceBinder = class(TBaseServiceBinder)
|
|
|
|
protected
|
|
|
|
procedure GetListHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
procedure AddHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
procedure UpdateHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
procedure FindHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
procedure DeleteHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
public
|
2007-05-02 22:55:35 +00:00
|
|
|
constructor Create();
|
2007-06-28 23:33:38 +00:00
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
type
|
2007-05-02 22:55:35 +00:00
|
|
|
TUserService_ServiceBinderFactory = class(TInterfacedObject,IItemFactory)
|
2007-06-28 23:33:38 +00:00
|
|
|
private
|
|
|
|
FInstance : IInterface;
|
2007-05-02 22:55:35 +00:00
|
|
|
protected
|
|
|
|
function CreateInstance():IInterface;
|
2007-06-28 23:33:38 +00:00
|
|
|
public
|
|
|
|
constructor Create();
|
|
|
|
destructor Destroy();override;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
procedure Server_service_RegisterUserServiceService();
|
|
|
|
|
|
|
|
Implementation
|
|
|
|
uses TypInfo, wst_resources_imp,metadata_repository;
|
|
|
|
|
|
|
|
{ TUserService_ServiceBinder implementation }
|
2007-06-28 23:33:38 +00:00
|
|
|
procedure TUserService_ServiceBinder.GetListHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
var
|
2007-05-02 22:55:35 +00:00
|
|
|
cllCntrl : ICallControl;
|
2007-06-28 23:33:38 +00:00
|
|
|
objCntrl : IObjectControl;
|
|
|
|
hasObjCntrl : Boolean;
|
2007-05-02 22:55:35 +00:00
|
|
|
tmpObj : UserService;
|
|
|
|
callCtx : ICallContext;
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName : string;
|
2007-05-02 22:55:35 +00:00
|
|
|
procName,trgName : string;
|
|
|
|
returnVal : TUserArray;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
callCtx := AContext;
|
2007-09-02 19:05:47 +00:00
|
|
|
Fillchar(returnVal,SizeOf(TUserArray),#0);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
tmpObj := Self.GetFactory().CreateInstance() as UserService;
|
|
|
|
if Supports(tmpObj,ICallControl,cllCntrl) then
|
2007-06-28 23:33:38 +00:00
|
|
|
cllCntrl.SetCallContext(callCtx);
|
|
|
|
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Activate();
|
|
|
|
try
|
|
|
|
returnVal := tmpObj.GetList();
|
|
|
|
if Assigned(TObject(returnVal)) then
|
|
|
|
callCtx.AddObjectToFree(TObject(returnVal));
|
|
|
|
|
|
|
|
procName := AFormatter.GetCallProcedureName();
|
|
|
|
trgName := AFormatter.GetCallTarget();
|
|
|
|
AFormatter.Clear();
|
|
|
|
AFormatter.BeginCallResponse(procName,trgName);
|
|
|
|
AFormatter.Put('result',TypeInfo(TUserArray),returnVal);
|
|
|
|
AFormatter.EndCallResponse();
|
|
|
|
|
|
|
|
callCtx := nil;
|
|
|
|
finally
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Deactivate();
|
|
|
|
Self.GetFactory().ReleaseInstance(tmpObj);
|
|
|
|
end;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2007-06-28 23:33:38 +00:00
|
|
|
procedure TUserService_ServiceBinder.AddHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
var
|
2007-05-02 22:55:35 +00:00
|
|
|
cllCntrl : ICallControl;
|
2007-06-28 23:33:38 +00:00
|
|
|
objCntrl : IObjectControl;
|
|
|
|
hasObjCntrl : Boolean;
|
2007-05-02 22:55:35 +00:00
|
|
|
tmpObj : UserService;
|
|
|
|
callCtx : ICallContext;
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName : string;
|
2007-05-02 22:55:35 +00:00
|
|
|
procName,trgName : string;
|
2007-09-02 19:05:47 +00:00
|
|
|
AUser : TUser;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
callCtx := AContext;
|
2007-09-02 19:05:47 +00:00
|
|
|
Fillchar(AUser,SizeOf(TUser),#0);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName := 'AUser'; AFormatter.Get(TypeInfo(TUser),locStrPrmName,AUser);
|
2007-06-28 23:33:38 +00:00
|
|
|
if Assigned(Pointer(AUser)) then
|
2007-05-02 22:55:35 +00:00
|
|
|
callCtx.AddObjectToFree(TObject(AUser));
|
|
|
|
|
|
|
|
tmpObj := Self.GetFactory().CreateInstance() as UserService;
|
|
|
|
if Supports(tmpObj,ICallControl,cllCntrl) then
|
2007-06-28 23:33:38 +00:00
|
|
|
cllCntrl.SetCallContext(callCtx);
|
|
|
|
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Activate();
|
|
|
|
try
|
|
|
|
tmpObj.Add(AUser);
|
|
|
|
|
|
|
|
procName := AFormatter.GetCallProcedureName();
|
|
|
|
trgName := AFormatter.GetCallTarget();
|
|
|
|
AFormatter.Clear();
|
|
|
|
AFormatter.BeginCallResponse(procName,trgName);
|
|
|
|
AFormatter.EndCallResponse();
|
|
|
|
|
|
|
|
callCtx := nil;
|
|
|
|
finally
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Deactivate();
|
|
|
|
Self.GetFactory().ReleaseInstance(tmpObj);
|
|
|
|
end;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2007-06-28 23:33:38 +00:00
|
|
|
procedure TUserService_ServiceBinder.UpdateHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
var
|
2007-05-02 22:55:35 +00:00
|
|
|
cllCntrl : ICallControl;
|
2007-06-28 23:33:38 +00:00
|
|
|
objCntrl : IObjectControl;
|
|
|
|
hasObjCntrl : Boolean;
|
2007-05-02 22:55:35 +00:00
|
|
|
tmpObj : UserService;
|
|
|
|
callCtx : ICallContext;
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName : string;
|
2007-05-02 22:55:35 +00:00
|
|
|
procName,trgName : string;
|
2007-09-02 19:05:47 +00:00
|
|
|
AUser : TUser;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
callCtx := AContext;
|
2007-09-02 19:05:47 +00:00
|
|
|
Fillchar(AUser,SizeOf(TUser),#0);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName := 'AUser'; AFormatter.Get(TypeInfo(TUser),locStrPrmName,AUser);
|
2007-06-28 23:33:38 +00:00
|
|
|
if Assigned(Pointer(AUser)) then
|
2007-05-02 22:55:35 +00:00
|
|
|
callCtx.AddObjectToFree(TObject(AUser));
|
|
|
|
|
|
|
|
tmpObj := Self.GetFactory().CreateInstance() as UserService;
|
|
|
|
if Supports(tmpObj,ICallControl,cllCntrl) then
|
2007-06-28 23:33:38 +00:00
|
|
|
cllCntrl.SetCallContext(callCtx);
|
|
|
|
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Activate();
|
|
|
|
try
|
|
|
|
tmpObj.Update(AUser);
|
|
|
|
|
|
|
|
procName := AFormatter.GetCallProcedureName();
|
|
|
|
trgName := AFormatter.GetCallTarget();
|
|
|
|
AFormatter.Clear();
|
|
|
|
AFormatter.BeginCallResponse(procName,trgName);
|
|
|
|
AFormatter.EndCallResponse();
|
|
|
|
|
|
|
|
callCtx := nil;
|
|
|
|
finally
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Deactivate();
|
|
|
|
Self.GetFactory().ReleaseInstance(tmpObj);
|
|
|
|
end;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2007-06-28 23:33:38 +00:00
|
|
|
procedure TUserService_ServiceBinder.FindHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
var
|
2007-05-02 22:55:35 +00:00
|
|
|
cllCntrl : ICallControl;
|
2007-06-28 23:33:38 +00:00
|
|
|
objCntrl : IObjectControl;
|
|
|
|
hasObjCntrl : Boolean;
|
2007-05-02 22:55:35 +00:00
|
|
|
tmpObj : UserService;
|
|
|
|
callCtx : ICallContext;
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName : string;
|
2007-05-02 22:55:35 +00:00
|
|
|
procName,trgName : string;
|
|
|
|
AName : string;
|
2007-09-02 19:05:47 +00:00
|
|
|
returnVal : TUser;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
callCtx := AContext;
|
2007-09-02 19:05:47 +00:00
|
|
|
Fillchar(returnVal,SizeOf(TUser),#0);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName := 'AName'; AFormatter.Get(TypeInfo(string),locStrPrmName,AName);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
tmpObj := Self.GetFactory().CreateInstance() as UserService;
|
|
|
|
if Supports(tmpObj,ICallControl,cllCntrl) then
|
2007-06-28 23:33:38 +00:00
|
|
|
cllCntrl.SetCallContext(callCtx);
|
|
|
|
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Activate();
|
|
|
|
try
|
|
|
|
returnVal := tmpObj.Find(AName);
|
|
|
|
if Assigned(TObject(returnVal)) then
|
|
|
|
callCtx.AddObjectToFree(TObject(returnVal));
|
|
|
|
|
|
|
|
procName := AFormatter.GetCallProcedureName();
|
|
|
|
trgName := AFormatter.GetCallTarget();
|
|
|
|
AFormatter.Clear();
|
|
|
|
AFormatter.BeginCallResponse(procName,trgName);
|
2007-09-02 19:05:47 +00:00
|
|
|
AFormatter.Put('result',TypeInfo(TUser),returnVal);
|
2007-06-28 23:33:38 +00:00
|
|
|
AFormatter.EndCallResponse();
|
|
|
|
|
|
|
|
callCtx := nil;
|
|
|
|
finally
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Deactivate();
|
|
|
|
Self.GetFactory().ReleaseInstance(tmpObj);
|
|
|
|
end;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2007-06-28 23:33:38 +00:00
|
|
|
procedure TUserService_ServiceBinder.DeleteHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
|
|
|
var
|
2007-05-02 22:55:35 +00:00
|
|
|
cllCntrl : ICallControl;
|
2007-06-28 23:33:38 +00:00
|
|
|
objCntrl : IObjectControl;
|
|
|
|
hasObjCntrl : Boolean;
|
2007-05-02 22:55:35 +00:00
|
|
|
tmpObj : UserService;
|
|
|
|
callCtx : ICallContext;
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName : string;
|
2007-05-02 22:55:35 +00:00
|
|
|
procName,trgName : string;
|
|
|
|
AName : string;
|
|
|
|
returnVal : boolean;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
callCtx := AContext;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
2010-01-29 15:30:24 +00:00
|
|
|
locStrPrmName := 'AName'; AFormatter.Get(TypeInfo(string),locStrPrmName,AName);
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
tmpObj := Self.GetFactory().CreateInstance() as UserService;
|
|
|
|
if Supports(tmpObj,ICallControl,cllCntrl) then
|
2007-06-28 23:33:38 +00:00
|
|
|
cllCntrl.SetCallContext(callCtx);
|
|
|
|
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Activate();
|
|
|
|
try
|
|
|
|
returnVal := tmpObj.Delete(AName);
|
|
|
|
|
|
|
|
procName := AFormatter.GetCallProcedureName();
|
|
|
|
trgName := AFormatter.GetCallTarget();
|
|
|
|
AFormatter.Clear();
|
|
|
|
AFormatter.BeginCallResponse(procName,trgName);
|
|
|
|
AFormatter.Put('result',TypeInfo(boolean),returnVal);
|
|
|
|
AFormatter.EndCallResponse();
|
|
|
|
|
|
|
|
callCtx := nil;
|
|
|
|
finally
|
|
|
|
if hasObjCntrl then
|
|
|
|
objCntrl.Deactivate();
|
|
|
|
Self.GetFactory().ReleaseInstance(tmpObj);
|
|
|
|
end;
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
constructor TUserService_ServiceBinder.Create();
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
inherited Create(GetServiceImplementationRegistry().FindFactory('UserService'));
|
2007-07-12 14:46:45 +00:00
|
|
|
RegisterVerbHandler('GetList',{$IFDEF FPC}@{$ENDIF}GetListHandler);
|
|
|
|
RegisterVerbHandler('Add',{$IFDEF FPC}@{$ENDIF}AddHandler);
|
|
|
|
RegisterVerbHandler('Update',{$IFDEF FPC}@{$ENDIF}UpdateHandler);
|
|
|
|
RegisterVerbHandler('Find',{$IFDEF FPC}@{$ENDIF}FindHandler);
|
|
|
|
RegisterVerbHandler('Delete',{$IFDEF FPC}@{$ENDIF}DeleteHandler);
|
2007-06-28 23:33:38 +00:00
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
{ TUserService_ServiceBinderFactory }
|
2007-06-28 23:33:38 +00:00
|
|
|
|
2007-05-02 22:55:35 +00:00
|
|
|
function TUserService_ServiceBinderFactory.CreateInstance():IInterface;
|
2007-06-28 23:33:38 +00:00
|
|
|
begin
|
|
|
|
Result := FInstance;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TUserService_ServiceBinderFactory.Create();
|
|
|
|
begin
|
|
|
|
FInstance := TUserService_ServiceBinder.Create() as IInterface;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TUserService_ServiceBinderFactory.Destroy();
|
|
|
|
begin
|
|
|
|
FInstance := nil;
|
|
|
|
inherited Destroy();
|
|
|
|
end;
|
2007-05-02 22:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
procedure Server_service_RegisterUserServiceService();
|
|
|
|
Begin
|
|
|
|
GetServerServiceRegistry().Register('UserService',TUserService_ServiceBinderFactory.Create() as IItemFactory);
|
|
|
|
End;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
|
|
|
|
{$i user_service_intf.wst}
|
|
|
|
|
2007-07-18 11:23:56 +00:00
|
|
|
{$IF DECLARED(Register_user_service_intf_ServiceMetadata)}
|
|
|
|
Register_user_service_intf_ServiceMetadata();
|
|
|
|
{$IFEND}
|
|
|
|
|
2007-05-02 22:55:35 +00:00
|
|
|
End.
|