Voilà, j'ai tenté d'adapter votre classe common avec du codemode = objectgenerator:
Include Ensemble
Class XXXX.Outils.BS.AuditCommons
{
/// Class of the audit to use for this flow. If the flow use/// iterative process, for instance a loop to inserted multiple/// lines in a table, you can use its insertdetails() method to/// log an error that occured in the loop without poluting/// the journal.Property auditClass As%String(MAXLEN = 500) [ InitialExpression = "XXXX.REPORTING.Tables.Commons.Main" ];/// Name of the flow that will be inserted in the audit.Property flowName As%String(MAXLEN = 500);/// Source of the flow that will be inserted in the audit.Property flowSource As%String(MAXLEN = 500);/// Target of the flow that will be inserted in the audit.Property flowTarget As%String(MAXLEN = 500);/// If true, the message will be sent synchronously.Property asynchronous As%Boolean;/// Audit instance of the current session /// XXXX.REPORTING.Tables.Commons.Main;Property audit As XXXX.REPORTING.Tables.Commons.Main;Property errMsg As%String(MAXLEN = "");Parameter auditLogError = 1;Parameter SETTINGS = "auditClass:flowParameters,flowName:flowParameters,flowSource:flowParameters,flowTarget:flowParameters,asynchronous:flowParameters";
Method SendRequestSync(pTargetDispatchName As%String, pRequest As%Library.Persistent, ByRef pResponse As%Library.Persistent, pTimeout As%Numeric = -1, pDescription As%String = "") As%Status [ CodeMode = objectgenerator, ForceGenerate ]
{
; Le code ne peut être généré que dans les sous classesIf%class.Name = "XXXX.Outils.BS.AuditCommons"Quit$$$OKDo%code.WriteLine($Char(9) _ "if ..asynchronous quit ..SendRequestAsync(pTargetDispatchName, pRequest, pDescription)")
Do%code.WriteLine($Char(9) _ "set pResponse = """"")
Do%code.WriteLine($Char(9) _ "set sc = ..initAudit(pRequest) quit:'sc sc")
Do%code.WriteLine($Char(9) _ "set req = ..setReq(pRequest, .sc) quit:'sc sc")
Do%code.WriteLine($Char(9) _ "quit ##super(pTargetDispatchName, req, .pResponse, .pTimeout, pDescription)")
Quit$$$OK
}
Method SendRequestAsync(pTargetDispatchName As%String, pRequest As%Library.Persistent, pDescription As%String = "") As%Status [ CodeMode = objectgenerator, ForceGenerate ]
{
; Le code ne peut être généré que dans les sous classesIf%class.Name = "XXXX.Outils.BS.AuditCommons"Quit$$$OKDo%code.WriteLine($Char(9) _ "if '..asynchronous quit ..SendRequestSync(pTargetDispatchName, pRequest, .pResponse, .pTimout, pDescription)")
Do%code.WriteLine($Char(9) _ "set sc = ..initAudit(pRequest) quit:'sc sc")
Do%code.WriteLine($Char(9) _ "set req = ..setReq(pRequest, .sc) quit:'sc sc")
Do%code.WriteLine($Char(9) _ "quit ##super(pTargetDispatchName, req, pDescription)")
}
/// Initialize an audit for the current session. You can/// use the audit instance using the ..audit property.
Method initAudit(req As Ens.Request = "") As%Status
{
do..generateSession()
set auditData = {
"session": (..getSessionId())
,"flowName": (..flowName)
,"flowSource": (..flowSource)
,"flowTarget": (..flowTarget)
,"filename": (##class(XXXX.OUTILS.File.FileInfos).getFilename(req))
}
set..audit = $CLASSMETHOD(..auditClass, "initialize", auditData, .sc)
if 'sc return..error("<Initialize audit>",, "initAudit", sc).AsStatus()
if..errMsg '= ""do..audit.setError(..errMsg, ..#auditLogError)
return1
}
Method setReq(pRequest As%Library.Persistent, Output gsc As%String = 1) As Ens.Request
{
return pRequest
}
Method generateSession() [ CodeMode = objectgenerator, ForceGenerate ]
{
; Le code ne peut être généré que dans les sous classesIf%class.Name = "XXXX.Outils.BS.AuditCommons"Quit$$$OKDo%code.WriteLine($Char(9)_"Set (..%SessionId,$$$JobSessionId) = ##class(Ens.MessageHeader).%New().MessageId()")
}
Method getSessionId() As%String [ CodeMode = objectgenerator, ForceGenerate ]
{
; Le code ne peut être généré que dans les sous classesIf%class.Name = "XXXX.Outils.BS.AuditCommons"Quit$$$OKDo%code.WriteLine($Char(9) _ "Quit ..%SessionId")
}
ClassMethod OnGetConnections(pArray As%String, item As Ens.Config.Item) As%Status
{
do##class(XXXX.OUTILS.Admin).linkBsToBp(.pArray, .item)
}
/// Method used as an alias to shorten the code.ClassMethod error(name As%String, code As%String = "", location As%String = "", data As%String = "") As%Exception.General
{
return##class(%Exception.General).%New(name, code, location, data)
}
}
ensuite, pour la classe "XXXX.Outils.BS.ComplexMap.FTP", modifiez juste l'ordre de l'héritage :
Class XXXX.Outils.BS.ComplexMap.FTP Extends (XXXX.Outils.BS.AuditCommons, EnsLib.RecordMap.Service.ComplexBatchFTPService)
{
}
Après compilation si vous regardez le code de la routine générée pour la classe ComplexMap.FTP (ctrl+maj+v) vous pourrez remarquer que le code des méthodes [ codemode = objectgenerator, ForceGenerate] a bien été inclus:
zSendRequestAsync(pTargetDispatchName,pRequest,pDescription="") public {
if '..asynchronousquit..SendRequestSync(pTargetDispatchName, pRequest, .pResponse, .pTimout, pDescription)
set sc = ..initAudit(pRequest) quit:'sc sc
set req = ..setReq(pRequest, .sc) quit:'sc sc
quit##class(XXXX.Outils.BS.AuditCommons)$this.SendRequestAsync(pTargetDispatchName, req, pDescription)
}
zSendRequestSync(pTargetDispatchName,pRequest,pResponse,pTimeout=-1,pDescription="") public {
if..asynchronousquit..SendRequestAsync(pTargetDispatchName, pRequest, pDescription)
set pResponse = ""set sc = ..initAudit(pRequest) quit:'sc sc
set req = ..setReq(pRequest, .sc) quit:'sc sc
quit##class(XXXX.Outils.BS.AuditCommons)$this.SendRequestSync(pTargetDispatchName, req, .pResponse, .pTimeout, pDescription)
}
zgenerateSession() public {
Set (..%SessionId,%Ensemble("SessionId")) = ##class(Ens.MessageHeader).%New().MessageId()
}
zgetSessionId() public {
Quit ..%SessionId }Logiquement comme la classe common n'hérite plus de Ens.BusinessService, le fait qu'elle soit la classe la plus à gauche dans l'ordre d'héritage ne devrait plus avoir d'influence négative.
- Se connecter pour publier des commentaires
.png)
.png)
.png)
.png)