78 lines
1.6 KiB
C#
78 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
|
|
namespace LeafWeb.Web.Charter
|
|
{
|
|
[Serializable]
|
|
public class PiscalOutput
|
|
{
|
|
private int nbrCurves; // This is the number of input files that were processed.
|
|
private readonly ArrayList curveData; // Each element will be a PiscalCurve element that contains
|
|
// all of the output data for one curve.
|
|
|
|
public PiscalOutput()
|
|
{
|
|
nbrCurves = 0;
|
|
curveData = new ArrayList();
|
|
}
|
|
|
|
public bool readFromStream(StreamReader sr, ref String errorMsg)
|
|
{
|
|
CurveData curve;
|
|
|
|
// Skip the first two lines.
|
|
|
|
sr.ReadLine();
|
|
sr.ReadLine();
|
|
var lineNbr = 2;
|
|
|
|
// Now, there should be one or more rows, delimited by a row that has
|
|
// CO2i in the first field. Read in all of these rows. The first field
|
|
// in each row is the curve ID (input filename).
|
|
|
|
var more = true;
|
|
while (more)
|
|
{
|
|
curve = new CurveData(sr, ref errorMsg, ref lineNbr);
|
|
if (errorMsg.Length > 0)
|
|
return false;
|
|
|
|
curveData.Add(curve);
|
|
if (sr.EndOfStream)
|
|
more = false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public bool readFromDataFile(Stream fileStream, ref String errorMsg)
|
|
{
|
|
StreamReader sr;
|
|
|
|
if (fileStream == null)
|
|
{
|
|
errorMsg = "Please choose a data file first";
|
|
return false;
|
|
}
|
|
|
|
try
|
|
{
|
|
sr = new StreamReader(fileStream);
|
|
}
|
|
catch (Exception openExc)
|
|
{
|
|
errorMsg = "Error opening file: " + openExc.Message;
|
|
return false;
|
|
}
|
|
|
|
readFromStream(sr, ref errorMsg);
|
|
sr.Close();
|
|
return true;
|
|
}
|
|
|
|
public ArrayList getCurveData()
|
|
{
|
|
return curveData;
|
|
}
|
|
}
|
|
} |