Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / November 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pawel - 18 Nov 2007 22:12 GMT
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 !!!!!!!!!!!!!!!
SSA - 20 Nov 2007 18:53 GMT
Make sure you are not running into an infinite loop. Test this code with
fewer records. It should work without any problem. If it doesnt then there is
a problem with your code. Performance issues occur only if your form is very
large and has lots of datasources and especially the datasources are not
defined properly in a hierarchical way. That is, if there is a text box
inside a section then the datasource of the text box should come inside the
datasource of the section. If not then it will affect the performance if you
have hundred datasources in your form not defined properly.

> Hi to all!!!!
>
[quoted text clipped - 83 lines]
>
> Thanks for ANY reply !!!!!!!!!!!!!!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.