Zooflow: WIP

This commit is contained in:
Jonathan Jenne
2021-12-01 16:22:51 +01:00
parent 8a76425c94
commit 77621193f2
45 changed files with 768 additions and 270 deletions

View File

@@ -0,0 +1,42 @@
Imports System.Runtime.Serialization
Namespace Methods
Public Class FileProperties
''' <summary>
''' Absolute filename of the file to be imported
''' </summary>
<DataMember>
Public Property FileName As String
''' <summary>
''' Creation date of the original file from the filesystem
''' </summary>
<DataMember>
Public Property FileCreatedAt As String
''' <summary>
''' Modification date of the original file from the filesystem
''' </summary>
<DataMember>
Public Property FileChangedAt As String
''' <summary>
''' Date for which the file should be show as imported
''' </summary>
<DataMember>
Public Property FileImportedAt As Date
''' <summary>
''' The byte array representing the file contents
''' </summary>
<DataMember>
Public Property FileContents As Byte()
''' <summary>
''' The SHA256 Hash of the file contents
''' </summary>
<DataMember>
Public Property FileChecksum As String
End Class
End Namespace

View File

@@ -0,0 +1,29 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Namespace Methods.GetAttributeValue
Public Class GetAttributeValueMethod
Inherits BaseMethod
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
MyBase.New(pLogConfig, pDatabase)
End Sub
Public Function Run(pData As GetAttributeValueRequest) As GetAttributeValueResponse
Try
If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
LogAndThrow("ObjectId does not exist!")
End If
Dim oValue As Object
' TODO: Implement GetAttributeValue
Return New GetAttributeValueResponse(pData.ObjectId, oValue)
Catch ex As Exception
Logger.Warn("Error occurred while getting attribute value!")
Return New GetAttributeValueResponse(ex)
End Try
End Function
End Class
End Namespace

View File

@@ -0,0 +1,5 @@
Namespace Methods.GetAttributeValue
Public Class GetAttributeValueRequest
Public Property ObjectId As Long
End Class
End Namespace

View File

@@ -0,0 +1,26 @@
Imports System.Runtime.Serialization
Namespace Methods.GetAttributeValue
<Serializable>
<DataContract>
Public Class GetAttributeValueResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property ObjectId As Long
Public Property Value As Object
Public Sub New(pObjectId As Long, pValue As Object)
MyBase.New()
ObjectId = pObjectId
Value = pValue
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,62 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging
Namespace Methods.GetDatatableFromCache
Public Class GetDatatableFromCacheMethod
Inherits BaseMethod
Private ReadOnly TableStore As DataSet
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pTableStore As DataSet)
MyBase.New(pLogConfig, pMSSQLServer)
TableStore = pTableStore
End Sub
Public Function Run(pData As GetDatatableFromCacheRequest) As GetDatatableFromCacheResponse
Try
Logger.Debug($"ReturnDatatableFromCache: Datatable: {pData.DataTable}")
Dim oDataTable As DataTable = Nothing
Logger.Debug("ReturnDatatableFromCache: DataSet contains [{0}] datatables", TableStore.Tables.Count)
If TableStore.Tables.Contains(pData.DataTable) Then
oDataTable = TableStore.Tables.Item(pData.DataTable).Copy()
' Apply filter and sorting to data
Dim oFilterExpression As String = Utils.NotNull(pData.FilterExpression, String.Empty)
Dim oSortByColumn As String = Utils.NotNull(pData.SortByColumn, String.Empty)
Dim oFilteredRows = oDataTable.Select(oFilterExpression, oSortByColumn)
Dim oFilteredTable As DataTable = Nothing
If oFilteredRows.Count > 0 Then
oFilteredTable = oFilteredRows.CopyToDataTable()
oFilteredTable.TableName = pData.DataTable
Else
' Produce empty table
oFilteredTable = oDataTable.Clone()
oFilteredTable.TableName = pData.DataTable
End If
Logger.Debug("ReturnDatatableFromCache: Datatable Stats for [{0}]:", pData.DataTable)
Logger.Debug("Unfiltered: [{0}] rows", oDataTable.Rows.Count)
Logger.Debug("Filtered: [{0}] rows", oFilteredTable.Rows.Count)
Return New GetDatatableFromCacheResponse(oFilteredTable)
Else
Logger.Warn($"ReturnDatatableFromCache: Datatable {pData.DataTable} does not exist")
Return New GetDatatableFromCacheResponse(New KeyNotFoundException($"Datatable {pData.DataTable} does not exist"))
End If
Catch ex As Exception
Logger.Error(ex)
Return New GetDatatableFromCacheResponse(ex)
End Try
End Function
End Class
End Namespace

