public DataGroup QueryDataGroup(int eventID, Meter meter)
        {
            string target = $"DataGroup-{eventID}";

            try
            {
                bool isSafe = s_mutex.WaitOne();
                if (isSafe)
                {
                    DataGroup dataGroup = m_memoryCache.GetOrCreate(target, task =>
                    {
                        task.SlidingExpiration = TimeSpan.FromMinutes(10.0D);
                        using (AdoDataConnection connection = new AdoDataConnection(m_configuration["OpenXDA:ConnectionString"], m_configuration["OpenXDA:DataProviderString"]))
                        {
                            List <byte[]> data = ChannelData.DataFromEvent(eventID, connection);
                            return(ToDataGroup(meter, data));
                        }
                    });
                    return(dataGroup);
                }
                else
                {
                    return(null);
                }
            }
            finally {
                s_mutex.ReleaseMutex();
            }
        }
 public AircraftVersionSelectionGroup(DataGroup @aircraftGroup, List<IAircraft> aircrafts)
     : base("","","",@aircraftGroup,55,0)
 {
     SetProperties(aircrafts[0]);
     SetAircraftList(aircrafts, @aircraftGroup);
     SetRightColumnSpan(aircrafts.Count);
 }
Beispiel #3
0
        private List <MeterDataSet> LoadMeterDataSets(DbAdapterContainer dbAdapterContainer, FileGroup fileGroup)
        {
            List <MeterDataSet> meterDataSets = new List <MeterDataSet>();

            MeterInfoDataContext  meterInfo        = dbAdapterContainer.GetAdapter <MeterInfoDataContext>();
            EventTableAdapter     eventAdapter     = dbAdapterContainer.GetAdapter <EventTableAdapter>();
            EventDataTableAdapter eventDataAdapter = dbAdapterContainer.GetAdapter <EventDataTableAdapter>();

            MeterData.EventDataTable eventTable = eventAdapter.GetDataByFileGroup(fileGroup.ID);

            MeterDataSet meterDataSet;
            DataGroup    dataGroup;

            foreach (IGrouping <int, MeterData.EventRow> eventGroup in eventTable.GroupBy(evt => evt.MeterID))
            {
                meterDataSet       = new MeterDataSet();
                meterDataSet.Meter = meterInfo.Meters.SingleOrDefault(meter => meter.ID == eventGroup.Key);

                foreach (MeterData.EventRow evt in eventGroup)
                {
                    dataGroup = new DataGroup();
                    dataGroup.FromData(meterDataSet.Meter, eventDataAdapter.GetTimeDomainData(evt.EventDataID));

                    foreach (DataSeries dataSeries in dataGroup.DataSeries)
                    {
                        meterDataSet.DataSeries.Add(dataSeries);
                    }
                }

                meterDataSets.Add(meterDataSet);
            }

            return(meterDataSets);
        }
        private EventClassification Classify(DataGroup dataGroup, VICycleDataGroup viCycleDataGroup)
        {
            double     nominalVoltage;
            DataSeries v1;
            DataSeries v2;
            DataSeries v3;

            // Get the line-to-neutral nominal voltage in volts
            nominalVoltage = dataGroup.Line.VoltageKV * 1000.0D / Math.Sqrt(3.0D);

            // Per-unit voltage waveforms based on nominal voltage
            v1 = viCycleDataGroup.VX1.RMS.Multiply(1.0D / nominalVoltage);
            v2 = viCycleDataGroup.VX2.RMS.Multiply(1.0D / nominalVoltage);
            v3 = viCycleDataGroup.VX3.RMS.Multiply(1.0D / nominalVoltage);

            if (HasInterruption(v1, v2, v3))
            {
                return(EventClassification.Interruption);
            }

            if (HasSwell(v1, v2, v3))
            {
                return(EventClassification.Swell);
            }

            if (HasSag(v1, v2, v3))
            {
                return(EventClassification.Sag);
            }

            return(EventClassification.Other);
        }
Beispiel #5
0
        public int Compare(Group <GridViewRowInfo> x, Group <GridViewRowInfo> y)
        {
            int parsedX;
            int parsedY;
            var first  = ((object[])x.Key).First().ToString().Trim();
            var second = ((object[])y.Key).First().ToString().Trim();

            if (first.Contains('/') && second.Contains('/'))
            {
                first  = first.Remove(0, first.LastIndexOf('/') + 1);
                second = second.Remove(0, second.LastIndexOf('/') + 1);
                if (first.Contains("d") && second.Contains("d"))
                {
                    first  = first.Remove(first.Length - 2);
                    second = second.Remove(second.Length - 2);
                }
            }


            if (int.TryParse(first, out parsedX) &&
                int.TryParse(second, out parsedY))
            {
                int       result = parsedX.CompareTo(parsedY);
                DataGroup xGroup = x as DataGroup;
                if (xGroup != null && ((DataGroup)x).GroupDescriptor.GroupNames.First().Direction == ListSortDirection.Descending)
                {
                    result *= -1;
                }
                return(result);
            }
            return(((object[])x.Key)[0].ToString().CompareTo(((object[])y.Key)[0].ToString()));
        }
Beispiel #6
0
        public int SelectAndShowData(Guid dataId, string extraWhere)
        {
            this.ParentGroup = BaseObject.GetById <DataGroup>(dataId);
            //controlleer of datacollectie klopt, zo nee parentgroup weer leegmaken
            if (this.ParentGroup != null && ParentGroup.DataCollection.ID != DataCollectionID)
            {
                ParentGroup = null;
            }
            if (ParentGroup != null)
            {
                this.ParentParentGroup = ParentGroup.ParentGroup;
            }

            //Null waarde kan niet (NullRefenceException)
            if (this.ParentGroup == null)
            {
                this.ParentGroup = new DataGroup();
            }
            if (this.ParentParentGroup == null)
            {
                this.ParentParentGroup      = new DataGroup();
                this.ParentParentGroup.Name = "Root";
            }

            BaseCollection <DataItem> items = getItems(dataId, extraWhere);

            DataBind(items);

            return(items.Count);
        }
Beispiel #7
0
        /// <inheritdoc />
        public Task <StationData> GetLastData(string stationId, DataGroup groupBy, int numberOfPeriod, TimePeriod period)
        {
            var time       = $"{numberOfPeriod}{period.GetDescription()}";
            var requestUri = $"/data/{stationId}/{groupBy}/last/{time}";

            return(GetAsync <StationData>(requestUri));
        }
        private DataGroup ToDataGroup(Meter meter, byte[] data)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(meter, data);
            return(dataGroup);
        }
Beispiel #9
0
    public void FooFunction(String Input, String Property, DataGroup Data)
    {
        switch (Property)
        {
        case "prop1":
            Data.prop1 = Input;
            break;

        case "prop2":
            Data.prop2 = Input;
            break;

        case "prop3":
            Data.prop1 = Input;
            break;

        case "prop4":
            Data.prop3 = Input;
            break;

        case "prop5":
            Data.prop5 = Input;
            break;
        }
    }
Beispiel #10
0
        /// <summary>
        /// ToDataSeries
        /// </summary>
        /// <param name="faultCurve"></param>
        /// <returns></returns>
        private DataSeries ToDataSeries(FaultLocationData.FaultCurveRow faultCurve)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(faultCurve.Data);
            return(dataGroup[0]);
        }
Beispiel #11
0
        public MeterDataSet(Event evt)
        {
            Resources            = new Dictionary <Type, object>();
            Configuration        = new ConfigurationDataSet();
            DataSeries           = new List <DataSeries>();
            Digitals             = new List <DataSeries>();
            ReportedDisturbances = new List <ReportedDisturbance>();

            using (AdoDataConnection connection = new AdoDataConnection("systemSettings"))
            {
                Meter = (new TableOperations <Meter>(connection)).QueryRecordWhere("ID = {0}", evt.MeterID);
                Meter.ConnectionFactory = () => new AdoDataConnection("systemSettings");
                CreateDbConnection      = () => new AdoDataConnection("systemSettings");
                ConnectionString        = string.Empty;
                FilePath  = (new TableOperations <DataFile>(connection)).QueryRecordWhere("FileGroupID = {0}", evt.FileGroupID).FilePath;
                FileGroup = (new TableOperations <FileGroup>(connection)).QueryRecordWhere("ID = {0}", evt.FileGroupID);
                Configuration.LineLength = (new TableOperations <Line>(connection)).QueryRecordWhere("ID = {0}", evt.LineID).Length;
                Configuration.X0         = (new TableOperations <LineImpedance>(connection)).QueryRecordWhere("LineID = {0}", evt.LineID)?.X0;
                Configuration.X1         = (new TableOperations <LineImpedance>(connection)).QueryRecordWhere("LineID = {0}", evt.LineID)?.X1;
                Configuration.R0         = (new TableOperations <LineImpedance>(connection)).QueryRecordWhere("LineID = {0}", evt.LineID)?.R0;
                Configuration.R1         = (new TableOperations <LineImpedance>(connection)).QueryRecordWhere("LineID = {0}", evt.LineID)?.R1;
                DataGroup dataGroup = ToDataGroup((new TableOperations <EventData>(connection)).QueryRecordWhere("ID = {0}", evt.EventDataID).TimeDomainData);
                DataSeries = dataGroup.DataSeries.Where(ds => ds.SeriesInfo.Channel.MeasurementType.Name != "Digital").ToList();
                Digitals   = dataGroup.DataSeries.Where(ds => ds.SeriesInfo.Channel.MeasurementType.Name == "Digital").ToList();
            }
        }
 public AlternativeDataItem(IUpgradeAlternative configurationAlternative, DataGroup @group)
     : base(configurationAlternative.UniqueId, configurationAlternative.Name, "", @group, 55, 0)
 {
     UpgradeItems = configurationAlternative.UpgradeItems;
     UpgradeAlternative = configurationAlternative;
     SetRightColumnSpan(UpgradeItems.Count);
 }
