Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="period"></param>
        /// <param name="type"></param>
        /// <returns>Список сущностей, список детализаций</returns>
        protected Tuple<List<dynamic>, List<dynamic>> GetCalculationObjects(List<Guid> ids,  Period period, CalculationObjectType type)
        {
            CalculationObject co = null;

            if (type == CalculationObjectType.Account)
            {
                co = AccountObject;
            }
            else if (type == CalculationObjectType.ExternalTransaction)
            {
                 co = ExternalTransactionObject;
            }
            else if (type == CalculationObjectType.InternalTransaction)
            {
                 co = InternalTransactionObject;
            }

            if (co == null)
            {
                return null;
            }

            List<dynamic> details;
            List<dynamic> entities;

            if (type == CalculationObjectType.Account)
            {

                var filterForEntity = FilterCriteriaSet.And.In(ids, co.EntitySearchProperty);

                entities = DynamicRepository.GetByEntity(co.EntityName, filterForEntity);

                if (!co.EntityName.Equals(co.DetailEntityName, StringComparison.InvariantCultureIgnoreCase))
                {
                    var filterForDetails = FilterCriteriaSet.And.In(ids, co.DetailSearchProperty);

                    if (period != null && !string.IsNullOrEmpty(co.PeriodProperty))
                    {
                        filterForDetails = filterForDetails.Equal(period.Id, co.PeriodProperty);
                    }

                    details = DynamicRepository.GetByEntity(co.DetailEntityName, filterForDetails);
                }
                else
                {
                    details = entities;
                }
            }
            else
            {
                var filterForDetails = FilterCriteriaSet.And.In(ids, co.DetailSearchProperty);

                if (period != null && !string.IsNullOrEmpty(co.PeriodProperty))
                {
                    filterForDetails = filterForDetails.Equal(period.Id, co.PeriodProperty);
                }

                details = DynamicRepository.GetByEntity(co.DetailEntityName, filterForDetails);

                if (!co.EntityName.Equals(co.DetailEntityName, StringComparison.InvariantCultureIgnoreCase))
                {
                    var filterForEntity =
                        FilterCriteriaSet.And.In(
                            details.Select(d => (d as DynamicEntity).GetProperty(co.EntityIdPropertyInDetail)).ToList(),
                            co.EntitySearchProperty);

                    entities = DynamicRepository.GetByEntity(co.EntityName, filterForEntity);
                }
                else
                {
                    entities = details;
                }
            }

            return new Tuple<List<dynamic>, List<dynamic>>(entities, details);
        }
Ejemplo n.º 2
0
        protected Tuple<List<dynamic>, List<dynamic>> GetAccounts(FilterCriteriaSet filter, Period period)
        {
            List<dynamic> details;

                List<dynamic> entities = DynamicRepository.GetByEntity(AccountObject.EntityName, filter);

                if (!AccountObject.EntityName.Equals(AccountObject.DetailEntityName, StringComparison.InvariantCultureIgnoreCase))
                {
                    var filterForDetails =
                        FilterCriteriaSet.And.In(entities.Select(e => (Guid) (e as DynamicEntity).GetId()).ToList(),
                            AccountObject.DetailSearchProperty);

                    if (period != null && !string.IsNullOrEmpty(AccountObject.PeriodProperty))
                    {
                        filterForDetails = filterForDetails.Equal(period.Id, AccountObject.PeriodProperty);
                    }

                    details = DynamicRepository.GetByEntity(AccountObject.DetailEntityName, filterForDetails);
                }
                else
                {
                    details = entities;
                }

                return new Tuple<List<dynamic>, List<dynamic>>(entities, details);
        }