Exemple #1
0
            public decimal ConsumptionforInterval(ulong start, ulong end, string index)
            {
                var dic = Consumables.ToDictionary(consumable => consumable.Key, consumable => consumable.Value);
                var f   = SourceTableOrdered.Where(t => t.ProductType == ResultId && t.Start > start && t.Start < end);

                if (!f.Any())
                {
                    return(0);
                }

                var allNodes = new HashSet <ModelNode>();

                //Direct
                decimal result = 0;

                foreach (var pair in Nodes)
                {
                    var sumTime = f.Where(t => t.ModelNode == pair.Key.ResourceModel.ProcessName).Sum(t => t.Total, null);
                    var count   = f.Count(t => t.ModelNode == pair.Key.ResourceModel.ProcessName);
                    foreach (var consumption in pair.Value.State.Consumptions.Where(t => t.Consumable.Name == index))
                    {
                        if (consumption == null)
                        {
                            continue;
                        }
                        if (!consumption.AllocationPerTime)
                        {
                            result += consumption.Amount;
                        }
                        else
                        {
                            result = consumption.Amount * sumTime / count;
                        }
                    }
                }
                //Indirect
                foreach (var node in Nodes.Select(t => t.Key))
                {
                    FindAll(allNodes, node);
                }
                foreach (var node in allNodes)
                {
                    result += IndirectConsumptionFor(f, node, index);
                }
                return(result);
            }