Beispiel #13
0
        private Dictionary <string, DataSeries> GetFaultCurveLookup()
        {
            TableOperations <FaultCurve> faultCurveTable = new TableOperations <FaultCurve>(m_connection);

            Func <FaultCurve, DataSeries> toDataSeries = faultCurve =>
            {
                DataGroup dataGroup = new DataGroup();
                dataGroup.FromData(new List <byte[]>()
                {
                    faultCurve.Data
                });
                return(dataGroup[0]);
            };

            return(faultCurveTable
                   .QueryRecordsWhere("EventID = {0}", m_eventID)
                   .GroupBy(faultCurve => faultCurve.Algorithm)
                   .ToDictionary(grouping => grouping.Key, grouping =>
            {
                if (grouping.Count() > 1)
                {
                    Log.Warn($"Duplicate fault curve ({grouping.Key}) found for event {grouping.First().EventID}");
                }

                return toDataSeries(grouping.First());
            }));
        }
        private VICycleDataGroup GetCycleData(AdoDataConnection connection, int eventID)
        {
            TableOperations <Event> eventTable = new TableOperations <Event>(connection);
            Event evt = eventTable.QueryRecordWhere("ID = {0}", eventID);

            if ((object)evt == null)
            {
                return(null);
            }

            byte[] timeDomainData = connection.ExecuteScalar <byte[]>("SELECT TimeDomainData FROM EventData WHERE ID = {0}", evt.EventDataID);

            if ((object)timeDomainData == null)
            {
                return(null);
            }

            TableOperations <Meter> meterTable = new TableOperations <Meter>(connection);
            Meter meter = meterTable.QueryRecordWhere("ID = {0}", evt.MeterID);

            if ((object)meter == null)
            {
                return(null);
            }

            meter.ConnectionFactory = () => new AdoDataConnection(connection.Connection, connection.AdapterType, false);

            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(meter, timeDomainData);
            return(Transform.ToVICycleDataGroup(new VIDataGroup(dataGroup), SystemFrequency));
        }
Beispiel #15
0
        private List <TreeNode> MapDataGroupToTreeNode(DataGroup dg, int parent, int boxId)
        {
            List <TreeNode> result = new List <TreeNode>();

            if (dg.Items != null)
            {
                foreach (DataItem di in dg.Items)
                {
                    var newNode = new TreeNode()
                    {
                        Name        = di.Title,
                        Type        = di.FileType,
                        Path        = di.Path,
                        IsDirectory = di.IsFolder,
                        ParentId    = parent,
                        IsShare     = di.Share,
                        IsShared    = di.Shared,
                        IsWritable  = di.IsWritable,
                        LocalBoxId  = boxId,
                        HasKeys     = di.HasKeys
                    };
                    result.Add(newNode);
                }
            }
            return(result);
        }
Beispiel #16
0
        public DataGroup GetGroup(string id, string parentgroupid, string datacollectionid)
        {
            BaseService.CheckLoginAndLicense();
            DataGroup group = null;

            if (id == null)
            {
                group                   = new DataGroup();
                group.Site              = SessionObject.CurrentSite;
                group.DataCollection    = new DataCollection();
                group.DataCollection.ID = new Guid(datacollectionid);
                if (parentgroupid != null && parentgroupid != "")
                {
                    group.ParentGroup    = new DataGroup();
                    group.ParentGroup.ID = new Guid(parentgroupid);
                    group.OrderNumber    = group.ParentGroup.GetMaxGroupOrderNumber() + 1;
                }
                else
                {
                    group.OrderNumber = group.DataCollection.GetMaxGroupOrderNumber() + 1;
                }
            }
            else
            {
                group = BaseObject.GetById <DataGroup>(new Guid(id));
            }
            return(group);
        }
Beispiel #17
0
        public override void Initialize(MeterDataSet meterDataSet)
        {
            List <DataGroup> dataGroups;
            DataGroup        dataGroup;

            dataGroups = new List <DataGroup>();

            foreach (IGrouping <Line, DataSeries> lineGroup in meterDataSet.DataSeries.Concat(meterDataSet.Digitals).GroupBy(GetLine))
            {
                foreach (IGrouping <DateTime, DataSeries> startTimeGroup in lineGroup.GroupBy(dataSeries => dataSeries.DataPoints[0].Time))
                {
                    foreach (IGrouping <DateTime, DataSeries> endTimeGroup in startTimeGroup.GroupBy(dataSeries => dataSeries.DataPoints[dataSeries.DataPoints.Count - 1].Time))
                    {
                        foreach (IGrouping <int, DataSeries> sampleCountGroup in endTimeGroup.GroupBy(dataSeries => dataSeries.DataPoints.Count))
                        {
                            dataGroup = new DataGroup();

                            foreach (DataSeries dataSeries in sampleCountGroup)
                            {
                                dataGroup.Add(dataSeries);
                            }

                            dataGroups.Add(dataGroup);
                        }
                    }
                }
            }

            m_dataGroups = dataGroups;
        }
Beispiel #18
0
 private void ShowData(DataGroup group)
 {
     formView = (Repeater)FindControl("Repeater" + ModuleID.ToString("N"));
     if (formView == null)
     {
         LabelMsg.Text = "Geen repeater gevonden.<br />";
     }
     if (group != null)
     {
         string pageLanguage = this.GetLanguageCodeFromMasterPage();
         if (pageLanguage != "" && pageLanguage != null)
         {
             group.Translate(pageLanguage);
         }
         //voor tag: {DirectUrl}
         group.RewriteUrl = group.GetRewriteUrl(Request.Url.LocalPath);
         //formview moet aan list worden gekoppeld, vreemd genoeg
         var list = new List <DataGroup> {
             group
         };
         formView.DataSource = list;
         formView.DataBind();
         overridePageTitleAndMetaTags(group);
         formView.Visible = true;
     }
     else
     {
         if (base.getSetting <bool>("HideWhenNoData"))
         {
             formView.Visible = false;
         }
     }
 }
Beispiel #19
0
        private void FindAllRestrikes(CycleDataResource cycleDataResource)
        {
            for (int i = 0; i < cycleDataResource.DataGroups.Count; i++)
            {
                DataGroup   dataGroup   = cycleDataResource.DataGroups[i];
                VIDataGroup viDataGroup = cycleDataResource.VIDataGroups[i];
                DataSeries  ia          = viDataGroup.IA;
                DataSeries  ib          = viDataGroup.IB;
                DataSeries  ic          = viDataGroup.IC;

                IEnumerable <Restrike> iaRestrikes = FindRestrikes(ia)
                                                     .Select(index => new Restrike(Phase.AN, index));

                IEnumerable <Restrike> ibRestrikes = FindRestrikes(ib)
                                                     .Select(index => new Restrike(Phase.BN, index));

                IEnumerable <Restrike> icRestrikes = FindRestrikes(ic)
                                                     .Select(index => new Restrike(Phase.CN, index));

                List <Restrike> allRestrikes = Enumerable.Empty <Restrike>()
                                               .Concat(iaRestrikes)
                                               .Concat(ibRestrikes)
                                               .Concat(icRestrikes)
                                               .ToList();

                if (allRestrikes.Any())
                {
                    RestrikeLookup.Add(dataGroup, allRestrikes);
                }
            }
        }
 public ConfigurationGroupDataItem(IConfigurationGroup configurationGroup, DataGroup @group, int configurationItemsCount)
     : base(configurationGroup.UniqueId, configurationGroup.Name, "", @group, 55, 40)
 {
     ConfigurationState = configurationGroup.GroupConfigurationState;
     _configurationGroup = configurationGroup;
     _configurationItemsCount = configurationItemsCount;
 }
        public List <string> readFile(DataGroup dataGroup, bool show)
        {
            List <string> highscorelist = new List <string>();
            string        file          = "../../highscore.txt";
            int           i             = 1;

            if (File.Exists(file))
            {
                string   fileContent = File.ReadAllText(file).Replace("\r", "");
                string[] lines       = fileContent.Split('\n');
                foreach (string value in lines)
                {
                    if (value != "")
                    {
                        if (show)
                        {
                            Console.WriteLine(i + " - " + value.Split(',')[0] + " - " + value.Split(',')[1]);
                        }
                        highscorelist.Add(value);
                        i++;
                    }
                }
            }
            else
            {
                File.OpenWrite(file);
            }

            return(highscorelist);
        }
