Ejemplo n.º 1
0
        /// <summary>
        ///     Populates the given <see cref="IResultStream{TDestination}" /> with the results, from the execution of
        ///     the given <see cref="IQueryableFlowQuery" />, in a streamed fashion.
        /// </summary>
        /// <typeparam name="TSource">
        ///     The <see cref="System.Type" /> of the source entity.
        /// </typeparam>
        /// <typeparam name="TDestination">
        ///     The <see cref="System.Type" /> of the result.
        /// </typeparam>
        /// <param name="query">
        ///     The query.
        /// </param>
        /// <param name="resultStream">
        ///     The <see cref="IResultStream{TDestination}" /> to stream the results into.
        /// </param>
        public static void SelectStream <TSource, TDestination>
        (
            IQueryableFlowQuery query,
            IResultStream <TDestination> resultStream
        )
        {
            Func <object, TDestination> converter = null;

            if (query.Constructor != null)
            {
                converter = ConstructionHelper.GetObjectByExpressionConverter <TDestination>(query.Constructor);
            }

            if (converter == null)
            {
                converter = x => (TDestination)x;
            }

            var streamer = new ResultStreamer <TDestination>(resultStream, converter);

            ICriteriaBuilder criteriaBuilder = GetCriteriaBuilder(query);

            ICriteria criteria = criteriaBuilder.Build <TSource, TDestination>(query);

            criteria.List(streamer);

            resultStream.EndOfStream();
        }
        public void Should_Return_Valid_Result_Stream()
        {
            WorkRelationTerms TEST_CONTRACT_TYPE = WorkRelationTerms.WORKTERM_EMPLOYMENT_1;

            WorkHealthTerms TEST_HEALTH_TYPE = WorkHealthTerms.HEALTH_TERM_EMPLOYMENT;

            WorkSocialTerms TEST_SOCIAL_TYPE = WorkSocialTerms.SOCIAL_TERM_EMPLOYMENT;

            ITargetValues contractValues = TargetValueBuilder.CreateContractEmplTermValues(
                TEST_CONTRACT_TYPE, TEST_HEALTH_TYPE, TEST_SOCIAL_TYPE, null, null);

            ITargetValues positionValues = TargetValueBuilder.CreatePositionEmplTermValues(null, null);

            ITargetValues positionSalary = TargetValueBuilder.CreateSalaryBaseValues(10000m);

            ITargetValues emptyValues = TargetValueBuilder.CreateEmptyValues();

            ITargetStream targets = TargetStream.CreateEmptyStream().
                                    AddNewContractsTarget(ConfigSetCzArticleName.REF_CONTRACT_EMPL_TERM, contractValues, testConfig).
                                    AddNewPositionsTarget(ConfigSetCzArticleName.REF_POSITION_EMPL_TERM, positionValues, testConfig).
                                    AddTargetIntoPosition(ConfigSetCzArticleName.REF_SALARY_BASE, positionSalary, testConfig).
                                    AddTargetIntoPosition(ConfigSetCzArticleName.REF_INCOME_GROSS, emptyValues, testConfig);

            IEngineProfile testProfile = testEngine.BuildEngineProfile(testPeriod);

            IProcessService testModule = ProcessServiceModule.CreateModule(targets, testConfig, testProfile, serviceLog);

            IResultStream results = testModule.EvaluateTargetsToResults();

            serviceLog.CloseLogStream();

            Assert.AreEqual(0, results.Results().Keys.Count);
        }
 public static void LogResultStream(IProcessServiceLogger logger, IResultStream results, string testName)
 {
     if (logger != null)
     {
         logger.LogResultStream(results, testName);
     }
 }
Ejemplo n.º 4
0
        public static Int32[] GetShiftTimetable(IResultStream results, IBookParty position, uint articleCode)
        {
            var resultList = results.GetPositionPartyResultList(position, articleCode);

            var resultValue = resultList.Select(x => x.ShiftTimetable()).DefaultIfEmpty(ResultValues.NULL_TIME_TABLE).FirstOrDefault();

            return(resultValue);
        }
