rename service directories
This commit is contained in:
81
Service.EDMIService/App.config
Normal file
81
Service.EDMIService/App.config
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.diagnostics>
|
||||
<sources>
|
||||
<source name="System.ServiceModel" switchValue="Information,ActivityTracing"
|
||||
propagateActivity="true">
|
||||
<listeners>
|
||||
<add name="xml" />
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.ServiceModel.MessageLogging">
|
||||
<listeners>
|
||||
<add name="xml" />
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<sharedListeners>
|
||||
<add initializeData="C:\logs\TracingAndLogging-service.svclog" type="System.Diagnostics.XmlWriterTraceListener"
|
||||
name="xml" />
|
||||
</sharedListeners>
|
||||
<trace autoflush="true" />
|
||||
</system.diagnostics>
|
||||
<appSettings>
|
||||
<add key="FIREBIRD_DATASOURCE" value="" />
|
||||
<add key="FIREBIRD_DATABASE_NAME" value="" />
|
||||
<add key="FIREBIRD_DATABASE_USER" value="" />
|
||||
<add key="FIREBIRD_DATABASE_PASS" value="" />
|
||||
<add key="CONTAINER_PATH" value="" />
|
||||
<add key="CONTAINER_PASSWORD" value="" />
|
||||
</appSettings>
|
||||
<system.serviceModel>
|
||||
<diagnostics wmiProviderEnabled="true">
|
||||
<messageLogging logEntireMessage="true" logMalformedMessages="true"
|
||||
logMessagesAtTransportLevel="true" />
|
||||
<endToEndTracing propagateActivity="true" activityTracing="true"
|
||||
messageFlowTracing="true" />
|
||||
</diagnostics>
|
||||
<bindings>
|
||||
<netTcpBinding>
|
||||
<binding name="tcpBinding" sendTimeout="00:10:00" transferMode="Buffered"
|
||||
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
|
||||
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
|
||||
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
|
||||
<security mode="None">
|
||||
<transport clientCredentialType="None" />
|
||||
</security>
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<services>
|
||||
<service behaviorConfiguration="DefaultServiceBehavior" name="DigitalData.Services.IDBService.IDBService">
|
||||
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBinding"
|
||||
name="tcpBinding" contract="DigitalData.Services.IDBService.IIDBService">
|
||||
<identity>
|
||||
<dns value="localhost" />
|
||||
</identity>
|
||||
</endpoint>
|
||||
<endpoint address="mex" binding="mexTcpBinding" name="MexTcpBinding"
|
||||
contract="IMetadataExchange" />
|
||||
<host>
|
||||
<baseAddresses>
|
||||
<add baseAddress="net.tcp://localhost:9000/DigitalData/Services/Main" />
|
||||
</baseAddresses>
|
||||
</host>
|
||||
</service>
|
||||
</services>
|
||||
<behaviors>
|
||||
<serviceBehaviors>
|
||||
<behavior name="DefaultServiceBehavior">
|
||||
<serviceMetadata httpGetEnabled="false" />
|
||||
<serviceDebug includeExceptionDetailInFaults="true" />
|
||||
</behavior>
|
||||
</serviceBehaviors>
|
||||
</behaviors>
|
||||
</system.serviceModel>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="FirebirdSql.Data.FirebirdClient" />
|
||||
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".NET Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient" />
|
||||
</DbProviderFactories>
|
||||
</system.data></configuration>
|
||||
21
Service.EDMIService/AppConfig.vb
Normal file
21
Service.EDMIService/AppConfig.vb
Normal file
@@ -0,0 +1,21 @@
|
||||
Imports System.Configuration
|
||||
|
||||
Public Class AppConfig
|
||||
Public Shared FirebirdDataSource As String
|
||||
Public Shared FirebirdDatabase As String
|
||||
Public Shared FirebirdUser As String
|
||||
Public Shared FirebirdPassword As String
|
||||
Public Shared ContainerPath As String
|
||||
Public Shared ContainerPassword As String
|
||||
|
||||
Public Shared Sub Load()
|
||||
With ConfigurationManager.AppSettings
|
||||
FirebirdDataSource = .Item("FIREBIRD_DATASOURCE")
|
||||
FirebirdDatabase = .Item("FIREBIRD_DATABASE_NAME")
|
||||
FirebirdUser = .Item("FIREBIRD_DATABASE_USER")
|
||||
FirebirdPassword = .Item("FIREBIRD_DATABASE_PASS")
|
||||
ContainerPath = .Item("CONTAINER_PATH")
|
||||
ContainerPassword = .Item("CONTAINER_PASSWORD")
|
||||
End With
|
||||
End Sub
|
||||
End Class
|
||||
341
Service.EDMIService/EDMIService.vb
Normal file
341
Service.EDMIService/EDMIService.vb
Normal file
@@ -0,0 +1,341 @@
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.EDMIService
|
||||
Imports System.IO
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class EDMIService
|
||||
Implements IEDMIService
|
||||
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database As Firebird
|
||||
Public Shared AppConfig As AppConfig
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
|
||||
Private _request As Request = Nothing
|
||||
Private _debug As Boolean = False
|
||||
Private _username As String
|
||||
|
||||
Public Sub New()
|
||||
Dim oOperationContext As OperationContext = OperationContext.Current
|
||||
Dim oInstanceContext As InstanceContext = oOperationContext.InstanceContext
|
||||
Dim oUsername = oOperationContext.ServiceSecurityContext.WindowsIdentity.Name
|
||||
|
||||
_username = oUsername
|
||||
_logger = LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
#Region "Auth"
|
||||
Private Function TestUserAuth() As Boolean
|
||||
Try
|
||||
'Dim oSQL As String = $"SELECT FNIDB_AUTH_USER('{_username}') FROM RDB$DATABASE;"
|
||||
'Dim oResult As Boolean = Database.GetScalarValue(oSQL)
|
||||
'Return oResult
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
#Region "Heartbeat"
|
||||
Public Function Heartbeat() As Boolean Implements IEDMIService.Heartbeat
|
||||
Return True
|
||||
End Function
|
||||
#End Region
|
||||
#Region "Request"
|
||||
Public Sub CreateRequest(Name As String, Optional Debug As Boolean = False)
|
||||
_request = New Request(Name, _username, Database, Debug)
|
||||
_debug = Debug
|
||||
|
||||
_logger.Info("Creating request {0}/{1}", _request.Name, _request.RequestId)
|
||||
End Sub
|
||||
|
||||
Public Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String Implements IEDMIService.CreateDatabaseRequest
|
||||
CreateRequest(Name, Debug)
|
||||
|
||||
Return _request.Name
|
||||
End Function
|
||||
|
||||
Public Sub CloseDatabaseRequest() Implements IEDMIService.CloseDatabaseRequest
|
||||
If IsNothing(_request) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_logger.Info("Closing request {0}", _request.ToString)
|
||||
_request.Connection.Close()
|
||||
_request = Nothing
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
#Region "Database"
|
||||
Private Sub TestRequestCreated()
|
||||
If IsNothing(_request) Then
|
||||
Throw New Exceptions.NoRequestException()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function ReturnDatatable(SQL As String) As TableResult Implements IEDMIService.ReturnDatatable
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ReturnDatatable, SQL: {SQL}")
|
||||
_request.LogDebug($"ReturnDatatable, SQL: {SQL}")
|
||||
|
||||
Dim oResult As DataTable = Database.GetDatatableWithConnection(SQL, _request.Connection)
|
||||
Return New TableResult(oResult)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New TableResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReturnScalar(SQL As String) As ScalarResult Implements IEDMIService.ReturnScalar
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ReturnScalar, SQL: {SQL}")
|
||||
_request.LogDebug($"ReturnScalar, SQL: {SQL}")
|
||||
|
||||
Dim oResult As Object = Database.GetScalarValueWithConnection(SQL, _request.Connection)
|
||||
Return New ScalarResult(oResult)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New ScalarResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQL As String) As NonQueryResult Implements IEDMIService.ExecuteNonQuery
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ExecuteNonQuery, SQL: {SQL}")
|
||||
_request.LogDebug($"ExecuteNonQuery, SQL: {SQL}")
|
||||
|
||||
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnection(SQL, _request.Connection)
|
||||
Return New NonQueryResult()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New NonQueryResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
#End Region
|
||||
#Region "Document (with FileContainer)"
|
||||
'Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResult Implements IEDMIService.NewFile
|
||||
' Try
|
||||
' Dim oContainer As FileContainer
|
||||
' Dim oContainerId As String
|
||||
|
||||
' If Not TestUserAuth() Then
|
||||
' Throw New Exception($"User {_username} not authorized.")
|
||||
' End If
|
||||
|
||||
' oContainer = FileContainer.Create(LogConfig, AppConfig.ContainerPassword)
|
||||
' oContainerId = oContainer.ContainerId
|
||||
' _logger.Debug("Container created with id {0}", oContainerId)
|
||||
|
||||
' Dim oExtension As String = Path.GetExtension(FileName).Substring(1)
|
||||
' _logger.Debug("File extension of file {0} is {1}", FileName, oExtension)
|
||||
|
||||
' Dim oSQL = $"SELECT FNICM_NEW_DOC('010', '{oContainerId}', '{GetContainerName(oContainerId)}', '{FileName}', '{oExtension}', '{_username}') FROM RDB$DATABASE;"
|
||||
' Dim oDocId As Int64 = Database.GetScalarValue(oSQL)
|
||||
|
||||
' If oDocId = -1 Then
|
||||
' _logger.Warn("Database returned -1 while creating Document Entry. File was not saved!")
|
||||
' Return Nothing
|
||||
' End If
|
||||
|
||||
' _logger.Debug("Database Entry created with DocId {0}", oDocId)
|
||||
|
||||
' oContainer.SetFile(Contents, FileName)
|
||||
' oContainer.SaveAs(GetContainerPath(oContainerId))
|
||||
|
||||
' _logger.Debug("File saved in Container!", FileName)
|
||||
|
||||
' Dim oDocument = New DocumentObject(oContainerId, oDocId, FileName)
|
||||
' Return New DocumentResult(oDocument)
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Return New DocumentResult(ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResult Implements IEDMIService.UpdateFile
|
||||
' Try
|
||||
' TestFileExists(DocObject.ContainerId)
|
||||
|
||||
' ' TODO: update db
|
||||
|
||||
' Dim oFilePath = GetContainerPath(DocObject.ContainerId)
|
||||
' Dim oFileContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oFilePath)
|
||||
|
||||
' oFileContainer.SetFile(Contents, oFileContainer.GetFile.FileName)
|
||||
' oFileContainer.Save()
|
||||
|
||||
|
||||
' Return New DocumentResult(DocObject)
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Return Nothing
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function GetFile(DocObject As DocumentObject) As DocumentResult Implements IEDMIService.GetFile
|
||||
' Try
|
||||
' TestFileExists(DocObject.ContainerId)
|
||||
|
||||
' Dim oContainerPath = GetContainerPath(DocObject.ContainerId)
|
||||
' Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
' Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
' Return New DocumentResult(DocObject, oContents)
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Return New DocumentResult(ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function DeleteFile(DocObject As DocumentObject) As Boolean Implements IEDMIService.DeleteFile
|
||||
' Try
|
||||
' TestFileExists(DocObject.ContainerId)
|
||||
|
||||
' Dim oFilePath = GetContainerPath(DocObject.ContainerId)
|
||||
' IO.File.Delete(oFilePath)
|
||||
|
||||
' 'TODO: Delete doc from db
|
||||
|
||||
' Return True
|
||||
' Catch ex As Exception
|
||||
' _logger.Error(ex)
|
||||
' Return False
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Private Function GetContainerPath(ContainerId As String) As String
|
||||
' Return Path.Combine(AppConfig.ContainerPath, GetContainerName(ContainerId))
|
||||
'End Function
|
||||
|
||||
'Private Function GetContainerName(ContainerId As String) As String
|
||||
' Return ContainerId & ".enc"
|
||||
'End Function
|
||||
|
||||
'Private Sub TestFileExists(ContainerId)
|
||||
' Dim oContainerPath = GetContainerPath(ContainerId)
|
||||
|
||||
' If Not IO.File.Exists(oContainerPath) Then
|
||||
' Throw New FileNotFoundException("Container existiert nicht", oContainerPath)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
'Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IEDMIService.GetDocumentByDocumentId
|
||||
' Try
|
||||
' Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE GUID = {DocumentId}"
|
||||
' Dim oTable = Database.GetDatatable(oSQL)
|
||||
|
||||
' If oTable.Rows.Count = 0 Then
|
||||
' Return New DocumentResult("Document not found")
|
||||
' End If
|
||||
|
||||
' Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
' Dim oDocument As New DocumentObject(
|
||||
' oRow.Item("CONTAINER_ID"),
|
||||
' oRow.Item("GUID"),
|
||||
' oRow.Item("ORIGINAL_FILENAME")
|
||||
' )
|
||||
|
||||
' TestFileExists(oDocument.ContainerId)
|
||||
|
||||
' Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
|
||||
' Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
' Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
' Return New DocumentResult(oDocument, oContents)
|
||||
' Catch ex As Exception
|
||||
' Return New DocumentResult(ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
|
||||
'Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IEDMIService.GetDocumentByContainerId
|
||||
' Try
|
||||
' Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'"
|
||||
' Dim oTable = Database.GetDatatable(oSQL)
|
||||
|
||||
' If oTable.Rows.Count = 0 Then
|
||||
' Return New DocumentResult("Document not found")
|
||||
' End If
|
||||
|
||||
' Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
' Dim oDocument As New DocumentObject(
|
||||
' oRow.Item("CONTAINER_ID"),
|
||||
' oRow.Item("GUID"),
|
||||
' oRow.Item("ORIGINAL_FILENAME")
|
||||
' )
|
||||
|
||||
' TestFileExists(oDocument.ContainerId)
|
||||
|
||||
' Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
|
||||
' Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
' Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
' Return New DocumentResult(oDocument, oContents)
|
||||
' Catch ex As Exception
|
||||
' Return New DocumentResult(ex.Message)
|
||||
' End Try
|
||||
'End Function
|
||||
#End Region
|
||||
|
||||
#Region "Document"
|
||||
Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IEDMIService.ImportFile
|
||||
Dim oFilePath = Path.Combine(AppConfig.ContainerPath, FileInfo.Name)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
|
||||
|
||||
Try
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath)
|
||||
Using oStream = New FileStream(oFilePath, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
Dim oAttributes = IO.File.GetAttributes(oFilePath) Or FileAttributes.ReadOnly
|
||||
|
||||
If RetentionPeriod Then
|
||||
_logger.Info("Setting LastAccessTime")
|
||||
IO.File.SetLastAccessTime(oFilePath, Date.Now.AddYears(30))
|
||||
End If
|
||||
|
||||
If [Readonly] Then
|
||||
_logger.Info("Setting ReadOnly Attribute")
|
||||
IO.File.SetAttributes(oFilePath, oAttributes)
|
||||
End If
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Index"
|
||||
Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult Implements IEDMIService.NewFileIndex
|
||||
Try
|
||||
Dim oSQL = $"SELECT FNIDB_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
|
||||
Dim oIndexId As Int64 = Database.GetScalarValue(oSQL)
|
||||
|
||||
Return New IndexResult(oIndexId)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New IndexResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
End Class
|
||||
166
Service.EDMIService/EDMIService.vbproj
Normal file
166
Service.EDMIService/EDMIService.vbproj
Normal file
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A8C3F298-76AB-4359-AB3C-986E313B4336}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<StartupObject>DigitalData.Services.EDMIService.WindowsService</StartupObject>
|
||||
<RootNamespace>DigitalData.Services.EDMIService</RootNamespace>
|
||||
<AssemblyName>EDMIService</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Console</MyType>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>EDMIService.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>EDMIService.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FirebirdSql.Data.FirebirdClient, Version=6.4.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\FirebirdSql.Data.FirebirdClient.6.4.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NLog.4.7.0\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppConfig.vb" />
|
||||
<Compile Include="Results\BaseResult.vb" />
|
||||
<Compile Include="Results\ContainerResult.vb" />
|
||||
<Compile Include="Results\DocumentResult.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Results\DatabaseResult.vb" />
|
||||
<Compile Include="EDMIService.vb" />
|
||||
<Compile Include="Results\DocumentResult2.vb" />
|
||||
<Compile Include="Results\IndexResult.vb" />
|
||||
<Compile Include="WindowsService.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IEDMIService.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Request.vb" />
|
||||
<Compile Include="SettingsModule.vb" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ProjectInstaller.resx">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="App.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Modules.Database\Database.vbproj">
|
||||
<Project>{EAF0EA75-5FA7-485D-89C7-B2D843B03A96}</Project>
|
||||
<Name>Database</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Modules.EDMIAPI\EDMI.API.vbproj">
|
||||
<Project>{5B1171DC-FFFE-4813-A20D-786AAE47B320}</Project>
|
||||
<Name>EDMI.API</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Filesystem\Filesystem.vbproj">
|
||||
<Project>{991D0231-4623-496D-8BD0-9CA906029CBC}</Project>
|
||||
<Name>Filesystem</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Logging\Logging.vbproj">
|
||||
<Project>{903B2D7D-3B80-4BE9-8713-7447B704E1B0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
</Project>
|
||||
7
Service.EDMIService/Exceptions.vb
Normal file
7
Service.EDMIService/Exceptions.vb
Normal file
@@ -0,0 +1,7 @@
|
||||
Public Class Exceptions
|
||||
|
||||
Public Class NoRequestException
|
||||
Inherits ApplicationException
|
||||
End Class
|
||||
|
||||
End Class
|
||||
343
Service.EDMIService/IDBService.vb
Normal file
343
Service.EDMIService/IDBService.vb
Normal file
@@ -0,0 +1,343 @@
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.IDBService
|
||||
Imports System.IO
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class IDBService
|
||||
Implements IIDBService
|
||||
|
||||
Public Shared LogConfig As LogConfig
|
||||
Public Shared Database As Firebird
|
||||
Public Shared AppConfig As AppConfig
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
|
||||
Private _request As Request = Nothing
|
||||
Private _debug As Boolean = False
|
||||
Private _username As String
|
||||
|
||||
Public Sub New()
|
||||
Dim oOperationContext As OperationContext = OperationContext.Current
|
||||
Dim oInstanceContext As InstanceContext = oOperationContext.InstanceContext
|
||||
Dim oUsername = oOperationContext.ServiceSecurityContext.WindowsIdentity.Name
|
||||
|
||||
_username = oUsername
|
||||
_logger = LogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
#Region "Auth"
|
||||
Private Function TestUserAuth() As Boolean
|
||||
Try
|
||||
'Dim oSQL As String = $"SELECT FNIDB_AUTH_USER('{_username}') FROM RDB$DATABASE;"
|
||||
'Dim oResult As Boolean = Database.GetScalarValue(oSQL)
|
||||
'Return oResult
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
#Region "Heartbeat"
|
||||
Public Function Heartbeat() As Boolean Implements IIDBService.Heartbeat
|
||||
Return True
|
||||
End Function
|
||||
#End Region
|
||||
#Region "Request"
|
||||
Public Sub CreateRequest(Name As String, Optional Debug As Boolean = False)
|
||||
_request = New Request(Name, _username, Database, Debug)
|
||||
_debug = Debug
|
||||
|
||||
_logger.Info("Creating request {0}/{1}", _request.Name, _request.RequestId)
|
||||
End Sub
|
||||
|
||||
Public Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String Implements IIDBService.CreateDatabaseRequest
|
||||
CreateRequest(Name, Debug)
|
||||
|
||||
Return _request.Name
|
||||
End Function
|
||||
|
||||
Public Sub CloseDatabaseRequest() Implements IIDBService.CloseDatabaseRequest
|
||||
If IsNothing(_request) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
_logger.Info("Closing request {0}", _request.ToString)
|
||||
_request.Connection.Close()
|
||||
_request = Nothing
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
#Region "Database"
|
||||
Private Sub TestRequestCreated()
|
||||
If IsNothing(_request) Then
|
||||
Throw New Exceptions.NoRequestException()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Function ReturnDatatable(SQL As String) As TableResult Implements IIDBService.ReturnDatatable
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ReturnDatatable, SQL: {SQL}")
|
||||
_request.LogDebug($"ReturnDatatable, SQL: {SQL}")
|
||||
|
||||
Dim oResult As DataTable = Database.GetDatatableWithConnection(SQL, _request.Connection)
|
||||
Return New TableResult(oResult)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New TableResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ReturnScalar(SQL As String) As ScalarResult Implements IIDBService.ReturnScalar
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ReturnScalar, SQL: {SQL}")
|
||||
_request.LogDebug($"ReturnScalar, SQL: {SQL}")
|
||||
|
||||
Dim oResult As Object = Database.GetScalarValueWithConnection(SQL, _request.Connection)
|
||||
Return New ScalarResult(oResult)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New ScalarResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function ExecuteNonQuery(SQL As String) As NonQueryResult Implements IIDBService.ExecuteNonQuery
|
||||
Try
|
||||
TestRequestCreated()
|
||||
|
||||
_logger.Info($"ExecuteNonQuery, SQL: {SQL}")
|
||||
_request.LogDebug($"ExecuteNonQuery, SQL: {SQL}")
|
||||
|
||||
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnection(SQL, _request.Connection)
|
||||
Return New NonQueryResult()
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_request.LogError(ex.Message)
|
||||
Return New NonQueryResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
#End Region
|
||||
#Region "Document (with FileContainer)"
|
||||
Public Function NewFile(FileName As String, Contents() As Byte) As DocumentResult Implements IIDBService.NewFile
|
||||
Try
|
||||
Dim oContainer As FileContainer
|
||||
Dim oContainerId As String
|
||||
|
||||
If Not TestUserAuth() Then
|
||||
Throw New Exception($"User {_username} not authorized.")
|
||||
End If
|
||||
|
||||
oContainer = FileContainer.Create(LogConfig, AppConfig.ContainerPassword)
|
||||
oContainerId = oContainer.ContainerId
|
||||
_logger.Debug("Container created with id {0}", oContainerId)
|
||||
|
||||
Dim oExtension As String = Path.GetExtension(FileName).Substring(1)
|
||||
_logger.Debug("File extension of file {0} is {1}", FileName, oExtension)
|
||||
|
||||
Dim oSQL = $"SELECT FNICM_NEW_DOC('010', '{oContainerId}', '{GetContainerName(oContainerId)}', '{FileName}', '{oExtension}', '{_username}') FROM RDB$DATABASE;"
|
||||
Dim oDocId As Int64 = Database.GetScalarValue(oSQL)
|
||||
|
||||
If oDocId = -1 Then
|
||||
_logger.Warn("Database returned -1 while creating Document Entry. File was not saved!")
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
_logger.Debug("Database Entry created with DocId {0}", oDocId)
|
||||
|
||||
oContainer.SetFile(Contents, FileName)
|
||||
oContainer.SaveAs(GetContainerPath(oContainerId))
|
||||
|
||||
_logger.Debug("File saved in Container!", FileName)
|
||||
|
||||
Dim oDocument = New DocumentObject(oContainerId, oDocId, FileName)
|
||||
Return New DocumentResult(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function UpdateFile(DocObject As DocumentObject, Contents() As Byte) As DocumentResult Implements IIDBService.UpdateFile
|
||||
Try
|
||||
TestFileExists(DocObject.ContainerId)
|
||||
|
||||
' TODO: update db
|
||||
|
||||
Dim oFilePath = GetContainerPath(DocObject.ContainerId)
|
||||
Dim oFileContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oFilePath)
|
||||
|
||||
oFileContainer.SetFile(Contents, oFileContainer.GetFile.FileName)
|
||||
oFileContainer.Save()
|
||||
|
||||
|
||||
Return New DocumentResult(DocObject)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFile(DocObject As DocumentObject) As DocumentResult Implements IIDBService.GetFile
|
||||
Try
|
||||
TestFileExists(DocObject.ContainerId)
|
||||
|
||||
Dim oContainerPath = GetContainerPath(DocObject.ContainerId)
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(DocObject, oContents)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function DeleteFile(DocObject As DocumentObject) As Boolean Implements IIDBService.DeleteFile
|
||||
Try
|
||||
TestFileExists(DocObject.ContainerId)
|
||||
|
||||
Dim oFilePath = GetContainerPath(DocObject.ContainerId)
|
||||
IO.File.Delete(oFilePath)
|
||||
|
||||
'TODO: Delete doc from db
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetContainerPath(ContainerId As String) As String
|
||||
Return Path.Combine(AppConfig.ContainerPath, GetContainerName(ContainerId))
|
||||
End Function
|
||||
|
||||
Private Function GetContainerName(ContainerId As String) As String
|
||||
Return ContainerId & ".enc"
|
||||
End Function
|
||||
|
||||
Private Sub TestFileExists(ContainerId)
|
||||
Dim oContainerPath = GetContainerPath(ContainerId)
|
||||
|
||||
If Not IO.File.Exists(oContainerPath) Then
|
||||
Throw New FileNotFoundException("Container existiert nicht", oContainerPath)
|
||||
End If
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "Document"
|
||||
Public Function ImportFile(FileInfo As FileInfo, Contents() As Byte, [Readonly] As Boolean, RetentionPeriod As Integer) As DocumentResult2 Implements IIDBService.ImportFile
|
||||
Dim oFilePath = Path.Combine(AppConfig.ContainerPath, FileInfo.Name)
|
||||
Dim oDocument = New DocumentResult2.DocumentObject() With {.FileName = FileInfo.Name}
|
||||
|
||||
Try
|
||||
_logger.Info("Saving file [{0}] to path [{1}]", FileInfo.Name, oFilePath)
|
||||
Using oStream = New FileStream(oFilePath, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
|
||||
Dim oAttributes = IO.File.GetAttributes(oFilePath) Or FileAttributes.ReadOnly
|
||||
|
||||
If RetentionPeriod Then
|
||||
_logger.Info("Setting LastAccessTime")
|
||||
IO.File.SetLastAccessTime(oFilePath, Date.Now.AddYears(30))
|
||||
End If
|
||||
|
||||
If [Readonly] Then
|
||||
_logger.Info("Setting ReadOnly Attribute")
|
||||
IO.File.SetAttributes(oFilePath, oAttributes)
|
||||
End If
|
||||
|
||||
Return New DocumentResult2(oDocument)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult2(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Utils"
|
||||
Public Function GetDocumentByDocumentId(DocumentId As Long) As DocumentResult Implements IIDBService.GetDocumentByDocumentId
|
||||
Try
|
||||
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE GUID = {DocumentId}"
|
||||
Dim oTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable.Rows.Count = 0 Then
|
||||
Return New DocumentResult("Document not found")
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oDocument As New DocumentObject(
|
||||
oRow.Item("CONTAINER_ID"),
|
||||
oRow.Item("GUID"),
|
||||
oRow.Item("ORIGINAL_FILENAME")
|
||||
)
|
||||
|
||||
TestFileExists(oDocument.ContainerId)
|
||||
|
||||
Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(oDocument, oContents)
|
||||
Catch ex As Exception
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetDocumentByContainerId(ContainerId As String) As DocumentResult Implements IIDBService.GetDocumentByContainerId
|
||||
Try
|
||||
Dim oSQL = $"SELECT GUID, CONTAINER_ID, ORIGINAL_FILENAME FROM TBIDB_DOCUMENT WHERE CONTAINER_ID = '{ContainerId}'"
|
||||
Dim oTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable.Rows.Count = 0 Then
|
||||
Return New DocumentResult("Document not found")
|
||||
End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oDocument As New DocumentObject(
|
||||
oRow.Item("CONTAINER_ID"),
|
||||
oRow.Item("GUID"),
|
||||
oRow.Item("ORIGINAL_FILENAME")
|
||||
)
|
||||
|
||||
TestFileExists(oDocument.ContainerId)
|
||||
|
||||
Dim oContainerPath = GetContainerPath(oDocument.ContainerId)
|
||||
Dim oContainer As FileContainer = FileContainer.Load(LogConfig, AppConfig.ContainerPassword, oContainerPath)
|
||||
Dim oContents As Byte() = oContainer.GetFile().Contents
|
||||
|
||||
Return New DocumentResult(oDocument, oContents)
|
||||
Catch ex As Exception
|
||||
Return New DocumentResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
#Region "Index"
|
||||
Public Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult Implements IIDBService.NewFileIndex
|
||||
Try
|
||||
Dim oSQL = $"SELECT FNIDB_NEW_DOC_VALUE({DocObject.DocumentId},'{Syskey}','{LanguageCode}','{Value}','{_username}') FROM RDB$DATABASE;"
|
||||
Dim oIndexId As Int64 = Database.GetScalarValue(oSQL)
|
||||
|
||||
Return New IndexResult(oIndexId)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New IndexResult(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
#End Region
|
||||
End Class
|
||||
61
Service.EDMIService/IEDMIService.vb
Normal file
61
Service.EDMIService/IEDMIService.vb
Normal file
@@ -0,0 +1,61 @@
|
||||
Imports System.IO
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
<ServiceContract([Namespace]:="http://DigitalData.Services.EDMIService")>
|
||||
Interface IEDMIService
|
||||
|
||||
#Region "Heartbeat"
|
||||
<OperationContract>
|
||||
Function Heartbeat() As Boolean
|
||||
#End Region
|
||||
|
||||
#Region "Database"
|
||||
<OperationContract>
|
||||
Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String
|
||||
|
||||
<OperationContract>
|
||||
Sub CloseDatabaseRequest()
|
||||
|
||||
<OperationContract>
|
||||
Function ReturnDatatable(SQL As String) As TableResult
|
||||
|
||||
<OperationContract>
|
||||
Function ReturnScalar(SQL As String) As ScalarResult
|
||||
|
||||
<OperationContract>
|
||||
Function ExecuteNonQuery(SQL As String) As NonQueryResult
|
||||
#End Region
|
||||
|
||||
#Region "Document (with FileContainer)"
|
||||
'<OperationContract>
|
||||
'Function NewFile(FileName As String, Contents As Byte()) As DocumentResult
|
||||
|
||||
'<OperationContract>
|
||||
'Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResult
|
||||
|
||||
'<OperationContract>
|
||||
'Function GetFile(DocObject As DocumentObject) As DocumentResult
|
||||
|
||||
'<OperationContract>
|
||||
'Function DeleteFile(DocObject As DocumentObject) As Boolean
|
||||
|
||||
'<OperationContract>
|
||||
'Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
|
||||
|
||||
'<OperationContract>
|
||||
'Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
|
||||
#End Region
|
||||
|
||||
#Region "Document (New)"
|
||||
<OperationContract>
|
||||
Function ImportFile(FileInfo As FileInfo, Contents As Byte(), [ReadOnly] As Boolean, RetentionTime As Integer) As DocumentResult2
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "Index"
|
||||
<OperationContract>
|
||||
Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
|
||||
#End Region
|
||||
|
||||
End Interface
|
||||
62
Service.EDMIService/IIDBService.vb
Normal file
62
Service.EDMIService/IIDBService.vb
Normal file
@@ -0,0 +1,62 @@
|
||||
Imports System.IO
|
||||
Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
<ServiceContract([Namespace]:="http://DigitalData.Services.IDBService")>
|
||||
Interface IIDBService
|
||||
|
||||
#Region "Heartbeat"
|
||||
<OperationContract>
|
||||
Function Heartbeat() As Boolean
|
||||
#End Region
|
||||
|
||||
#Region "Database"
|
||||
<OperationContract>
|
||||
Function CreateDatabaseRequest(Name As String, Optional Debug As Boolean = False) As String
|
||||
|
||||
<OperationContract>
|
||||
Sub CloseDatabaseRequest()
|
||||
|
||||
<OperationContract>
|
||||
Function ReturnDatatable(SQL As String) As TableResult
|
||||
|
||||
<OperationContract>
|
||||
Function ReturnScalar(SQL As String) As ScalarResult
|
||||
|
||||
<OperationContract>
|
||||
Function ExecuteNonQuery(SQL As String) As NonQueryResult
|
||||
#End Region
|
||||
|
||||
#Region "Document (with FileContainer)"
|
||||
<OperationContract>
|
||||
Function NewFile(FileName As String, Contents As Byte()) As DocumentResult
|
||||
|
||||
<OperationContract>
|
||||
Function UpdateFile(DocObject As DocumentObject, Contents As Byte()) As DocumentResult
|
||||
|
||||
<OperationContract>
|
||||
Function GetFile(DocObject As DocumentObject) As DocumentResult
|
||||
|
||||
<OperationContract>
|
||||
Function DeleteFile(DocObject As DocumentObject) As Boolean
|
||||
#End Region
|
||||
|
||||
#Region "Document (New)"
|
||||
<OperationContract>
|
||||
Function ImportFile(FileInfo As FileInfo, Contents As Byte(), [ReadOnly] As Boolean, RetentionTime As Integer) As DocumentResult2
|
||||
#End Region
|
||||
|
||||
#Region "Utils"
|
||||
<OperationContract>
|
||||
Function GetDocumentByDocumentId(DocumentId As Int64) As DocumentResult
|
||||
|
||||
<OperationContract>
|
||||
Function GetDocumentByContainerId(ContainerId As String) As DocumentResult
|
||||
#End Region
|
||||
|
||||
#Region "Index"
|
||||
<OperationContract>
|
||||
Function NewFileIndex(DocObject As DocumentObject, Syskey As String, LanguageCode As String, Value As String) As IndexResult
|
||||
#End Region
|
||||
|
||||
End Interface
|
||||
13
Service.EDMIService/My Project/Application.Designer.vb
generated
Normal file
13
Service.EDMIService/My Project/Application.Designer.vb
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
10
Service.EDMIService/My Project/Application.myapp
Normal file
10
Service.EDMIService/My Project/Application.myapp
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<MySubMain>false</MySubMain>
|
||||
<SingleInstance>false</SingleInstance>
|
||||
<ShutdownMode>0</ShutdownMode>
|
||||
<EnableVisualStyles>true</EnableVisualStyles>
|
||||
<AuthenticationMode>0</AuthenticationMode>
|
||||
<ApplicationType>2</ApplicationType>
|
||||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit>
|
||||
</MyApplicationData>
|
||||
35
Service.EDMIService/My Project/AssemblyInfo.vb
Normal file
35
Service.EDMIService/My Project/AssemblyInfo.vb
Normal file
@@ -0,0 +1,35 @@
|
||||
Imports System
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
|
||||
' Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
' die einer Assembly zugeordnet sind.
|
||||
|
||||
' Werte der Assemblyattribute überprüfen
|
||||
|
||||
<Assembly: AssemblyTitle("IDBService")>
|
||||
<Assembly: AssemblyDescription("")>
|
||||
<Assembly: AssemblyCompany("Digital Data")>
|
||||
<Assembly: AssemblyProduct("IDBService")>
|
||||
<Assembly: AssemblyCopyright("Copyright © 2018")>
|
||||
<Assembly: AssemblyTrademark("")>
|
||||
|
||||
<Assembly: ComVisible(False)>
|
||||
|
||||
'Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird.
|
||||
<Assembly: Guid("46d157e2-ffc2-4b40-a73b-2fd76aa7049b")>
|
||||
|
||||
' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
'
|
||||
' Hauptversion
|
||||
' Nebenversion
|
||||
' Buildnummer
|
||||
' Revision
|
||||
'
|
||||
' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
63
Service.EDMIService/My Project/Resources.Designer.vb
generated
Normal file
63
Service.EDMIService/My Project/Resources.Designer.vb
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
'''<summary>
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
'''<summary>
|
||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("DigitalData.Services.IDBService.Resources", GetType(Resources).Assembly)
|
||||
resourceMan = temp
|
||||
End If
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
117
Service.EDMIService/My Project/Resources.resx
Normal file
117
Service.EDMIService/My Project/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
Service.EDMIService/My Project/Settings.Designer.vb
generated
Normal file
73
Service.EDMIService/My Project/Settings.Designer.vb
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "Automatische My.Settings-Speicherfunktion"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.DigitalData.Services.IDBService.My.MySettings
|
||||
Get
|
||||
Return Global.DigitalData.Services.IDBService.My.MySettings.Default
|
||||
End Get
|
||||
End Property
|
||||
End Module
|
||||
End Namespace
|
||||
7
Service.EDMIService/My Project/Settings.settings
Normal file
7
Service.EDMIService/My Project/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" UseMySettingsClassName="true">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
123
Service.EDMIService/ProjectInstaller.resx
Normal file
123
Service.EDMIService/ProjectInstaller.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
24
Service.EDMIService/ProjectInstaller.vb
Normal file
24
Service.EDMIService/ProjectInstaller.vb
Normal file
@@ -0,0 +1,24 @@
|
||||
Imports System.ComponentModel
|
||||
Imports System.Configuration.Install
|
||||
Imports System.ServiceProcess
|
||||
|
||||
<RunInstaller(True)>
|
||||
Public Class ProjectInstaller
|
||||
Inherits Installer
|
||||
|
||||
Private ReadOnly process As ServiceProcessInstaller
|
||||
Private ReadOnly components As IContainer
|
||||
Private ReadOnly service As ServiceInstaller
|
||||
|
||||
Public Sub New()
|
||||
process = New ServiceProcessInstaller With {
|
||||
.Account = ServiceAccount.NetworkService
|
||||
}
|
||||
service = New ServiceInstaller With {
|
||||
.ServiceName = SERVICE_NAME,
|
||||
.DisplayName = SERVICE_DISPLAY_NAME
|
||||
}
|
||||
Installers.Add(process)
|
||||
Installers.Add(service)
|
||||
End Sub
|
||||
End Class
|
||||
42
Service.EDMIService/Request.vb
Normal file
42
Service.EDMIService/Request.vb
Normal file
@@ -0,0 +1,42 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports FirebirdSql.Data.FirebirdClient
|
||||
|
||||
''' <summary>
|
||||
''' TODO: BRAUCHEN WIR DAS ÜBERHAUPT?
|
||||
''' </summary>
|
||||
Public Class Request
|
||||
Public Name As String
|
||||
Public Username As String
|
||||
Public RequestId As String
|
||||
Public Connection As FbConnection
|
||||
Public Database As Firebird
|
||||
Public Debug As Boolean
|
||||
|
||||
Public Sub New(Name As String, Username As String, Database As Firebird, Debug As Boolean)
|
||||
Me.Username = Username
|
||||
Me.Name = Name
|
||||
Me.RequestId = Guid.NewGuid().ToString()
|
||||
Me.Connection = Database.GetConnection()
|
||||
Me.Database = Database
|
||||
Me.Debug = Debug
|
||||
|
||||
'Dim oSql = $"INSERT INTO TBEDM_REQUEST_USER (REQUEST_GUID, USER_NAME) VALUES ('{RequestId}', '{Username}')"
|
||||
'Database.ExecuteNonQueryWithConnection(oSql, Connection)
|
||||
End Sub
|
||||
|
||||
Public Sub LogDebug(Message As String)
|
||||
'If Debug Then
|
||||
' Dim oSqlCommand = $"INSERT INTO TBEDM_REQUEST_LOG (REQUEST_GUID, LOG_MSG, DEBUG) VALUES ('{RequestId}','{Message}', True)"
|
||||
' Database.ExecuteNonQueryWithConnection(oSqlCommand, Connection)
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
Public Sub LogError(Message As String)
|
||||
'Dim oSqlCommand = $"INSERT INTO TBEDM_REQUEST_LOG (REQUEST_GUID, LOG_MSG, ERROR) VALUES ('{RequestId}','{Message}', True)"
|
||||
'Database.ExecuteNonQueryWithConnection(oSqlCommand, Connection)
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return $"<Name={Name},RequestId={RequestId}>"
|
||||
End Function
|
||||
End Class
|
||||
20
Service.EDMIService/Results/BaseResult.vb
Normal file
20
Service.EDMIService/Results/BaseResult.vb
Normal file
@@ -0,0 +1,20 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
<KnownType(GetType(DBNull))>
|
||||
Public MustInherit Class BaseResult
|
||||
<DataMember>
|
||||
Public Property OK As Boolean
|
||||
<DataMember>
|
||||
Public Property ErrorMessage As String
|
||||
|
||||
Public Sub New()
|
||||
OK = True
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
OK = False
|
||||
Me.ErrorMessage = ErrorMessage
|
||||
End Sub
|
||||
End Class
|
||||
18
Service.EDMIService/Results/ContainerResult.vb
Normal file
18
Service.EDMIService/Results/ContainerResult.vb
Normal file
@@ -0,0 +1,18 @@
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
<Serializable>
|
||||
Public Class ContainerResult
|
||||
Public ReadOnly OK As Boolean
|
||||
Public ReadOnly ErrorMessage As String
|
||||
Public Container As FileContainerInner
|
||||
|
||||
Public Sub New()
|
||||
OK = True
|
||||
ErrorMessage = Nothing
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
OK = False
|
||||
Me.ErrorMessage = ErrorMessage
|
||||
End Sub
|
||||
End Class
|
||||
56
Service.EDMIService/Results/DatabaseResult.vb
Normal file
56
Service.EDMIService/Results/DatabaseResult.vb
Normal file
@@ -0,0 +1,56 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
<KnownType(GetType(DBNull))>
|
||||
Public Class TableResult
|
||||
Inherits BaseResult
|
||||
|
||||
<DataMember>
|
||||
Public Property Table As DataTable
|
||||
|
||||
Public Sub New(Table As DataTable)
|
||||
MyBase.New()
|
||||
Me.Table = Table
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
<KnownType(GetType(DBNull))>
|
||||
Public Class ScalarResult
|
||||
Inherits BaseResult
|
||||
|
||||
<DataMember>
|
||||
Public Property Scalar As Object
|
||||
|
||||
Public Sub New(Scalar As Object)
|
||||
MyBase.New()
|
||||
Me.Scalar = Scalar
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
<KnownType(GetType(DBNull))>
|
||||
Public Class NonQueryResult
|
||||
Inherits BaseResult
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
|
||||
26
Service.EDMIService/Results/DocumentResult.vb
Normal file
26
Service.EDMIService/Results/DocumentResult.vb
Normal file
@@ -0,0 +1,26 @@
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
|
||||
<Serializable>
|
||||
Public Class DocumentResult
|
||||
Inherits BaseResult
|
||||
|
||||
Public Document As DocumentObject
|
||||
Public HasContents As Boolean = False
|
||||
Public Contents As Byte()
|
||||
|
||||
Public Sub New(Document As DocumentObject)
|
||||
MyBase.New()
|
||||
Me.Document = Document
|
||||
End Sub
|
||||
|
||||
Public Sub New(Document As DocumentObject, Contents As Byte())
|
||||
MyBase.New()
|
||||
Me.Document = Document
|
||||
Me.Contents = Contents
|
||||
Me.HasContents = True
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
28
Service.EDMIService/Results/DocumentResult2.vb
Normal file
28
Service.EDMIService/Results/DocumentResult2.vb
Normal file
@@ -0,0 +1,28 @@
|
||||
<Serializable>
|
||||
Public Class DocumentResult2
|
||||
Inherits BaseResult
|
||||
|
||||
Public Document As DocumentObject
|
||||
Public HasContents As Boolean = False
|
||||
Public Contents As Byte()
|
||||
|
||||
Public Sub New(Document As DocumentObject)
|
||||
MyBase.New()
|
||||
Me.Document = Document
|
||||
End Sub
|
||||
|
||||
Public Sub New(Document As DocumentObject, Contents As Byte())
|
||||
MyBase.New()
|
||||
Me.Document = Document
|
||||
Me.Contents = Contents
|
||||
Me.HasContents = True
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
|
||||
Public Class DocumentObject
|
||||
Public FileName As String
|
||||
End Class
|
||||
End Class
|
||||
15
Service.EDMIService/Results/IndexResult.vb
Normal file
15
Service.EDMIService/Results/IndexResult.vb
Normal file
@@ -0,0 +1,15 @@
|
||||
<Serializable>
|
||||
Public Class IndexResult
|
||||
Inherits BaseResult
|
||||
|
||||
Public ReadOnly IndexId As Int64
|
||||
|
||||
Public Sub New(IndexId As Int64)
|
||||
MyBase.New()
|
||||
Me.IndexId = IndexId
|
||||
End Sub
|
||||
|
||||
Public Sub New(ErrorMessage As String)
|
||||
MyBase.New(ErrorMessage)
|
||||
End Sub
|
||||
End Class
|
||||
4
Service.EDMIService/SettingsModule.vb
Normal file
4
Service.EDMIService/SettingsModule.vb
Normal file
@@ -0,0 +1,4 @@
|
||||
Module SettingsModule
|
||||
Public Const SERVICE_NAME As String = "DDIDBSvc"
|
||||
Public Const SERVICE_DISPLAY_NAME As String = "Digital Data IDB Service"
|
||||
End Module
|
||||
78
Service.EDMIService/WindowsService.vb
Normal file
78
Service.EDMIService/WindowsService.vb
Normal file
@@ -0,0 +1,78 @@
|
||||
Imports System.ServiceModel
|
||||
Imports System.ServiceProcess
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
|
||||
Public Class WindowsService
|
||||
Inherits ServiceBase
|
||||
|
||||
Private _serviceHost As ServiceHost = Nothing
|
||||
Private _edmService As IDBService = Nothing
|
||||
|
||||
Private _logConfig As LogConfig
|
||||
Private _logger As Logger
|
||||
Private _db As Firebird
|
||||
Private _clientsConnected As Integer = 0
|
||||
Private _config As AppConfig
|
||||
|
||||
Public Sub New()
|
||||
ServiceName = SERVICE_NAME
|
||||
End Sub
|
||||
|
||||
Public Shared Sub Main()
|
||||
Run(New WindowsService())
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args As String())
|
||||
Try
|
||||
AppConfig.Load()
|
||||
|
||||
_logConfig = New LogConfig(LogConfig.PathType.CustomPath, "E:\EDMService")
|
||||
_logConfig.Debug = True
|
||||
|
||||
_logger = _logConfig.GetLogger()
|
||||
|
||||
_logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
|
||||
_logger.Debug("Connecting to database...")
|
||||
|
||||
_db = New Firebird(
|
||||
_logConfig,
|
||||
AppConfig.FirebirdDataSource,
|
||||
AppConfig.FirebirdDatabase,
|
||||
AppConfig.FirebirdUser,
|
||||
AppConfig.FirebirdPassword
|
||||
)
|
||||
|
||||
_logger.Info("Database connection established.")
|
||||
|
||||
IDBService.Database = _db
|
||||
IDBService.LogConfig = _logConfig
|
||||
IDBService.AppConfig = _config
|
||||
|
||||
_logger.Debug("Starting WCF ServiceHost...")
|
||||
|
||||
_serviceHost = New ServiceHost(GetType(IDBService))
|
||||
_serviceHost.Open()
|
||||
|
||||
_logger.Debug("WCF ServiceHost started.")
|
||||
|
||||
_logger.Info("Service {0} successfully started.", SERVICE_DISPLAY_NAME)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, "Failed to start the service host!")
|
||||
GracefullyStop()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
GracefullyStop()
|
||||
End Sub
|
||||
|
||||
Private Sub GracefullyStop()
|
||||
If _serviceHost IsNot Nothing Then
|
||||
_serviceHost.Close()
|
||||
_serviceHost = Nothing
|
||||
End If
|
||||
_logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
5
Service.EDMIService/packages.config
Normal file
5
Service.EDMIService/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FirebirdSql.Data.FirebirdClient" version="6.4.0" targetFramework="net461" />
|
||||
<package id="NLog" version="4.6.8" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user