Beispiel #22
0
        private static Dictionary <string, DataSeries> GetSeriesLookup(DataGroup waveFormData)
        {
            string[] measurementTypes = { "Voltage", "Current" };
            string[] phases           = { "AN", "BN", "CN" };

            Func <DataSeries, string> typeSelector = series =>
            {
                string measurementType = series.SeriesInfo.Channel.MeasurementType.Name;
                string phase           = series.SeriesInfo.Channel.Phase.Name;

                if (measurementType == "Current")
                {
                    measurementType = "I";
                }

                return(string.Format("{0}{1}", measurementType[0], phase[0]));
            };

            return(waveFormData.DataSeries
                   .Where(series => series.SeriesInfo.SeriesType.Name == "Values")
                   .Where(series => series.SeriesInfo.Channel.MeasurementCharacteristic.Name == "Instantaneous")
                   .Where(series => measurementTypes.Contains(series.SeriesInfo.Channel.MeasurementType.Name))
                   .Where(series => phases.Contains(series.SeriesInfo.Channel.Phase.Name))
                   .ToDictionary(typeSelector));
        }
        /// <inheritdoc />
        public Task <IEnumerable <string> > GetLastImageChart(string stationId, DataGroup dataGroup, int numberOfPeriod, TimePeriod period)
        {
            var time       = $"{numberOfPeriod}{period.GetDescription()}";
            var requestUri = $"chart/{ChartType.Image.GetDescription()}/{stationId}/{dataGroup.GetDescription()}/last/{time}";

            return(GetAsync <IEnumerable <string> >(requestUri));
        }
Beispiel #24
0
        private DataGroup ToDataGroup(List <byte[]> data)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(Meter, data);
            return(dataGroup);
        }
Beispiel #25
0
        /// <summary>
        /// ToDataSeries
        /// </summary>
        /// <param name="faultCurve"></param>
        /// <returns></returns>
        private DataGroup ToDataSeries(MeterData.EventDataRow faultCurve)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(faultCurve.FrequencyDomainData);
            return(dataGroup);
        }
Beispiel #26
0
        public ActionResult Get(int eventID, int pixels)
        {
            using (AdoDataConnection connection = new AdoDataConnection(m_configuration["OpenXDA:ConnectionString"], m_configuration["OpenXDA:DataProviderString"]))
            {
                Event evt = new TableOperations <Event>(connection).QueryRecordWhere("ID = {0}", eventID);
                if (evt == null)
                {
                    return(BadRequest("Must provide a valid EventID"));
                }
                Meter meter = new TableOperations <Meter>(connection).QueryRecordWhere("ID = {0}", evt.MeterID);
                meter.ConnectionFactory = () => new AdoDataConnection(m_configuration["OpenXDA:ConnectionString"], m_configuration["OpenXDA:DataProviderString"]);

                Dictionary <string, IEnumerable <double[]> > returnData = new Dictionary <string, IEnumerable <double[]> >();
                DataGroupHelper dataGroupHelper = new DataGroupHelper(m_configuration, m_memoryCache);
                DataGroup       dataGroup       = dataGroupHelper.QueryDataGroup(eventID, meter);;
                VIDataGroup     vIDataGroup     = new VIDataGroup(dataGroup);
                double          systemFrequency = connection.ExecuteScalar <double?>("SELECT Value FROM Setting WHERE Name = 'SystemFrequency'") ?? 60.0;


                Dictionary <string, List <double[]> > returnList = new Dictionary <string, List <double[]> >();

                returnList.Add("VA", GenerateFrequency(systemFrequency, vIDataGroup.VA));
                returnList.Add("VB", GenerateFrequency(systemFrequency, vIDataGroup.VB));
                returnList.Add("VC", GenerateFrequency(systemFrequency, vIDataGroup.VC));
                returnList.Add("Average", GenerateFrequency(systemFrequency, vIDataGroup.VC));

                return(Ok(returnList));
            }
        }
        private Dictionary <string, FlotSeries> QueryBreakerData(int eventID, Meter meter)
        {
            byte[]    timeDomainData = m_dataContext.Connection.ExecuteScalar <byte[]>("SELECT TimeDomainData FROM EventData WHERE ID = (SELECT EventDataID FROM Event WHERE ID = {0})", eventID);
            DataGroup dataGroup      = ToDataGroup(meter, timeDomainData);

            return(GetBreakerLookup(dataGroup));
        }
Beispiel #28
0
        private void WriteResults(MeterDataSet meterDataSet, DataGroup dataGroup, VICycleDataGroup viCycleDataGroup, List <Fault> faults, string resultsFilePath)
        {
            XDocument resultsDocument;
            XElement  results;
            string    lineName;

            lineName = meterDataSet.Meter.MeterLines
                       .Where(ml => ml.LineID == dataGroup.Line.ID)
                       .Select(ml => ml.LineName)
                       .FirstOrDefault() ?? dataGroup.Line.AssetKey;

            results =
                new XElement("results",
                             new XElement("meter", meterDataSet.Meter.Name),
                             new XElement("disturbanceFiles", GetPathElements(meterDataSet.FileGroup)),
                             new XElement("line",
                                          new XElement("name", lineName),
                                          new XElement("length", dataGroup.Line.Length.ToString(DoubleFormat))
                                          ),
                             new XElement("prefault",
                                          new XElement("time", dataGroup.StartTime.ToString(DateTimeFormat)),
                                          GetCycleElements(viCycleDataGroup, 0)
                                          ),
                             GetFaultElements(faults)
                             );

            // Create the XML document
            resultsDocument =
                new XDocument(
                    new XElement("openFLE", results)
                    );

            resultsDocument.Save(resultsFilePath);
        }
            private byte[] Serialize(DataSeries series)
            {
                DataGroup group = new DataGroup();

                group.Add(series);
                return(group.ToData());
            }
Beispiel #30
0
        private List <Tuple <string, DataSeries> > ToFaultCurves(DataGroup dataGroup, List <Fault> faults)
        {
            double maxDistance;
            double minDistance;

            List <Tuple <string, DataSeries> > faultCurves;

            string     algorithm;
            DataSeries faultCurve;

            maxDistance = dataGroup.Line.Length * m_faultLocationSettings.MaxFaultDistanceMultiplier;
            minDistance = dataGroup.Line.Length * m_faultLocationSettings.MinFaultDistanceMultiplier;
            faultCurves = new List <Tuple <string, DataSeries> >();

            for (int c = 0; c < faults[0].Curves.Count; c++)
            {
                algorithm  = faults[0].Curves[c].Algorithm;
                faultCurve = dataGroup[0].Multiply(0.0D);

                foreach (Fault fault in faults)
                {
                    for (int i = fault.StartSample; fault.Curves[c].HasData(i); i++)
                    {
                        faultCurve[i].Value = Common.Mid(minDistance, fault.Curves[c][i].Value, maxDistance);
                    }
                }

                faultCurves.Add(Tuple.Create(algorithm, faultCurve));
            }

            return(faultCurves);
        }
Beispiel #31
0
        public DataGroup ToDataGroup(Meter meter, List <byte[]> data)
        {
            DataGroup dataGroup = new DataGroup();

            dataGroup.FromData(meter, data);
            return(dataGroup);
        }
Beispiel #32
0
        private void FindAllTrips(CycleDataResource cycleDataResource)
        {
            for (int i = 0; i < cycleDataResource.DataGroups.Count; i++)
            {
                DataGroup        dataGroup        = cycleDataResource.DataGroups[i];
                VICycleDataGroup viCycleDataGroup = cycleDataResource.VICycleDataGroups[i];

                IEnumerable <Trip> iaTrips = FindTrips(viCycleDataGroup.IA?.Peak)
                                             .Select(point => new Trip(Phase.AN, point.Time));

                IEnumerable <Trip> ibTrips = FindTrips(viCycleDataGroup.IB?.Peak)
                                             .Select(point => new Trip(Phase.BN, point.Time));

                IEnumerable <Trip> icTrips = FindTrips(viCycleDataGroup.IC?.Peak)
                                             .Select(point => new Trip(Phase.CN, point.Time));

                List <Trip> allTrips = Enumerable.Empty <Trip>()
                                       .Concat(iaTrips)
                                       .Concat(ibTrips)
                                       .Concat(icTrips)
                                       .ToList();

                if (allTrips.Any())
                {
                    TripLookup.Add(dataGroup, allTrips);
                }
            }
        }
