Exemple #1
0
 public ReliableConnection(IConnectionFactory connectionFactory, ITimer timer, IWaiter waiter, IAggregator aggregator)
 {
     this.connectionFactory = connectionFactory;
     this.timer = timer;
     this.waiter = waiter;
     this.aggregator = aggregator;
     token = tokenSource.Token;
     timer.Callback += BlockingConnect;
 }
        public SearchService(IScraper[] scrapers, IAggregator aggregator)
        {
            if (scrapers == null)
            {
                throw new ArgumentNullException("scrapers");
            }
            if (aggregator == null)
            {
                throw new ArgumentNullException("aggregator");
            }

            this._aggregator = aggregator;
            this._scrapers = scrapers;
        }
        public static void AddAggregator(IDataPublisher publisher, 
            IAggregator<double, double> agg, 
            Action<double, string> act, int symbolId)
        {
            eventAsObservable = from update in  Observable.FromEvent<OnFeedReceived, Feed>(
                mktH => publisher.FeedArrived += mktH,
                mktH => publisher.FeedArrived -= mktH
                ).Where((feed) => feed.SymbolId == symbolId)
                                    select update.LTP;

            //aggregates and yields results.
            subs = eventAsObservable
                .Scan<double, double>(0,
                (acc, currentValue) =>
                {
                    return agg.Aggregate(currentValue);
                }).Subscribe((state) => act(state, Constants.REDIS_MVA_ROOM_PREFIX + symbolId));
        }
Exemple #4
0
        public AverageAggregator(IAggregator sumAggregator, Expression<object> avgExpression, ParameterBinding sumParameter, ParameterBinding countParameter)
        {
            if (sumAggregator == null)
                throw ExceptionBuilder.ArgumentNull("sumAggregator");

            if (avgExpression == null)
                throw ExceptionBuilder.ArgumentNull("avgExpression");

            if (sumParameter == null)
                throw ExceptionBuilder.ArgumentNull("sumParam");

            if (countParameter == null)
                throw ExceptionBuilder.ArgumentNull("countParam");

            _sumAggregator = sumAggregator;
            _avgExpression = avgExpression;
            _returnType = avgExpression.Resolve();
            _sumParameter = sumParameter;
            _countParameter = countParameter;
        }
 /// <summary>
 /// Use this constructor for set one of two servers and set token directly.
 /// </summary>
 /// <param name="server"><see cref="Servers"/></param>
 /// <param name="token">API-token.</param>
 public TradingAdapter(Servers?server, string token)
 {
     Account = new Aggregator(server, token);
     Init();
 }
 public HomeController(IAggregator aggregator)
 {
     if (aggregator == null) throw new ArgumentNullException("aggregator");
     this.aggregator = aggregator;
 }
