Nextis.SmartSearch.Client: Porovnání verzí
Z Podpora.nextis.cz
Řádka 7: | Řádka 7: | ||
* Nextis.SmartSearch.Client.dll (provided by Nextis) | * Nextis.SmartSearch.Client.dll (provided by Nextis) | ||
* Nextis.SmartSearch.Proxy.dll (provided by Nextis) | * Nextis.SmartSearch.Proxy.dll (provided by Nextis) | ||
+ | |||
+ | ==== Supporting libraries (not referenced) ==== | ||
+ | * Nextis.SmartSearch.Engine.dll (provided by Nextis) | ||
==== Framework ==== | ==== Framework ==== | ||
Řádka 34: | Řádka 37: | ||
</syntaxhighlight>Put your authorization token and address instead of the address in the example. | </syntaxhighlight>Put your authorization token and address instead of the address in the example. | ||
− | INFO: After the initialization of client object, should be the status connected <code>Client.Status =SmartSearchClient.ClientStatuses._initialized</code> | + | INFO: After the initialization of client object, should be the status connected <code>Client.Status = SmartSearchClient.ClientStatuses._initialized</code> |
==== Searching through the client ==== | ==== Searching through the client ==== |
Verze z 5. 7. 2019, 10:33
This article describes, how to implement and use Nextis.SmartSearch technology within the third party products.
Prerequisites
Referenced libraries
- Core.UI.Culture.dll (provided by Nextis)
- Nextis.SmartSearch.Client.dll (provided by Nextis)
- Nextis.SmartSearch.Proxy.dll (provided by Nextis)
Supporting libraries (not referenced)
- Nextis.SmartSearch.Engine.dll (provided by Nextis)
Framework
- .NET Framework ver.: 4.6.1 and higher
Connection information
- Authorization token (provided by Nextis)
- Service location/address (provided by Nextis)
Implementation
Declaration of the client object
Private WithEvents Client As Nextis.SmartSearch.Client.SmartSearchClient
Initialization of the client object
Sub Initialize()
Dim Config As New Nextis.SmartSearch.Client.SmartSearchClientConfiguration()
With Config
.Mode = Nextis.SmartSearch.Client.SmartSearchClient.ClientMode.RemoteWS
.WSAddress = "smartsearch.nextis.cz:port"
.AuthorizationToken = "token"
End With
Me.Client = New Nextis.SmartSearch.Client.SmartSearchClient(Config)
End Sub
INFO: After the initialization of client object, should be the status connected Client.Status = SmartSearchClient.ClientStatuses._initialized
Searching through the client
1.Creating the request
'Create request
Dim rq As New Nextis.SmartSearch.Proxy.SmartSearchRequest('Text to recognize', Core.UI.Culture.Languages.de)
'Enable/disable recognition options
With rq
.AllowCar = True
.AllowCode = True
.AllowKBA = False 'Not implemented yet
.AllowText = True
.AllowVIN = True
'.CarSpecificModelYearFrom = 1990 'Allows you to limit the vehicle specific result to vehicles, manufactured since the specified construction year
End With
3.Sending the request
Asynchronous
Me.Client.SmartSearchAsync(rq)
- The result is available only within the event SearchFinished
- This version is most useful in a winforms application
- In case of more threads (search requests) at the same time is always returned the last one and all previous are cancelled
Synchronous
Dim rp As Nextis.SmartSearch.Proxy.SmartSearchResult = Me.Client.SmartSearch(rq)
- The result is available within the event SearchFinished and also as a return value of the method
- Most useful in a web application to manage multi-threading on your own
4.Getting the response
For both synchronous and asynchronous calling, you can get the result within the eventClient.SearchFinished
that is also the preferred option.Private Sub Client_SearchFinished(Data As SmartSearchResult) Handles Client.SearchFinished
Dim Info As String = ""
If Data.ResultState = Nextis.SmartSearch.Proxy.Definitions.ResponseStatus.Ok Then
For Each SearchType As Nextis.SmartSearch.Proxy.Definitions.SearchTargetTypes In Data.ResultPercentage.Keys
Info &= SearchType.ToString & ": " & Data.ResultPercentage(SearchType) & "%" & vbCrLf
Next
'Vehicle specific data (filled whend enginde decides that user is lookinf for specific vehicle)
If Data.ResultPercentage(Definitions.SearchTargetTypes.Car) > 50.0 Then
If Not Data.VehicleSpecificData Is Nothing Then
For Each cr As SmartSearch.Proxy.VehicleSpecific.VehicleSearchResult In Data.VehicleSpecificData.Models
'Case when result contain only vehicle specific data (does not contain any generic articles)
If Data.VehicleSpecificData.Articles.Count = 0 Then
Dim vInfo As String = cr.ManuID & "_" & cr.ModelID & "_" & cr.EngineID & "_" & -1 & ", "
vInfo &= cr.ManuName + " " + cr.ModelName & ", "
If cr.EngineID > 0 Then
vInfo &= cr.EngineName & ", "
vInfo &= cr.EnginePowerHP & ", "
vInfo &= cr.EnginePowerKW & ", "
vInfo &= cr.EngineConstFrom & " - " & IIf(Val(cr.EngineConstTo) > 2500, " > ", cr.EngineConstTo) & ", "
Else
vInfo &= "-" & ", "
vInfo &= "-" & ", "
End If
vInfo &= "-"
vInfo &= "Ranking:" & Format(cr.RankCar * 1000, "#00000") & "_" & cr.ModelName & "_" & cr.EngineName & ", "
Info &= Chr(10) & vInfo
Else
'Case when result contains vehicle specific data and also generic articles
For Each Article As SmartSearch.Proxy.VehicleSpecific.VehicleConstructionGroup In Data.VehicleSpecificData.Articles
If cr.SupportedArticlesIDs.Contains(Article.ID) = True Then
Dim vInfo As String = cr.ManuID & "_" & cr.ModelID & "_" & cr.EngineID & "_" & Article.ID & ", "
vInfo &= cr.ManuName + " " + cr.ModelName & ", "
If cr.EngineID > 0 Then
vInfo &= cr.EngineName & ", "
vInfo &= cr.EnginePowerHP & ", "
vInfo &= cr.EnginePowerKW & ", "
vInfo &= cr.EngineConstFrom & " - " & IIf(Val(cr.EngineConstTo) > 2500, " > ", cr.EngineConstTo) & ", "
Else
vInfo &= "-" & ", "
vInfo &= "-" & ", "
End If
vInfo &= Article.Phrase & " " & " (ID " & Article.ID & ")" & ","
vInfo &= "Ranking:" & Format(cr.RankCar * 1000, "#00000") & "_" & cr.ModelName & "_" & cr.EngineName & "_" & Format(Article.Match, "#00000.0000")
Info &= Chr(10) & vInfo
End If
Next
End If
Next
End If
End If
Else
Info = Data.ResultState.ToString
End If
Me.TextBox2.Text = Info
End Sub
Data as SmartSearchResult
contains all possible information about the pattern recognition, vehicle specific data including EngineID's, GenericArticleID's if applicable and so on.
Obtaining the service state
Functionality, that provides general information about the Nextis.SmartSearch service, you are connected to.Dim ServiceInfoResponse = Me.Client.ServiceInfo
With ServiceInfoResponse
'.ActiveLanguages (list of currently supported languages)
'.ArticleCount (count of all available generic articles)
'.CarModelCount (count of all available vehicle models)
'.RelationCount (count of relations between vehicles and generic articles)
'.ResultState (general information that request has been processed properly)
'.Loaded (true if service is properly loaded into the memory)
End With