Ejemplo n.º 5
0
        public static Int32 GetAbsenceHours(IResultStream results, IBookParty position, uint articleCode)
        {
            var resultList = results.GetPositionPartyResultList(position, articleCode);

            var resultValue = resultList.Select(x => x.AbsenceCount()).DefaultIfEmpty(ResultValues.NULL_TIME_COUNTS).FirstOrDefault();

            return(resultValue);
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        public virtual void Select(IResultStream <TSource> stream)
        {
            Constructor       = null;
            Mappings          = null;
            Projection        = null;
            ResultTransformer = null;

            SelectStream(stream);
        }
Ejemplo n.º 7
0
            private static IResultStream EvaluateTarget(
                IResultStream resultStream, IBookTarget target, IProcessConfig config, IEngineProfile engine)
            {
                var targetResults = target.Evaluate(config, engine, resultStream);

                var results = resultStream.AggregateResultList(targetResults);

                return(results);
            }
Ejemplo n.º 8
0
            public static IResultStream EvaluateTargetsToResults(IDictionary <IBookIndex, IBookTarget> targets, IProcessConfig config, IEngineProfile engine)
            {
                IResultStream emptyResults = ResultStream.CreateEmptyStream();

                var results = targets.Aggregate(emptyResults,
                                                (agr, target) => EvaluateTarget(agr, target.Value, config, engine));

                return(results);
            }
Ejemplo n.º 9
0
        /// <inheritdoc />
        public virtual void Select
        (
            IResultStream <TSource> stream,
            IProjection projection
        )
        {
            Project(projection);

            SelectStream(stream);
        }
Ejemplo n.º 10
0
        /// <inheritdoc />
        public virtual void Select
        (
            IResultStream <TSource> stream,
            params Expression <Func <TSource, object> >[] properties
        )
        {
            Project(properties);

            SelectStream(stream);
        }
Ejemplo n.º 11
0
        /// <inheritdoc />
        public virtual void Select <TDestination>
        (
            IResultStream <TDestination> stream,
            Expression <Func <TSource, TDestination> > projection
        )
        {
            Project(projection);

            SelectStream(stream);
        }
Ejemplo n.º 12
0
        public static Int32 GetSumAbsenceTimetable(IResultStream results, IBookParty position, uint articleCode)
        {
            var resultList = results.GetPositionPartyResultList(position, articleCode);

            var resultHours = resultList.Select(x => x.AbsenceTimetable()).DefaultIfEmpty(ResultValues.NULL_TIME_TABLE).FirstOrDefault();

            var resultValue = resultHours.Aggregate(0, (agr, x) => (agr + x));

            return(resultValue);
        }
Ejemplo n.º 13
0
        /// <inheritdoc />
        public virtual void Select <TDestination>
        (
            IResultStream <TDestination> stream,
            ISelectSetup <TSource, TDestination> setup
        )
        {
            Project(setup);

            SelectStream(stream);
        }
Ejemplo n.º 14
0
        /// <inheritdoc />
        /// <typeparam name="TDestination">
        ///     The <see cref="System.Type" /> of the selection.
        /// </typeparam>
        public virtual void Select <TDestination>
        (
            IResultStream <TDestination> stream,
            IProjection projection
        )
        {
            Project <TDestination>(projection);

            SelectStream(stream);
        }
Ejemplo n.º 15
0
        public static decimal GetSummaryPaymentAmount(IResultStream results, ICodeIndex contract, uint articleCode)
        {
            var resultList = results.GetContractPartySummaryList(contract, articleCode);

            var resultAmounts = resultList.Select(x => x.AmountPayments()).ToArray();

            var resultValue = resultAmounts.Aggregate(0m, (agr, x) => (decimal.Add(agr, x)));

            return(resultValue);
        }
Ejemplo n.º 16
0
        /// <inheritdoc />
        /// <typeparam name="TDestination">
        ///     The <see cref="System.Type" /> of the selection.
        /// </typeparam>
        public virtual void Select <TDestination>
        (
            IResultStream <TDestination> stream,
            string property,
            params string[] properties
        )
        {
            Project <TDestination>(property, properties);

            SelectStream(stream);
        }
Ejemplo n.º 17
0
        /// <inheritdoc />
        public virtual void Select
        (
            IResultStream <TSource> stream,
            string property,
            params string[] properties
        )
        {
            Project(property, properties);

            SelectStream(stream);
        }
Ejemplo n.º 18
0
        public void LogResultStream(IResultStream results, string testName)
        {
            OpenLogStream(testName);

            using (StreamWriter logWriter = new StreamWriter(LogFileStream))
            {
                string lineDefinition = "\n--- begin ---";

                lineDefinition += ResultStreamLogger.LogResultStreamInfo(results.Results());

                if (lineDefinition.Length > 0)
                {
                    logWriter.WriteLine(lineDefinition);
                }
                logWriter.WriteLine("--- end ---");
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ResultStreamer{T}" /> class.
        /// </summary>
        /// <param name="resultStream">
        ///     The <see cref="IResultStream{T}" /> into which this <see cref="ResultStreamer{T}" /> will stream each
        ///     query result item.
        /// </param>
        /// <param name="converter">
        ///     The converter used to convert each query result item into the destination <see cref="System.Type" />
        ///     specified by <typeparamref name="T" />.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="resultStream" /> and/or <paramref name="converter" /> is null.
        /// </exception>
        public ResultStreamer
        (
            IResultStream <T> resultStream,
            Func <object, T> converter
        )
        {
            if (resultStream == null)
            {
                throw new ArgumentNullException("resultStream");
            }

            if (converter == null)
            {
                throw new ArgumentNullException("converter");
            }

            _resultStream = resultStream;
            _converter    = converter;
        }
Ejemplo n.º 20
0
        /// <inheritdoc />
        public virtual void Select <TDestination>
        (
            IResultStream <TDestination> stream,
            IPartialSelection <TSource, TDestination> combiner
        )
        {
            if (combiner == null)
            {
                throw new ArgumentNullException("combiner");
            }

            if (combiner.Count == 0)
            {
                throw new ArgumentException("No projection is made in ExpressionCombiner'2", "combiner");
            }

            Expression <Func <TSource, TDestination> > expression = combiner.Compile();

            Select(stream, expression);
        }
Ejemplo n.º 21
0
        public static uint GetContractDayEnds(IResultStream results, ICodeIndex contract)
        {
            var contractResult = results.GetContractResult(contract);

            return(contractResult.PeriodDayEndsOrdinal());
        }
 public void LogResultStream(IResultStream results, string testName)
 {
 }
Ejemplo n.º 23
0
 public override IBookResult[] CallEvaluate(IProcessConfig config, IEngineProfile engine,
                                            IPayrollArticle article, IBookIndex element, ITargetValues values, IResultStream results)
 {
     return(GeneralModule.EMPTY_RESULT_LIST);
 }
Ejemplo n.º 24
0
 /// <summary>
 ///     Populates the given <see cref="IResultStream{TDestination}" /> with the results of this query in a
 ///     streamed fashion.
 /// </summary>
 /// <param name="stream">
 ///     The <see cref="IResultStream{TDestination}" /> to stream the results into.
 /// </param>
 /// <typeparam name="TDestination">
 ///     The <see cref="System.Type" /> of the selection.
 /// </typeparam>
 protected virtual void SelectStream <TDestination>(IResultStream <TDestination> stream)
 {
     SelectionHelper.SelectStream <TSource, TDestination>(QuerySelection.Create(this), stream);
 }
Ejemplo n.º 25
0
 public virtual IBookResult[] CallEvaluate(IProcessConfig config, IEngineProfile engine,
                                           IPayrollArticle article, IBookIndex element, ITargetValues values, IResultStream results)
 {
     if (__evaluate != null)
     {
         return(__evaluate(this, config, engine, article, element, values, results));
     }
     return(GeneralModule.EMPTY_RESULT_LIST);
 }
Ejemplo n.º 26
0
 public IBookResult[] Evaluate(IProcessConfig config, IEngineProfile engine, IResultStream results)
 {
     return(__concept.CallEvaluate(config, engine, __article, __element, __values, results));
 }
Ejemplo n.º 27
0
        public static uint GetPositionDayEnds(IResultStream results, IBookParty position)
        {
            var positionResult = results.GetPositionResult(position);

            return(positionResult.PeriodDayEndsOrdinal());
        }
Ejemplo n.º 28
0
        public ResultCursor(IResultStream resultStream)
        {
            Throw.ArgumentNullException.IfNull(resultStream, nameof(resultStream));

            _resultStream = resultStream;
        }