public void SetBinSizeList() { List <BinFactoryOptions.BinSize> binSizes = Enum.GetValues(typeof(BinFactoryOptions.BinSize)).Cast <BinFactoryOptions.BinSize>().ToList(); foreach (var binSize in binSizes) { switch (binSize) { case BinFactoryOptions.BinSize.FifteenMinute: BinSizes.Add(new Tuple <int, string>((int)binSize, "Fifteen Minutes")); break; case BinFactoryOptions.BinSize.ThirtyMinute: BinSizes.Add(new Tuple <int, string>((int)binSize, "Thirty Minutes")); break; case BinFactoryOptions.BinSize.Hour: BinSizes.Add(new Tuple <int, string>((int)binSize, "Hour")); break; case BinFactoryOptions.BinSize.Day: BinSizes.Add(new Tuple <int, string>((int)binSize, "Day")); break; case BinFactoryOptions.BinSize.Month: BinSizes.Add(new Tuple <int, string>((int)binSize, "Month")); break; case BinFactoryOptions.BinSize.Year: BinSizes.Add(new Tuple <int, string>((int)binSize, "Year")); break; } } }
private void TestQuery(object sender, RoutedEventArgs e) { if (login == null || String.IsNullOrEmpty(login.SessionID)) { AddMessage("Not logged in."); return; } try { BinSizes binSize = (BinSizes)(Convert.ToInt32((binSel.SelectedItem as ComboBoxItem).Tag.ToString())); Functions function = (Functions)(Convert.ToInt32((funcSel.SelectedItem as ComboBoxItem).Tag.ToString())); List <DataField> queryFields = new List <DataField>(); foreach (CheckBox cb in fields.Items) { if (cb.IsChecked == true) { string[] chops = cb.Content.ToString().Split('.'); DataField f = new DataField() { HID = Convert.ToInt32(chops[0]), FieldName = chops[1], Function = function }; queryFields.Add(f); } } // Add one more field that doesn't exist //DataField fTest = new DataField() { HID = queryFields[0].HID, FieldName = "Vdc12", Function = queryFields[0].Function }; //queryFields.Add(fTest); DataResult result = api.GetBinData(login.SessionID, startDate.Text, endDate.Text, binSize, queryFields); if ((AEResultCodes)result.Code == AEResultCodes.OK) { AddMessage(string.Format("*** GetBinData returned {0} rows", result.DataSet.Count())); for (int i = 0; i < result.DataSet.Count(); i++) { DataBin db = result.DataSet[i]; AddMessage(string.Format("{0}: {1} {2}", i, db.Timestamp, string.Join(", ", (from z in db.Data select string.Format("{0:0.000}", z))))); } } else { AddMessage(string.Format("*** GetBinData returned {0}", result.ResultCodeString())); } } catch (CommunicationException) { AddMessage("GetBinData failed. Returned data may exceed allowable size. Try reducing the timespan on the query."); } catch { AddMessage("GetBinData failed. Please check your connection."); } }