View File

@@ -0,0 +1,14 @@
Imports System.Runtime.Serialization
Namespace Methods.GetDatatableFromCache
<Serializable>
<DataContract>
Public Class GetDatatableFromCacheRequest
<DataMember>
Public Property DataTable As String
<DataMember>
Public Property FilterExpression As String
<DataMember>
Public Property SortByColumn As String
End Class
End Namespace

View File

@@ -0,0 +1,22 @@
Imports System.Runtime.Serialization
Namespace Methods.GetDatatableFromCache
<Serializable>
<DataContract>
Public Class GetDatatableFromCacheResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property Table As DataTable
Public Sub New(pTable As DataTable)
MyBase.New()
Table = pTable
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,227 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Patterns
Imports DigitalData.Modules.Language
Imports DigitalData.Services.EDMIService.Methods.GetDatatableFromCache
Namespace Methods.GlobalIndexer.ImportFile
Public Class ImportFileMethod
Inherits BaseMethod
Private ReadOnly TableStore As DataSet
Private ReadOnly Patterns As Patterns2
Private ReadOnly GetDatatable As GetDatatableFromCacheMethod
Private ManualIndexes As DataTable
Private AutomaticIndexes As DataTable
Private ManualIndexesPostProcessing As DataTable
Private Const VIEW_INDEX_MANUAL = "VWDDINDEX_MAN"
Private Const VIEW_INDEX_AUTOMATIC = "VWDDINDEX_AUTOM"
Private Const TABLE_POST_PROCESSING = "TBDD_INDEX_MAN_POSTPROCESSING"
Private Const TYPE_VBSPLIT = "VBSPLIT"
Private Const TYPE_VBREPLACE = "VBREPLACE"
Private Const TYPE_REGEXPRESSION = "REG. EXPRESSION"
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pTableStore As DataSet)
MyBase.New(pLogConfig, pMSSQLServer)
TableStore = pTableStore
Patterns = New Patterns2(pLogConfig)
GetDatatable = New GetDatatableFromCacheMethod(LogConfig, Database, TableStore)
End Sub
''' <summary>
'''
''' </summary>
''' <remarks>
'''
'''
'''
''' </remarks>
Public Function Run(pData As ImportFileRequest)
Try
LoadIndexes(pData.ProfileId)
Dim oFinalAttributes = pData.AttributeValues
' apply the post processing
oFinalAttributes = ApplyManualPostprocessing(oFinalAttributes, ManualIndexesPostProcessing)
' TODO: apply the manual attributes
oFinalAttributes = ApplyAutomaticeAttributes(oFinalAttributes)
Catch ex As Exception
Return New ImportFileResponse(ex)
End Try
End Function
Private Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue), pPostprocessingSteps As DataTable) As List(Of UserAttributeValue)
Logger.Debug("Start of Method [ApplyManualPostprocessing]")
Dim oAttributes = pManualAttributes
For Each oProcessingRow As DataRow In pPostprocessingSteps.Rows
Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")
Dim oIndexRow As DataRow = ManualIndexes.Select($"GUID = {oIndexId}").FirstOrDefault()
Dim oIndex As UserAttributeValue = pManualAttributes.
Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")).
FirstOrDefault()
Dim oValue = GetPostprocessingValue(oIndex.AttributeValues, oIndexRow)
oAttributes.Add(New UserAttributeValue With {
.AttributeId = oIndexId,
.AttributeName = oIndex.AttributeName,
.AttributeValues = oIndex.AttributeValues,
.ControlName = oIndex.ControlName
})
Next
Return oAttributes
End Function
Private Function ApplyAutomaticeAttributes(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue)
Logger.Debug("Start of Method [ApplyAutomaticeAttributes]")
Return pManualAttributes
End Function
Private Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow)
Logger.Debug("Start of Method [GetPostprocessingValue]")
Dim oType = pRow.Item("TYPE")
Dim oResult As New List(Of String)
Logger.Debug("Type of Postprocessing is [{0}]", oType)
Select Case oType
Case TYPE_VBREPLACE
Dim oFindString = pRow.Item("TEXT1")
Dim oReplaceString = pRow.Item("TEXT2")
Logger.Debug("Replacing [{0}] with [{1}]", oFindString, oReplaceString)
For Each oIndexValue In pValues
Dim oReplaceResult = oIndexValue.Replace(oFindString, oReplaceString)
If oReplaceResult.Equals(oIndexValue) Then
Logger.Debug("Replace did not succeed, ReplaceString was not found.")
Else
Logger.Debug("Replace successful for [{0}].", oIndexValue)
End If
oResult.Add(oReplaceResult)
Next
Case TYPE_VBSPLIT
Dim oSeparator As String = pRow.Item("TEXT1")
Dim oSplitIndex As Integer = 0
Integer.TryParse(pRow.Item("TEXT2"), oSplitIndex)
Logger.Debug("Splitting String at Separator [{0}] and Index [{1}]", oSeparator, oSplitIndex)
For Each oIndexValue In pValues
Dim oSplitted As List(Of String) = oIndexValue.Split(oSeparator).ToList()
Logger.Debug("Split succeeded, resulting list has [{0}] items.", oSplitted.Count)
If oSplitIndex < oSplitted.Count Then
Dim oValue = oSplitted.Item(oSplitIndex)
Logger.Debug("Saving value [{0}] from Index [{1}]", oValue, oSplitIndex)
oResult.Add(oValue)
Else
Logger.Debug("SplitIndex(TEXT2) was out of array bounds. Skipping.")
End If
Next
Case Else
LogAndThrow($"Postprocessing type [{oType}] is not supported!")
End Select
Return oResult
End Function
Private Sub LoadIndexes(pProfileId As Integer)
Logger.Debug("Start of Method [LoadIndexes]")
LoadManualIndexes(pProfileId)
LoadAutomaticIndexes(pProfileId)
LoadPostProcessingSteps()
End Sub
Private Sub LoadAutomaticIndexes(pProfileId As Integer)
Logger.Debug("Start of Method [LoadAutomaticIndexes]")
Try
' Load automatic Indexes for this Import
Dim oAutomaticIndexes = GetDatatable.Run(
New GetDatatableFromCacheRequest With {
.DataTable = VIEW_INDEX_MANUAL,
.FilterExpression = $"DOK_ID = {pProfileId}"
})
If oAutomaticIndexes.OK = False Then
LogAndThrow(oAutomaticIndexes.ErrorMessage)
End If
AutomaticIndexes = oAutomaticIndexes.Table
Catch ex As Exception
LogAndThrow(ex, "Error while automatic loading indexes!")
End Try
End Sub
Private Sub LoadManualIndexes(pProfileId As Integer)
Logger.Debug("Start of Method [LoadManualIndexes]")
Try
' Load manual Indexes for this Import
Dim oManualIndexes = GetDatatable.Run(
New GetDatatableFromCacheRequest With {
.DataTable = VIEW_INDEX_MANUAL,
.FilterExpression = $"DOK_ID = {pProfileId}"
})
If oManualIndexes.OK = False Then
LogAndThrow(oManualIndexes.ErrorMessage)
End If
ManualIndexes = oManualIndexes.Table
Catch ex As Exception
LogAndThrow(ex, "Error while loading indexes!")
End Try
End Sub
Private Sub LoadPostProcessingSteps()
Logger.Debug("Start of Method [LoadPostProcessingSteps]")
Try
' Generate a string containing all index ids joined into a string
Dim oIndexIdList As New List(Of Integer)
For Each oRow As DataRow In ManualIndexes.Rows
oIndexIdList.Add(oRow.ItemEx(Of Integer)("GUID"))
Next
Dim oIndexIds As String = String.Join(",", oIndexIdList)
' Load all relevant postprocessing steps
Dim oPostProcessingSteps = GetDatatable.Run(
New GetDatatableFromCacheRequest With {
.DataTable = TABLE_POST_PROCESSING,
.FilterExpression = $"IDXMAN_ID IN ({oIndexIds})"
})
If oPostProcessingSteps.OK = False Then
LogAndThrow(oPostProcessingSteps.ErrorMessage)
End If
ManualIndexesPostProcessing = oPostProcessingSteps.Table
Catch ex As Exception
LogAndThrow(ex, "Error while loading post processing steps!")
End Try
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,36 @@
Imports System.Runtime.Serialization
Namespace Methods.GlobalIndexer.ImportFile
<Serializable>
<DataContract>
Public Class ImportFileRequest
''' <summary>
''' Important File properties like, Name, Contents, CreatedAt, ModifiedAt, Checksum
''' </summary>
<DataMember>
Public Property File As FileProperties
''' <summary>
''' The ProfileId the file will be imported with
''' </summary>
Public Property ProfileId As Integer
''' <summary>
''' The attribute values given by the user in the form of
''' Attribute Name/Attribute Value/ControlName
''' </summary>
Public Property AttributeValues As List(Of UserAttributeValue)
''' <summary>
''' The name of the user importing the file, ex. JenneJ
''' </summary>
<DataMember>
Public Property Who As String
''' <summary>
''' The language of the user, ex. de-DE
''' </summary>
<DataMember>
Public Property Language As String
End Class
End Namespace