Beispiel #33
0
    void Run()
    {
        DataGroup WorkingData = new DataGroup();

        Modify("Put This string in here", new FooMethod(), "prop1", WorkingData);
        Modify("This wont do anything", new BarMethod(), "prop5", WorkingData);
    }
        public VIDataGroup(DataGroup dataGroup)
        {
            string[] instantaneousSeriesTypes = { "Values", "Instantaneous" };

            // Initialize each of
            // the indexes to -1
            m_vaIndex = -1;
            m_vbIndex = -1;
            m_vcIndex = -1;
            m_vabIndex = -1;
            m_vbcIndex = -1;
            m_vcaIndex = -1;
            m_iaIndex = -1;
            m_ibIndex = -1;
            m_icIndex = -1;
            m_irIndex = -1;

            // Initialize the data group
            m_dataGroup = new DataGroup(dataGroup.DataSeries);

            for (int i = 0; i < dataGroup.DataSeries.Count; i++)
            {
                string measurementType = dataGroup[i].SeriesInfo.Channel.MeasurementType.Name;
                string measurementCharacteristic = dataGroup[i].SeriesInfo.Channel.MeasurementCharacteristic.Name;
                string seriesType = dataGroup[i].SeriesInfo.SeriesType.Name;
                string phase = dataGroup[i].SeriesInfo.Channel.Phase.Name;

                // If the data group is not instantaneous, do not use it in the VIDataGroup
                if (measurementCharacteristic != "Instantaneous")
                    continue;

                // If the data group is not instantaneous, do not use it in the VIDataGroup
                if (!instantaneousSeriesTypes.Contains(seriesType))
                    continue;

                // Assign the proper indexes for the seven VIDataGroup
                // channels by checking the name of the channel
                if (measurementType == "Voltage" && phase == "AN")
                    m_vaIndex = i;
                else if (measurementType == "Voltage" && phase == "BN")
                    m_vbIndex = i;
                else if (measurementType == "Voltage" && phase == "CN")
                    m_vcIndex = i;
                else if (measurementType == "Voltage" && phase == "AB")
                    m_vabIndex = i;
                else if (measurementType == "Voltage" && phase == "BC")
                    m_vbcIndex = i;
                else if (measurementType == "Voltage" && phase == "CA")
                    m_vcaIndex = i;
                else if (measurementType == "Current" && phase == "AN")
                    m_iaIndex = i;
                else if (measurementType == "Current" && phase == "BN")
                    m_ibIndex = i;
                else if (measurementType == "Current" && phase == "CN")
                    m_icIndex = i;
                else if (measurementType == "Current" && phase == "RES")
                    m_irIndex = i;
            }
        }
        public override List<string> GetAllQueryableFieldNames(DataGroup @group)
        {
            var fields = new List<string>
                         	{
                                            "SKU","ProdName","ProdDescription","Brand","Manufacturer","IsRetail","RetailPrice","RetailPriceCat","IsWholesale","WholesalePrice","WholesaleQty","ProdStatus","ProdInventory","OutOfStockPoint","ProdOnOrder","AltID","VendorID","DescriptionHeader","ProductURLName","SpecialPrice","IsSpecialOngoing","SpecialStart","SpecialEnd","SpecialText","BackorderedDate","IgnoreBackorder","MinimumQuantity","MaximumQuantity","QuantityInSet","NumIterationsDisplayed","DisplayWeight","ActualWeight","Unit","ImageSetThumb","ImageSetLarge","ImageSetPopup","ImageSetType","ImageSetAttributeName","ImageSetTitle","ImageSetEditType","IsInactive","IsOutOfSeason","IsTaxExempt","HasTextField","IsHidden","IsFeatured","IsNew","IsGoogleCheckoutExempt","IsComparable","IsContentOnly","IsInventoryExempt","IsSubscription","IsDonation","SubscriptionPrice","HasElectronicDelivery","ElectronicDeliveryLink","ElectronicDeliveryDaysAvailable","ElectronicDeliveryDescription","ElectronicDeliveryEditType","IsKit","KitProductSKUs","ShipPreference","ByShipperMethod","ByShipperPreference","ByShipperFixedShipping","FixedShipping","ShipsInOwnBox","PackageLength","PackageWidth","PackageHeight","FreightClass","IsGiftCertificate","GiftCertificateDaysAvailable","GiftCertificateValue","Rating","Keywords","MetaKeywords","MetaTitle","MetaDescription","CategoryIDs","DefaultCategoryID","Custom","Template","DependencySKUs","DependencyType","AdditionalProdSKUs","RelatedProdSKUs","GiftWrap","GiftWrapName","GiftWrapSKU","GiftWrapAmount","CategoryFilter","CategoryFilterValue","CategoryFilterSortValue","ParentSKU","ChildImage","IsRewardsEligible","RewardsPoints","SubProductAttributes","IsAttribute","AttributeTitle1","AttributeTitle2","AttributeTitle3","AttributeTitle4","AttributeSKU","Attribute1","Attribute2","Attribute3","Attribute4","Attribute1Code","Attribute2Code","Attribute3Code","Attribute4Code","AttributePrice","AttributePriceCat","AttributeSpecialPrice","IsAttributeSpecialOngoing","AttributeSpecialStart","AttributeSpecialEnd","AttributeBackorderedDate","AttributeIgnoreBackorder","AttributeInventory","AttributeOutOfStockPoint","AttributeOnOrder","IsAttributeInactive","AttributeStatus","IsAttributeGiftCertificate","AttributeGiftCertificateDaysAvailable","AttributeGiftCertificateValue","IsAttributeSubscription","AttributeSubscriptionPrice","IsAttributeDonation","AttributeRewardsPoints"
                         	};

            return fields;
        }
 public CommonMandelbrotDrawer(String uniqueId, String title, String imagePath, Color color, Trajectory trajectory, int iters, 
     DataGroup group, float scaling = 1.0f)
     : base(uniqueId, title, imagePath, group)
 {
     this.color = color;
     this.trajectory = trajectory;
     this.iters = iters;
     this.scaling = scaling;
 }
        public VICycleDataGroup(DataGroup dataGroup)
        {
            m_cycleDataGroups = dataGroup.DataSeries
                .Select((dataSeries, index) => new { DataSeries = dataSeries, Index = index })
                .GroupBy(obj => obj.Index / 4)
                .Where(grouping => grouping.Count() >= 4)
                .Select(grouping => grouping.Select(obj => obj.DataSeries))
                .Select(grouping => new CycleDataGroup(new DataGroup(grouping)))
                .ToList();

            MapIndexes();
        }
 public DataHandlerBase(SiteRules rules, CartExtractor cart, ExtractorProgress progress, DataGroup group)
 {
     _cart = cart;
     _rules = rules;
     _progress = progress;
     _group = group;
     _exportDate = DateTime.Now;
     _exportDateInitialized = false;
     _migrationSlave = _rules.MigrationRules != null && _rules.MigrationRules.Enabled
                                         && !_rules.MigrationRules.IsMigrationMaster;
     Reset();
 }
        public static DataGroup Combine(params DataGroup[] dataGroups)
        {
            DataGroup combination = new DataGroup();

            foreach (DataGroup dataGroup in dataGroups)
            {
                foreach (DataSeries dataSeries in dataGroup.DataSeries)
                    combination.Add(dataSeries);
            }

            return combination;
        }
 private void SetAircraftList(List<IAircraft> aircrafts, DataGroup @group)
 {
     AircraftList = new ObservableCollection<AircraftSelectionDataItem>();
     if (aircrafts.Count == 1)
     {
         AircraftList.Add(new AircraftSelectionDataItem(aircrafts[0], @group, 30,30));
         return;
     }
     foreach (var aircraft in aircrafts)
     {
         AircraftList.Add(new AircraftSelectionDataItem(aircraft, group));
     }
 }
        public static void Write(Meter meter, DataGroup waveFormData, FaultLocationData.FaultCurveDataTable faultCurveTable, List<FaultSegment> segments, string originalFilePath, string filePath)
        {
            List<DataSeries> waveFormSeriesList = GetWaveFormSeriesList(waveFormData);
            DataGroup faultLocationData = GetFaultLocationData(meter, faultCurveTable);

            string absoluteFilePath = FilePath.GetAbsolutePath(filePath);

            using (StreamWriter fileStream = new StreamWriter(File.OpenWrite(absoluteFilePath)))
            {
                string originalDirectory;
                string originalRootFileName;
                string originalSchemaFilePath;
                string absoluteOriginalFilePath;
                Schema originalSchema = null;

                string headerRow;

                absoluteOriginalFilePath = FilePath.GetAbsolutePath(originalFilePath);

                if (File.Exists(absoluteOriginalFilePath))
                {
                    originalDirectory = FilePath.GetDirectoryName(absoluteOriginalFilePath);
                    originalRootFileName = FilePath.GetFileNameWithoutExtension(originalFilePath);
                    originalSchemaFilePath = Path.Combine(originalDirectory, originalRootFileName + ".cfg");
                    originalSchema = new Schema(originalSchemaFilePath);
                }

                headerRow = waveFormData.DataSeries
                    .Select(series => GetOriginalChannelName(originalSchema, series))
                    .Concat(faultCurveTable.Select(row => string.Format("Fault Location ({0} Algorithm)", row.Algorithm)))
                    .Aggregate("Time", (s, s1) => s + "," + s1);

                fileStream.WriteLine(headerRow);

                for (int i = 0; i < waveFormData.Samples; i++)
                {
                    DateTime time = waveFormSeriesList[0].DataPoints[i].Time;

                    double[] values = waveFormSeriesList
                        .Select(series => series.DataPoints[i].Value)
                        .Concat(faultLocationData.DataSeries.Select(series => series.DataPoints.Count > i ? series.DataPoints[i].Value : 0.0D))
                        .ToArray();

                    fileStream.WriteLine(values.Aggregate(time.ToString("yyyy-MM-dd HH:mm:ss.ffffff"), (s, d) => s + "," + d));
                }
            }
        }
        public static void Write(string connectionString, int eventID, string originalFilePath, string filePath)
        {
            MeterInfoDataContext meterInfo = new MeterInfoDataContext(connectionString);
            FaultLocationInfoDataContext faultLocationInfo = new FaultLocationInfoDataContext(connectionString);
            MeterData.EventRow eventRow;

            Meter meter;
            DataGroup waveFormData;
            FaultLocationData.FaultCurveDataTable faultCurveTable;
            List<FaultSegment> segments;

            using (EventTableAdapter eventAdapter = new EventTableAdapter())
            {
                eventAdapter.Connection.ConnectionString = connectionString;
                eventRow = eventAdapter.GetDataByID(eventID).FirstOrDefault();
            }

            if ((object)eventRow == null)
                throw new InvalidOperationException(string.Format("Event with ID {0} not found", eventID));

            meter = meterInfo.Meters.FirstOrDefault(dbMeter => dbMeter.ID == eventRow.MeterID);

            waveFormData = new DataGroup();
            waveFormData.FromData(meter, eventRow.Data);

            using (FaultCurveTableAdapter faultCurveAdapter = new FaultCurveTableAdapter())
            {
                faultCurveAdapter.Connection.ConnectionString = connectionString;
                faultCurveTable = faultCurveAdapter.GetDataBy(eventID);
            }

            segments = faultLocationInfo.FaultSegments
                .Where(segment => segment.EventID == eventID)
                .OrderBy(segment => segment.StartSample)
                .ToList();

            Write(meter, waveFormData, faultCurveTable, segments, originalFilePath, filePath);
        }
