Познакомьтесь с пентестом веб-приложений на практике в нашем новом бесплатном курсе
надопонимать, что каждый "инстанс" либы (т.е. Use) - это набор индивидуальных элементов, отсюда два следствия:Скажем... подформа встроена в несколько документов и выполняет общий для них код, но при это у каждой формы еще свои события прописаны. Если использовать данную либу конфликты элементов/объектов будут?
вполне очевидно - для подключения доп. обработчиков - буде на то есть необходимостьНепонятно назначение цепочки
Option Public
Option Declare
Use "ErrorHandling"
Private Const ERR_BASE=1024
Const UNPROPER_CHAIN=ERR_BASE+1,CS_UNPROPER_CHAIN={Действие не соответствует типу в цепочке}
Const CS_ERR_UIDOC={не установлен объект NotesUIDocument}
Const CS_QUERYOPEN={QUERYOPEN}
Const CS_CALLER_SB={вызывающая ф-ция д.б.:}
Const ACT_TYPES={}
Private wks As NotesUIWorkspace
Private ses As NotesSession
Private source As NotesUIDocument
Dim formObj As FormBase
Private gContinue As Boolean
%REM
Class FormBase
Description: InitObjectsUI нобходимо переопределить
%END REM
Class FormBase As ErrorHandler
Private actList List As ActionObject
%REM
Sub New
Description: Comments for Sub
%END REM
Sub New
End Sub
%REM
Function Regiter
Description: Comments for Function
%END REM
Function Register(act As ActionObject) As Boolean
On Error GoTo ErrH
If Not act Is Nothing Then
Dim s As String
s=act.Name
Dim obj As ActionObject
If Not IsElement(actList(s)) Then
Set actList(s)=act
Set obj=act
Else
Set obj=actList(s)
End If
Dim res As ActionObject
Set res=obj.ChainAction(act)
Call obj.Register()
End If
Quit:
Exit Function
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Function
%REM
Sub InitObjectsUI
Description: ф-ция для примера, нужно переписывать для своей реализации
%END REM
Function InitObjectsUI(uidoc As NotesUIDocument, xMode As Integer, xIsnewdoc, Xcontinue)
On Error GoTo ErrH
'устанавливаем глобальную переменную (не д.б. Nothing)
Set source=uidoc
Dim act_QO As TemplQueryOpen, _
act_PO As TemplPostOpen, _
act_QS As TemplQuerySave
Set act_QO=New TemplQueryopen()
Set act_PO=New TemplPostOpen()
Set act_QS=New TemplQuerySave()
Call Me.Register(act_QO)
Call Me.Register(act_PO)
Dim tmp As New TemplQueryRecalc()
Call Me.Register(tmp)
Call Me.Register(act_QS)
Call act_QO.Action(uidoc, xMode, xIsnewdoc, Xcontinue)
Quit:
Exit Function
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Function
End Class
%REM
Class ActionObject
Description: Comments for Class
%END REM
Class ActionObject As ErrorHandler
Private actName As String
Private actObj As Variant
Private actNext As ActionObject
Private isRegistred As Boolean
Sub New(obj, xName As String)
Me.actName=xName
Set Me.actObj=obj
End Sub
Public Property Get Name As String
Me.Name=actName
End Property
%REM
Property Get Object
Description: Comments for Property Get
%END REM
Public Property Get Object As Variant
Set Me.Object=actObj
End Property
%REM
Function ChainAction
Description: определяет цепочку обработки однотипных событий
%END REM
Public Function ChainAction(nxt As ActionObject) As ActionObject
On Error GoTo ErrH
If nxt Is Nothing Then _
Print {actNext is Nothing}:Exit Function
If UCase(Me.actName) <> UCase(nxt.Name) Then _
Error UNPROPER_CHAIN,CS_UNPROPER_CHAIN &actName &{<>} &nxt.Name
If nxt Is Me.actNext Or nxt Is Me Then _
Print {existing action incl to chain}:Set ChainAction=actNext:Exit Function
If Not actNext Is Nothing Then
Set ChainAction=actNext.ChainAction(nxt)
Else
Set actNext=nxt
Set ChainAction=actNext
Print {next action:} &typeName(actNext)
End If
Quit:
Exit Function
ErrH:
Error ERR_BASE, Me.RaiseError
End Function
%REM
Sub Register
Description: Comments for Sub
%END REM
Sub Register
End Sub
End Class
%REM
Class FromAction
Description: Comments for Class
%END REM
Class FormAction As ActionObject
Sub New(uidoc As NotesUIDocument, xName As String), ActionObject(uidoc, xName)
If uidoc Is Nothing Then Error ERR_BASE, CS_ERR_UIDOC
Set source=uidoc
End Sub
End Class
%REM
Class ActionPostOpen
Description: Comments for Class
%END REM
Private Class TemplPostOpen As FormAction
Sub New(), FormAction(source, {PostOpen})
' Set source=uidoc
End Sub
Sub Action(uidoc As NotesUIDocument)
Print {Action:} &Me.actName
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event PostOpen From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
Private Class TemplQueryopen As FormAction
Sub New(), FormAction(source, {Queryopen})
End Sub
Sub Action(uidoc As NotesUIDocument, xMode As Integer, xIsnewdoc, xContinue)
Print {Action:} &Me.actName
Dim nxt As TemplQueryopen
'class casting
Set nxt=Me.actNext
If Not nxt Is Nothing Then _
Call nxt.Action(uidoc,xMode,xIsnewdoc,xContinue)
' Call uidoc.Document.Computewithform(False, False)
' Print {Form:} &uidoc.Document.Form(0)
' xcontinue=False
End Sub
Sub Register
On Error GoTo ErrH
If Me.IsRegistred Then Exit Sub
On Event QueryOpen From source Call Action
Me.isRegistred=true
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class QuerySave
Description: Comments for Class
%END REM
Private Class TemplQuerySave As FormAction
Sub New(), FormAction(source, {QuerySave})
End Sub
Sub Action(uidoc As NotesUIDocument, xContinue)
Print {Action:} &Me.actName
Dim nxt
'class casting
Set nxt=Me.actNext
If Not nxt Is Nothing Then _
Call nxt.Action(uidoc,xContinue)
xContinue=False
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event QuerySave From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class TemplQueryRecalc
Description: Comments for Class
%END REM
Private Class TemplQueryRecalc As FormAction
Sub New(), FormAction(source, {QueryRecalc})
End Sub
Sub Action(uidoc As NotesUIDocument, Continue)
Print {Action:} &Me.actName
Continue=False
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event QueryRecalc From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class TemplPostSave
Description: Comments for Class
%END REM
Private Class TemplPostSave As FormAction
Sub New(), FormAction(source, {PostSave})
' Set source=uidoc
End Sub
Sub Action(uidoc As NotesUIDocument)
Print {Action:} &Me.actName
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event PostSave From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class TemplPostRecalc
Description: Comments for Class
%END REM
Private Class TemplPostRecalc As FormAction
Sub New(), FormAction(source, {PostRecalc})
' Set source=uidoc
End Sub
Sub Action(uidoc As NotesUIDocument)
Print {Action:} &Me.actName
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event PostRecalc From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class TemplQueryClose
Description: Comments for Class
%END REM
Private Class TemplQueryClose As FormAction
Sub New(), FormAction(source, {QueryClose})
End Sub
Sub Action(uidoc As NotesUIDocument, xContinue)
Print {Action:} &Me.actName
xContinue=False
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event QueryClose From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
%REM
Class SubQuerySave
Description: Comments for Class
%END REM
Class SubQuerySave As FormAction
Sub New(), FormAction(source, {QuerySave})
End Sub
Sub Action(uidoc As NotesUIDocument, xContinue)
Print {Sub Action:} &Me.actName
xContinue=False
End Sub
Sub Register
On Error GoTo ErrH
If Not Me.IsRegistred Then
On Event QuerySave From source Call Action
Me.isRegistred=True
End If
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError
Resume Quit
End Sub
End Class
Sub Initialize
Set wks=New NotesUIWorkspace
Set ses=New NotesSession
Set formObj=New FormBase
gContinue=True
End Sub
%REM
Sub InitObjects
Description: Comments for Sub
%END REM
Sub InitObjects
On Error GoTo ErrH
Dim formObj As New FormBase
Dim act_QO As New TemplQueryopen()
Dim act_PO As New TemplPostOpen()
Call formObj.Register(act_QO)
Call formObj.Register(act_PO)
Quit:
Exit Sub
ErrH:
Error ERR_BASE, RaiseError()
Resume Quit
End Sub
%REM
Sub InitObjectsUI
Description: вызывать нужно из QueryOpen
%END REM
Sub InitObjectsUI(uidoc As NotesUIDocument, xMode As Integer, xIsnewdoc, Xcontinue)
On Error GoTo ErrH
If CStr(GetThreadInfo(LSI_THREAD_CALLPROC))<> CS_QUERYOPEN Then _
Error ERR_BASE, CS_CALLER_SB &CS_QUERYOPEN
If gContinue Then
Call formObj.InitObjectsUI(Uidoc, Xmode, Xisnewdoc, Xcontinue)
Else
xContinue=gcontinue
End if
Quit:
Exit Sub
ErrH:
gContinue=false
Error ERR_BASE, RaiseError()
Resume Quit
End Sub
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
On Error Goto ErrH
Dim act_QS As New SubQuerySave()
Call formObj.Register(act_QS)
Goto Quit
ErrH:
Error 1024,RaiseError
Resume Quit
Quit:
End Sub
Print {Action:} &Me.actName
Dim nxt
'class casting
Set nxt=Me.actNext
If Not nxt Is Nothing Then _
Call nxt.Action(uidoc,xContinue)
Хм...чего не хватает для альтернативной ИДЕ кроме времени?
Никсоводы негодуют ...Честно, я бы не в сторону IDE лез
Designer для Linux это хорошая тема, я бы обязательно себе поставил. Винда тогда вообще нужна не будет, т.к. только из-за него и держу.Никсоводы негодуют ...
перенос кода из др. ИДЕ в БД доминыЧто за проблема с "бесшовным переносом"?
Обучение наступательной кибербезопасности в игровой форме. Начать игру!