public void TestWithTwoTargets()
        {
            var target = new CompositeTarget("MyName");

            target.Targets.Add(new TestTarget());
            target.Targets.Add(new TestTarget());

            target.Enqueue(new LogEntry());

            Assert.NotEmpty(((TestTarget)target.Targets.First()).Entries);
            Assert.NotEmpty(((TestTarget)target.Targets.Last()).Entries);
        }
        public void TestWithFilterOn()
        {
            var target     = new CompositeTarget("MyName");
            var testTarget = new TestTarget();

            target.Targets.Add(testTarget);
            var filter = new TestPostFilter {
                CanLogResult = false
            };

            target.AddFilter(filter);

            target.Enqueue(new LogEntry());

            Assert.Empty(testTarget.Entries);
        }
        public void TestWithTwoTargetsAndActiveFilter()
        {
            var target = new CompositeTarget("MyName");

            target.Targets.Add(new TestTarget());
            target.Targets.Add(new TestTarget());
            var filter = new TestPostFilter {
                CanLogResult = false
            };

            target.AddFilter(filter);

            target.Enqueue(new LogEntry());

            Assert.Empty(((TestTarget)target.Targets.First()).Entries);
            Assert.Empty(((TestTarget)target.Targets.Last()).Entries);
        }
예제 #4
0
        // This processes a single line for AREA files
        // TODO: since this saves 1 line at a time to SQL, we should set up NH to use batches
        /// <summary>
        /// This processes a single line for AREA files.
        /// </summary>
        /// <param name="inputLine">The input line.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">
        /// Empty line !
        /// or
        /// Measure code length can't must be greater than zero
        /// or
        /// Unexpected token [TOTAL]
        /// </exception>
        public bool LineFunction(string inputLine)
        {
            if (string.IsNullOrEmpty(inputLine))
            {
                throw new Exception("Empty line !");
            }

            var cols = inputLine.Split(new[] { "," }, StringSplitOptions.None);

            var measureCode = cols[0].Trim()    // Added to handle changes in measure names.
                              .Replace("IQI Cond", "IQI 91")
                              .Replace("IQI Proc", "IQI 90")
                              .Replace("PSI Comp", "PSI 90");

            if (string.IsNullOrEmpty(measureCode))
            {
                throw new Exception("Measure code length can't must be greater than zero");
            }

            var stratId = cols[1].Trim();

            if (stratId.Length < 0 || stratId.Equals("TOTAL"))
            {
                throw new Exception("Unexpected token [TOTAL]");
            }
            var compositeTarget = new CompositeTarget
            {
                Dataset            = DataContextObject.DatasetItem,
                MeasureCode        = measureCode,
                LocalHospitalID    = stratId,
                ObservedRate       = GetDecimalFromString(cols[5]),
                RiskAdjustedRate   = GetDecimalFromString(cols[2]),
                RiskAdjustedCILow  = GetDecimalFromString(cols[6]),
                RiskAdjustedCIHigh = GetDecimalFromString(cols[7]),
                ExpectedRate       = GetDecimalFromString(cols[3]),
                StandardErr        = GetDecimalFromString(cols[4])
            };

            if (AnyHospital <CompositeTarget>(measureCode, stratId, compositeTarget.Dataset.Id))
            {
                return(false);
            }

            Insert(compositeTarget);
            return(true);
        }