View File

@@ -0,0 +1,22 @@
Imports System.Runtime.Serialization
Namespace Methods.GlobalIndexer.ImportFile
<Serializable>
<DataContract>
Public Class ImportFileResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property ObjectId As Long
Public Sub New(pObjectId As Long)
MyBase.New()
ObjectId = pObjectId
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,224 @@
Imports System.Data.SqlClient
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Database.MSSQLServer.TransactionMode
Imports DigitalData.Modules.Logging
Imports DigitalData.Services.EDMIService.Methods
Imports DigitalData.Services.EDMIService.GlobalState
Public Class NewFileMethod
Inherits BaseMethod
Private ReadOnly ObjectStores As List(Of ObjectStore)
Private ReadOnly Connection As SqlConnection
Private ReadOnly Transaction As SqlTransaction
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pObjectStores As List(Of ObjectStore))
MyBase.New(pLogConfig, pMSSQLServer)
ObjectStores = pObjectStores
Connection = Database.GetConnection()
Transaction = Connection.BeginTransaction()
End Sub
Public Function Run(pData As NewFile.NewFileRequest) As NewFile.NewFileResponse
Dim oFilePath As String = Nothing
Dim oExistingObjectId = TestFileChecksumExists(pData.File.FileChecksum)
If oExistingObjectId > 0 Then
Return New NewFile.NewFileResponse(oExistingObjectId)
End If
Try
Dim oObjectId = NewObjectId(pData.KindType, pData.BusinessEntity, pData.Who)
If oObjectId = 0 Then
LogAndThrow("Could not create new ObjectId!")
End If
' Find ObjectStore by Title
Logger.Debug("Checking for DataStore [{0}].", pData.StoreName)
Dim oStore = ObjectStores.
Where(Function(store) store.Title.Equals(pData.StoreName, StringComparison.OrdinalIgnoreCase)).
SingleOrDefault()
If oStore Is Nothing Then
LogAndThrow($"DataStore [{pData.StoreName}] does not exist. Exiting.")
End If
' Get Store base path
Dim oBasePath As String = oStore.Path
Logger.Debug("Store BasePath is [{0}]", oBasePath)
' Get directory by DateImported or, if not supplied, by current date
Dim oSubDirectory As String
If IsNothing(pData.File.FileImportedAt) Then
oSubDirectory = GetDateSubDirectory(Now)
Else
oSubDirectory = GetDateSubDirectory(pData.File.FileImportedAt)
End If
Logger.Debug("Subdirectory is [{0}]", oSubDirectory)
' Check and create final path, if necessary
Dim oFinalPath = IO.Path.Combine(oBasePath, oSubDirectory)
If Not IO.Directory.Exists(oFinalPath) Then
Try
Logger.Debug("Path does not exist, creating: [{0}]", oFinalPath)
IO.Directory.CreateDirectory(oFinalPath)
Logger.Debug("Created folder [{0}]", oFinalPath)
Catch ex As Exception
LogAndThrow(ex, $"Store Directory [{oFinalPath}] could not be created!")
End Try
End If
Logger.Debug("Final Directory is [{0}]", oFinalPath)
' Get filename
Dim oKeepFileName As Boolean = False
If oStore.IsArchive Then
Logger.Debug("Object Store is an archive: [{0}]", oStore.IsArchive)
oKeepFileName = True
End If
Dim oFileName As String = GetFileObjectFileName(oObjectId, pData.File.FileName, oKeepFileName)
Logger.Debug("Filename is [{0}]", oFileName)
oFilePath = IO.Path.Combine(oFinalPath, oFileName)
Dim oFileObjectInfo As IO.FileInfo = New IO.FileInfo(oFilePath)
Dim oFileObjectSize As Long = pData.File.FileContents.Length
Dim oFileObjectExtension As String = oFileObjectInfo.Extension.Substring(1)
Dim oFileObjectName As String = oFileObjectInfo.Name
Logger.Debug("File Information for [{0}]:", oFileObjectName)
Logger.Debug("Size: [{0}]", oFileObjectSize)
Logger.Debug("Extension: [{0}]", oFileObjectExtension)
Logger.Debug("Checksum: [{0}]", pData.File.FileChecksum)
Try
Using oStream = New IO.FileStream(oFilePath, IO.FileMode.Create, IO.FileAccess.Write)
Logger.Info("Saving file to path [{0}]", oFilePath)
oStream.Write(pData.File.FileContents, 0, oFileObjectSize)
oStream.Flush(True)
oStream.Close()
End Using
Catch ex As Exception
LogAndThrow(ex, $"Could not write file [{oFilePath}] to disk!")
End Try
'---------------------------------------------------------------------------
Logger.Info("Creating IDB FileObject for ObjectId [{0}].", oObjectId)
' Insert into DB
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{oFinalPath}', '{oFileObjectName}', '{oFileObjectExtension}',{oFileObjectSize},'{pData.File.FileChecksum}' ,'{pData.Who}','{oObjectId}',{oStore.Id}"
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnectionObject(oSQL, Connection, ExternalTransaction, Transaction)
If oResult = False Then
LogAndThrow("IDB FileObject could not be created!")
End If
'---------------------------------------------------------------------------
'TODO: File dates in try catch
Dim oDefaultAttributes As New Dictionary(Of String, Object) From {
{"OriginFileName", pData.File.FileName},
{"OriginCreationDatetime", pData.File.FileCreatedAt},
{"OriginChangedDatetime", pData.File.FileChangedAt}
}
For Each oAttribute As KeyValuePair(Of String, Object) In oDefaultAttributes
Try
' Dont write empty attributes
If oAttribute.Value Is Nothing Then
Continue For
End If
Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, "de-DE", pData.Who)
If oSuccess Then
Logger.Debug("Default Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
Else
Logger.Warn("Default attribute value could not be written")
End If
Catch ex As Exception
LogAndThrow(ex, $"System attribute [{oAttribute.Key}] could not be written!")
End Try
Next
'---------------------------------------------------------------------------
' Finally, commit the transaction
Transaction?.Commit()
Return New NewFile.NewFileResponse(oObjectId)
Catch ex As Exception
Logger.Warn("Error occurred while importing file!")
Logger.Error(ex)
Logger.Info("Cleaning up files.")
If Not IsNothing(oFilePath) AndAlso IO.File.Exists(oFilePath) Then
Try
IO.File.Delete(oFilePath)
Catch exInner As Exception
Logger.Warn("Error while cleaning up files.")
Logger.Error(exInner)
End Try
End If
Logger.Info("Rolling back transaction.")
Transaction?.Rollback()
Return New NewFile.NewFileResponse(ex)
End Try
End Function
Private Function TestFileChecksumExists(pChecksum As String) As Long
Try
Dim oChecksumSQL = $"SELECT IDB_OBJ_ID FROM TBIDB_FILE_OBJECT WHERE FILE_HASH = '{pChecksum}'"
Dim oExistingObjectId As Long = Database.GetScalarValue(oChecksumSQL)
If oExistingObjectId > 0 Then
Logger.Info("Returning early with ObjectId [{0}] because Checksum [{1}] already exists.", oExistingObjectId, pChecksum)
Return oExistingObjectId
End If
Return Nothing
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
Private Function NewObjectId(pKindType As String, pBusinessEntity As String, pWho As String) As Long
Try
Dim oNewObjectIdSQL = $"DECLARE @NEW_IDB_OBJ_ID BIGINT
EXEC PRIDB_NEW_OBJECT '{pKindType}','{pWho}','{pBusinessEntity}',0, @IDB_OBJ_ID = @NEW_IDB_OBJ_ID OUTPUT;
SELECT @NEW_IDB_OBJ_ID"
Dim oObjectId As Long = Database.GetScalarValueWithConnectionObject(oNewObjectIdSQL, Connection, ExternalTransaction, Transaction)
Logger.Info("New Object with Id [{0}] created!", oObjectId)
If IsNothing(oObjectId) Then
LogAndThrow("Could not create new ObjectId!")
End If
Return oObjectId
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
End Function
Private Function GetFileObjectFileName(IDB_OBJ_ID As Long, pFilename As String, pKeepFilename As Boolean) As String
If pKeepFilename Then
Return pFilename
Else
Return $"{IDB_OBJ_ID}.ddfo"
End If
End Function
Private Function GetDateSubDirectory(pDate As Date) As String
Return IO.Path.Combine(pDate.ToString("yyyy"), pDate.ToString("MM"), pDate.ToString("dd"))
End Function
End Class

View File

@@ -0,0 +1,43 @@
Imports System.Runtime.Serialization
Namespace Methods.NewFile
<Serializable>
<DataContract>
Public Class NewFileRequest
<DataMember>
Public Property File As FileProperties
''' <summary>
''' Name/title of the ObjectStore to save the file to, ex. Work
''' </summary>
<DataMember>
Public Property StoreName As String
''' <summary>
''' The business entity of the file, ex DEFAULT
''' </summary>
<DataMember>
Public Property BusinessEntity As String
''' <summary>
''' The kind of object to be created, ex. DOC
''' </summary>
<DataMember>
Public Property KindType As String
''' <summary>
''' The name of the user importing the file, ex. JenneJ
''' </summary>
<DataMember>
Public Property Who As String
''' <summary>
''' The language of the user
''' </summary>
''' <returns></returns>
<DataMember>
Public Property Language As String
End Class
End Namespace

View File

@@ -0,0 +1,22 @@
Imports System.Runtime.Serialization
Namespace Methods.SetAttributeValue
<Serializable>
<DataContract>
Public Class SetAttributeValueResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property ObjectId As Long
Public Sub New(pObjectId As Long)
MyBase.New()
ObjectId = pObjectId
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,41 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Database
Imports DigitalData.Services.EDMIService.IDB
Imports System.Data.SqlClient
Namespace Methods.SetAttributeValue
Public Class SetAttributeValueMethod
Inherits BaseMethod
Private Connection As SqlConnection
Private Transaction As SqlTransaction
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
MyBase.New(pLogConfig, pDatabase)
Connection = Database.GetConnection()
Transaction = Connection.BeginTransaction()
End Sub
Public Function Run(pData As SetAttributeValueRequest) As SetAttributeValueResponse
Try
If Helpers.TestObjectIdExists(pData.ObjectId) = False Then
LogAndThrow("ObjectId does not exist!")
End If
Dim oResult = Helpers.SetAttributeValue(Connection, Transaction,
pData.ObjectId, pData.AttributeName, pData.AttributeValue, pData.Language, pData.Who)
If oResult = False Then
LogAndThrow("Attribute value could not be set!")
End If
Return New SetAttributeValueResponse(pData.ObjectId)
Catch ex As Exception
Logger.Warn("Error occurred while setting attribute value!")
Return New SetAttributeValueResponse(ex)
End Try
End Function
End Class
End Namespace

View File

@@ -0,0 +1,25 @@
Imports System.Runtime.Serialization
Namespace Methods.SetAttributeValue
<Serializable>
<DataContract>
Public Class SetAttributeValueRequest
''' <summary>
''' Object Id
''' </summary>
<DataMember>
Public Property ObjectId As Long
<DataMember>
Public Property AttributeName As String
<DataMember>
Public Property AttributeValue As String
<DataMember>
Public Property Who As Long
<DataMember>
Public Property Language As String
End Class
End Namespace

View File

@@ -0,0 +1,22 @@
Imports System.Runtime.Serialization
Namespace Methods.NewFile
<Serializable>
<DataContract>
Public Class NewFileResponse
Inherits Messages.BaseResponse
<DataMember>
Public Property ObjectId As Long
Public Sub New(pObjectId As Long)
MyBase.New()
ObjectId = pObjectId
End Sub
Public Sub New(pException As Exception, Optional pDetails As String = "")
MyBase.New(pException, pDetails)
End Sub
End Class
End Namespace

View File

@@ -0,0 +1,10 @@
Namespace Methods
Public Class UserAttributeValue
Public Property AttributeId As Integer
Public Property AttributeName As String
Public Property AttributeValues As List(Of String)
Public Property ControlName As String
End Class
End Namespace