From 22b23d0589533cb55f26687603a977626a4452c8 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 30 Jul 2008 15:00:17 +0000 Subject: [PATCH] - Servidor: mejorada la forma de llamar a los servicios desde otros servicios. git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@301 f4e31baf-9722-1c47-927c-6f952f962d4b --- .../Controller/uUsuariosController.pas | 4 + .../Usuarios/Data/uDataModuleUsuarios.dfm | 7 ++ .../Usuarios/Data/uDataModuleUsuarios.pas | 13 +++ .../Model/Data/uIDataModuleUsuarios.pas | 3 + .../Contabilidad/Model/uBizAsientosServer.pas | 16 ++-- .../Servidor/srvContabilidad_Impl.pas | 23 +++--- .../Contactos/Model/uBizClientesServer.pas | 71 ++++++++-------- .../Contactos/Model/uBizProveedoresServer.pas | 78 ++++++++---------- Source/Servicios/FactuGES.RODL | 18 +++- Source/Servicios/FactuGES_Intf.pas | 44 +++++++++- Source/Servicios/FactuGES_Invk.pas | 49 ++++++++++- Source/Servicios/RODLFILE.res | Bin 28408 -> 28067 bytes Source/Servidor/FactuGES_Server.RES | Bin 23344 -> 23352 bytes Source/Servidor/FactuGES_Server.dpr | 6 +- Source/Servidor/FactuGES_Server.rc | 2 +- Source/Servidor/srvLogin_Impl.pas | 66 ++++++++++++++- 16 files changed, 289 insertions(+), 111 deletions(-) diff --git a/Source/ApplicationBase/Usuarios/Controller/uUsuariosController.pas b/Source/ApplicationBase/Usuarios/Controller/uUsuariosController.pas index a0809b49..b6eceb96 100644 --- a/Source/ApplicationBase/Usuarios/Controller/uUsuariosController.pas +++ b/Source/ApplicationBase/Usuarios/Controller/uUsuariosController.pas @@ -349,6 +349,10 @@ begin end; end; end; + +{ if Result then + // Para que el servidor cree la sesión del usuario + FDataModule.Login(User, Password);} end; constructor TUsuariosController.Create; diff --git a/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.dfm b/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.dfm index 473654b1..56e8c065 100644 --- a/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.dfm +++ b/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.dfm @@ -423,4 +423,11 @@ inherited DataModuleUsuarios: TDataModuleUsuarios Left = 272 Top = 136 end + object srvLogin: TRORemoteService + Message = dmConexion.ROMessage + Channel = dmConexion.ROChannel + ServiceName = 'srvLogin' + Left = 40 + Top = 208 + end end diff --git a/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.pas b/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.pas index 43f82090..77014797 100644 --- a/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.pas +++ b/Source/ApplicationBase/Usuarios/Data/uDataModuleUsuarios.pas @@ -20,6 +20,7 @@ type ds_USUARIOS: TDADataSource; tbl_PERFILES: TDAMemDataTable; ds_PERFILES: TDADataSource; + srvLogin: TRORemoteService; procedure DataModuleCreate(Sender: TObject); private @@ -38,6 +39,9 @@ type procedure InicializarUserControl (AUserControl : TUserControl); function DarTiendaUsuario(const ID_Usuario: Integer; var AID_Tienda: Integer; var ATienda: String) : Boolean; + + function Login(const AUser: String; const APassword: String): Boolean; + procedure Logout; end; @@ -476,5 +480,14 @@ begin end; end; +function TDataModuleUsuarios.Login(const AUser: String; const APassword: String): Boolean; +begin + Result := (srvLogin as IsrvLogin).Login(AUser, APassword); +end; + +procedure TDataModuleUsuarios.Logout; +begin + (srvLogin as IsrvLogin).Logout; +end; end. diff --git a/Source/ApplicationBase/Usuarios/Model/Data/uIDataModuleUsuarios.pas b/Source/ApplicationBase/Usuarios/Model/Data/uIDataModuleUsuarios.pas index 5cceb718..73c8286c 100644 --- a/Source/ApplicationBase/Usuarios/Model/Data/uIDataModuleUsuarios.pas +++ b/Source/ApplicationBase/Usuarios/Model/Data/uIDataModuleUsuarios.pas @@ -19,6 +19,9 @@ type function GetPerfil(const ID : Integer) : IBizPerfilUsuario; function DarTiendaUsuario(const ID_Usuario: Integer; var AID_Tienda: Integer; var ATienda: String) : Boolean; + + function Login(const AUser: String; const APassword: String): Boolean; + procedure Logout; end; implementation diff --git a/Source/Modulos/Contabilidad/Model/uBizAsientosServer.pas b/Source/Modulos/Contabilidad/Model/uBizAsientosServer.pas index f30b8c6b..e6c9f75c 100644 --- a/Source/Modulos/Contabilidad/Model/uBizAsientosServer.pas +++ b/Source/Modulos/Contabilidad/Model/uBizAsientosServer.pas @@ -19,22 +19,26 @@ implementation uses Variants, uDAClasses, uBusinessUtils, uROClasses, uDataModuleServer, - srvContabilidad_Impl; + SysUtils, uROServer, FactuGES_Intf; { TBizAsientosServer } procedure TBizAsientosServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); +var + AContabilidadService : IsrvContabilidad; + Intf : IInterface; + AClientID : TGUID; begin case Sender.CurrentChange.ChangeType of ctInsert, ctUpdate: begin //Si el orden del asiento no ha sido asignado le asignamos uno nosotros if (ORDENIsNull) or (ORDEN = 0) then begin - with TsrvContabilidad.Create(Nil) do - begin - ORDEN := DarNumOrden; - Free; - end; + CreateGUID(AClientID); + + GetClassFactory('srvContabilidad').CreateInstance(AClientID, Intf); + AContabilidadService := Intf as IsrvContabilidad; + ORDEN := AContabilidadService.DarNumOrdenAsiento; end; end; end; diff --git a/Source/Modulos/Contabilidad/Servidor/srvContabilidad_Impl.pas b/Source/Modulos/Contabilidad/Servidor/srvContabilidad_Impl.pas index d21d30f5..d899407b 100644 --- a/Source/Modulos/Contabilidad/Servidor/srvContabilidad_Impl.pas +++ b/Source/Modulos/Contabilidad/Servidor/srvContabilidad_Impl.pas @@ -38,13 +38,13 @@ type procedure DARemoteServiceCreate(Sender: TObject); procedure DataAbstractServiceBeforeAcquireConnection(aSender: TObject; var aConnectionName: string); private - function darEjercicioActivo(const ID_EMPRESA: Integer): Integer; + function DarEjercicioActivo(const ID_EMPRESA: Integer): Integer; public function TieneCuentaAsociada(const ID_CONTACTO: Integer; const ID_EMPRESA: Integer): Boolean; function AnadirSubCuentaCliente(const ID_CONTACTO: Integer; const ID_TIENDA: Integer; const ID_EMPRESA: Integer; const CLIENTE: String): Boolean; function AnadirSubCuentaProveedor(const ID_CONTACTO: Integer; const ES_ACREEDOR: Integer; const ID_EMPRESA: Integer; const PROVEEDOR: String): Boolean; - function DarNumOrden : Integer; + function DarNumOrdenAsiento : Integer; end; implementation @@ -226,14 +226,17 @@ begin end; end; -function TsrvContabilidad.darEjercicioActivo(const ID_EMPRESA: Integer): Integer; +function TsrvContabilidad.DarEjercicioActivo(const ID_EMPRESA: Integer): Integer; +var + AEjerciciosService : IsrvEjercicios; + Intf : IInterface; + AClientID : TGUID; begin - with TsrvEjercicios.Create(NIL) do - try - Result := DarEjercicioActivo(ID_EMPRESA) - finally - Free; - end; + CreateGUID(AClientID); + + GetClassFactory('srvEjercicios').CreateInstance(AClientID, Intf); + AEjerciciosService := Intf as IsrvEjercicios; + Result := AEjerciciosService.darEjercicioActivo(ID_EMPRESA) end; procedure TsrvContabilidad.DARemoteServiceCreate(Sender: TObject); @@ -242,7 +245,7 @@ begin bpAsientos.BusinessRulesID := BIZ_SERVER_ASIENTOS; end; -function TsrvContabilidad.DarNumOrden: Integer; +function TsrvContabilidad.DarNumOrdenAsiento: Integer; var AConn : IDAConnection; dsData: IDADataset; diff --git a/Source/Modulos/Contactos/Model/uBizClientesServer.pas b/Source/Modulos/Contactos/Model/uBizClientesServer.pas index 8ea76adf..838cb697 100644 --- a/Source/Modulos/Contactos/Model/uBizClientesServer.pas +++ b/Source/Modulos/Contactos/Model/uBizClientesServer.pas @@ -15,6 +15,7 @@ type FReferenciaAutomatica : Boolean; function DarReferencia : String; function IncrementarReferencia : Boolean; + procedure CrearCuentaContable(aChange: TDADeltaChange); protected procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override; procedure Update_Datos_Contacto(aChange: TDADeltaChange); override; @@ -28,7 +29,8 @@ implementation uses uDataModuleServer, uDAClasses, srvContabilidad_Impl, - schContactosClient_Intf, uBusinessUtils; + schContactosClient_Intf, uBusinessUtils, FactuGES_Intf, + uROServer, SysUtils; const REF_CLIENTE = 'REF_CLIENTE'; @@ -51,6 +53,30 @@ begin end; end; +procedure TBizClienteServer.CrearCuentaContable(aChange: TDADeltaChange); +var + AContabilidadService : IsrvContabilidad; + Intf : IInterface; + AClientID : TGUID; + + ANombre: string; + AIDEmpresa: Integer; + AIDCliente: Integer; + AIDTienda: Integer; +begin + AIDCliente := aChange.NewValueByName[fld_ClientesID]; + AIDTienda := aChange.NewValueByName[fld_ClientesID_TIENDA]; + AIDEmpresa := aChange.NewValueByName[fld_ClientesID_EMPRESA]; + ANombre := aChange.NewValueByName[fld_ClientesNOMBRE]; + + CreateGUID(AClientID); + GetClassFactory('srvContabilidad').CreateInstance(AClientID, Intf); + AContabilidadService := Intf as IsrvContabilidad; + + if not AContabilidadService.TieneCuentaAsociada(AIDCliente, AIDEmpresa) then + AContabilidadService.AnadirSubCuentaCliente(AIDCliente, AIDTienda, AIDEmpresa, ANombre); +end; + procedure TBizClienteServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); begin FReferenciaAutomatica := False; @@ -105,12 +131,6 @@ var ASchema : TDASchema; ACurrentConn : IDAConnection; ACommand : IDASQLCommand; - - idCliente: integer; - idTienda: integer; - idEmpresa: integer; - Nombre: string; - begin inherited; @@ -142,20 +162,10 @@ begin //En caso de no ignorar contabilidad se deberá dar de alta una cuenta para el cliente si el usuario no la ha asignado - if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) - and (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then + if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) and + (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then begin - with TsrvContabilidad.Create(NIL) do - try - IdCliente := aChange.NewValueByName[fld_ClientesID]; - IdTienda := aChange.NewValueByName[fld_ClientesID_TIENDA]; - IdEmpresa := aChange.NewValueByName[fld_ClientesID_EMPRESA]; - Nombre := aChange.NewValueByName[fld_ClientesNOMBRE]; - if not TieneCuentaAsociada(idCliente, idEmpresa) then - AnadirSubCuentaCliente(idCliente, idTienda, idEmpresa, Nombre); - finally - Free; - end; + CrearCuentaContable(aChange); end; finally @@ -169,11 +179,6 @@ var ASchema : TDASchema; ACurrentConn : IDAConnection; ACommand : IDASQLCommand; - - idCliente: integer; - idTienda: integer; - idEmpresa: integer; - begin inherited; @@ -205,20 +210,10 @@ begin end; //En caso de no ignorar contabilidad se deberá dar de alta una cuenta para el cliente si el usuario no la ha asignado - if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) - and (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then + if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) and + (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then begin - with TsrvContabilidad.Create(NIL) do - try - IdCliente := aChange.NewValueByName[fld_ClientesID]; - IdTienda := aChange.NewValueByName[fld_ClientesID_TIENDA]; - IdEmpresa := aChange.NewValueByName[fld_ClientesID_EMPRESA]; - Nombre := aChange.NewValueByName[fld_ClientesNOMBRE]; - if not TieneCuentaAsociada(idCliente, idEmpresa) then - AnadirSubCuentaCliente(idCliente, idTienda, idEmpresa, Nombre); - finally - Free; - end; + CrearCuentaContable(aChange); end; finally diff --git a/Source/Modulos/Contactos/Model/uBizProveedoresServer.pas b/Source/Modulos/Contactos/Model/uBizProveedoresServer.pas index 75c13d90..4b3dd5c6 100644 --- a/Source/Modulos/Contactos/Model/uBizProveedoresServer.pas +++ b/Source/Modulos/Contactos/Model/uBizProveedoresServer.pas @@ -15,6 +15,7 @@ type FReferenciaAutomatica : Boolean; function DarReferencia : String; function IncrementarReferencia : Boolean; + procedure CrearCuentaContable(aChange: TDADeltaChange); protected procedure Insert_Datos_Contacto(aChange: TDADeltaChange); override; procedure Update_Datos_Contacto(aChange: TDADeltaChange); override; @@ -28,7 +29,8 @@ implementation uses uDataModuleServer, uDAClasses, srvContabilidad_Impl, - schContactosClient_Intf, uBusinessUtils; + schContactosClient_Intf, uBusinessUtils, FactuGES_Intf, + uROServer, SysUtils; const REF_PROVEEDOR = 'REF_PROVEEDOR'; @@ -51,6 +53,31 @@ begin end; end; +procedure TBizProveedorServer.CrearCuentaContable(aChange: TDADeltaChange); +var + AIDProveedor: Integer; + bEsAcreedor: Integer; + ANombre: string; + AIDEmpresa: Integer; + + Intf: IInterface; + AContabilidadService: IsrvContabilidad; + AClientID: TGUID; +begin + AIDProveedor := aChange.NewValueByName[fld_ProveedoresID]; + bEsAcreedor := aChange.NewValueByName[fld_ProveedoresES_ACREEDOR]; + AIDEmpresa := aChange.NewValueByName[fld_ProveedoresID_EMPRESA]; + ANombre := aChange.NewValueByName[fld_ProveedoresNOMBRE]; + + CreateGUID(AClientID); + GetClassFactory('srvContabilidad').CreateInstance(AClientID, Intf); + AContabilidadService := Intf as IsrvContabilidad; + + if not AContabilidadService.TieneCuentaAsociada(AIDProveedor, AIDEmpresa) then + AContabilidadService.AnadirSubCuentaProveedor(AIDProveedor, bEsAcreedor, AIDEmpresa, ANombre); +end; + + procedure TBizProveedorServer.BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); begin FReferenciaAutomatica := False; @@ -102,15 +129,9 @@ end; procedure TBizProveedorServer.Insert_Datos_Contacto(aChange: TDADeltaChange); var - ASchema : TDASchema; ACurrentConn : IDAConnection; ACommand : IDASQLCommand; - - idProveedor: integer; - EsAcreedor: integer; - idEmpresa: integer; - Nombre: string; - + ASchema : TDASchema; begin inherited; @@ -140,22 +161,11 @@ begin end; //En caso de no ignorar contabilidad se deberá dar de alta una cuenta para el cliente si el usuario no la ha asignado - if (aChange.NewValueByName[fld_ProveedoresIGNORAR_CONTABILIDAD] = 0) - and (aChange.NewValueByName[fld_ProveedoresTIENE_SUBCUENTA] = 0) then + if (aChange.NewValueByName[fld_ProveedoresIGNORAR_CONTABILIDAD] = 0) and + (aChange.NewValueByName[fld_ProveedoresTIENE_SUBCUENTA] = 0) then begin - with TsrvContabilidad.Create(NIL) do - try - IdProveedor := aChange.NewValueByName[fld_ProveedoresID]; - EsAcreedor := aChange.NewValueByName[fld_ProveedoresES_ACREEDOR]; - IdEmpresa := aChange.NewValueByName[fld_ProveedoresID_EMPRESA]; - Nombre := aChange.NewValueByName[fld_ProveedoresNOMBRE]; - if not TieneCuentaAsociada(IdProveedor, IdEmpresa) then - AnadirSubCuentaProveedor(IdProveedor, EsAcreedor, IdEmpresa, Nombre); - finally - Free; - end; + CrearCuentaContable(aChange); end; - finally ACommand := NIL; end; @@ -167,12 +177,6 @@ var ASchema : TDASchema; ACurrentConn : IDAConnection; ACommand : IDASQLCommand; - - idProveedor: integer; - EsAcreedor: integer; - idEmpresa: integer; - Nombre: string; - begin inherited; @@ -198,25 +202,15 @@ begin ParamByName('IGNORAR_CONTABILIDAD').Value := aChange.NewValueByName[fld_ProveedoresIGNORAR_CONTABILIDAD]; ParamByName('TIENE_SUBCUENTA').Value := aChange.NewValueByName[fld_ProveedoresTIENE_SUBCUENTA]; ParamByName('NOMBRE_COMERCIAL').Value := aChange.NewValueByName[fld_ProveedoresNOMBRE_COMERCIAL]; - ParamByName('ES_ACREEDOR').Value := aChange.NewValueByName[fld_ProveedoresES_ACREEDOR]; + ParamByName('ES_ACREEDOR').Value := aChange.NewValueByName[fld_ProveedoresES_ACREEDOR]; Execute; end; //En caso de no ignorar contabilidad se deberá dar de alta una cuenta para el cliente si el usuario no la ha asignado - if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) - and (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then + if (aChange.NewValueByName[fld_ClientesIGNORAR_CONTABILIDAD] = 0) and + (aChange.NewValueByName[fld_ClientesTIENE_SUBCUENTA] = 0) then begin - with TsrvContabilidad.Create(NIL) do - try - IdProveedor := aChange.NewValueByName[fld_ProveedoresID]; - EsAcreedor := aChange.NewValueByName[fld_ProveedoresEs_ACREEDOR]; - IdEmpresa := aChange.NewValueByName[fld_ProveedoresID_EMPRESA]; - Nombre := aChange.NewValueByName[fld_ProveedoresNOMBRE]; - if not TieneCuentaAsociada(IdProveedor, IdEmpresa) then - AnadirSubCuentaProveedor(IdProveedor, EsAcreedor, IdEmpresa, Nombre); - finally - Free; - end; + CrearCuentaContable(aChange); end; finally diff --git a/Source/Servicios/FactuGES.RODL b/Source/Servicios/FactuGES.RODL index 7f33465f..3b2a450e 100644 --- a/Source/Servicios/FactuGES.RODL +++ b/Source/Servicios/FactuGES.RODL @@ -36,7 +36,7 @@ - + @@ -48,6 +48,16 @@ + + + + + + + + + + @@ -439,6 +449,12 @@ + + + + + + diff --git a/Source/Servicios/FactuGES_Intf.pas b/Source/Servicios/FactuGES_Intf.pas index ca5cae6a..25f3c52e 100644 --- a/Source/Servicios/FactuGES_Intf.pas +++ b/Source/Servicios/FactuGES_Intf.pas @@ -185,7 +185,8 @@ type { IsrvLogin } IsrvLogin = interface(IDataAbstractService) ['{399F9DB4-1B34-4140-AB6E-3BC10C0A7034}'] - function Login(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login2(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login(const User: String; const Password: String): Boolean; procedure Logout; function Ping: Boolean; end; @@ -200,7 +201,8 @@ type protected function __GetInterfaceName:string; override; - function Login(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login2(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login(const User: String; const Password: String): Boolean; procedure Logout; function Ping: Boolean; end; @@ -622,6 +624,7 @@ type function TieneCuentaAsociada(const ID_CONTACTO: Integer; const ID_EMPRESA: Integer): Boolean; function AnadirSubCuentaCliente(const ID_CONTACTO: Integer; const ID_TIENDA: Integer; const ID_EMPRESA: Integer; const CLIENTE: String): Boolean; function AnadirSubCuentaProveedor(const ID_CONTACTO: Integer; const ES_ACREEDOR: Integer; const ID_EMPRESA: Integer; const PROVEEDOR: String): Boolean; + function DarNumOrdenAsiento: Integer; end; { CosrvContabilidad } @@ -637,6 +640,7 @@ type function TieneCuentaAsociada(const ID_CONTACTO: Integer; const ID_EMPRESA: Integer): Boolean; function AnadirSubCuentaCliente(const ID_CONTACTO: Integer; const ID_TIENDA: Integer; const ID_EMPRESA: Integer; const CLIENTE: String): Boolean; function AnadirSubCuentaProveedor(const ID_CONTACTO: Integer; const ES_ACREEDOR: Integer; const ID_EMPRESA: Integer; const PROVEEDOR: String): Boolean; + function DarNumOrdenAsiento: Integer; end; { IsrvUnidadesMedida } @@ -1033,11 +1037,11 @@ begin result := 'srvLogin'; end; -function TsrvLogin_Proxy.Login(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; +function TsrvLogin_Proxy.Login2(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; begin try LoginInfo := nil; - __Message.InitializeRequestMessage(__TransportChannel, 'FactuGES', __InterfaceName, 'Login'); + __Message.InitializeRequestMessage(__TransportChannel, 'FactuGES', __InterfaceName, 'Login2'); __Message.Write('User', TypeInfo(String), User, []); __Message.Write('Password', TypeInfo(String), Password, []); __Message.Finalize; @@ -1052,6 +1056,23 @@ begin end end; +function TsrvLogin_Proxy.Login(const User: String; const Password: String): Boolean; +begin + try + __Message.InitializeRequestMessage(__TransportChannel, 'FactuGES', __InterfaceName, 'Login'); + __Message.Write('User', TypeInfo(String), User, []); + __Message.Write('Password', TypeInfo(String), Password, []); + __Message.Finalize; + + __TransportChannel.Dispatch(__Message); + + __Message.Read('Result', TypeInfo(Boolean), result, []); + finally + __Message.UnsetAttributes(__TransportChannel); + __Message.FreeStream; + end +end; + procedure TsrvLogin_Proxy.Logout; begin try @@ -1732,6 +1753,21 @@ begin end end; +function TsrvContabilidad_Proxy.DarNumOrdenAsiento: Integer; +begin + try + __Message.InitializeRequestMessage(__TransportChannel, 'FactuGES', __InterfaceName, 'DarNumOrdenAsiento'); + __Message.Finalize; + + __TransportChannel.Dispatch(__Message); + + __Message.Read('Result', TypeInfo(Integer), result, []); + finally + __Message.UnsetAttributes(__TransportChannel); + __Message.FreeStream; + end +end; + { CosrvUnidadesMedida } class function CosrvUnidadesMedida.Create(const aMessage: IROMessage; aTransportChannel: IROTransportChannel): IsrvUnidadesMedida; diff --git a/Source/Servicios/FactuGES_Invk.pas b/Source/Servicios/FactuGES_Invk.pas index d3e7f1ee..c4891ba1 100644 --- a/Source/Servicios/FactuGES_Invk.pas +++ b/Source/Servicios/FactuGES_Invk.pas @@ -32,6 +32,7 @@ type private protected published + procedure Invoke_Login2(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); procedure Invoke_Login(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); procedure Invoke_Logout(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); procedure Invoke_Ping(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); @@ -193,6 +194,7 @@ type procedure Invoke_TieneCuentaAsociada(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); procedure Invoke_AnadirSubCuentaCliente(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); procedure Invoke_AnadirSubCuentaProveedor(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); + procedure Invoke_DarNumOrdenAsiento(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); end; TsrvUnidadesMedida_Invoker = class(TDataAbstractService_Invoker) @@ -275,8 +277,8 @@ end; { TsrvLogin_Invoker } -procedure TsrvLogin_Invoker.Invoke_Login(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); -{ function Login(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; } +procedure TsrvLogin_Invoker.Invoke_Login2(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); +{ function Login2(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; } var User: String; Password: String; @@ -289,9 +291,9 @@ begin __Message.Read('User', TypeInfo(String), User, []); __Message.Read('Password', TypeInfo(String), Password, []); - lResult := (__Instance as IsrvLogin).Login(User, Password, LoginInfo); + lResult := (__Instance as IsrvLogin).Login2(User, Password, LoginInfo); - __Message.InitializeResponseMessage(__Transport, 'FactuGES', 'srvLogin', 'LoginResponse'); + __Message.InitializeResponseMessage(__Transport, 'FactuGES', 'srvLogin', 'Login2Response'); __Message.Write('Result', TypeInfo(Boolean), lResult, []); __Message.Write('LoginInfo', TypeInfo(FactuGES_Intf.TRdxLoginInfo), LoginInfo, []); __Message.Finalize; @@ -307,6 +309,28 @@ begin end; end; +procedure TsrvLogin_Invoker.Invoke_Login(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); +{ function Login(const User: String; const Password: String): Boolean; } +var + User: String; + Password: String; + lResult: Boolean; +begin + try + __Message.Read('User', TypeInfo(String), User, []); + __Message.Read('Password', TypeInfo(String), Password, []); + + lResult := (__Instance as IsrvLogin).Login(User, Password); + + __Message.InitializeResponseMessage(__Transport, 'FactuGES', 'srvLogin', 'LoginResponse'); + __Message.Write('Result', TypeInfo(Boolean), lResult, []); + __Message.Finalize; + __Message.UnsetAttributes(__Transport); + + finally + end; +end; + procedure TsrvLogin_Invoker.Invoke_Logout(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); { procedure Logout; } begin @@ -887,6 +911,23 @@ begin end; end; +procedure TsrvContabilidad_Invoker.Invoke_DarNumOrdenAsiento(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); +{ function DarNumOrdenAsiento: Integer; } +var + lResult: Integer; +begin + try + lResult := (__Instance as IsrvContabilidad).DarNumOrdenAsiento; + + __Message.InitializeResponseMessage(__Transport, 'FactuGES', 'srvContabilidad', 'DarNumOrdenAsientoResponse'); + __Message.Write('Result', TypeInfo(Integer), lResult, []); + __Message.Finalize; + __Message.UnsetAttributes(__Transport); + + finally + end; +end; + { TsrvComisiones_Invoker } procedure TsrvComisiones_Invoker.Invoke_GenerateReport(const __Instance:IInterface; const __Message:IROMessage; const __Transport:IROTransport; out __oResponseOptions:TROResponseOptions); diff --git a/Source/Servicios/RODLFILE.res b/Source/Servicios/RODLFILE.res index d5094919319a8a565928c5bb05f08b059005a327..6f5cfcae72eab555019f8d7232a4068316a28b4d 100644 GIT binary patch delta 224 zcmexymvQlJ#t8~c!MPii+!$5O4J=J8EM1LtjUC-wbxll6EOjkRoPk^eQ)eR!Gb1Ns z6N}o(38MC!&oFM|-dxWw$T;~vGy7&np*lfEqs{fo(-|iVNO7qcIXRj+TN)ednmAhk z2}@%`T?+$eb6pb`V^?D%XA?6=BeThZ4(5~n#mpy5s?<#0prE^1ShdS!a)W??txIB& zUumv?QA%o_V{v9`UP-=^La3*Utx~m%k&%mqv$>0|qlK%bu8EVefv%IItE;ZLi-oC~ Yv$>m@v*F~0rsk6cv@|w1L{^9b0DG`LsQ>@~ delta 299 zcmZ2{oAJk8#t8~cEAlofxiP95I~g0hI2*X>x;k5$=$aTCyXsn+J38yS7+4y(nOQhF zyP7%HPBxIV-+YE~8@H)@YKco?Nuq0ol0vAbi>*?%fsv`BnX7?|u7#iBiBsU{-5`*I8?kHKo9EMVcJcd+; YVg?-s1qLGqi^&J0w3$tT^!q4J0HdT9#Q*>R diff --git a/Source/Servidor/FactuGES_Server.dpr b/Source/Servidor/FactuGES_Server.dpr index 2c6b47ba..d9f84245 100644 --- a/Source/Servidor/FactuGES_Server.dpr +++ b/Source/Servidor/FactuGES_Server.dpr @@ -58,8 +58,6 @@ uses uBizPedidosProveedorServer in '..\Modulos\Pedidos a proveedor\Model\uBizPedidosProveedorServer.pas', uBizAlbaranProveedorServer in '..\Modulos\Albaranes de proveedor\Model\uBizAlbaranProveedorServer.PAS', uBizFacturasProveedorServer in '..\Modulos\Facturas de proveedor\Model\uBizFacturasProveedorServer.pas', - schAlmacenesClient_Intf in '..\Modulos\Almacenes\Model\schAlmacenesClient_Intf.pas', - schAlmacenesServer_Intf in '..\Modulos\Almacenes\Model\schAlmacenesServer_Intf.pas', schArticulosClient_Intf in '..\Modulos\Articulos\Model\schArticulosClient_Intf.pas', schArticulosServer_Intf in '..\Modulos\Articulos\Model\schArticulosServer_Intf.pas', srvRemesasCliente_Impl in '..\Modulos\Remesas de cliente\Servidor\srvRemesasCliente_Impl.pas' {srvRemesasCliente: TDataAbstractService}, @@ -125,7 +123,9 @@ uses schEjerciciosClient_Intf in '..\ApplicationBase\Ejercicios\Model\schEjerciciosClient_Intf.pas', schEjerciciosServer_Intf in '..\ApplicationBase\Ejercicios\Model\schEjerciciosServer_Intf.pas', schUsuariosClient_Intf in '..\ApplicationBase\Usuarios\Model\schUsuariosClient_Intf.pas', - schUsuariosServer_Intf in '..\ApplicationBase\Usuarios\Model\schUsuariosServer_Intf.pas'; + schUsuariosServer_Intf in '..\ApplicationBase\Usuarios\Model\schUsuariosServer_Intf.pas', + schAlmacenesClient_Intf in '..\Modulos\Almacenes\Model\schAlmacenesClient_Intf.pas', + schAlmacenesServer_Intf in '..\Modulos\Almacenes\Model\schAlmacenesServer_Intf.pas'; {$R *.res} {$R ..\Servicios\RODLFile.res} diff --git a/Source/Servidor/FactuGES_Server.rc b/Source/Servidor/FactuGES_Server.rc index a45399c7..0811847b 100644 --- a/Source/Servidor/FactuGES_Server.rc +++ b/Source/Servidor/FactuGES_Server.rc @@ -16,7 +16,7 @@ BEGIN VALUE "FileVersion", "2.2.3.0\0" VALUE "ProductName", "FactuGES (Servidor)\0" VALUE "ProductVersion", "2.2.3.0\0" - VALUE "CompileDate", "lunes, 28 de julio de 2008 12:58\0" + VALUE "CompileDate", "miércoles, 30 de julio de 2008 12:09\0" END END BLOCK "VarFileInfo" diff --git a/Source/Servidor/srvLogin_Impl.pas b/Source/Servidor/srvLogin_Impl.pas index a73d90f9..3053a273 100644 --- a/Source/Servidor/srvLogin_Impl.pas +++ b/Source/Servidor/srvLogin_Impl.pas @@ -31,7 +31,8 @@ type procedure DataAbstractServiceCreate(Sender: TObject); private protected - function Login(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login2(const User: String; const Password: String; out LoginInfo: TRdxLoginInfo): Boolean; + function Login(const User: String; const Password: String): Boolean; procedure Logout; function Ping: Boolean; end; @@ -63,7 +64,68 @@ begin SessionManager := dmServer.SessionManager; end; -function TsrvLogin.Login(const User, Password: String; out LoginInfo: TRdxLoginInfo): Boolean; +function TsrvLogin.Login(const User, Password: String): Boolean; +var + dsUser, + dsPerfiles, + dsEmpresas : IDADataset; + LoginInfo : TRdxLoginInfo; +begin + LoginInfo := NIL; + Result := False; + + dsUser := schLogin.NewDataset(Connection, 'UsuarioPermitido', ['Usuario', 'Pass'], [User, Password]); + + if (dsUser.RecordCount = 1) then + begin + try + LoginInfo := TRdxLoginInfo.Create(); + with LoginInfo do + begin + UserID := dsUser.FieldValues[0]; + Usuario := User; + SessionID := GUIDToString(Session.SessionID); + Perfiles := StringArray.Create(); + Empresas := TRdxEmpresasArray.Create; + end; + + // Asigna los perfiles del usuario + LoginInfo.Perfiles.Clear; + dsPerfiles := schLogin.NewDataset(Connection, 'PerfilesUsuario', ['ID_USUARIO'], [LoginInfo.UserID]); + while not dsPerfiles.EOF do + begin + LoginInfo.Perfiles.Add(VarToStr(dsPerfiles.FieldValues[0])); + dsPerfiles.Next; + end; + + // Asigna las empresas del usuario + LoginInfo.Empresas.Clear; + dsEmpresas := schLogin.NewDataset(Connection, 'EmpresasUsuario', ['ID_USUARIO'], [LoginInfo.UserID]); + while not dsEmpresas.EOF do + begin + LoginInfo.Empresas.Add(dsEmpresas.FieldValues[0]); + dsEmpresas.Next; + end; + + SesionesHelper.SaveSessionObject(Session, SESION_LOGININFO, LoginInfo); + + Result := True; + except + on e : exception do + begin + ShowMessage(e.Message); + raise + end; + end; + end + else begin +// Invalid login. The temporary session is not to be kept. + DestroySession; + end; +end; + +function TsrvLogin.Login2(const User, Password: String; + out LoginInfo: TRdxLoginInfo): Boolean; var dsUser, dsPerfiles,