本文整理汇总了C#中TimeSeries.Index方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.Index方法的具体用法?C# TimeSeries.Index怎么用?C# TimeSeries.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.Index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public void GetData(string parameterId, DateTime start, int slots, TimeSeries ts, int col_index, string dateFormat)
{
try
{
string address = string.Format(Server + "addUPI?function=getdata&session-id={0}&id={1}&df={2}&date={3}&slots={4}&cache={5}&mode={6}",
Uri.EscapeDataString(sessionId),
Uri.EscapeDataString(parameterId),
Uri.EscapeDataString(DateFormat),
Uri.EscapeDataString(start.ToString("yyyyMMddTHH:mm:ss")),
Uri.EscapeDataString(slots.ToString()),
Uri.EscapeDataString(Cache),
Uri.EscapeDataString(Mode));
string result = wc.DownloadString(address);
XPathDocument doc = new XPathDocument(new StringReader(result));
XPathNavigator error, nav = doc.CreateNavigator();
nav.MoveToRoot();
nav.MoveToFirstChild();
if (nav.LocalName != "response") throw new Exception("Expecting 'response' but found '" + nav.LocalName);
XPathNodeIterator nodeRows, ni = nav.SelectChildren("node", "");
if (ni.Count < 1)
{
string addUPIError = "";
ni = nav.SelectChildren("error", "");
if (ni.Count > 0)
{
ni.MoveNext();
error = ni.Current;
if (error.HasAttributes)
{
if (error.MoveToAttribute("msg", ""))
addUPIError = error.Value;
}
}
throw new Exception(addUPIError);
}
//List<MeteoAgriNode> nodesList = new List<MeteoAgriNode>();
MeteoAgriData newData = new MeteoAgriData();
DateTime instant = DateTime.Now;
string instant_str;
bool start_defined = false;
XPathNavigator row, node;
while (ni.MoveNext())
{
node = ni.Current;
nodeRows = node.SelectChildren("v", "");
string nodeId = "";
if (node.HasAttributes)
{
nodeId = node.GetAttribute("id", "");
}
if (nodeRows.Count < 1)
{
throw new Exception("No values were found for 'parameter id' = " + parameterId + " [nodeId='" + nodeId + "']");
}
//MeteoAgriNode newNode = new MeteoAgriNode(nodeId);
//nodesList.Add(newNode);
while (nodeRows.MoveNext())
{
//MeteoAgriData newData = new MeteoAgriData();
row = nodeRows.Current;
newData.Value = row.Value;
if (row.HasAttributes)
{
newData.Type = row.GetAttribute("type", "");
newData.D = row.GetAttribute("d", "");
newData.S = row.GetAttribute("s", "");
newData.T = row.GetAttribute("t", "");
}
int instant_index = -1;
if (!start_defined)
{
instant = DateTime.ParseExact(newData.T, "yyyyMMddTHH:mm:ss", null);
instant_str = start.ToString(dateFormat);
start_defined = true;
if (ts.StartInstant > instant)
{
ts.StartInstant = instant;
instant_index = ts.AddInstant(instant);
}
else if (ts.StartInstant != instant)
{
instant_index = ts.Index(instant, Mohid.Core.SearchType.FIND_EXACTLY);
if (instant_index == -1)
instant_index = ts.AddInstant(instant);
}
//.........这里部分代码省略.........