jj: add SetFileIndex, Convert Index Value
This commit is contained in:
parent
7fa329a349
commit
650e6fe365
@ -33,6 +33,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Controls", "Controls", "{F9
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LookupGrid", "LookupGrid\LookupGrid.vbproj", "{3DCD6D1A-C830-4241-B7E4-27430E7EA483}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Filesystem", "Filesystem\Filesystem.vbproj", "{991D0231-4623-496D-8BD0-9CA906029CBC}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Licenses", "Licenses", "{59A45678-44A7-4A59-9FC4-C2643E431B52}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
FIREBIRD-LICENSE.txt = FIREBIRD-LICENSE.txt
|
||||
NLOG-LICENSE.txt = NLOG-LICENSE.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -79,6 +87,10 @@ Global
|
||||
{3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3DCD6D1A-C830-4241-B7E4-27430E7EA483}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{991D0231-4623-496D-8BD0-9CA906029CBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{991D0231-4623-496D-8BD0-9CA906029CBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{991D0231-4623-496D-8BD0-9CA906029CBC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{991D0231-4623-496D-8BD0-9CA906029CBC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -94,6 +106,7 @@ Global
|
||||
{836C9ADE-E04E-4E1E-B17A-201E68014790} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
|
||||
{44982F9B-6116-44E2-85D0-F39650B1EF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
|
||||
{3DCD6D1A-C830-4241-B7E4-27430E7EA483} = {F98C0329-C004-417F-B2AB-7466E88D8220}
|
||||
{991D0231-4623-496D-8BD0-9CA906029CBC} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Public Class ClassHelper
|
||||
|
||||
End Class
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Public Class Exceptions
|
||||
Public Class SessionException
|
||||
Inherits Exception
|
||||
Inherits ApplicationException
|
||||
|
||||
Public Sub New()
|
||||
End Sub
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
Imports DigitalData.Modules.Windream.Constants
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DigitalData.Modules.Windream.Constants
|
||||
|
||||
Public Class Helpers
|
||||
Private Shared ReadOnly VectorIndicies As List(Of Integer) = New List(Of Integer) From {
|
||||
@ -49,6 +50,37 @@ Public Class Helpers
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Friend Shared Function ConvertIndexValue(Type As Integer, Value As String) As Object
|
||||
' Leerzeichen an Anfang und Ende entfernen
|
||||
Value = Value.Trim()
|
||||
|
||||
Select Case Type
|
||||
Case INDEX_TYPE_HASH
|
||||
Case INDEX_TYPE_STRING
|
||||
Case INDEX_TYPE_VECTOR_STRING
|
||||
Return Value
|
||||
Case INDEX_TYPE_INTEGER
|
||||
Case INDEX_TYPE_VECTOR_INTEGER
|
||||
Value = Value.Replace(" ", String.Empty)
|
||||
Return Convert.ToInt16(Value)
|
||||
Case INDEX_TYPE_VECTOR_INTEGER_64BIT
|
||||
Value = Value.Replace(" ", String.Empty)
|
||||
Return Convert.ToInt64(Value)
|
||||
Case INDEX_TYPE_VECTOR_BOOLEAN
|
||||
Case INDEX_TYPE_BOOLEAN
|
||||
Return Convert.ToBoolean(Value)
|
||||
Case INDEX_TYPE_DATE
|
||||
Case INDEX_TYPE_DATE_TIME
|
||||
Case INDEX_TYPE_TIME
|
||||
Case INDEX_TYPE_VECTOR_DATE_TIME
|
||||
Case INDEX_TYPE_VECTOR_DATE
|
||||
Return Convert.ToDateTime(Value)
|
||||
Case INDEX_TYPE_FLOAT
|
||||
Case INDEX_TYPE_VECTOR_FLOAT
|
||||
Return Convert.ToDouble(Value)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Friend Shared Function IsVectorIndex(indexType As Integer)
|
||||
Return VectorIndicies.Contains(indexType)
|
||||
End Function
|
||||
|
||||
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.0.0.0")>
|
||||
<Assembly: AssemblyVersion("0.0.0.4")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.5.10\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
@ -92,7 +92,6 @@
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClassHelper.vb" />
|
||||
<Compile Include="ConnectionBuilder.vb" />
|
||||
<Compile Include="Constants.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
|
||||
@ -129,6 +129,177 @@ Public Class Windream2
|
||||
_sessionDomain = SessionDomain
|
||||
End Sub
|
||||
|
||||
Public Function GetChoiceListItems(ChoiceListName As String) As List(Of String)
|
||||
Dim oItems As New List(Of String)
|
||||
Dim oChoicelist As WMObject
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
Try
|
||||
oChoicelist = Session.GetWMObjectByName(WMEntityChoiceList, ChoiceListName)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, "Could not get choice list")
|
||||
Return oItems
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oChoiceListItems As Object = oChoicelist.GetVariableValue("vItems")
|
||||
|
||||
If oChoiceListItems Is Nothing Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
For Each oChoiceListItem In oChoiceListItems
|
||||
oItems.Add(oChoiceListItem)
|
||||
Next
|
||||
|
||||
Return oItems
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, "Could not get choice list items")
|
||||
Return oItems
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetChoiceLists() As List(Of String)
|
||||
Dim oItems As New List(Of String)
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oChoiceLists As WMObjects
|
||||
Dim oChoiceList As IWMObject2
|
||||
'load list of choicelists
|
||||
oChoiceLists = Session.GetAllObjects(WMEntityChoiceList)
|
||||
|
||||
For Each oChoiceList In oChoiceLists
|
||||
oItems.Add(oChoiceList.aName)
|
||||
Next
|
||||
|
||||
Return oItems
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oItems
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetFileByPath(Path As String) As WMObject
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oWMObject As WMObject
|
||||
|
||||
Try
|
||||
oWMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||
Return oWMObject
|
||||
Catch ex As Exception
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndexType(IndexName As String) As Integer
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oAttribute = Session.GetWMObjectByName(WMEntityAttribute, IndexName)
|
||||
Dim oType = oAttribute.GetVariableValue("dwAttrType")
|
||||
Return oType
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndexValue(Path As String, IndexName As String) As List(Of String)
|
||||
Dim oResult As New List(Of String)
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||
|
||||
If oWMObject Is Nothing Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
Dim oValues = oWMObject.GetVariableValue(IndexName)
|
||||
|
||||
If oValues Is Nothing Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
If TypeOf oValues Is IEnumerable Then
|
||||
For Each oValue In oValues
|
||||
oResult.Add(oValue)
|
||||
Next
|
||||
Else
|
||||
oResult.Add(oValues)
|
||||
End If
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndiciesByObjecttype(ObjectTypeName As String) As List(Of String)
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oObjectType As WMObject
|
||||
Dim oIndexAttributes As WMObjectRelation
|
||||
Dim oIndexAttribute As WMObject
|
||||
Dim oIndex As WMObject
|
||||
Dim oRelProperties As WMObjectRelation
|
||||
Dim oTempSession As IWMSession2
|
||||
Dim oIndicies As New List(Of String)
|
||||
|
||||
Try
|
||||
' den Objekttyp laden
|
||||
oTempSession = DirectCast(Session, IWMSession2)
|
||||
oObjectType = Session.GetWMObjectByName(WMEntityObjectType, ObjectTypeName)
|
||||
|
||||
' Beziehung zu Indizes des Objekttyp auslesen
|
||||
oIndexAttributes = oObjectType.GetWMObjectRelationByName("TypeAttributes")
|
||||
|
||||
' alle Indizes durchlaufen
|
||||
For j As Integer = 0 To oIndexAttributes.Count - 1
|
||||
|
||||
' aktuellen Index auslesen
|
||||
oIndexAttribute = oIndexAttributes.Item(j)
|
||||
|
||||
' Eigenschaften des Index auslesen
|
||||
oRelProperties = oIndexAttribute.GetWMObjectRelationByName("Attribute")
|
||||
|
||||
' Index aus den Eigenschaften auslesen
|
||||
oIndex = oRelProperties.Item(0)
|
||||
|
||||
' Indexname speichern
|
||||
'aIndexNames(j) = oIndex.aName
|
||||
oIndicies.Add(oIndex.aName)
|
||||
Next
|
||||
|
||||
' Indexarray zurückgeben
|
||||
'Return aIndexNames
|
||||
Return oIndicies
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oIndicies
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function NewSession(Optional ServerName As String = Nothing, Optional UserName As String = Nothing, Optional Password As String = Nothing, Optional Domain As String = Nothing) As IWMSession2
|
||||
Dim oBrowser As ServerBrowser
|
||||
Dim oConnect As IWMConnect2
|
||||
@ -535,161 +706,13 @@ Public Class Windream2
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetChoiceLists() As List(Of String)
|
||||
Dim oItems As New List(Of String)
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oChoiceLists As WMObjects
|
||||
Dim oChoiceList As IWMObject2
|
||||
'load list of choicelists
|
||||
oChoiceLists = Session.GetAllObjects(WMEntityChoiceList)
|
||||
|
||||
For Each oChoiceList In oChoiceLists
|
||||
oItems.Add(oChoiceList.aName)
|
||||
Next
|
||||
|
||||
Return oItems
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oItems
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetChoiceListItems(ChoiceListName As String) As List(Of String)
|
||||
Dim oItems As New List(Of String)
|
||||
Dim oChoicelist As WMObject
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
Try
|
||||
oChoicelist = Session.GetWMObjectByName(WMEntityChoiceList, ChoiceListName)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, "Could not get choice list")
|
||||
Return oItems
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oChoiceListItems As Object = oChoicelist.GetVariableValue("vItems")
|
||||
|
||||
If oChoiceListItems Is Nothing Then
|
||||
Return oItems
|
||||
End If
|
||||
|
||||
For Each oChoiceListItem In oChoiceListItems
|
||||
oItems.Add(oChoiceListItem)
|
||||
Next
|
||||
|
||||
Return oItems
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex, "Could not get choice list items")
|
||||
Return oItems
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndiciesByObjecttype(ObjectTypeName As String) As List(Of String)
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim oObjectType As WMObject
|
||||
Dim oIndexAttributes As WMObjectRelation
|
||||
Dim oIndexAttribute As WMObject
|
||||
Dim oIndex As WMObject
|
||||
Dim oRelProperties As WMObjectRelation
|
||||
Dim oTempSession As IWMSession2
|
||||
Dim oIndicies As New List(Of String)
|
||||
|
||||
Try
|
||||
' den Objekttyp laden
|
||||
oTempSession = DirectCast(Session, IWMSession2)
|
||||
oObjectType = Session.GetWMObjectByName(WMEntityObjectType, ObjectTypeName)
|
||||
|
||||
' Beziehung zu Indizes des Objekttyp auslesen
|
||||
oIndexAttributes = oObjectType.GetWMObjectRelationByName("TypeAttributes")
|
||||
|
||||
' alle Indizes durchlaufen
|
||||
For j As Integer = 0 To oIndexAttributes.Count - 1
|
||||
|
||||
' aktuellen Index auslesen
|
||||
oIndexAttribute = oIndexAttributes.Item(j)
|
||||
|
||||
' Eigenschaften des Index auslesen
|
||||
oRelProperties = oIndexAttribute.GetWMObjectRelationByName("Attribute")
|
||||
|
||||
' Index aus den Eigenschaften auslesen
|
||||
oIndex = oRelProperties.Item(0)
|
||||
|
||||
' Indexname speichern
|
||||
'aIndexNames(j) = oIndex.aName
|
||||
oIndicies.Add(oIndex.aName)
|
||||
Next
|
||||
|
||||
' Indexarray zurückgeben
|
||||
'Return aIndexNames
|
||||
Return oIndicies
|
||||
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oIndicies
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndexType(IndexName As String) As Integer
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oAttribute = Session.GetWMObjectByName(WMEntityAttribute, IndexName)
|
||||
Dim oType = oAttribute.GetVariableValue("dwAttrType")
|
||||
Return oType
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetIndexValue(Path As String, IndexName As String) As List(Of String)
|
||||
Dim oResult As New List(Of String)
|
||||
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
Try
|
||||
Path = GetNormalizedPath(Path)
|
||||
Dim oWMObject As WMObject = Session.GetWMObjectByPath(WMEntityDocument, Path)
|
||||
|
||||
If oWMObject Is Nothing Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
Dim oValues = oWMObject.GetVariableValue(IndexName)
|
||||
|
||||
If oValues Is Nothing Then
|
||||
Return oResult
|
||||
End If
|
||||
|
||||
If TypeOf oValues Is IEnumerable Then
|
||||
For Each oValue In oValues
|
||||
oResult.Add(oValue)
|
||||
Next
|
||||
Else
|
||||
oResult.Add(oValues)
|
||||
End If
|
||||
|
||||
Return oResult
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return oResult
|
||||
End Try
|
||||
End Function
|
||||
''' <summary>
|
||||
''' Gets an array of the actual vektorvalues of index, collated with the passed values
|
||||
''' </summary>
|
||||
@ -890,7 +913,7 @@ Public Class Windream2
|
||||
Dim oNewValues As New List(Of Object)
|
||||
oNewValues = oVectorValues.Except(New List(Of Object) From {ValueToDelete}).ToList()
|
||||
|
||||
''' BEGIN WRITE INDEX
|
||||
' BEGIN WRITE INDEX
|
||||
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
|
||||
_logger.Warn("File {0} could not be locked")
|
||||
Return False
|
||||
@ -902,7 +925,36 @@ Public Class Windream2
|
||||
UnlockObject(oWMObject)
|
||||
|
||||
Return True
|
||||
''' END WRITE INDEX
|
||||
' END WRITE INDEX
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function SetFileIndex(Path As String, IndexName As String, Value As String) As Boolean
|
||||
If TestSessionLoggedIn() = False Then
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim oWMObject As WMObject = GetFileByPath(Path)
|
||||
|
||||
If LockObject(oWMObject, WMObjectEditModeIndexEdit) = False Then
|
||||
_logger.Warn("File {0} could not be locked")
|
||||
Return False
|
||||
End If
|
||||
|
||||
Try
|
||||
Dim oType As Integer = GetIndexType(IndexName)
|
||||
Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, Value)
|
||||
oWMObject.SetVariableValue(IndexName, oConvertedValue)
|
||||
oWMObject.Save()
|
||||
|
||||
If UnlockObject(oWMObject) = False Then
|
||||
_logger.Warn("File {0} could not be unlocked", Path)
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return False
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NLog" version="4.5.8" targetFramework="net461" />
|
||||
<package id="NLog" version="4.5.10" targetFramework="net461" />
|
||||
</packages>
|
||||
Loading…
x
Reference in New Issue
Block a user