OWC11 Charts - Not saving to disk?

B

Ben

I have an aspx page that creates several charts for the page. Most of the
time all charts are created no problem, but sometimes, I see x's where a
chart should be. I check the should be file name vs files in the directory,
and its' not there. What could cause something like this? I mean, it works
most of the time...


Thanks,
Ben
 
W

Wei-Dong XU [MSFT]

Hi Ben,

I have heard this before. I'd suggest you can give me one detailed repro
steps and environment information. I will perform one test to reproduce
this issue, thn I can try to find there the culprit for your issue locates.
Greatly appreciate in advance!

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Ben

I create the chart with the code below. The environment is Windows 2003
server with the .Net framework 1.1 version. Coded in c# in Visual Studio
..Net 2003.

string[][] SCIData = new string[4][];

// preload arrays

for (int SCILoop = 0; SCILoop < SCIData.Length; SCILoop++)

{

SCIData[SCILoop] = new string[5];

for (int QtrLoop = 0; QtrLoop < SCIData[SCILoop].Length; QtrLoop++)

{

SCIData[SCILoop][QtrLoop] = "0";

}

}

SqlDataReader dr =
Globals.SqlHelper.ExecuteReader(Globals.AppSettings.ConnectionString,
"spSplash_SCI", oSecurity.ReportFiscalYear, oSecurity.SecurityInfo.UserID);

while (dr.Read())

{

SCIData[dr.GetInt32(1) - 1][dr.GetInt32(0) - 1] = dr.GetValue(2).ToString();

}

dr.Close();

string QuarterNames = "Q1\tQ2\tQ3\tQ4\tYTD";

string SecureSeries = string.Join("\t", SCIData[0]);

string FavorableSeries = string.Join("\t", SCIData[1]);

string IndifferentSeries = string.Join("\t", SCIData[2]);

string AtRiskSeries = string.Join("\t", SCIData[3]);

OWC11.ChartSpace oChartSpace = new OWC11.ChartSpaceClass();

OWC11.ChChart oChart = oChartSpace.Charts.Add(0);

oChart.Type = OWC11.ChartChartTypeEnum.chChartTypeColumnClustered;

oChart.HasTitle = true;

oChart.Title.Caption = "Loyalty Hierarchy";

oChart.HasLegend = true;

oChart.Axes[1].Scaling.Minimum = 0;

oChart.Axes[1].HasTitle = true;

oChart.Axes[1].Title.Caption = "Percent";

oChart.SeriesCollection.Add(0);

oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimCategories
, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, QuarterNames);

oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Secure");

oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, SecureSeries);

oChart.SeriesCollection[0].DataLabelsCollection.Add();

oChart.SeriesCollection.Add(1);

oChart.SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Favorable");

oChart.SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, FavorableSeries);

oChart.SeriesCollection[1].DataLabelsCollection.Add();

oChart.SeriesCollection.Add(2);

oChart.SeriesCollection[2].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Indifferent");

oChart.SeriesCollection[2].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, IndifferentSeries);

oChart.SeriesCollection[2].DataLabelsCollection.Add();

oChart.SeriesCollection.Add(3);

oChart.SeriesCollection[3].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "At Risk");

oChart.SeriesCollection[3].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, AtRiskSeries);

oChart.SeriesCollection[3].DataLabelsCollection.Add();

string VirtualFileName = "/srrs/charts/" +
System.DateTime.Now.Ticks.ToString() + ".gif";

string FullFileName = Server.MapPath(VirtualFileName);

oChartSpace.ExportPicture(FullFileName, "GIF", 400, 350);



Again, most of the time the chart works, but randomly I get a broken image
in I.E. because the chart object appearently wasn't written to disk. I do
know that the method is running because there is additional code in the
method that reports the chart data inside a table showing the values.

Ben
 
W

Wei-Dong XU [MSFT]

Hi Ben,

Thank you for the source code!

From my experience, since ASP.net page runs under MTA (multiple thread
apartment) mode, the ExportPicture may need more time to finish the IO
operation. So I'd suggset you can set the aspx page mode to STA; the same
to asp; by setting the ASPcompat to true in the @page directive. Then you
can test to see whether this issue remains.

If so, after the code of ExportPicture method, you can make the thread
sleep for a little time and then continue the execution with the code below:
Thread.Sleep( 1000 );
or
while( !File.Exits( FullFileName ) )
Thread.Sleep( 1000 );

Please feel free to let me know if you have any question.

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Ben

Thanks a ton for you assistance. While it didn't fix the problem (it
couldn't have), it did point out the problem. My file maintainance routine
was deleting files after two seconds instead of minutes! So after applying
the wait for exists and it still not showing up it was obvious where the
problem was.

Thanks a lot!!!!
Ben
 
A

Alvin Bruney [MVP]

Your cleanup code still poses a problem. If a user looks at a chart for more
than 2 minutes and then refreshes, your clean up code would have cleaned up
the file and the chart would not show.

one other approach you may want to consider is having .net auto clean the
files for you.
you'd have to use tempfilename from the io class which automatically
generates a temp file for you that you can write your charts to. the auto
files get purged on reboot or you can schedule the disk clean utility to run
at an appointed time. it's effect is to cleanup the temp file directory.
 
W

Wei-Dong XU [MSFT]

You are welcome! Have a nice weekend!

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top