Exemplo n.º 1
0
        public double?GetFillRate(TaxonomyInfo taxonomy, Attribute attribute, Filter filter)
        {
            var fillRateObject = FillRates.FirstOrDefault(fr => fr.Taxonomy.Equals(taxonomy));

            if (fillRateObject == null)
            {
                fillRateObject = new FillRate(taxonomy, null, null, FillRate.DataState.Active, DateTime.Now);
                FillRates.Add(fillRateObject);
                if (UseBackgroundWorker)
                {
                    EnqueWork(fillRateObject, attribute, filter);
                    return(double.MinValue);
                }
            }

            double?fillRateValue = fillRateObject.TryGetFillRate(attribute, filter);

            if (fillRateValue == null)
            {
                if (UseBackgroundWorker)
                {
                    EnqueWork(fillRateObject, attribute, filter);
                    return(double.MinValue);
                }
                fillRateValue = fillRateObject.FetchFillRate(attribute, filter);
            }

            if (double.IsNaN((double)fillRateValue))
            {
                return(null);
            }

            //return string.Format("{0:0.00}", fillRateValue);
            return(Math.Round((double)fillRateValue, 2));
        }
Exemplo n.º 2
0
 private void EnqueWork(FillRate fillRate, Attribute attribute, Filter filter)
 {
     lock (CalculateFillRateQueue)
     {
         CalculateFillRateQueue.Enqueue(new FillRateWorkUnit(fillRate, attribute, filter));
         if (CalculateFillRateQueue.Count == 1)
         {
             Monitor.PulseAll(CalculateFillRateQueue);
         }
     }
 }
Exemplo n.º 3
0
 public FillRateWorkUnit(FillRate fillRate, Attribute attribute, Filter filter)
 {
     FillRateUnit  = fillRate;
     AttributeUnit = attribute;
     FilterUnit    = filter;
 }