Posted on 22/06/2016 16:44:17
Hi Peter
I will see if retry makes sense and have it implemented as a core fetaure.
You can find information on the builds and instances from the Tracker that is used by the TaskManager when Dynamicweb builds the indexes.
This is the code we use to get the status of instances - it relies on information you can find in \Files\System\Diagnostics\* folders where all activity regarding the indexing process is stored. The code below will use our API to locate the status and return status and timestamps related to the build.
Dim indexingService As IIndexService = ServiceLocator.Current.GetInstance(Of IIndexService)()
Dim repositoryName As String = repository
Dim index As IIndex = indexingService.LoadIndex(repositoryName, item + ".index")
Dim supportsResume As Boolean = index.Builds.Count > 0 AndAlso (TypeOf index.Builds.ElementAt(0).Value Is IResumable)
Dim statuslist As New Dictionary(Of String, Object)
For Each instance As IIndexProvider In index.Instances.Values
Dim taskname As String = String.Format("{0}#{1}#{2}", repositoryName, index.Name, instance.Name)
Dim trackerPath As String = Path.Combine(repositoryName, item + ".index", instance.Name)
Dim history As IEnumerable(Of Status) = Tracker.GetStatusHistory(trackerPath, 2)
Dim currentStatus As Status
Dim lastStatus As Status = Nothing
Dim taskIsActive As Boolean = TaskManager.IsTaskActive(taskname)
If taskIsActive Then
currentStatus = TaskManager.GetTaskInfo(taskname).Value.Tracker.Status
Else
currentStatus = history.FirstOrDefault
End If
If history.Count() = 2 Then
lastStatus = history(1)
End If
Dim res As Object = New With {
.IsActive = taskIsActive,
.Status = currentStatus,
.LastStatus = lastStatus,
.Resumable = supportsResume
}
statuslist.Add(instance.Name, res)
Next
Return statuslist