Exemple #7
0
        /// <inheritdoc/>
        public void Scan(IAggregator aggregator, Dictionary <string, PackageDeclaration> output)
        {
            if (aggregator == null || aggregator.RootPath == null)
            {
                throw new ArgumentNullException($"{nameof(aggregator)} or one of its property must not be null.");
            }

            if (output == null)
            {
                throw new ArgumentNullException($"{nameof(output)} must not be null.");
            }

            var nugetFiles = Directory.EnumerateFiles(
                aggregator.RootPath,
                "*.nuspec",
                SearchOption.AllDirectories).ToArray();

            var xmlNsResolver = new NsResolver(
                new Dictionary <string, string>()
            {
                { "n", "http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" },
            });

            foreach (var nugetFile in nugetFiles)
            {
                var nuspecFileName = Path.GetFileNameWithoutExtension(nugetFile);
                var nugetName      = nuspecFileName;

                using var nugetFileStream = File.OpenRead(nugetFile);
                using var xmlReader       = XmlReader.Create(nugetFileStream);
                var xmlProj = XDocument.Load(xmlReader);

                var packageId = xmlProj.XPathSelectElements(
                    "/n:package/n:metadata/n:id",
                    xmlNsResolver)
                                .SingleOrDefault();

                if (packageId != null)
                {
                    nugetName = packageId.Value;
                }

                // match with the project name
                var prj = aggregator.AllProjects.Where(p => p.Name == nugetName || p.Name == nuspecFileName).FirstOrDefault();
                if (prj != null && !output.ContainsKey(nugetName))
                {
                    var version = xmlProj.XPathSelectElements(
                        "/n:package/n:metadata/n:version",
                        xmlNsResolver)
                                  .SingleOrDefault();

                    output.Add(nugetName, new PackageDeclaration(nugetFile, nugetName, version?.Value, new[] { prj }));
                }
                else
                {
                    // Scan files elements.
                    var fileElements = xmlProj.XPathSelectElements(
                        "/n:package/n:files/n:file",
                        xmlNsResolver);

                    var projects = new List <Project>();

                    foreach (var fileElement in fileElements)
                    {
                        var srcAttribute    = fileElement.Attributes().SingleOrDefault(a => a.Name.LocalName == "src");
                        var targetAttribute = fileElement.Attributes().SingleOrDefault(a => a.Name.LocalName == "target");
                        if (srcAttribute != null && targetAttribute != null)
                        {
                            var src    = srcAttribute.Value;
                            var target = targetAttribute.Value;
                            if (target.StartsWith("lib", StringComparison.InvariantCultureIgnoreCase) &&
                                src.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase))
                            {
                                src = src.Replace("\\", "/", StringComparison.InvariantCulture);
                                var assemblyName = Path.GetFileNameWithoutExtension(src);
                                var assemblyPrj  = aggregator.AllProjects.Where(p => p.Name == assemblyName).FirstOrDefault();
                                if (assemblyPrj != null)
                                {
                                    projects.Add(assemblyPrj);
                                }
                            }
                        }
                    }

                    if (projects.Any() && !output.ContainsKey(nugetName))
                    {
                        var version = xmlProj.XPathSelectElements(
                            "/n:package/n:metadata/n:version",
                            xmlNsResolver)
                                      .SingleOrDefault();

                        output.Add(nugetName, new PackageDeclaration(nugetFile, nugetName, version?.Value, projects));
                    }
                }
            }
        }
 public OrderLimit(OrderSide side, decimal quantity, decimal price, Symbol symbol, IAggregator account = null, OrderDuration duration = OrderDuration.Gtc, uint leverage = 1)
     : base(OrderType.Limit, side, quantity, account, symbol, price, duration, leverage)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationRuleSetDescriptor"/> class.
 /// </summary>
 /// <param name="breakOnFirstViolation">if set to <c>true</c> the aggregation of rules is 
 /// stopped when the first violation occurs, all remaining rules are not evaluated.].</param>
 public ValidationRuleSetDescriptor(bool breakOnFirstViolation)
 {
     this.factory = new ValidationFactory();
     this.aggregator = new ValidationAggregator(this.factory, breakOnFirstViolation);
 }
Exemple #10
0
        // Will aggregate metrics for a single tag of a single template
        IEnumerable <Metric> AggregateTag(IEnumerable <Metric> metrics, IEnumerable <string> targetMetricNames, string targetTag, IAggregator aggregator)
        {
            var aggregateValues = new DefaultDictionary <AggregateMetric, IAggregator>(_ => aggregator.New());

            foreach (Metric metric in metrics)
            {
                // if metric is the aggregation target and it has a tag that should be aggregated
                if (targetMetricNames.Contains(metric.Name) && metric.Tags.ContainsKey(targetTag))
                {
                    var aggregateMetric = new AggregateMetric(metric, targetTag);
                    aggregateValues[aggregateMetric].PutValue(metric.Value);
                }
                else
                {
                    yield return(metric);
                }
            }

            // aggregate all and construct new metrics from result
            foreach (var aggregatePair in aggregateValues)
            {
                double aggregatedValue = aggregatePair.Value.GetAggregate();
                yield return(aggregatePair.Key.ToMetric(aggregatedValue));
            }
        }
 public AggregationQueryHandler(IAggregator <T> aggregator, EventQueryHandler inner, IDocumentSession session = null)
 {
     _aggregator = aggregator;
     _inner      = inner;
     _session    = session;
 }
 public AggregationProjection(IAggregationFinder <T> finder, IAggregator <T> aggregator)
 {
     _finder     = finder;
     _aggregator = aggregator;
 }
