Click here to Skip to main content
15,899,314 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to print a web page in c# without using Javascript Pin
dan!sh 2-Aug-09 23:12
professional dan!sh 2-Aug-09 23:12 
GeneralRe: how to print a web page in c# without using Javascript Pin
marcoreg4-Aug-09 4:54
marcoreg4-Aug-09 4:54 
Question64bit and OutOfMemory Pin
Super Lloyd2-Aug-09 20:32
Super Lloyd2-Aug-09 20:32 
AnswerRe: 64bit and OutOfMemory Pin
Christian Graus2-Aug-09 20:40
protectorChristian Graus2-Aug-09 20:40 
GeneralRe: 64bit and OutOfMemory Pin
Super Lloyd2-Aug-09 23:38
Super Lloyd2-Aug-09 23:38 
AnswerRe: 64bit and OutOfMemory Pin
Vimalsoft(Pty) Ltd2-Aug-09 21:39
professionalVimalsoft(Pty) Ltd2-Aug-09 21:39 
AnswerRe: 64bit and OutOfMemory Pin
Luc Pattyn3-Aug-09 0:10
sitebuilderLuc Pattyn3-Aug-09 0:10 
GeneralRe: 64bit and OutOfMemory Pin
Super Lloyd3-Aug-09 0:28
Super Lloyd3-Aug-09 0:28 
I guess I'm hitting problem number 3.

The code is hard to share if only because I extensively using a 3rd party GIS library called MapXtreme, which is damn slow to write its data files.
Sometimes I can get tens of thousands row in a select, and then I write a feature table with same size. In fact I'm generating (spatial) report in the background and I will get many such case.

Here is relevant method.
Which is invoked continuously in a never ending process until all trucks travel for the period (usually day) have been accounted for.

static void AddFeatures(ReportTask report, Guid taskId, out int nRow, out Table table)
{
	table = null;
	nRow = 0;
	var miStyle = TabUtility.MakeMapInfoStyle(report.Style);
	var dbtable = new DataTable();
    try
    {
        using (var cmd = new SqlCommand())
        using (var conn = Config.GetOpenedConnection())
        {
            cmd.Connection = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandTimeout = Config.SqlTimeout;
            cmd.CommandText = report.StoredProc;
            cmd.AddParameter("uidTaskID", SqlDbType.UniqueIdentifier, taskId);

			// 1st quick read of all data: no SqlTimeout
			// there might be tens of thousand of row in this data
			using (var reader = cmd.ExecuteReader())
			{
				// 1st OutOfMemory sometimes here
				if (reader.HasRows)
					dbtable.Load(reader);
			}
        }
    }
    catch (Exception ex)
    {
        ex.Data["ReportName"] = report.Name;
        ex.Data["ReportSP"] = report.StoredProc;
        throw;
    }

	// then slow creation of MapXtreme table
	try
	{
        long TotalWKBRead = 0;
		foreach (DataRow row in dbtable.Rows)
		{
            try
            {
                var wkb = row[GeomColumnName] as byte[];
                if (wkb == null || wkb.Length == 0)
                    continue;
                var geom = WKB.ToFeatureGeometry(wkb);
                if (geom == null)
                    continue;

                TotalWKBRead = wkb.Length;

                if (table == null)
                {
                    table = CreateTable(report.BasePath, report.Name, miStyle, dbtable);
                    table.BeginAccess(TableAccessMode.Write);
                }

                var feature = new Feature(table.TableInfo.Columns);
                feature.Geometry = geom;
                feature.Style = miStyle;
                TabUtility.SetFeatureValues(feature, row);

		// 2. OutOfMemory exception, in 3rd party code, damn it!
                table.InsertFeature(feature);
                nRow++;
            }
            catch (Exception ex)
            {
                var wkb = row[GeomColumnName] as byte[];

                ex.Data["TaskID"] = taskId;
                ex.Data["ReportName"] = report.Name;
                ex.Data["table.Row.Count"] = nRow;
                ex.Data["WKB.Length"] = wkb != null ? wkb.Length : 0;
                ex.Data["TotalWKB.Length"] = TotalWKBRead;
                throw;
            }
		}
	}
	finally
	{
		if (table != null)
			table.EndAccess();
	}
}


A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

GeneralRe: 64bit and OutOfMemory Pin
Luc Pattyn3-Aug-09 0:55
sitebuilderLuc Pattyn3-Aug-09 0:55 
GeneralRe: 64bit and OutOfMemory Pin
Super Lloyd3-Aug-09 1:09
Super Lloyd3-Aug-09 1:09 
AnswerRe: 64bit and OutOfMemory Pin
Alan Balkany3-Aug-09 4:47
Alan Balkany3-Aug-09 4:47 
QuestionHow to detect if a folder is open Pin
rick05562-Aug-09 20:25
rick05562-Aug-09 20:25 
AnswerRe: How to detect if a folder is open Pin
Christian Graus2-Aug-09 20:37
protectorChristian Graus2-Aug-09 20:37 
Answer[Message Deleted] Pin
Hristo-Bojilov2-Aug-09 21:31
Hristo-Bojilov2-Aug-09 21:31 
GeneralRe: How to detect if a folder is open Pin
rick05562-Aug-09 21:45
rick05562-Aug-09 21:45 
GeneralRe: How to detect if a folder is open Pin
Christian Graus2-Aug-09 21:58
protectorChristian Graus2-Aug-09 21:58 
GeneralRe: How to detect if a folder is open Pin
Dave Kreskowiak3-Aug-09 3:49
mveDave Kreskowiak3-Aug-09 3:49 
GeneralRe: How to detect if a folder is open Pin
Hristo-Bojilov3-Aug-09 7:37
Hristo-Bojilov3-Aug-09 7:37 
QuestionLinq Pin
Sayed Sajid2-Aug-09 20:21
Sayed Sajid2-Aug-09 20:21 
AnswerRe: Linq Pin
Christian Graus2-Aug-09 20:35
protectorChristian Graus2-Aug-09 20:35 
GeneralRe: Linq Pin
Sayed Sajid2-Aug-09 20:42
Sayed Sajid2-Aug-09 20:42 
GeneralRe: Linq Pin
riced2-Aug-09 23:18
riced2-Aug-09 23:18 
AnswerRe: Linq Pin
N a v a n e e t h2-Aug-09 20:42
N a v a n e e t h2-Aug-09 20:42 
QuestionFinding Nested ( ) pairs Pin
Adam R Harris2-Aug-09 20:07
Adam R Harris2-Aug-09 20:07 
AnswerRe: Finding Nested ( ) pairs Pin
OriginalGriff2-Aug-09 21:24
mveOriginalGriff2-Aug-09 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.