Documente Academic
Documente Profesional
Documente Cultură
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;
namespace Test2
{
String filePath="";
fullTable.Clear();
//startDate=startDate.AddDays(1);
while (diff<=0)
{
filePath = fullpath;
if (File.Exists(@filePath))
{
fullTable.Merge(createTable(turbine, startDate));
startDate = startDate.AddDays(1);
diff = DateTime.Compare(startDate, endDate);
}
else
{
MyGlobals.ErrorLog = String.Concat(MyGlobals.ErrorLog,
startDate.ToString("yyyy-MM-dd")," ,");
startDate = startDate.AddDays(1);
diff = DateTime.Compare(startDate, endDate);
continue;
}
}
return fullTable;
}
/// <summary>
/// Converts a given delimited file into a dataset.
/// Assumes that the first line
/// of the text file contains the column names.
/// </summary>
/// <param name="File">The name of the file to open</param>
/// <param name="TableName">The name of the
/// Table to be made within the DataSet returned</param>
/// <param name="delimiter">The string to delimit by</param>
/// <returns></returns>
records = rows.Length;
short j = 0;
//Now add each row to the DataSet
foreach (string r in rows)
{
if (r != "")
{
//Split the row at the delimiter.
string[] items = r.Split(delimiter.ToCharArray());
System.Data.DataTable dt = (System.Data.DataTable)result.Tables[0];
DataTable filteredTable = dt.DefaultView.ToTable(false,
"power_limit_min", "active_power_avg", "wind_speed_avg");
//DataView dv = filteredTable.DefaultView;
//dv.RowFilter = "wind_speed_avg > 3";
//filteredTable=dv.ToTable();
dv.RowFilter = query;
// AND power_limit_min>1000
filteredTable = dv.ToTable();
public Form1()
{
InitializeComponent();
MyGlobals.StandardTable.Clear();
MyGlobals.StandardTable.Columns.Add("WindSpeed", typeof(float));
chart1.Series.Clear();
DataView dv = dt.DefaultView;
dv.Sort = "Average Wind Speed /ms-1";
//test
resultTable.DataSource = dt;
chart1.Series.Clear();
var enumerableTable = (dt as
System.ComponentModel.IListSource).GetList();
chart1.DataBindTable(enumerableTable, "Average Wind Speed /ms-1");
chart1.Series[0].ChartType =
System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
}
catch (IndexOutOfRangeException)
{
// Write error.
MessageBox.Show(String.Concat("No Mean files found for the selected
date range"),
"File Missing",
MessageBoxButtons.OK,
MessageBoxIcon.Error
//MessageBoxIcon.Warning // for Warning
//MessageBoxIcon.Error // for Error
//MessageBoxIcon.Information // for Information
//MessageBoxIcon.Question // for Question
);
}
}