Beispiel #43
0
 /// <summary>
 /// Builds a table with all the user fields and returns the string.
 /// </summary>
 /// <returns>An HTML string.</returns>
 public string GetUserFields(bool isSelfInfo)
 {
     //tal vez esta función no deba ir aqui...
     string retval = "<div id='tabNav'><ul>";
     string tabBody = "";
     int currentIdDataGroup = 0;
     List<DataDesc> dataDescList = Data.Data.GetDataDesc();
     foreach (DataDesc dataDesc in dataDescList)
     {
         foreach (UserData userData in userDataList)
         {
             if (userData.IdData == dataDesc.IdData)
             {
                 if (!String.IsNullOrEmpty(userData.Value))
                 {
                     dataDesc.Value = userData.Value;
                 }
             }
         }
         if (dataDesc.IdDataGroup != currentIdDataGroup)
         {
             if (currentIdDataGroup != 0)
             {
                 tabBody += "</table></div>";
             }
             tabBody += "<div id='tab" + dataDesc.IdDataGroup + "'><table width='70%' align='center'>";
             currentIdDataGroup = dataDesc.IdDataGroup;
             DataGroup dataGroup = new DataGroup(dataDesc.IdDataGroup);
             retval += "<li><a href='#tab" + dataDesc.IdDataGroup + "'>" + dataGroup.Name + "</a></li>";
         }
         if (dataDesc.Kind != Data.Data.LABEL)
         {
             bool canBeShown = false;
             if (dataDesc.InvisibleToSelf == 1)
             {
                 if (isSelfInfo)
                 {
                     if (Modules.Permission(SessionHandler.Modules, Modules.USER_ADMINISTRATION))
                     {
                         canBeShown = true;
                     }
                 }
             }
             else
             {
                 canBeShown = true;
             }
             if (canBeShown)
             {
                 string fieldName = dataDesc.Name;
                 if (dataDesc.Required == 1) fieldName = "<span class='required'>" + fieldName + "</span>";
                 string valueFromRequest = HttpContext.Current.Request.Form["data_" + dataDesc.IdData];
                 //if (dataDesc.Value == "") dataDesc.Value = valueFromRequest;
                 if (!String.IsNullOrEmpty(valueFromRequest)) dataDesc.Value = valueFromRequest;
                 tabBody += "<tr><td width='30%'>" + fieldName + ":</td><td width='70%'>" + dataDesc.GetFieldHTML() + "</td></tr>";
             }
         }
         else
         {
             tabBody += "<tr><td colspan='2'>" + dataDesc.GetFieldHTML() + "</td></tr>";
         }
     }
     if (!String.IsNullOrEmpty(tabBody)) tabBody += "</table></div>";
     return retval + "</ul>" + tabBody + "</div>";
 }
 public ConfigurationDataItem(IConfigurationFile configuration, DataGroup @group)
     : base(configuration.UniqueId, configuration.ConfigurationDate, configuration.AircraftProgrammImage,  @group, 28, 25)
 {
     _configuration = configuration;
 }
