Programatically Adding Repeating Section Row - Works In Client But Times Out In Browser - InfoPath Dev
in

InfoPath Dev

Programatically Adding Repeating Section Row - Works In Client But Times Out In Browser

Last post 02-24-2012 08:40 AM by Beircheart. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-24-2012 01:44 AM

    Programatically Adding Repeating Section Row - Works In Client But Times Out In Browser

    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 String

    For Each Node As XPathNavigator In NodeIterator

    Dim MyNamespace As String = NamespaceManager.LookupNamespace("my")

    If Node Is Nothing Then

    'Do Nothing

    Else

    Using 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|") Then

    Dim SplitSourceField() As String = SourceFields(i).ToString.Split("|")

    Writer.WriteElementString(DestFields(i), MyNamespace, SplitSourceField(1))

    ElseIf Node.SelectSingleNode(SourceFields(i)) Is Nothing Then

    Writer.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

  • 02-24-2012 08:40 AM In reply to

    Re: Programatically Adding Repeating Section Row - Works In Client But Times Out In Browser

    Hi,

    I've been doing some more debugging and, I may be wrong, but it's starting to feel like this problem is being caused by memory not being released.

    Is there anywhere in the above function that I can release the server resources being used?

    Or do you know of a general way to release resources that might be applicable to me?

    Thanks a million,

    Ben

    *****EDIT*****

    I just added a button to call a function which adds more rows to the problematic repeating section. As I mentioned before, on the initial load the first 10-20 rows are added almost immediately as i step through the code and it then starts getting noticeably slower. So I figured that if it is a memory issue, when i click this new button to add 83 more rows to the repeating section that already contains 83 rows, then the first 10-20 should be entered immediately again. This was not the case. This would suggest to me that the repeating section does not like appending a new row when the repeating section already contains 20+ rows and it's not a memory issue afterall

    Obviously, I think that the repeating section should be able to handle waaaaaaaaaaay more than that so there must be something else wrong..... what tangled webs we weave....

    *****UPDATE*****

    Hi...... I have "fixed" it now..... I ended up recreating the necessary repeating elements and remapped the data to it..... It's working now but I hate that type of workaround because I don't now what the problem really was! I copied everything exactly as it was before except for one thing which sounds like a major change but I'm not convinced that this was the problem

    The thing I changed was the structure of the schema. In the original form, the schema did not match the layout in infopath. For example, I could have a field inside a section in the form but it would be outside of the relevant group in the schema. Maybe this was causing the problem... ya.... lets say that was the problem and at least my mind will be at ease :)

    In all honesty though, if anyone has any experience of this, I'd appreciate your thoughts on this.

    All the best,

    Ben

     *****SOLUTION*****

    So I kept looking and finally found the true cause of the problem. There was a very complex calculation that was refreshing on each insert of the repeating section. I know this sounds obvious but trust me, this is the type of thing that I was looking for from the beginning but given the size and complexity of the form, I had missed it because it was not in a place I expected it would be

    Anyway, just said I'd let you know

    All the best,

    Ben

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.