public SignalCode.eventSet getFaultCurveDataByID(string EventInstanceID)
    {
        SignalCode sc = new SignalCode();
        return sc.getFaultCurveDataByID(EventInstanceID);

        //return (FetchMeterEventFaultCurveByID(EventInstanceID));
    }
    public SignalCode.eventSet getSignalDataByIDAndType(string EventInstanceID, String DataType)
    {
        //eventSet theset = new eventSet();
        //theset.data = new List<signalDetail>();
        //MeterData.EventDataTable events;
        //DataGroup eventDataGroup = new DataGroup();
        //using (MeterInfoDataContext meterInfo = new MeterInfoDataContext(ConnectionString))
        //using (EventTableAdapter eventAdapter = new EventTableAdapter())
        //using (EventDataTableAdapter eventDataAdapter = new EventDataTableAdapter())

        //{
        //    eventAdapter.Connection.ConnectionString = ConnectionString;
        //    eventDataAdapter.Connection.ConnectionString = ConnectionString;

        //    events = eventAdapter.GetDataByID(Convert.ToInt32(EventInstanceID));

        //    foreach (MeterData.EventRow evt in events)
        //    {
        //        Meter meter = meterInfo.Meters.Single(m => m.ID == evt.MeterID);

        //        FaultData.Database.Line line = meterInfo.Lines.Single(l => l.ID == evt.LineID);

        //        eventDataGroup.FromData(meter, eventDataAdapter.GetTimeDomainData(evt.EventDataID));

        //        //eventDataGroup.FromData(meter, evt.Data);

        //        int i = -1;

        //        int datacount = eventDataGroup.DataSeries[0].DataPoints.Count();
        //        theset.xAxis = new string[datacount];

        //        foreach (DataSeries theseries in eventDataGroup.DataSeries)
        //        {
        //            i++;

        //            signalDetail theitem = new signalDetail();

        //            string measurementType = "I"; // Assume Current, sorry this is ugly
        //            string phasename = theseries.SeriesInfo.Channel.Phase.Name;

        //            if (theseries.SeriesInfo.Channel.MeasurementType.Name.Equals("Voltage"))
        //            {
        //                measurementType = "V";
        //            }

        //            if (theseries.SeriesInfo.Channel.MeasurementType.Name.Equals("Power"))
        //            {
        //                measurementType = "P";
        //            }

        //            if (theseries.SeriesInfo.Channel.MeasurementType.Name.Equals("Energy"))
        //            {
        //                measurementType = "E";
        //            }

        //            if (theseries.SeriesInfo.Channel.MeasurementType.Name.Equals("Digital"))
        //            {
        //                if (theseries.SeriesInfo.Channel.MeasurementCharacteristic.Name == "None")
        //                    continue;

        //                measurementType = "D";
        //                phasename = theseries.SeriesInfo.Channel.Description;
        //            }

        //            if (DataType != null)
        //            {
        //                if (measurementType != DataType)
        //                {
        //                    continue;
        //                }
        //            }

        //            if (theseries.SeriesInfo.SeriesType.Name.Substring(0, 3) == "Min") continue;
        //            if (theseries.SeriesInfo.SeriesType.Name.Substring(0, 3) == "Max") continue;

        //            theset.Yaxis0name = "Current";

        //            if (measurementType == "V")
        //            {
        //                theset.Yaxis0name = "Voltage";
        //            }

        //            if (measurementType == "D")
        //            {
        //                theset.Yaxis0name = "Breakers";
        //            }

        //            //theitem.name = theseries.SeriesInfo.SeriesType.Name.Substring(0, 3) + " " + measurementType + theseries.SeriesInfo.Channel.Phase.Name;
        //            theitem.name = measurementType + phasename;
        //            theitem.data = new double[datacount];
        //            theitem.type = "line";
        //            theitem.yAxis = 0;

        //            if (theitem.name.Contains("IRES"))
        //            {
        //            theitem.showInTooltip = false;
        //            theitem.visible = false;
        //            }

        //            int j = 0;
        //            DateTime beginticks = eventDataGroup.DataSeries[i].DataPoints[0].Time;
        //            foreach (FaultData.DataAnalysis.DataPoint thepoint in eventDataGroup.DataSeries[i].DataPoints)
        //            {
        //                double elapsed = thepoint.Time.Subtract(beginticks).TotalSeconds;
        //                theset.xAxis[j] = elapsed.ToString();
        //                theitem.data[j] = thepoint.Value;
        //                j++;
        //            }
        //            theset.data.Add(theitem);
        //        }
        //        break;
        //    }
        //}

        ////theset = FetchFaultSegmentDetails(EventInstanceID, theset);

        //eventSet thereturnset = FetchMeterEventCycleData(EventInstanceID, theset.Yaxis0name, theset);

        //return (thereturnset);
        SignalCode sc = new SignalCode();
        return sc.getSignalDataByIDAndType(EventInstanceID, DataType);
    }
    public List<SignalCode.FlotSeries> GetFlotData(int eventID, List<int> seriesIndexes)
    {
        //List<FlotSeries> flotSeriesList = new List<FlotSeries>();

        //using (DbAdapterContainer dbAdapterContainer = new DbAdapterContainer(ConnectionString))
        //using (AdoDataConnection connection = new AdoDataConnection(dbAdapterContainer.Connection, typeof(SqlDataAdapter), false))
        //{
        //    EventTableAdapter eventAdapter = dbAdapterContainer.GetAdapter<EventTableAdapter>();
        //    EventDataTableAdapter eventDataAdapter = dbAdapterContainer.GetAdapter<EventDataTableAdapter>();
        //    FaultCurveTableAdapter faultCurveAdapter = dbAdapterContainer.GetAdapter<FaultCurveTableAdapter>();
        //    MeterInfoDataContext meterInfo = dbAdapterContainer.GetAdapter<MeterInfoDataContext>();
        //    FaultLocationInfoDataContext faultLocationInfo = dbAdapterContainer.GetAdapter<FaultLocationInfoDataContext>();

        //    MeterData.EventRow eventRow = eventAdapter.GetDataByID(eventID).FirstOrDefault();
        //    Meter meter = meterInfo.Meters.First(m => m.ID == eventRow.MeterID);

        //    List<FlotSeries> flotInfo = GetFlotInfo(eventID);
        //    DateTime epoch = new DateTime(1970, 1, 1);

        //    Lazy<Dictionary<int, DataSeries>> waveformData = new Lazy<Dictionary<int, DataSeries>>(() =>
        //    {
        //        return ToDataGroup(meter, eventDataAdapter.GetTimeDomainData(eventRow.EventDataID)).DataSeries
        //            .ToDictionary(dataSeries => dataSeries.SeriesInfo.ID);
        //    });

        //    Lazy<DataGroup> cycleData = new Lazy<DataGroup>(() => ToDataGroup(meter, eventDataAdapter.GetFrequencyDomainData(eventRow.EventDataID)));

        //    Lazy<Dictionary<string, DataSeries>> faultCurveData = new Lazy<Dictionary<string, DataSeries>>(() =>
        //    {
        //        return faultCurveAdapter
        //            .GetDataBy(eventRow.ID)
        //            .Select(faultCurve => new
        //            {
        //                Algorithm = faultCurve.Algorithm,
        //                DataGroup = ToDataGroup(meter, faultCurve.Data)
        //            })
        //            .Where(obj => obj.DataGroup.DataSeries.Count > 0)
        //            .ToDictionary(obj => obj.Algorithm, obj => obj.DataGroup[0]);
        //    });

        //    foreach (int index in seriesIndexes)
        //    {
        //        DataSeries dataSeries = null;
        //        FlotSeries flotSeries;

        //        if (index >= flotInfo.Count)
        //            continue;

        //        flotSeries = flotInfo[index];

        //        if (flotSeries.FlotType == FlotSeriesType.Waveform)
        //        {
        //            if (!waveformData.Value.TryGetValue(flotSeries.SeriesID, out dataSeries))
        //                continue;
        //        }
        //        else if (flotSeries.FlotType == FlotSeriesType.Cycle)
        //        {
        //            dataSeries = cycleData.Value.DataSeries
        //                .Where(series => series.SeriesInfo.Channel.MeasurementType.Name == flotSeries.MeasurementType)
        //                .Where(series => series.SeriesInfo.Channel.Phase.Name == flotSeries.Phase)
        //                .Skip(flotSeries.SeriesID)
        //                .FirstOrDefault();

        //            if ((object)dataSeries == null)
        //                continue;
        //        }
        //        else if (flotSeries.FlotType == FlotSeriesType.Fault)
        //        {
        //            string algorithm = flotSeries.ChannelName;

        //            if (!faultCurveData.Value.TryGetValue(algorithm, out dataSeries))
        //                continue;
        //        }
        //        else
        //        {
        //            continue;
        //        }

        //        foreach (DataPoint dataPoint in dataSeries.DataPoints)
        //        {
        //            if (!double.IsNaN(dataPoint.Value))
        //                flotSeries.DataPoints.Add(new double[] { dataPoint.Time.Subtract(epoch).TotalMilliseconds, dataPoint.Value });
        //        }

        //        flotSeriesList.Add(flotSeries);
        //    }
        //}
        SignalCode sc = new SignalCode();
        return sc.GetFlotData(eventID, seriesIndexes);
    }