Beispiel #45
0
 public static extern TwainResult DsStatus([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Status dsmstat);
Beispiel #46
0
 public static extern TwainResult DsmParent([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr windowHandle);
Beispiel #47
0
 public static extern TwainResult DsImageTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref IntPtr hbitmap);
Beispiel #48
0
 public static extern TwainResult DsImageInfo([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageInfo imginf);
        public void GetEntity(DataGroup group, JObject entity)
        {
            switch (group)
            {
                case DataGroup.Catalog:
                case DataGroup.Inventory:
                    //{
                    //  "id": 32,
                    //  "keyword_filter": null,
                    //  "name": "[Sample] Tomorrow is today, Red printed scarf",
                    //  "type": "physical",
                    //  "sku": "",
                    //  "description": "Densely pack your descriptions with useful information and watch products fly off the shelf.",
                    //  "search_keywords": null,
                    //  "availability_description": "",
                    //  "price": "89.0000",
                    //  "cost_price": "0.0000",
                    //  "retail_price": "0.0000",
                    //  "sale_price": "0.0000",
                    //  "calculated_price": "89.0000",
                    //  "sort_order": 0,
                    //  "is_visible": true,
                    //  "is_featured": true,
                    //  "related_products": "-1",
                    //  "inventory_level": 0,
                    //  "inventory_warning_level": 0,
                    //  "warranty": null,
                    //  "weight": "0.3000",
                    //  "width": "0.0000",
                    //  "height": "0.0000",
                    //  "depth": "0.0000",
                    //  "fixed_cost_shipping_price": "10.0000",
                    //  "is_free_shipping": false,
                    //  "inventory_tracking": "none",
                    //  "rating_total": 0,
                    //  "rating_count": 0,
                    //  "total_sold": 0,
                    //  "date_created": "Fri, 21 Sep 2012 02:31:01 +0000",
                    //  "brand_id": 17,
                    //  "view_count": 4,
                    //  "page_title": "",
                    //  "meta_keywords": null,
                    //  "meta_description": null,
                    //  "layout_file": "product.html",
                    //  "is_price_hidden": false,
                    //  "price_hidden_label": "",
                    //  "categories": [
                    //    14
                    //  ],
                    //  "date_modified": "Mon, 24 Sep 2012 01:34:57 +0000",
                    //  "event_date_field_name": "Delivery Date",
                    //  "event_date_type": "none",
                    //  "event_date_start": "",
                    //  "event_date_end": "",
                    //  "myob_asset_account": "",
                    //  "myob_income_account": "",
                    //  "myob_expense_account": "",
                    //  "peachtree_gl_account": "",
                    //  "condition": "New",
                    //  "is_condition_shown": false,
                    //  "preorder_release_date": "",
                    //  "is_preorder_only": false,
                    //  "preorder_message": "",
                    //  "order_quantity_minimum": 0,
                    //  "order_quantity_maximum": 0,
                    //  "open_graph_type": "product",
                    //  "open_graph_title": "",
                    //  "open_graph_description": null,
                    //  "is_open_graph_thumbnail": true,
                    //  "upc": null,
                    //  "avalara_product_tax_code": "",
                    //  "date_last_imported": "",
                    //  "option_set_id": null,
                    //  "tax_class_id": 0,
                    //  "option_set_display": "right",
                    //  "bin_picking_number": "",
                    //  "custom_url": "/tomorrow-is-today-red-printed-scarf/",
                    //  "primary_image": {
                    //    "id": 247,
                    //    "zoom_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.1280.1280.jpg?c=1",
                    //    "thumbnail_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.220.290.jpg?c=1",
                    //    "standard_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.386.513.jpg?c=1",
                    //    "tiny_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.44.58.jpg?c=1"
                    //  },
                    //  "availability": "available",
                    //  "brand": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/brands/17.json",
                    //    "resource": "/brands/17"
                    //  },
                    //  "images": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/images.json",
                    //    "resource": "/products/32/images"
                    //  },
                    //  "discount_rules": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/discountrules.json",
                    //    "resource": "/products/32/discountrules"
                    //  },
                    //  "configurable_fields": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/configurablefields.json",
                    //    "resource": "/products/32/configurablefields"
                    //  },
                    //  "custom_fields": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/customfields.json",
                    //    "resource": "/products/32/customfields"
                    //  },
                    //  "videos": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/videos.json",
                    //    "resource": "/products/32/videos"
                    //  },
                    //  "skus": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/skus.json",
                    //    "resource": "/products/32/skus"
                    //  },
                    //  "rules": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/rules.json",
                    //    "resource": "/products/32/rules"
                    //  },
                    //  "option_set": null,
                    //  "options": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/products/32/options.json",
                    //    "resource": "/products/32/options"
                    //  },
                    //  "tax_class": {
                    //    "url": "https://store-et7xe3pz.mybigcommerce.com/api/v2/taxclasses/0.json",
                    //    "resource": "/taxclasses/0"
                    //  }
                    //}
                    string _PIdName = extractor.Rules.Fields.GetName(FieldName.ProductId);
                    string _NameName = extractor.Rules.Fields.GetName(FieldName.Name);
                    string _Att1Name = extractor.Rules.UseDepartmentsAsCategories
                                                ? extractor.Rules.Fields.GetName(FieldName.Department)
                                                : extractor.Rules.Fields.GetName(FieldName.Att1Id);
                    string _Att2Name = extractor.Rules.Fields.GetName(FieldName.Att2Id);
                    string _PriceName = extractor.Rules.Fields.GetName(FieldName.Price);
                    string _SaleName = extractor.Rules.Fields.GetName(FieldName.SalePrice);
                    string _ListName = extractor.Rules.Fields.GetName(FieldName.ListPrice);
                    string _CostName = extractor.Rules.Fields.GetName(FieldName.Cost);
                    string _InvName = extractor.Rules.Fields.GetName(FieldName.Inventory);
                    string _VisName = extractor.Rules.Fields.GetName(FieldName.Visible);
                    string _LinkName = extractor.Rules.Fields.GetName(FieldName.Link);
                    string _ImagName = extractor.Rules.Fields.GetName(FieldName.ImageLink);
                    string _RateName = extractor.Rules.Fields.GetName(FieldName.Rating);
                    string _ParentIdName = extractor.Rules.Fields.GetName(FieldName.ParentId);
                    string _CodeName = extractor.Rules.Fields.GetName(FieldName.StandardCode);

                    Catalog.Entry entry = new Catalog.Entry();

                    try
                    {
                        // Standard Fields
                        entry.ProductID = entity.SelectToken(_PIdName).ToString();
                        entry.Name = entity.SelectToken(_NameName).ToString();
                        JArray categoryIds = (JArray)entity.SelectToken(_Att1Name);
                        foreach (JValue categoryId in categoryIds)
                            entry.AddCategory(categoryId.ToString());
                        string brand = "";
                        if (brands != null && brands.d.TryGetValue(entity.SelectToken(_Att2Name).ToString(), out brand))
                            entry.ManufacturerID = brand;
                        entry.Visible = (int)entity.SelectToken(_VisName);
                        entry.Link = entity.SelectToken(_LinkName).ToString();
                        entry.Imagelink = entity.SelectToken(_ImagName).ToString();
                        entry.Price = entity.SelectToken(_PriceName).ToString();
                        entry.SalePrice = entity.SelectToken(_SaleName).ToString();
                        entry.ListPrice = entity.SelectToken(_ListName).ToString();
                        entry.Cost = entity.SelectToken(_CostName).ToString();
                        entry.Inventory = entity.SelectToken(_InvName).ToString();
                        entry.Rating = entity.SelectToken(_RateName).ToString();
                        entry.StandardCode = entity.SelectToken(_CodeName).ToString();

                        // Extra Fields
                        foreach (string extraFieldName in catalog.extraFieldNames)
                            if (extraFieldName != "")
                                entry.ExtraFields.Add(entity.SelectToken(extraFieldName) == null ? "" : entity.SelectToken(extraFieldName).ToString());

                        // Custom Fields
                        // walk the column names and for each determine whether the product at hand has one of these custom field, if so post it's value in the position corresponding to the index of name in customFieldNames
                        bool found = false;
                        foreach (string customFileName in catalog.customFieldNames)
                        {
                            found = false;
                            foreach (CustomField field in customfields.fields)
                            {
                                // see if there's a customfield for this product and it matches the custom field we're on
                                if (field.ProductID == entry.ProductID && field.Name == customFileName)
                                {
                                    found = true;
                                    entry.CustomFields.Add(field.Value);
                                    break;
                                }
                            }
                            if (found == false)
                                entry.CustomFields.Add("");
                        }
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }

                    catalog.AddEntry(entry);

                    // Now get product options as children
                    List<Option> productOptions = options.GetProductOptions(entry.ProductID);
                    foreach (Option option in productOptions)
                    {
                        try
                        {
                            Catalog.Entry childEntry = new Catalog.Entry();

                            // Standard Fields
                            childEntry.ProductID = option.ChildID;
                            if (option.PriceType == "absolute")
                                childEntry.Price = option.Price;
                            else
                            {
                                Single ePrice = 0.0f;
                                Single oPrice = 0.0f;
                                if (!Single.TryParse(entry.Price, out ePrice))
                                    throw new FormatException("Number format not supported");
                                if (!Single.TryParse(option.Price, out oPrice))
                                    throw new FormatException("Number format not supported");
                                childEntry.Price = (ePrice + oPrice).ToString();
                            }
                            childEntry.ParentProductID = option.ProductID;

                            // Extra Fields
                            foreach (string extraFieldName in catalog.extraFieldNames)
                                if (extraFieldName != "")
                                    entry.ExtraFields.Add("");

                            // Custom Fields
                            // walk the column names and for each determine whether the product at hand has one of these custom field, if so post it's value in the position corresponding to the index of name in customFieldNames
                            foreach (string customFileName in catalog.customFieldNames)
                                entry.CustomFields.Add("");

                            catalog.AddEntry(childEntry);
                        }
                        catch (RuntimeBinderException e)
                        {
                            //throw;
                        }
                    }
                    break;
                case DataGroup.Sales:
                    //[
                    //  {
                    //    "id": 100,
                    //    "customer_id": 10,
                    //    "date_created": "Wed, 14 Nov 2012 19:26:23 +0000",
                    //    "date_modified": "Wed, 14 Nov 2012 19:26:23 +0000",
                    //    "date_shipped": "",
                    //    "status_id": 11,
                    //    "status": "Awaiting Fulfillment",
                    //    "subtotal_ex_tax": "79.0000",
                    //    "subtotal_inc_tax": "79.0000",
                    //    "subtotal_tax": "0.0000",
                    //    "base_shipping_cost": "0.0000",
                    //    "shipping_cost_ex_tax": "0.0000",
                    //    "shipping_cost_inc_tax": "0.0000",
                    //    "shipping_cost_tax": "0.0000",
                    //    "shipping_cost_tax_class_id": 2,
                    //    "base_handling_cost": "0.0000",
                    //    "handling_cost_ex_tax": "0.0000",
                    //    "handling_cost_inc_tax": "0.0000",
                    //    "handling_cost_tax": "0.0000",
                    //    "handling_cost_tax_class_id": 2,
                    //    "base_wrapping_cost": "0.0000",
                    //    "wrapping_cost_ex_tax": "0.0000",
                    //    "wrapping_cost_inc_tax": "0.0000",
                    //    "wrapping_cost_tax": "0.0000",
                    //    "wrapping_cost_tax_class_id": 3,
                    //    "total_ex_tax": "79.0000",
                    //    "total_inc_tax": "79.0000",
                    //    "total_tax": "0.0000",
                    //    "items_total": 1,
                    //    "items_shipped": 0,
                    //    "payment_method": "cash",
                    //    "payment_provider_id": null,
                    //    "payment_status": "",
                    //    "refunded_amount": "0.0000",
                    //    "order_is_digital": false,
                    //    "store_credit_amount": "0.0000",
                    //    "gift_certificate_amount": "0.0000",
                    //    "ip_address": "50.58.18.2",
                    //    "geoip_country": "",
                    //    "geoip_country_iso2": "",
                    //    "currency_id": 1,
                    //    "currency_code": "USD",
                    //    "currency_exchange_rate": "1.0000000000",
                    //    "default_currency_id": 1,
                    //    "default_currency_code": "USD",
                    //    "staff_notes": "",
                    //    "customer_message": "",
                    //    "discount_amount": "0.0000",
                    //    "coupon_discount": "0.0000",
                    //    "shipping_address_count": 1,
                    //    "is_deleted": false,
                    //    "billing_address": {
                    //      "first_name": "Trisha",
                    //      "last_name": "McLaughlin",
                    //      "company": "",
                    //      "street_1": "12345 W Anderson Ln",
                    //      "street_2": "",
                    //      "city": "Austin",
                    //      "state": "Texas",
                    //      "zip": "78757",
                    //      "country": "United States",
                    //      "country_iso2": "US",
                    //      "phone": "",
                    //      "email": "*****@*****.**"
                    //    },
                    //    "products": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/products.json",
                    //      "resource": "/orders/100/products"
                    //    },
                    //    "shipping_addresses": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/shippingaddresses.json",
                    //      "resource": "/orders/100/shippingaddresses"
                    //    },
                    //    "coupons": {
                    //      "url": "https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/coupons.json",
                    //      "resource": "/orders/100/coupons"
                    //    }
                    //  }
                    //]

                    // get the order id first, then retrieve products for it, use e.g. https://store-bwvr466.mybigcommerce.com/api/v2/orders/100/products.json

                    //{
                    //  "id": 16,
                    //  "order_id": 115,
                    //  "product_id": 0,
                    //  "order_address_id": 16,
                    //  "name": "Cynthia Gilbert Signature Collection",
                    //  "sku": "",
                    //  "type": "physical",
                    //  "base_price": "93.1800",
                    //  "price_ex_tax": "93.1800",
                    //  "price_inc_tax": "93.1800",
                    //  "price_tax": "0.0000",
                    //  "base_total": "93.1800",
                    //  "total_ex_tax": "93.1800",
                    //  "total_inc_tax": "93.1800",
                    //  "total_tax": "0.0000",
                    //  "weight": "0",
                    //  "quantity": 1,
                    //  "base_cost_price": "0.0000",
                    //  "cost_price_inc_tax": "0.0000",
                    //  "cost_price_ex_tax": "0.0000",
                    //  "cost_price_tax": "0.0000",
                    //  "is_refunded": false,
                    //  "refund_amount": "0.0000",
                    //  "return_id": 0,
                    //  "wrapping_name": "",
                    //  "base_wrapping_cost": "0.0000",
                    //  "wrapping_cost_ex_tax": "0.0000",
                    //  "wrapping_cost_inc_tax": "0.0000",
                    //  "wrapping_cost_tax": "0.0000",
                    //  "wrapping_message": "",
                    //  "quantity_shipped": 0,
                    //  "event_name": null,
                    //  "event_date": "",
                    //  "fixed_shipping_cost": "0.0000",
                    //  "ebay_item_id": "",
                    //  "ebay_transaction_id": "",
                    //  "option_set_id": null,
                    //  "parent_order_product_id": null,
                    //  "is_bundled_product ": false,
                    //  "bin_picking_number": "",
                    //  "applied_discounts": [
                    //    {
                    //      "id": "coupon",
                    //      "amount": 4.66
                    //    }
                    //  ],
                    //  "product_options": [
                    //  ],
                    //  "configurable_fields": [
                    //  ]
                    //}
                    //response = client.GetAsync("orders/" + orderId + "/products.json").Result;
                    //result = response.Content.ReadAsStringAsync().Result;
                    try
                    {
                        string orderId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderId)).ToString();
                        string customerId = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderCustomerId)).ToString();
                        DateTime temp = Convert.ToDateTime(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.OrderDate)).ToString());
                        string _OrderProductIdName = extractor.Rules.Fields.GetName(FieldName.OrderProductId);
                        string _OrderQuantityName = extractor.Rules.Fields.GetName(FieldName.OrderQuantity);

                        queryResult = extractor.GetQueryResponse(group, "orders/" + orderId + "/products.json");
                        JArray Products = JArray.Parse(queryResult);
                        foreach (JObject product in Products)
                        {
                            Sale s = new Sale();

                            s.ProductID = product.SelectToken(_OrderProductIdName).ToString();
                            s.Quantity = product.SelectToken(_OrderQuantityName).ToString();
                            s.OrderID = orderId;
                            s.CustomerID = customerId;
                            s.Date = temp.ToShortDateString();

                            sales.AddSale(s);
                        }
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.Customers:
                    //{
                    //  "id": 1,
                    //  "company": "",
                    //  "first_name": "Random ",
                    //  "last_name": "Joe Bob",
                    //  "email": "*****@*****.**",
                    //  "phone": "252-101-2010",
                    //  "date_created": "Tue, 13 Nov 2012 21:16:41 +0000",
                    //  "date_modified": "Tue, 13 Nov 2012 21:16:41 +0000",
                    //  "store_credit": "0.0000",
                    //  "registration_ip_address": "50.58.18.2",
                    //  "customer_group_id": 0,
                    //  "notes": "",
                    //  "tax_exempt_category": "",
                    //  "addresses": {
                    //    "url": "https://store-bwvr466.mybigcommerce.com/api/v2/customers/1/addresses.json",
                    //    "resource": "/customers/1/addresses"
                    //  }
                    //},
                    Customer c = new Customer();
                    try
                    {
                        //  {
                        //  "id": 1,
                        //  "customer_id": 10,
                        //  "first_name": "Trisha",
                        //  "last_name": "McLaughlin",
                        //  "company": "",
                        //  "street_1": "12345 W Anderson Ln",
                        //  "street_2": "",
                        //  "city": "Austin",
                        //  "state": "Texas",
                        //  "zip": "78757",
                        //  "country": "United States",
                        //  "country_iso2": "US",
                        //  "phone": ""
                        //}
                        //response = client.GetAsync("customers/" + customerId + "/addresses.json").Result;
                        //result = response.Content.ReadAsStringAsync().Result;
                        c.CustomerID = entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.CustomerId)).ToString();
                        c.Email = entity.SelectToken("email").ToString();
                        c.Name = entity.SelectToken("first_name").ToString() + " " + entity.SelectToken("last_name").ToString();
                        // retrieve addresses for this customer and use the first one
                        queryResult = extractor.GetQueryResponse(group, "customers/" + c.CustomerID + "/addresses.json");
                        if (queryResult != "")
                        {
                            JArray Addresses = JArray.Parse(queryResult);
                            JObject firstAddress = (JObject)Addresses[0];

                            c.Address = firstAddress.SelectToken("street_1").ToString() + "\n" + firstAddress.SelectToken("street_2").ToString();
                            c.City = firstAddress.SelectToken("city").ToString();
                            c.State = firstAddress.SelectToken("state").ToString();
                            c.PostalCode = firstAddress.SelectToken("zip").ToString();
                            c.Country = firstAddress.SelectToken("country").ToString();
                            c.Phone = firstAddress.SelectToken("phone").ToString();
                        }
                        c.Gender = "";
                        c.Birthday = "";
                        c.AgeRange = "";
                        c.AlternativeIDs = "";
                        c.DoNotTrack = "";
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    customers.AddCustomer(c);
                    break;
                case DataGroup.Custom:
                    //{
                    //  "id": 1,
                    //  "product_id": 30,
                    //  "name": "Toy manufactured in",
                    //  "text": "USA"
                    //}
                    try
                    {
                        customfields.AddCustomField(entity.SelectToken("product_id").ToString(), entity.SelectToken("name").ToString(), entity.SelectToken("text").ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.Options:
                    //    "url": "https://store-bwvr466.mybigcommerce.com/api/v2/products/rules.json",
                    //{
                    //      "id":120,
                    //      "product_id":61
                    //      "price_adjuster":{"adjuster":"absolute","adjuster_value":13.99},"
                    //},
                    try
                    {
                        if (entity.SelectToken("price_adjuster").ToString() != "")
                            options.AddOption(entity.SelectToken("id").ToString(), entity.SelectToken("product_id").ToString(), entity.SelectToken("price_adjuster.adjuster_value").ToString(), entity.SelectToken("price_adjuster.adjuster").ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.CategoryNames:
                    // {
                    //  "id": 1,
                    //  "parent_id": 0,
                    //  "name": "Shop Mac",
                    //  "description": "",
                    //  "sort_order": 0,
                    //  "page_title": "",
                    //  "meta_keywords": "",
                    //  "meta_description": "",
                    //  "layout_file": "category.html",
                    //  "parent_category_list": [
                    //    1
                    //  ],
                    //  "image_file": "",
                    //  "is_visible": true,
                    //  "search_keywords": "",
                    //  "url": "/shop-mac/"
                    //}
                    try
                    {
                        categories.AddCategory(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameId)).ToString(), entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att1NameName)).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.ManufacturerNames:
                    //{
                    //  "id": 1,
                    //  "name": "Apple",
                    //  "page_title": "",
                    //  "meta_keywords": "",
                    //  "meta_description": "",
                    //  "image_file": "",
                    //  "search_keywords": ""
                    //},
                    try
                    {
                        brands.AddBrand(entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att2NameId)).ToString(), entity.SelectToken(extractor.Rules.Fields.GetName(FieldName.Att2NameName)).ToString());
                    }
                    catch (RuntimeBinderException e)
                    {
                        //throw;
                    }
                    break;
                case DataGroup.DepartmentNames:
                case DataGroup.All:
                    break;
                default:
                    throw new ArgumentOutOfRangeException("group");
            }
        }
