Get format data

Build 1501 on 14/Nov/2017  This topic last edited on: 2/Sep/2016, at 09:27

To convert format id to format name

  public overridable function GetFormatNameFromId(ByVal id As Object) As String

    If Not id Is Nothing Then

      Dim oFormat = Fred.GetFormat

      oFormat.Id = CInt(id)

      Return oFormat.Name

    Else

      Return ""

    End If

  End Function

To convert format name to format id

public overridable function GetFormatId(ByVal name As String) As Integer

    Dim formatId As Integer

    name = name.ToLower()

 

    If Not s_FormatIds.TryGetValue(name, formatId) Then

      Dim s As New SearchConditions("justContext")

      s.SearchNode = Search.Node.Condition.CreateMatchValue("justContext.name", name)

 

      Dim results As SearchResultList = DataConnection.Instance.Search(s, Nothing, False)

 

      If results IsNot Nothing AndAlso results.Count > 0 Then

        formatId = results(0).Id

      End If

 

      s_FormatIds(name) = formatId

    End If