0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[OutSystems]Extensionからログを出力する方法を試してみる

Posted at

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の定義例。

  1. 左のツリービューでActionsフォルダを右クリックし、Add Actionで追加
  2. 追加したAction定義が右に開くので、Nameを変更(これがService Studioで呼ぶときのAction名になる)
  3. 画面下部のParametersで、Input ParameterとしてText型のMessageを追加

image.png

C#実装

Integration Studio上部のアイコンの一番右が、C#用IDEを起動するボタンなので、これをクリック。
image.png

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

  1. Visual Studioでの編集を終える
  2. Visual Studioを閉じる
  3. Integration Studioに戻り、1-Click Publishボタンをクリック()C#実装の項のスクリーンショットで、緑の●の中に白抜きで「1」と描かれているアイコン)

実行・Service Centerでログ確認

Publishが終わると、普通のPublic=YesなServer Actionと同様に実行できる。

  1. テスト用モジュールから、Manage Dependenciesダイアログで作成したActionへの参照を追加する
  2. 適当なメッセージを渡してActionを実行する
  3. Service Centerを開く
  4. Monitoring > General Logで、テスト用モジュールのログを探す

Action呼び出し
image.png

Service CenterのMonitoring > General Logに出力されたログの例
(ローコードのLogMessageで出力するログと同じ場所で閲覧できる)
image.png

利用クラス

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?