Beispiel #50
0
 public static extern TwainResult DsCapability([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] TwainCapability capa);
Beispiel #51
0
 public static extern TwainResult DsEvent([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, ref Event evt);
        private void SetGetParameters(DataGroup group, string groupIdentifier, int pageSize, string minModSpecifier, string maxModSpecifier, ref string startdate, ref string enddate, ref string rowrange, out int firstPage, out int rowStart, out int lastPage, out int rowEnd, out string taretGetString)
        {
            // initialize count get string
            string countUrl = string.Format("{0}/count.json", groupIdentifier);

            // handle date range
            string dateRange = "";
            if (startdate != "" && enddate != "")
            {
                DateTime startTime = Convert.ToDateTime(startdate);
                DateTime endTime = Convert.ToDateTime(enddate);
                string bt = Rfc822DateTime.ToString(startTime.ToUniversalTime()).Replace("Z", "-0700").Trim();
                string et = Rfc822DateTime.ToString(endTime.ToUniversalTime()).Replace("Z", "-0700").Trim();
                dateRange = string.Format("{0}={1}&{2}={3}", minModSpecifier, startdate, maxModSpecifier, enddate);
                countUrl += "?" + dateRange;
            }

            // get entity and page counts
            int entityCount = 0;
            queryResult = extractor.GetQueryResponse(group, countUrl);
            //HttpResponseMessage response = client.GetAsync(countUrl).Result;
            //if (response.IsSuccessStatusCode)
            if (queryResult != "")
            {
                //string result = response.Content.ReadAsStringAsync().Result;
                var jObj = JObject.Parse(queryResult);
                var token = jObj.SelectToken("count");
                entityCount = (int)token;
            }
            int pageCount = (int)Math.Ceiling((double)entityCount / pageSize);
            firstPage = 0;
            lastPage = pageCount - 1;

            // handle row range
            rowStart = 0;
            rowEnd = 0;
            if (rowrange != "")
            {
                string[] rows = rowrange.Split(',');
                rowStart = int.Parse(rows[0]);
                int numberOfRows = int.Parse(rows[1]);
                // check for legal row specifications
                if (rowStart < 0 || numberOfRows <= 0)
                    rowrange = "";
                else
                {
                    // estabblish start and end page
                    rowEnd = rowStart + numberOfRows - 1;
                    // check for legal rowEnd
                    if (rowEnd > entityCount - 1)
                        rowEnd = entityCount - 1;
                    firstPage = rowStart / pageSize;
                    lastPage = rowEnd / pageSize;
                    // check for legal start and end page
                    if (firstPage > pageCount - 1)
                        lastPage = -1;
                    else if (lastPage > pageCount - 1)
                        lastPage = pageCount - 1;
                }
            }

            // set target get string
            if (dateRange != "")
                dateRange += "&";
            taretGetString = string.Format("{0}.json?limit={1}&{2}", groupIdentifier, pageSize, dateRange);
        }
Beispiel #53
0
 public static extern TwainResult DsImageLayout([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] ImageLayout imglyt);
        public override void GetFeedData(out List<List<string>> data, DataGroup group, DateTime exportDate, int firstRow = 1, int maxRows = 0, string extraFields = "")
        {
            var range = "";
            if (maxRows > 0)
                range = string.Format("{0},{1}", firstRow, maxRows);
            var queryParams = GetQueryParams(group, exportDate, range, extraFields);

            string DateRange = FindValueAsNonNullString(queryParams, "DateRange");
            string RowRange = FindValueAsNonNullString(queryParams, "RowRange");
            string startdate = "";
            string enddate = "";
            if (DateRange != "")
            {
                string[] dates = DateRange.Split(',');
                startdate = dates[0];
                enddate = dates[1];
            }
            adaptor.InitializeGroupData(group, extraFields);
            adaptor.GetGroupData(group, startdate, enddate, RowRange);
            data = adaptor.ReturnGroupData(group);
        }
Beispiel #55
0
 public static extern TwainResult DsmIdentity([In, Out] Identity origin, IntPtr zeroPtr, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] Identity idds);
        private void DetectDisturbances(DataGroup dataGroup, VICycleDataGroup viCycleDataGroup)
        {
            List<Range<int>> aPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VA?.RMS));
            List<Range<int>> bPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VB?.RMS));
            List<Range<int>> cPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VC?.RMS));
            List<Range<int>> abPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VAB?.RMS));
            List<Range<int>> bcPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VBC?.RMS));
            List<Range<int>> caPhaseDisturbanceRanges = DetectDisturbanceRanges(ToPerUnit(viCycleDataGroup.VCA?.RMS));

            List<Disturbance> disturbanceList = aPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VA?.RMS, range, Phase.AN))
                .Concat(bPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VB?.RMS, range, Phase.BN)))
                .Concat(cPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VC?.RMS, range, Phase.CN)))
                .Concat(abPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VAB?.RMS, range, Phase.AB)))
                .Concat(bcPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VBC?.RMS, range, Phase.BC)))
                .Concat(caPhaseDisturbanceRanges.Select(range => ToDisturbance(viCycleDataGroup.VCA?.RMS, range, Phase.CA)))
                .ToList();

            IEnumerable<Range<int>> allDisturbanceRanges = aPhaseDisturbanceRanges
                .Concat(bPhaseDisturbanceRanges)
                .Concat(cPhaseDisturbanceRanges)
                .Concat(abPhaseDisturbanceRanges)
                .Concat(bcPhaseDisturbanceRanges)
                .Concat(caPhaseDisturbanceRanges);

            IEnumerable<Disturbance> worstDisturbances = Range<int>.MergeAllOverlapping(allDisturbanceRanges)
                .Select(range =>
                {
                    Disturbance worst = null;

                    foreach (Disturbance disturbance in disturbanceList.Where(disturbance => ToRange(disturbance).Overlaps(range)))
                    {
                        if ((object)worst == null || m_isMoreSevere(disturbance.PerUnitMagnitude, worst.PerUnitMagnitude))
                            worst = disturbance;
                    }

                    worst = worst.Clone();
                    worst.Phase = Phase.Worst;
                    return worst;
                });

            disturbanceList.AddRange(worstDisturbances);
            m_disturbances.Add(dataGroup, disturbanceList);
        }
Beispiel #57
0
 public static extern TwainResult DsPendingTransfer([In, Out] Identity origin, [In] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, [In, Out] PendingXfers pxfr);
 public TrajectoryMandelbrotDrawer(String uniqueId, String title, String imagePath, Color color, Trajectory trajectory, int iters, DataGroup group)
     : base(uniqueId, title, imagePath, color, trajectory, iters, group, 3)
 {
 }
Beispiel #59
0
 public static extern TwainResult DsUserInterface([In, Out] Identity origin, [In, Out] Identity dest, DataGroup dg, DataArgumentType dat, Message msg, UserInterface ui);
 public StaticMandelbrotDrawer(String uniqueId, String title, String imagePath, Color color, float rCenter, float iCenter, float width, int iters, DataGroup group)
     : base(uniqueId, title, imagePath, color, new StaticTrajectory(rCenter, iCenter, width), iters, group)
 {
 }