Exemple #13
0
 public ReliableConnection(IConnectionFactory connectionFactory, ITimer reconnectionTimer, IAggregator aggregator)
     : this(connectionFactory, reconnectionTimer, new DefaultWaiter(), aggregator)
 {
 }
 public ReadThroughResultCache(IAggregator source)
 {
     if (source == null) throw new ArgumentNullException("source");
     this.source = source;
     cache = new MemoryCache(typeof(ReadThroughResultCache).Name);
 }
        public HomeController(IAggregator aggregator)
        {
            Check.Require(aggregator != null, "aggregator may not be null");

            this.aggregator = aggregator;
        }
 /// <summary>
 /// Use this constructor if <see cref="Configuration.Server"/> and <see cref="Configuration.Token"/> are set.
 /// </summary>
 public TradingAdapter()
 {
     Account = new Aggregator();
     Init();
 }
Exemple #17
0
        private static void AggregateAllDimensionsFlat(object aggregationContext, DataBlock block, ushort itemCount, ShortSet baseWhereSet, List <List <Tuple <IExpression, ShortSet> > > allDimensionValueSets, IUntypedColumn[] columns, IAggregator aggregator)
        {
            int nextBlockRow = 0;

            int dimensionCount = allDimensionValueSets.Count;

            int currentDimension = 0;

            int[]      nextIndexPerDimension = new int[dimensionCount];
            ShortSet[] setsPerDimension      = new ShortSet[dimensionCount + 1];

            setsPerDimension[0] = baseWhereSet;
            for (int i = 1; i < setsPerDimension.Length; ++i)
            {
                setsPerDimension[i] = new ShortSet(itemCount);
            }

            object[] aggregationResults = new object[block.RowCount];

            while (currentDimension >= 0)
            {
                if (currentDimension == dimensionCount)
                {
                    // Leaf: Compute Aggregate, then ask for next combination
                    aggregationResults[nextBlockRow] = aggregator.Aggregate(aggregationContext, setsPerDimension[currentDimension], columns);
                    nextBlockRow++;
                    currentDimension--;
                }
                else if (nextIndexPerDimension[currentDimension] < allDimensionValueSets[currentDimension].Count)
                {
                    // Non-leaf, more values: Get next value and combine
                    Tuple <IExpression, ShortSet> dimensionValue = allDimensionValueSets[currentDimension][nextIndexPerDimension[currentDimension]];

                    ShortSet current = setsPerDimension[currentDimension + 1];
                    current.FromAnd(setsPerDimension[currentDimension], dimensionValue.Item2);

                    nextIndexPerDimension[currentDimension]++;
                    currentDimension++;

                    // Skip rest of range if set already empty [slower; IsEmpty too expensive]
                    if (current.IsEmpty())
                    {
                        int rowsToSkip = 1;
                        for (int i = currentDimension; i < dimensionCount; ++i)
                        {
                            rowsToSkip *= allDimensionValueSets[i].Count;
                        }

                        nextBlockRow += rowsToSkip;
                        currentDimension--;
                    }
                }
                else
                {
                    // Non-leaf, no more values: Pop up to previous dimension for next value there
                    nextIndexPerDimension[currentDimension] = 0;
                    currentDimension--;
                }
            }

            block.SetColumn(block.ColumnCount - 1, aggregationResults);
        }
        public void TestApplyConfirmations(string testConfigurationFileName)
        {
            InitThisTest(testConfigurationFileName);

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            // Ein CustomerOrderParts darf kein Kind haben und darf nicht beendet sein
            Ids customerOrderIds = new Ids();

            foreach (var demand in dbTransactionData.CustomerOrderPartGetAll())
            {
                CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand;
                customerOrderIds.Add(customerOrderPart.GetCustomerOrderId());
                Providers childs = aggregator.GetAllChildProvidersOf(customerOrderPart);
                Assert.False(childs.Any());
                Assert.False(customerOrderPart.IsFinished());
            }

            // Ein PurchaseOrderPart darf kein Elter haben und darf nicht beendet sein.
            Ids purchaseOrderIds = new Ids();

            foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll())
            {
                PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand;
                purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId());

                Assert.False(purchaseOrderPart.IsFinished());
                Demands demands = aggregator.GetAllParentDemandsOf(demand);
                Assert.True(demands == null || demands.Any() == false);
            }

            // Für jede CustomerOrder muss es mind. noch ein CustomerOrderPart geben.
            foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll())
            {
                Assert.True(customerOrderIds.Contains(customerOrder.GetId()));
            }

            // Für jede PurchaseOrder muss es mind. noch ein PurchaseOrderPart geben.
            foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll())
            {
                Assert.True(purchaseOrderIds.Contains(purchaseOrder.GetId()));
            }

            // Ein StockExchangeProvider muss mind. ein Kind haben.
            foreach (var stockExchangeProvider in dbTransactionData.StockExchangeProvidersGetAll())
            {
                Demands childs = aggregator.GetAllChildDemandsOf(stockExchangeProvider);
                Assert.True(childs.Any());
            }

            // Ein StockExchangeDemand darf nicht beendet und geschlossen sein.
            foreach (var stockExchangeDemand in dbTransactionData.StockExchangeDemandsGetAll())
            {
                bool isOpen = OpenDemandManager.IsOpen((StockExchangeDemand)stockExchangeDemand);
                Assert.False(stockExchangeDemand.IsFinished() && isOpen == false);
            }

            // Eine ProductionOrder darf nicht beendet sein und für eine ProductionOrder
            // muss es mind. eine  Operation geben.
            Ids productionOrderIds = new Ids();
            Ids operationIds       = new Ids();

            foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll())
            {
                Id productionOrderId = operation.GetProductionOrderId();
                if (productionOrderIds.Contains(productionOrderId) == false)
                {
                    productionOrderIds.Add(productionOrderId);
                }

                operationIds.Add(operation.GetId());
            }
            foreach (var provider in dbTransactionData.ProductionOrderGetAll())
            {
                ProductionOrder productionOrder = (ProductionOrder)provider;
                Assert.False(productionOrder.DetermineProductionOrderState()
                             .Equals(State.Finished));
                Assert.True(productionOrderIds.Contains(productionOrder.GetId()));
            }

            // Für jede ProductionOrderBom muss die dazugehörige Operation da sein.
            foreach (var demand in dbTransactionData.ProductionOrderBomGetAll())
            {
                ProductionOrderBom productionOrderBom = (ProductionOrderBom)demand;
                operationIds.Contains(productionOrderBom.GetProductionOrderOperationId());
            }

            // Für jeden DemandToProvider und ProviderToDemand müssen die dazugehörigen
            // Demands und Provider existieren.
            foreach (var demandToProvider in dbTransactionData.DemandToProviderGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(demandToProvider.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(demandToProvider.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }

            foreach (var providerToDemand in dbTransactionData.ProviderToDemandGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(providerToDemand.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(providerToDemand.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }
        }
Exemple #19
0
 public IteratorImpl(IAggregator <T> aggregator)
 {
     _aggregator = aggregator;
 }
Exemple #20
0
 public void UseArchiveForGetters()
 {
     _dbTransactionDataBackup = _dbTransactionData;
     _dbTransactionData       = _dbTransactionDataArchive;
     _aggregator = new Aggregator(_dbTransactionDataArchive);
 }
 private AggregateAggregateValue(IAggregator aggregator)
 {
     this.aggregator = aggregator ?? throw new ArgumentNullException(nameof(aggregator));
 }
 public INEStatisticsProvider(IINERequesterWrapper requester, IAggregator aggregator)
 {
     _requester = requester;
     _aggregator = aggregator;
 }
Exemple #23
0
        public static void CreateConfirmationsOld(SimulationInterval simulationInterval)
        {
            /*ISimulator simulator = new Simulator();
             * simulator.ProcessCurrentInterval(simulationInterval, _orderGenerator);*/
            // --> does not work correctly, use trivial impl instead

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            // stockExchanges, purchaseOrderParts, operations(use PrBom instead):
            // set in progress when startTime is within interval
            DemandOrProviders demandOrProvidersToSetInProgress = new DemandOrProviders();

            demandOrProvidersToSetInProgress.AddAll(
                aggregator.GetDemandsOrProvidersWhereStartTimeIsWithinInterval(simulationInterval,
                                                                               new DemandOrProviders(dbTransactionData.PurchaseOrderPartGetAll())));
            demandOrProvidersToSetInProgress.AddAll(
                aggregator.GetDemandsOrProvidersWhereStartTimeIsWithinInterval(simulationInterval,
                                                                               new DemandOrProviders(dbTransactionData.StockExchangeDemandsGetAll())));
            demandOrProvidersToSetInProgress.AddAll(
                aggregator.GetDemandsOrProvidersWhereStartTimeIsWithinInterval(simulationInterval,
                                                                               new DemandOrProviders(dbTransactionData.StockExchangeProvidersGetAll())));
            demandOrProvidersToSetInProgress.AddAll(
                aggregator.GetDemandsOrProvidersWhereStartTimeIsWithinInterval(simulationInterval,
                                                                               new DemandOrProviders(dbTransactionData.ProductionOrderBomGetAll())));

            foreach (var demandOrProvider in demandOrProvidersToSetInProgress)
            {
                demandOrProvider.SetInProgress();
                demandOrProvider.SetReadOnly();
            }

            // stockExchanges, purchaseOrderParts, operations(use PrBom instead):
            // set finished when endTime is within interval
            DemandOrProviders demandOrProvidersToSetFinished = new DemandOrProviders();

            demandOrProvidersToSetFinished.AddAll(
                aggregator.GetDemandsOrProvidersWhereEndTimeIsWithinIntervalOrBefore(
                    simulationInterval,
                    new DemandOrProviders(dbTransactionData.PurchaseOrderPartGetAll())));
            demandOrProvidersToSetFinished.AddAll(
                aggregator.GetDemandsOrProvidersWhereEndTimeIsWithinIntervalOrBefore(
                    simulationInterval,
                    new DemandOrProviders(dbTransactionData.StockExchangeDemandsGetAll())));
            demandOrProvidersToSetFinished.AddAll(
                aggregator.GetDemandsOrProvidersWhereEndTimeIsWithinIntervalOrBefore(
                    simulationInterval,
                    new DemandOrProviders(dbTransactionData.StockExchangeProvidersGetAll())));
            demandOrProvidersToSetFinished.AddAll(
                aggregator.GetDemandsOrProvidersWhereEndTimeIsWithinIntervalOrBefore(
                    simulationInterval,
                    new DemandOrProviders(dbTransactionData.ProductionOrderBomGetAll())));
            foreach (var demandOrProvider in demandOrProvidersToSetFinished)
            {
                demandOrProvider.SetFinished();
                demandOrProvider.SetReadOnly();
            }

            // customerOrderParts: set finished if all childs are finished
            DemandToProviderGraph demandToProviderGraph = new DemandToProviderGraph();
            INodes rootNodes = demandToProviderGraph.GetRootNodes();

            foreach (var rootNode in rootNodes)
            {
                if (rootNode.GetEntity().GetType() == typeof(CustomerOrderPart))
                {
                    CustomerOrderPart customerOrderPart = (CustomerOrderPart)rootNode.GetEntity();
                    customerOrderPart.SetReadOnly();

                    bool allChildsAreFinished = true;
                    foreach (var stockExchangeProvider in aggregator.GetAllChildProvidersOf(
                                 customerOrderPart))
                    {
                        if (stockExchangeProvider.IsFinished() == false)
                        {
                            allChildsAreFinished = false;
                            break;
                        }
                    }

                    if (allChildsAreFinished)
                    {
                        customerOrderPart.SetFinished();
                    }
                }
            }

            // set operations readonly
            foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll())
            {
                operation.SetReadOnly();
            }

            // set productionOrders readonly
            foreach (var productionOrder in dbTransactionData.ProductionOrderGetAll())
            {
                productionOrder.SetReadOnly();
            }

            // future SEs are still not readonly, set it so
            foreach (var stockExchangeDemand in dbTransactionData.StockExchangeDemandsGetAll())
            {
                stockExchangeDemand.SetReadOnly();
            }

            foreach (var stockExchangeProvider in dbTransactionData.StockExchangeProvidersGetAll())
            {
                stockExchangeProvider.SetReadOnly();
            }
        }
 public AggregationEndpoint(IAggregator aggregator)
 {
     _aggregator = aggregator;
 }
 public KStreamAggregate(string storeName, Initializer <T> initializer, IAggregator <K, V, T> aggregator)
 {
     this.storeName   = storeName;
     this.initializer = initializer;
     this.aggregator  = aggregator;
 }
 public void Init()
 {
     _impl = UserDefinedAggregates.BitwiseOr();
 }
Exemple #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValidationRuleSetDescriptor"/> class.
 /// </summary>
 /// <param name="breakOnFirstViolation">if set to <c>true</c> the aggregation of rules is
 /// stopped when the first violation occurs, all remaining rules are not evaluated.].</param>
 public ValidationRuleSetDescriptor(bool breakOnFirstViolation)
 {
     this.factory    = new ValidationFactory();
     this.aggregator = new ValidationAggregator(this.factory, breakOnFirstViolation);
 }
 public void Init()
 {
     _impl = UserDefinedAggregates.Average();
 }
 /// <summary>
 /// Use this constructor for set hostName and token directly.
 /// </summary>
 /// <param name="hostName">Address of exchange without prefix.</param>
 /// <param name="token">API-token.</param>
 /// <param name="secureConnection">Use (true) ssh or not (false).</param>
 public TradingAdapter(string hostName, string token, bool secureConnection)
 {
     Account = new Aggregator(hostName, token, secureConnection);
     Init();
 }
 public void Init()
 {
     _impl = UserDefinedAggregates.StrConcat();
 }
 /// <summary>
 /// Use this constructor for set token directly and if <see cref="Configuration.Server"/> is set.
 /// </summary>
 /// <param name="token">API-token.</param>
 public TradingAdapter(string token)
 {
     Account = new Aggregator(token);
     Init();
 }
 /* ----------------------------------------------------------------- */
 ///
 /// Get
 ///
 /// <summary>
 /// Casts the specified object to the EventAggregator class.
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 public static EventAggregator Get(this IAggregator src) => src as EventAggregator;
 public TradingAdapter(IAggregator account)
 {
     Account = account;
     Init();
 }
Exemple #34
0
 private bool matchAll(object[] key, IAggregator entry)
 {
     return(true);
 }
 public AggregationEndpoint(IAggregator aggregator)
 {
     _aggregator = aggregator;
 }
Exemple #36
0
 public SetSourceMetric(string parentName, string key, string name, IPullable <float> source, string unit, TimeDomain domain, IAggregator <float> aggregator = null) : base(parentName, key, name, source, unit, domain)
 {
     if (aggregator == null)
     {
         this.aggregator = new AverageAggregator();
     }
     else
     {
         this.aggregator = aggregator;
     }
 }
Exemple #37
0
 public void AddAggregator <T>(IAggregator <T> aggregator) where T : class, new()
 {
     Options.Storage.MappingFor(typeof(T));
     _aggregates.Swap(a => a.AddOrUpdate(typeof(T), aggregator));
 }
Exemple #38
0
 public OlapCube Aggregate(IAggregator aggregator, string title = "")
 {
     Aggregators.Add(aggregator);
     ValueTitles.Add(title);
     return(this);
 }
Exemple #39
0
 /* ----------------------------------------------------------------- */
 ///
 /// GetEvents
 ///
 /// <summary>
 /// Aggregator で定義されているイベント群にアクセス可能な
 /// オブジェクトを取得します。
 /// </summary>
 ///
 /// <param name="src">イベント集約オブジェクト</param>
 ///
 /// <returns>Aggregator オブジェクト</returns>
 ///
 /* ----------------------------------------------------------------- */
 public static Aggregator GetEvents(this IAggregator src) => src as Aggregator;
        private static void ArchiveDemandOrProvider(IDemandOrProvider demandOrProvider,
                                                    IDbTransactionData dbTransactionData, IAggregator aggregator, bool includeArrows)
        {
            if (demandOrProvider == null)
            {
                throw new MrpRunException("Given demandOrProvider cannot be null.");
            }

            IDbTransactionData dbTransactionDataArchive =
                ZppConfiguration.CacheManager.GetDbTransactionDataArchive();

            if (includeArrows)
            {
                ArchiveArrowsToAndFrom(demandOrProvider, dbTransactionData,
                                       dbTransactionDataArchive, aggregator);
            }

            dbTransactionDataArchive.AddA(demandOrProvider);
            dbTransactionData.DeleteA(demandOrProvider);
        }
 public TradingAlgorithm(IAggregator account)
     : base(account)
 {
 }
        /**
         * Subgraph of a productionOrder includes:
         * - parent (StockExchangeDemand) if includeStockExchanges true
         * - childs (ProductionOrderBoms)
         * - childs of childs (StockExchangeProvider) if includeStockExchanges true
         */
        private static List <IDemandOrProvider> CreateProductionOrderSubGraph(
            bool includeStockExchanges, ProductionOrder productionOrder, IAggregator aggregator)
        {
            List <IDemandOrProvider> demandOrProvidersOfProductionOrderSubGraph =
                new List <IDemandOrProvider>();

            demandOrProvidersOfProductionOrderSubGraph.Add(productionOrder);

            if (includeStockExchanges)
            {
                Demands stockExchangeDemands = aggregator.GetAllParentDemandsOf(productionOrder);
                if (stockExchangeDemands.Count() > 1)
                {
                    throw new MrpRunException(
                              "A productionOrder can only have one parentDemand (stockExchangeDemand).");
                }

                demandOrProvidersOfProductionOrderSubGraph.AddRange(stockExchangeDemands);
                foreach (var stockExchangeDemand in stockExchangeDemands)
                {
                    Providers parentStockExchangeProviders =
                        aggregator.GetAllParentProvidersOf(stockExchangeDemand);

                    foreach (var parentStockExchangeProvider in parentStockExchangeProviders)
                    {
                        if (aggregator.GetAllChildDemandsOf(parentStockExchangeProvider).Count() ==
                            1)
                        {
                            demandOrProvidersOfProductionOrderSubGraph.Add(
                                parentStockExchangeProvider);
                        }
                        else
                        {
                            // stockExchangeProvider must stay
                        }
                    }
                }
            }

            Demands productionOrderBoms = aggregator.GetAllChildDemandsOf(productionOrder);

            demandOrProvidersOfProductionOrderSubGraph.AddRange(productionOrderBoms);

            if (includeStockExchanges)
            {
                foreach (var productionOrderBom in productionOrderBoms)
                {
                    Providers stockExchangeProvider =
                        aggregator.GetAllChildProvidersOf(productionOrderBom);
                    if (stockExchangeProvider.Count() > 1)
                    {
                        throw new MrpRunException(
                                  "A ProductionOrderBom can only have one childProvider (stockExchangeProvider).");
                    }

                    demandOrProvidersOfProductionOrderSubGraph.AddRange(stockExchangeProvider);
                }
            }

            return(demandOrProvidersOfProductionOrderSubGraph);
        }
Exemple #43
0
 /// <summary>
 /// Constructor to initialize instance of class.
 /// </summary>
 /// <param name="aggregator">instance of IAggregator</param>
 /// <param name="classType">Class data type</param>
 public AggregatorCombiner(IAggregator aggregator, Type classType)
 {
     _aggregator   = aggregator;
     _classType    = classType;
     _combinerList = new ArrayList();
 }
        private static void ArchiveOperations(IDbTransactionData dbTransactionData,
                                              IDbTransactionData dbTransactionDataArchive, IAggregator aggregator,
                                              ProductionOrder productionOrder)
        {
            List <ProductionOrderOperation> operations =
                aggregator.GetProductionOrderOperationsOfProductionOrder(productionOrder);

            dbTransactionDataArchive.ProductionOrderOperationAddAll(operations);
            dbTransactionData.ProductionOrderOperationDeleteAll(operations);
        }