Hi all,
I've been hammering away at this issue for the last few days and I'm starting to run out of ideas. I'll explain:
My environment:
Using Infopath 2010 with VB code behind
Deploying on a Sharepoint 2010 server
Performance Problem:
I am programmatically adding rows to a repeating section in my form. The data is being gathered from a web service and loaded in to the form on a 'Start' button click event. Performance in the client is acceptable i.e. In the worst case, it takes 169 rows from the web service and adds them to the form in ~30 seconds. However, when I deploy it to the server and trigger the same event in the browser based version, it 'Sends data to the server' for ~ 7 minutes and then times out.
I've debugged it in the browser and it looks like it works fine for the first 17 rows but then starts getting noticeably slower for each row added. This looks like it's effecting all existing rows in the repeating table whenever a new row is added. However, this does not act the same when I debug in the client. In the client, each row is added at (what looks like) the same speed irrelevant of how many rows have already been added.
Can anyone tell me why this would be a problem in the browser but not in the client?
Also, here are the rules (Pseudo Code) attached to the repeating section using the Infopath interface:
Rule 1:
None - Rule runs when field changes
RouteCounter = RouteCounter+1
Rule 2:
If RouteCode Is Blank Then
RouteCode = concat("ROUTECODE", RouteCounter)
Rule 3:
If RouteDesc Is Blank Then
RouteDesc = concat("ROUTEDESC", RouteCounter)
I can also provide the XML if necessary, I just don't want to be smothering anyone with code!
I would really appreciate any advice on this
All the best,
Ben
See below the function call and the function itself that I'm using to populate the repeating section:
Function Call Including Parameters:
SourceFieldArray = New String() {"Nothing", "Nothing", "VALUE|Show", "ROUTE_CODE", "ROUTE_NAME", "ROUTE_DESC", "ROUTE_STREAM_CODE1", "ROUTE_STREAM_CODE2", "ROUTE_STREAM_CODE3", "ROUTE_STREAM_CODE4"}
DestFieldArray =
New String() {"RoutesAdminSection", "RouteShowHideSection", "RouteShowHide", "RouteCode", "RouteName", "RouteDesc", "CoreRouteCoreStream", "RoutesStreamII", "RoutesStreamIII", "RoutesStreamIV"}ClearRepeatingTable("/my:ProgrammeForm/my:Structure/my:RoutesGroup/my:Routes")
PopulateRepeatingTable(DataSourceName, SecondaryPath +
"RouteElem", SourceFieldArray, _"/my:ProgrammeForm/my:Structure/my:RoutesGroup", "Routes", DestFieldArray)
Function:
Sub PopulateRepeatingTable(ByVal DataSource As String, ByVal SourceXPath As String, ByVal SourceFields() As String, _
ByVal DestXPath As String, ByVal DestTable As String, ByVal DestFields() As String, Optional ByVal Nested As String = "")Dim NodeIterator As XPathNodeIterator = DataSources(DataSource).CreateNavigator().Select(SourceXPath, NamespaceManager)
Dim Field As StringFor Each Node As XPathNavigator In NodeIterator
Dim MyNamespace As String = NamespaceManager.LookupNamespace("my")
If Node Is Nothing Then
'Do Nothing
ElseUsing Writer As XmlWriter = MainDataSource.CreateNavigator().SelectSingleNode(DestXPath, NamespaceManager).AppendChild()
Writer.WriteStartElement(DestTable, MyNamespace)
Dim i As Integer = 0
For Each Field In SourceFields
If SourceFields(i).ToString.StartsWith("VALUE|") ThenDim SplitSourceField() As String = SourceFields(i).ToString.Split("|")
Writer.WriteElementString(DestFields(i), MyNamespace, SplitSourceField(1))
ElseIf Node.SelectSingleNode(SourceFields(i)) Is Nothing ThenWriter.WriteElementString(DestFields(i), MyNamespace, "")
Else
Writer.WriteElementString(DestFields(i), MyNamespace, Node.SelectSingleNode(SourceFields(i)).ToString)
End If
i = i + 1
Next
Writer.WriteEndElement()
Writer.Close()
End Using
End If
Next
End Sub