Extreme performance problems with a repeating table -> C# / web - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Extreme performance problems with a repeating table -> C# / web

Last post 11-19-2007 01:33 AM by davidair. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 11-18-2007 02:23 PM

    • gicio
    • Not Ranked
    • Joined on 11-18-2007
    • Posts 5

    Extreme performance problems with a repeating table -> C# / web

    Hi to all!!!!

    I have a problem with performance of a template working in browser mode.  It seems that filling a repeating table using a XmlWriter is the case.

    First I tried to fill like this:

    foreach (DataRow row in dataTable.Rows)
    {
                    string myNamespace = NamespaceManager.LookupNamespace("my");
                    using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).AppendChild())
                    {
                                   writer.WriteStartElement("Values", myNamespace);

                                   writer.WriteElementString("Value1", myNamespace, row["Value1"].ToString());
                                   writer.WriteElementString("Value2", myNamespace, row["Value2"].ToString());
                                    writer.WriteElementString("Value3", myNamespace, row["Value3"].ToString());
                                   writer.WriteElementString("Value4", myNamespace, row["Value4"].ToString());
                                   writer.WriteElementString("Value5", myNamespace, row["Value5"].ToString());

                                   writer.WriteEndElement();        
                                   writer.Close();
                    }
    }

    While opening in browser after about half a minute a dialog box apper saying that "A Scripts on this page is causing Internet Explorer to run slowly. If it

    continues to run, your computer may become unresponsive".

    The InternetExplorer 7 has at this time OVER 0,5 gigs in the task manager!!!!!!!! (The server an the client is up-to-date with all services packs)


    It seemed to me that AppendChild() method is the problem so I tried first to generate the xml with the data to MemoryStream:

    MemoryStream memoryStream = new MemoryStream();
    XmlWriter memoryXmlWriter = XmlWriter.Create(memoryStream);

    string myNamespace = NamespaceManager.LookupNamespace("my");

    foreach (DataRow row in dtTasks.Rows)
    {
                    memoryXmlWriter.WriteStartElement("Values", myNamespace);

                     memoryXmlWriter.WriteElementString("Value1", myNamespace, row["Value1"].ToString());
                    memoryXmlWriter.WriteElementString("Value2", myNamespace, row["Value2"].ToString());
                    memoryXmlWriter.WriteElementString("Value3", myNamespace, row["Value3"].ToString());
                    memoryXmlWriter.WriteElementString("Value4", myNamespace, row["Value4"].ToString());
                    memoryXmlWriter.WriteElementString("Value5", myNamespace, row["Value5"].ToString());
                 
                    memoryXmlWriter.WriteEndElement();
    }

    memoryXmlWriter.Flush();
    memoryXmlWriter.Close();

    string outStr = Encoding.UTF8.GetString(memoryStream.ToArray());

    //Add "my:" and "/my:" prefix
    string rtXml = AddPrefixMy(outStr);

    And then replace directly repeating table InnerXml:

    MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1", NamespaceManager).InnerXml = rtXml;

    While opening in browser nothing changes and the same dialog box appers.

    Do you have any ideas how to optimize this code.

    Thanks for ANY reply !!!!!!!!!!!!!!!
     

  • 11-19-2007 01:33 AM In reply to

    Re: Extreme performance problems with a repeating table -> C# / web

    How many rows do you have in dataTable.Rows?

    Does the table have a lot of conditional formatting / default values / rules?

    All of the code runs on the server-side before the results gets downloaded into the browser so the very fact that IE gets to 500MB is telling me that the problem is not with the actual performance of your code but with its end result so changing how you generate the rows is probably not going to help - you'll have to look at what you're generating.

     

    David Airapetyan / Software Services Architect
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.