本文整理汇总了C#中DataSet.AttachMeta方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.AttachMeta方法的具体用法?C# DataSet.AttachMeta怎么用?C# DataSet.AttachMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSet
的用法示例。
在下文中一共展示了DataSet.AttachMeta方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: port_DataReceived
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
System.Threading.Thread.Sleep(100);
int toRead = ((SerialPort)sender).BytesToRead;
byte[] byte_buffer = new byte[toRead];
port.Read(byte_buffer, 0, toRead);
var data = System.Text.Encoding.Default.GetString(byte_buffer);
//LogText(data.ToString());
//LogText(data);
Console.WriteLine(data.ToString());
XmlNode node;
int dayNow = DateTime.Now.Day;
if (ds == null)
{
ds = new DataSet();
ds.SetFolderPath(@"c:\datalog");
ds.AttachMeta("Start Time", DateTime.Now);
dayOld = dayNow;
}
else if (dayNow != dayOld)
{
ds.EndWrite();
ds = new DataSet();
ds.SetFolderPath(@"c:\datalog");
ds.AttachMeta("Start Time", DateTime.Now);
dayOld = dayNow;
}
bool any = false;
//parse the data.
try
{
using (XmlReader reader = XmlReader.Create(new StringReader(data.ToString())))
{
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
//Console.WriteLine(reader.LocalName);
if (reader.LocalName == "Data")
{
if (!any)
{
ds.AddParameterDate("Timestamp", DateTime.Now);
any = true;
}
var val = reader.GetAttribute("Value");
//Console.WriteLine(reader.LocalName + ": " + val);
ds.AddParameterDouble(reader.LocalName, Convert.ToDouble(val));
LogText(val.ToString());
}
}
}
}
}
catch (Exception ex) { }
if (any = true && ds != null)
{
ds.EndItem();
}
}