2024-05-09 10:23:01 +00:00
|
|
|
|
using InSituLaboratory.Entities.Sensor;
|
2024-05-11 09:48:17 +00:00
|
|
|
|
using InSituLaboratory.Models.Sendsor;
|
2024-05-09 10:23:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Data.OracleClient;
|
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace InSituLaboratory.Base
|
|
|
|
|
|
{
|
|
|
|
|
|
public class CSVDownload
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create target file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="folder">folder</param>
|
|
|
|
|
|
/// <param name="fileName">folder name</param>
|
|
|
|
|
|
/// <param name="fileExtension">file extension</param>
|
|
|
|
|
|
/// <returns>file path</returns>
|
|
|
|
|
|
public static string CreateFile(string folder, string fileName, string fileExtension)
|
|
|
|
|
|
{
|
|
|
|
|
|
FileStream fs = null;
|
|
|
|
|
|
string filePath = folder + fileName + "." + fileExtension;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Directory.Exists(folder))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(folder);
|
|
|
|
|
|
}
|
|
|
|
|
|
fs = File.Create(filePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (fs != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
fs.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return filePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-14 09:30:27 +00:00
|
|
|
|
#region MEMS色谱仪
|
2024-05-09 10:23:01 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static PropertyInfo[] GetMEMSSPInfoArray()
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] props = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = typeof(MEMSSpModels);
|
|
|
|
|
|
object obj = Activator.CreateInstance(type);
|
|
|
|
|
|
props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
return props;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the List data to CSV file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BaseStationList">data source</param>
|
|
|
|
|
|
/// <param name="filePath">file path</param>
|
|
|
|
|
|
/// <returns>success flag</returns>
|
|
|
|
|
|
public static bool SaveMEMSSPDataToCSVFile(ObservableCollection<MEMSSpModels> BaseStationList, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool successFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strColumn = new StringBuilder();
|
|
|
|
|
|
StringBuilder strValue = new StringBuilder();
|
|
|
|
|
|
StreamWriter sw = null;
|
|
|
|
|
|
PropertyInfo[] props = GetMEMSSPInfoArray();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
sw = new StreamWriter(filePath);
|
|
|
|
|
|
for (int i = 0; i < props.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strColumn.Append(props[i].Name);
|
|
|
|
|
|
strColumn.Append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
strColumn.Remove(strColumn.Length - 1, 1);
|
|
|
|
|
|
sw.WriteLine(strColumn); //write the column name
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < BaseStationList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strValue.Remove(0, strValue.Length); //clear the temp row value
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Id);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CreateTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].SamplingTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Tem);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Hum);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Pressure);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Insulation);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C2);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C3);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C4);
|
|
|
|
|
|
|
|
|
|
|
|
sw.WriteLine(strValue); //write the row value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
successFlag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sw != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return successFlag;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-05-10 10:13:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
2024-05-14 09:30:27 +00:00
|
|
|
|
#region MEMS质谱仪
|
2024-05-10 10:13:30 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static PropertyInfo[] GetMEMSZPInfoArray()
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] props = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = typeof(MEMSZpModels);
|
|
|
|
|
|
object obj = Activator.CreateInstance(type);
|
|
|
|
|
|
props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
return props;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the List data to CSV file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BaseStationList">data source</param>
|
|
|
|
|
|
/// <param name="filePath">file path</param>
|
|
|
|
|
|
/// <returns>success flag</returns>
|
|
|
|
|
|
public static bool SaveMEMSZPDataToCSVFile(ObservableCollection<MEMSZpModels> BaseStationList, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool successFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strColumn = new StringBuilder();
|
|
|
|
|
|
StringBuilder strValue = new StringBuilder();
|
|
|
|
|
|
StreamWriter sw = null;
|
|
|
|
|
|
PropertyInfo[] props = GetMEMSZPInfoArray();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
sw = new StreamWriter(filePath);
|
|
|
|
|
|
for (int i = 0; i < props.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strColumn.Append(props[i].Name);
|
|
|
|
|
|
strColumn.Append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
strColumn.Remove(strColumn.Length - 1, 1);
|
|
|
|
|
|
sw.WriteLine(strColumn); //write the column name
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < BaseStationList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strValue.Remove(0, strValue.Length); //clear the temp row value
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Id);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CreateTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].SamplingTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Tem);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Hum);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Pressure);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Insulation);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CH4);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].H2O);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].N2);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].O2);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Ar);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CO2);
|
|
|
|
|
|
|
|
|
|
|
|
sw.WriteLine(strValue); //write the row value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
successFlag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sw != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return successFlag;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-05-11 09:48:17 +00:00
|
|
|
|
|
2024-05-13 10:53:45 +00:00
|
|
|
|
|
2024-05-14 09:30:27 +00:00
|
|
|
|
#region 色质联用仪
|
2024-05-11 09:48:17 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static PropertyInfo[] GetColorMSInfoArray()
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] props = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = typeof(ColorMSModels);
|
|
|
|
|
|
object obj = Activator.CreateInstance(type);
|
|
|
|
|
|
props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
return props;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the List data to CSV file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BaseStationList">data source</param>
|
|
|
|
|
|
/// <param name="filePath">file path</param>
|
|
|
|
|
|
/// <returns>success flag</returns>
|
|
|
|
|
|
public static bool SaveColorMSDataToCSVFile(ObservableCollection<ColorMSModels> BaseStationList, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool successFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strColumn = new StringBuilder();
|
|
|
|
|
|
StringBuilder strValue = new StringBuilder();
|
|
|
|
|
|
StreamWriter sw = null;
|
|
|
|
|
|
PropertyInfo[] props = GetColorMSInfoArray();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
sw = new StreamWriter(filePath);
|
|
|
|
|
|
for (int i = 0; i < props.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strColumn.Append(props[i].Name);
|
|
|
|
|
|
strColumn.Append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
strColumn.Remove(strColumn.Length - 1, 1);
|
|
|
|
|
|
sw.WriteLine(strColumn); //write the column name
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < BaseStationList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strValue.Remove(0, strValue.Length); //clear the temp row value
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Id);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CreateTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].SamplingTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Tem);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Hum);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Pressure);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Insulation);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C2);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C3);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C4);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C5);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C6);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C7);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C8);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C9);
|
|
|
|
|
|
|
|
|
|
|
|
sw.WriteLine(strValue); //write the row value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
successFlag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sw != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return successFlag;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-05-13 10:53:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
2024-05-14 09:30:27 +00:00
|
|
|
|
#region 甲烷同位素分析仪
|
2024-05-13 10:53:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static PropertyInfo[] GetCH4IsotopeInfoArray()
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] props = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = typeof(CH4IsotopeModels);
|
|
|
|
|
|
object obj = Activator.CreateInstance(type);
|
|
|
|
|
|
props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
return props;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the List data to CSV file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BaseStationList">data source</param>
|
|
|
|
|
|
/// <param name="filePath">file path</param>
|
|
|
|
|
|
/// <returns>success flag</returns>
|
|
|
|
|
|
public static bool SaveCh4IsotopeDataToCSVFile(ObservableCollection<CH4IsotopeModels> BaseStationList, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool successFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strColumn = new StringBuilder();
|
|
|
|
|
|
StringBuilder strValue = new StringBuilder();
|
|
|
|
|
|
StreamWriter sw = null;
|
|
|
|
|
|
PropertyInfo[] props = GetCH4IsotopeInfoArray();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
sw = new StreamWriter(filePath);
|
|
|
|
|
|
for (int i = 0; i < props.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strColumn.Append(props[i].Name);
|
|
|
|
|
|
strColumn.Append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
strColumn.Remove(strColumn.Length - 1, 1);
|
|
|
|
|
|
sw.WriteLine(strColumn); //write the column name
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < BaseStationList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strValue.Remove(0, strValue.Length); //clear the temp row value
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Id);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CreateTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].SamplingTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Tem);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Hum);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Pressure);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Insulation);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C1);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].C2);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Abundance);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sw.WriteLine(strValue); //write the row value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
successFlag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sw != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return successFlag;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-05-14 09:30:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 二氧化碳同位素分析仪
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取类的属性集合(以便生成CSV文件的所有Column标题)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static PropertyInfo[] GetCO2IsotopeInfoArray()
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] props = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = typeof(CO2IsotopsModels);
|
|
|
|
|
|
object obj = Activator.CreateInstance(type);
|
|
|
|
|
|
props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
return props;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Save the List data to CSV file
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="BaseStationList">data source</param>
|
|
|
|
|
|
/// <param name="filePath">file path</param>
|
|
|
|
|
|
/// <returns>success flag</returns>
|
|
|
|
|
|
public static bool SaveCO2IsotopeDataToCSVFile(ObservableCollection<CO2IsotopsModels> BaseStationList, string filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool successFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder strColumn = new StringBuilder();
|
|
|
|
|
|
StringBuilder strValue = new StringBuilder();
|
|
|
|
|
|
StreamWriter sw = null;
|
|
|
|
|
|
PropertyInfo[] props = GetCO2IsotopeInfoArray();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
sw = new StreamWriter(filePath);
|
|
|
|
|
|
for (int i = 0; i < props.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strColumn.Append(props[i].Name);
|
|
|
|
|
|
strColumn.Append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
strColumn.Remove(strColumn.Length - 1, 1);
|
|
|
|
|
|
sw.WriteLine(strColumn); //write the column name
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < BaseStationList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
strValue.Remove(0, strValue.Length); //clear the temp row value
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Id);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CreateTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].SamplingTime);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Tem);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Hum);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Pressure);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].Insulation);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].LightIntensity);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].LaserTemperature);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].CO2Concentration);
|
|
|
|
|
|
strValue.Append(",");
|
|
|
|
|
|
strValue.Append(BaseStationList[i].IsotopicAbundance);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sw.WriteLine(strValue); //write the row value
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
successFlag = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sw != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sw.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return successFlag;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-05-09 10:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|