diff --git a/Windream/Constants.vb b/Windream/Constants.vb index 228533c9..10e61c4c 100644 --- a/Windream/Constants.vb +++ b/Windream/Constants.vb @@ -40,6 +40,7 @@ Public Const HISTORY_NEW_FROM_VERSION = "HISTORY_New_From_Version" Public Const HISTORY_USER_DEFINED = "HISTORY_User_Defined" + ' Entity Types Public Const ENTITY_TYPE_OBJECTTYPE = 10 @@ -54,6 +55,7 @@ ' Misc Public Const OBJECT_TYPE_DEFAULT = "Standard" + Public Const DELETE_ATTRIBUTE_VALUE = "DeleteWMAttributeValue" ' File Stream Public Const STREAM_BINARY_OBJECT = "BinaryObject" diff --git a/Windream/Helpers.vb b/Windream/Helpers.vb index acc79e13..0ddaea76 100644 --- a/Windream/Helpers.vb +++ b/Windream/Helpers.vb @@ -20,51 +20,84 @@ Public Class Helpers ReDim myArray(0) Select Case pIndexType Case INDEX_TYPE_HASH ' 36865 - 'Umwandeln in String - myArray(0) = CStr(pValue) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return String.Empty + Else + 'Umwandeln in String + myArray(0) = CStr(pValue) + End If Case INDEX_TYPE_VECTOR_STRING '4097 - 'Umwandeln in String - myArray(0) = CStr(pValue) - Return myArray(0) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return String.Empty + Else + 'Umwandeln in String + myArray(0) = CStr(pValue) + End If Case INDEX_TYPE_VECTOR_INTEGER '4098 - 'Umwandeln in Integer - myArray(0) = CInt(pValue.Replace(" ", "")) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Integer + myArray(0) = CInt(pValue.Replace(" ", "")) + End If Case INDEX_TYPE_VECTOR_FLOAT '4099 pValue = pValue. Replace(" ", ""). Replace(".", ",") - 'Umwandeln in Double - myArray(0) = CDbl(pValue) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Double + myArray(0) = CDbl(pValue) + End If Case INDEX_TYPE_VECTOR_BOOLEAN '4100 - 'Umwandeln in Boolean - myArray(0) = CBool(pValue) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Boolean + myArray(0) = CBool(pValue) + End If + Case INDEX_TYPE_VECTOR_DATE '4101 - 'Umwandeln in Date - myArray(0) = CDate(pValue) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Date + myArray(0) = CDate(pValue) + End If Case INDEX_TYPE_VECTOR_INTEGER_64BIT '4107 - myArray(0) = Convert.ToInt64(pValue) - Return myArray + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Date + myArray(0) = Convert.ToInt64(pValue) + End If Case INDEX_TYPE_VECTOR_DATE_TIME '4103 - 'Umwandeln in Datum Uhrzeit - Return pValue + Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Date + myArray(0) = Convert.ToDateTime(pValue) + End If + Case 8204 - 'Umwandeln in Integer - myArray(0) = CInt(pValue.Replace(" ", "")) - Return myArray + pValue = pValue.Replace(" ", "") + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Umwandeln in Integer + myArray(0) = CInt(pValue.Replace(" ", "")) + End If Case Else 'Umwandeln in String myArray(0) = CStr(pValue) - Return myArray End Select + Return myArray End Function Friend Shared Function ConvertIndexValue(Type As Integer, pValue As String) As Object - ' Leerzeichen an Anfang und Ende entfernen + pValue = pValue.Trim() If Type > 4095 Then Return ConvertVectorType(Type, pValue) @@ -75,40 +108,102 @@ Public Class Helpers Case INDEX_TYPE_HASH Return pValue Case INDEX_TYPE_STRING - Return pValue + ' Leerzeichen an Anfang und Ende entfernen + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return String.Empty + Else + Return pValue + End If + Case INDEX_TYPE_VECTOR_STRING - Return pValue + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return String.Empty + Else + Return pValue + End If Case INDEX_TYPE_INTEGER pValue = pValue.Replace(" ", String.Empty) - Return Convert.ToInt32(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToInt32(pValue) + End If Case INDEX_TYPE_VECTOR_INTEGER pValue = pValue.Replace(" ", String.Empty) - Return Convert.ToInt32(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToInt32(pValue) + End If Case INDEX_TYPE_VECTOR_INTEGER_64BIT pValue = pValue.Replace(" ", String.Empty) - Return Convert.ToInt64(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToInt64(pValue) + End If Case INDEX_TYPE_VECTOR_BOOLEAN Return Convert.ToBoolean(pValue) Case INDEX_TYPE_BOOLEAN - Return Convert.ToBoolean(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToBoolean(pValue) + End If + Case INDEX_TYPE_DATE - Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDateTime(pValue) + End If + Case INDEX_TYPE_DATE_TIME - Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDateTime(pValue) + End If Case INDEX_TYPE_TIME - Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDateTime(pValue) + End If Case INDEX_TYPE_VECTOR_DATE_TIME - Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDateTime(pValue) + End If Case INDEX_TYPE_VECTOR_DATE - Return Convert.ToDateTime(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDateTime(pValue) + End If Case INDEX_TYPE_FLOAT - Return Convert.ToDouble(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDouble(pValue) + End If + Case INDEX_TYPE_VECTOR_FLOAT - Return Convert.ToDouble(pValue) + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + Return Convert.ToDouble(pValue) + End If Case INDEX_TYPE_CURRENCY - 'Wegen currency muß ein eigenes Objekt vom typ Variant erzeugt werden - Dim aValueWrapper As System.Runtime.InteropServices.CurrencyWrapper = New System.Runtime.InteropServices.CurrencyWrapper(CDec(pValue)) - Return aValueWrapper + If pValue = DELETE_ATTRIBUTE_VALUE Then + Return Nothing + Else + 'Wegen currency muß ein eigenes Objekt vom typ Variant erzeugt werden + Dim aValueWrapper As System.Runtime.InteropServices.CurrencyWrapper = New System.Runtime.InteropServices.CurrencyWrapper(CDec(pValue)) + Return aValueWrapper + End If + Case Else Return pValue End Select diff --git a/Windream/My Project/AssemblyInfo.vb b/Windream/My Project/AssemblyInfo.vb index 15623946..f633756e 100644 --- a/Windream/My Project/AssemblyInfo.vb +++ b/Windream/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Windream/Windream.vb b/Windream/Windream.vb index e667d3ec..340faac6 100644 --- a/Windream/Windream.vb +++ b/Windream/Windream.vb @@ -1220,7 +1220,7 @@ Public Class Windream End Try End Function - Public Function SetFileIndex(Path As String, IndexName As String, Value As String, ObjectType As String) As Boolean + Public Function SetFileIndex(Path As String, pIndexName As String, pStringValue As String, pObjectType As String) As Boolean If TestSessionLoggedIn() = False Then Return False End If @@ -1238,15 +1238,15 @@ Public Class Windream End If If oWMObject.aObjectType.aName = Constants.OBJECT_TYPE_DEFAULT Then - oWMObject.aObjectType = GetObjectByName(ObjectType, WMEntityObjectType) + oWMObject.aObjectType = GetObjectByName(pObjectType, WMEntityObjectType) End If Try - Dim oType As Integer = GetIndexType(IndexName) + Dim oType As Integer = GetIndexType(pIndexName) If Not IsNothing(oType) Then - Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, Value) + Dim oConvertedValue As Object = Helpers.ConvertIndexValue(oType, pStringValue) - oWMObject.SetVariableValue(IndexName, oConvertedValue) + oWMObject.SetVariableValue(pIndexName, oConvertedValue) oWMObject.Save() If UnlockObject(oWMObject) = False Then