Public Class Service1Agent
Inherits SyncServiceAgentBase(Of ServiceReference1.Service1Client)
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' セッション情報を格納するクラスです。
''' </summary>
''' <history>
''' [夏鯤鵬] 2009/02/12 新規作成
''' </history>
''' ----------------------------------------------------------------------------------------------------
Private _sessionInfo As SessionInfo
Public Sub New()
MyBase.SetServiceInstance(True)
End Sub
#Region "オーバーライド関数定義"
Protected Overrides ReadOnly Property Address() As String
Get
Return "Service1"
End Get
End Property
Protected Overrides Sub LocalDispose()
If Me.ClientService IsNot Nothing AndAlso _
Me.ClientService.State = CommunicationState.Opened Then
Me.ClientService.Close()
End If
End Sub
Protected Overrides ReadOnly Property TcpEndpointConfigName() As String
Get
Return ""
End Get
End Property
Protected Overrides ReadOnly Property WebEndpointConfigName() As String
Get
Return "HttpBind"
End Get
End Property
#End Region
Public Function GetData(ByVal value As Integer) As String
Dim errorInfo As ErrorInfo = Nothing
Try
' 開始ログ
SampleTraceLogPublisher.PutVerboseLog(LogFormat.METHOD_START_END, _
Me.GetType.Namespace, Me.GetType.Name, "GetData", "開始")
Dim sw As New Stopwatch
sw.Start()
Using scope As New OperationContextScope(MyBase.ClientService.InnerChannel)
' サービスオペレーションを実行する前の初期化処理を行います。
MyBase.InitializeOperation()
Dim retvalue As String
retvalue = MyBase.ClientService.GetData(value)
' サービスオペレーションを実行した後の終了処理を行います。
MyBase.FinalizeOperation(errorInfo, _sessionInfo)
sw.Stop()
' サービスオペレーションを実行しました。({0}:サービス名、{1}:操作名、{2}:所要時間、{3}:業務キー)
SampleTraceLogPublisher.PutInformationLog(LogFormat.SERVICE_OPERATE_EXCUTE_2, _
"Service1", "GetData", _
sw.ElapsedMilliseconds.ToString(), "111")
CheckException(errorInfo)
Return retvalue
End Using
Catch exception As Exception
MyBase.SetCommunicationError(exception, errorInfo)
CheckException(errorInfo)
Finally
' 終了ログ
SampleTraceLogPublisher.PutVerboseLog(LogFormat.METHOD_START_END, Me.GetType.Namespace, Me.GetType.Name, "GetData", "終了")
End Try
Return True
End Function
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' 例外処理
''' </summary>
''' <param name="errInfo">サーバサービスで発生したエラー情報です。</param>
''' <history>
''' [林 清] 2009/02/17 新規作成
''' </history>
''' ----------------------------------------------------------------------------------------------------
Private Sub CheckException(ByVal errInfo As ErrorInfo)
Dim exception As CustomBaseException
Select Case errInfo.ErrorLevel
Case ErrorLevelType.None
Exit Select
Case ErrorLevelType.Business
exception = New BusinessLevelException(errInfo.ErrorMessage, errInfo.MessageID)
exception.IsClientSide = True
Throw exception
Exit Select
Case Else
exception = New SystemLevelException(errInfo.ErrorMessage, errInfo.MessageID)
exception.IsClientSide = False
Throw exception
Exit Select
End Select
End Sub