Beispiel #1
0
        /// <summary>
        /// Ajoute tous les compteurs à la collection.
        /// </summary>
        /// <param name="moduleKey">Clef de module.</param>
        /// <param name="counterDataList">Listes des compteurs.</param>
        void ICube.ExportCounters(object moduleKey, ICollection <CounterData> counterDataList)
        {
            if (counterDataList == null)
            {
                throw new ArgumentNullException("counterDataList");
            }

            CounterData counterData;

            if (_timeCounter != null)
            {
                counterData           = new CounterData();
                counterData.ModuleKey = moduleKey;
                Cube.InitCounterData(_timeCounter, counterData, _key, _databaseName);
                counterDataList.Add(counterData);
            }

            foreach (string code in _counters.Keys)
            {
                ExternalCounter counter = _counters[code];

                counterData             = new CounterData();
                counterData.ModuleKey   = moduleKey;
                counterData.CounterCode = code;
                Cube.InitCounterData(counter, counterData, _key, _databaseName);

                counterDataList.Add(counterData);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Ajoute un compteur au cube.
        /// </summary>
        /// <param name="counter">Données.</param>
        internal void AddCounter(CounterData counter)
        {
            if (counter.StartDate < _firstHit)
            {
                _firstHit = counter.StartDate;
            }

            string counterCode = counter.CounterCode;

            if (counterCode == null)
            {
                if (_timeCounter == null)
                {
                    _timeCounter = new ExternalCounter(this, counter);
                }
                else
                {
                    _timeCounter.Merge(counter);
                }
            }
            else
            {
                ExternalCounter externalCounter;
                if (_counters.TryGetValue(counterCode, out externalCounter))
                {
                    externalCounter.Merge(counter);
                }
                else
                {
                    _counters[counterCode] = new ExternalCounter(this, counter);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Ajoute un compteur.
        /// </summary>
        /// <param name="counter">Compteur.</param>
        /// <param name="mergeTimeAxis">Indique si l'axe de temps doit être mergé.</param>
        /// <param name="mergeDate">Date à utiliser pour le merge.</param>
        internal void AddCounter(CounterData counter, bool mergeTimeAxis, DateTime mergeDate)
        {
            // Alimentation du dictionnaire des axes.
            string axis = counter.Axis;

            if (!_axis.ContainsKey(axis))
            {
                _axis.Add(axis, null);
            }

            if (_counters == null)
            {
                // Alimentation de la base de données des compteurs.
                string counterCode = counter.CounterCode;
                if (counterCode != null && !_counterDefinitions.ContainsKey(counterCode))
                {
                    _counterDefinitions.Add(
                        counterCode,
                        new CounterDefinition(counterCode, counter.CounterLabel, 1, 0, 0));
                }
            }

            // Alimentation du cube de données.
            DateTime startDate = mergeTimeAxis ? mergeDate : counter.StartDate;
            CubeKey  key       = new CubeKey(startDate, axis, TimeLevel.ValueOf(counter.Level));
            ICube    cube;

            if (!_cubes.TryGetValue(key, out cube))
            {
                cube = new ExternalCube(_name, key);
                _cubes.Add(key, cube);
            }

            ((ExternalCube)cube).AddCounter(counter);
        }
Beispiel #4
0
        /// <summary>
        /// Crée un nouveau compteur.
        /// </summary>
        /// <param name="cube">Cube contenant le compteur.</param>
        /// <param name="counter">Données du compteur.</param>
        internal ExternalCounter(ExternalCube cube, CounterData counter)
        {
            _counter = counter;
            _cube    = cube;

            // Indexation de l'échantillonnage.
            _sampleData = new Dictionary <double, CounterSampleData>();
            foreach (CounterSampleData data in counter.Sample)
            {
                _sampleData[data.SampleValue] = data;
            }
        }
Beispiel #5
0
        /// <summary>
        /// Merge les données d'un compteur avec le compteur courant.
        /// </summary>
        /// <param name="counter">Compteur à merger.</param>
        internal void Merge(CounterData counter)
        {
            if (counter.StartDate > _counter.StartDate)
            {
                _counter.StartDate = counter.StartDate;
                _counter.Last      = counter.Last;
            }

            if (_counter.Min > counter.Min)
            {
                _counter.Min     = counter.Min;
                _counter.MinName = counter.MinName;
            }

            if (_counter.Max < counter.Max)
            {
                _counter.Max     = counter.Max;
                _counter.MaxName = counter.MaxName;
            }

            _counter.Total          += counter.Total;
            _counter.TotalOfSquares += counter.TotalOfSquares;
            _counter.Hits           += counter.Hits;

            // Indexation des données d'échantillonnage.
            foreach (CounterSampleData data in counter.Sample)
            {
                CounterSampleData existingData;
                if (_sampleData.TryGetValue(data.SampleValue, out existingData))
                {
                    existingData.SampleCount += data.SampleCount;
                }
                else
                {
                    _sampleData[data.SampleValue] = data;
                }
            }
        }