OutSystems Platform — Auditing 101 — Part IIIで紹介されていた方法を試してみます。
OutSystemsでは標準でログ出力するAPI(ローコードのAction)、ログ格納用Entity、ログを検索/閲覧するUI (Service CenterのMonitoringタブ)が備わっています。
ここでは、OutSystemsをC#で拡張できるExtensionで使用でき、標準で備わっているEntityに記録できるC#用のメソッドの動作確認をします。
確認環境
Personal Environment(Version 11.13.0 (Build 31107))
Service Studio (Version 11.12.2)
Integration Studio (Version 11.11.5)
OutSystems.HubEdition.RuntimePlatform (Version=11.0.0.0)
動作確認用にExtensionが必要です。また、Extensionは通常Visual Studioで開発します。
エクステンションを作成するを参考にExtensionを作成しておいてください。
実装方法
Actionを定義
Integration Studioを使って、新しいActionを定義します。
以下は、Text型のパラメータを渡してログ出力するActionの定義例。
- 左のツリービューでActionsフォルダを右クリックし、Add Actionで追加
- 追加したAction定義が右に開くので、Nameを変更(これがService Studioで呼ぶときのAction名になる)
- 画面下部のParametersで、Input ParameterとしてText型のMessageを追加
C#実装
Integration Studio上部のアイコンの一番右が、C#用IDEを起動するボタンなので、これをクリック。
Visual Studioが起動するので、「<Extension名>.cs」ファイルを開き、「Mss<Action名>」メソッドを変更。
/// <summary>
/// Extensionからログ出力する
/// </summary>
/// <param name="ssMessage"></param>
public void MssLogMessage(string ssMessage) {
GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext,
ssMessage, BuiltInFunction.GetEntryEspaceName());
} // MssLogMessage
C#コードの解説
- GenericExtendedActionsクラス:Extensionで自動で参照されるOutSystems.HubEdition.RuntimePlatform Namespaceのクラス。概ね(System)モジュールのServer Actionと同じものが含まれている模様
- LogMessage:(System)に含まれるローコード版のAction LogMessageに対応するメソッド。
- パラメータ1 (HeContext):説明によると、「現在の処理中のリクエストで使用されるプラットフォームの実行コンテキスト」とのこと。わかりにくい説明だが、OutSystemsで現在処理中のリクエストに関わる情報を保持しているものと思われる。AppInfo.GetAppInfo().OsContextで取得できる
- パラメータ2 (string):ログに出力したい文字列。「ss<Input Parameter名>」でActionに渡したパラメータにアクセスできる
- パラメータ3 (string):Service Centerのログ一覧上でSource列に表示したい文字列を指定する。BuiltInFunction.GetEntryEspaceName()で、ユーザーのリクエストを受け付けたモジュール名を取得して渡している
- BuiltInFunction:恐らくローコード部分で使用可能なビルトイン関数を、ExtensionのC#でも使用可能にするクラス。
動作確認
Publish
- Visual Studioでの編集を終える
- Visual Studioを閉じる
- Integration Studioに戻り、1-Click Publishボタンをクリック()C#実装の項のスクリーンショットで、緑の●の中に白抜きで「1」と描かれているアイコン)
実行・Service Centerでログ確認
Publishが終わると、普通のPublic=YesなServer Actionと同様に実行できる。
- テスト用モジュールから、Manage Dependenciesダイアログで作成したActionへの参照を追加する
- 適当なメッセージを渡してActionを実行する
- Service Centerを開く
- Monitoring > General Logで、テスト用モジュールのログを探す
Service CenterのMonitoring > General Logに出力されたログの例
(ローコードのLogMessageで出力するログと同じ場所で閲覧できる)
利用クラス
GenericExtendedActions
(System)モジュールのServer Actionと共通するメソッドを大量に持つクラス。
メソッドリスト
- ActivityClose
- ActivityCloseAsynchronous
- ActivityGetUrl
- ActivityOpen
- ActivityReset
- ActivitySchedule
- ActivitySetGroup
- ActivitySkip
- ActivityStart
- Audit
- ChangeSiteProperty
- Check
- ClientCertificateGetDetails
- ClientCertificateGetValue
- CreateOrUpdateSiteProperty
- CreateTenant
- Deprecated_Notify
- Deprecated_NotifyWidget
- Deprecated_NotifyWidgetGetMessage
- EspaceInvalidate
- GenerateGuid
- Grant
- InboundSmsGetDetails
- IntegratedSecurityCheckRole
- IntegratedSecurityGetDetails
- Login
- LoginPassword
- LogMessage
- Notify
- NotifyGetMessage
- NotifyWidget
- NotifyWidgetGetMessage
- NotifyWidget_Deprecated
- ProcessLaunch
- ProcessRelease
- ProcessSuspend
- ProcessTerminate
- Revoke
- SetCurrentLocale
- TenantDeploy
- TenantInvalidate
- TenantRedeploy
- TenantSwitch
- UpdateSiteProperty
BuiltInFunction
ビルトイン関数を概ね網羅している。恐らくローコード部分で使用可能なビルトイン関数を、ExtensionのC#でも使用可能にするクラス。
メソッドリスト
- Abs
- AddDays
- AddHours
- AddMinutes
- AddMonths
- AddPersonalAreaToURLPath
- AddSeconds
- AddYears
- AreBinaryNulls
- BooleanToInteger
- BooleanToText
- BuildDateTime
- CheckRole
- Chr
- Concat
- CurrDate
- CurrDateTime
- CurrentThemeIsMobile
- CurrTime
- DateTimeToDate
- DateTimeToText
- DateTimeToTime
- DateToDateTime
- DateToText
- Day
- DayOfWeek
- DecimalToBoolean
- DecimalToInteger
- DecimalToIntegerValidate
- DecimalToLongInteger
- DecimalToLongIntegerValidate
- DecimalToText
- DiffDays
- DiffHours
- DiffMinutes
- DiffSeconds
- EmailAddressCreate
- EmailAddressesConcatenate
- EmailAddressValidate
- EncodeHtml
- EncodeHtmlAttribute
- EncodeJavascript
- EncodeSql
- EncodeUrl
- Encrypt
- FormatBoolean
- FormatCurrency
- FormatDateTime
- FormatDecimal
- FormatFullDate
- FormatFullDateTime
- FormatMonthDayDate
- FormatPercent
- FormatPhoneNumber
- FormatShortDate
- FormatShortDateTime
- FormatText
- FormatTextSC
- FormatTime
- FormatYearMonthDate
- GeneratePassword
- GetApplicationServerType
- GetBookmarkableURL
- GetBrowserCapabilities
- GetBrowserType
- GetCurrentLocale
- GetDatabaseProvider
- GetEntryEspaceName
- GetExceptionURL
- GetObsoleteTenantId
- GetPersonalAreaName
- GetUserAgent
- GetUserId
- Hour
- IdentifierToInteger
- IdentifierToLongInteger
- IdentifierToText
- Index
- IndexSC
- IntegerToBoolean
- IntegerToDecimal
- IntegerToIdentifier
- IntegerToText
- internalIf
- IsLoadingScreen
- Length
- LengthSC
- LongIntegerToIdentifier
- LongIntegerToInteger
- LongIntegerToIntegerValidate
- LongIntegerToText
- Max
- MaxDate
- Min
- Minute
- Mod
- Month
- NewDate
- NewDateTime
- NewLine
- NewTime
- NotifyWidgetGetMessage
- NullBinary
- NullDate
- NullIdentifier
- object NullObject
- NullTextIdentifier
- Power
- Replace
- Round
- Second
- Sign
- Sqrt
- Substr
- SubstrSC
- TextToDate
- TextToDateTime
- TextToDateTimeValidate
- TextToDateValidate
- TextToDecimal
- TextToDecimalInput
- TextToDecimalInputValidate
- TextToDecimalValidate
- TextToIdentifier
- TextToInteger
- TextToIntegerInput
- TextToIntegerInputValidate
- TextToIntegerValidate
- TextToLongInteger
- TextToLongIntegerInput
- TextToLongIntegerInputValidate
- TextToLongIntegerValidate
- TextToTime
- TextToTimeValidate
- TimeToText
- ToLower
- object ToObject
- ToUpper
- Trim
- TrimEnd
- TrimStart
- Trunc
- Year