예제 #1
0
        /// <summary>
        /// Определяем собственную реализацию фильтра для товаров
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <Article> crit = (Infrastructure.Repositories.Criteria.ICriteria <Article>)criteria;

            Regex regexp = new Regex(@"ArticleGroup=\d+;");
            var   match  = regexp.Match(filter);
            IEnumerable <ArticleGroup> childGroups = null;

            if (match.Length > 0)
            {
                var value = match.Value;
                filter = filter.Replace(value, "");
                var articleGroupId = Convert.ToInt16(value.Replace("ArticleGroup=", "").Replace(";", ""));

                var articleGroupRepository = new ArticleGroupRepository();
                var articleGroup           = articleGroupRepository.GetById(articleGroupId);

                childGroups = (new List <ArticleGroup> {
                    articleGroup
                }).Concat(articleGroup.Childs.Concat(articleGroup.Childs.SelectMany(x => x.Childs)));
            }

            if (childGroups != null)
            {
                crit.OneOf("ArticleGroup", childGroups);
            }

            base.CreateFilter <T>(criteria);
        }
예제 #2
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <Organization> query = (Infrastructure.Repositories.Criteria.ICriteria <Organization>)criteria;

            ParameterString df = new ParameterString(filter);

            var jQuery = SubQuery <JuridicalPerson>().Select(x => x.Id);
            var pQuery = SubQuery <PhysicalPerson>().Select(x => x.Id);

            if (!String.IsNullOrEmpty(df["Name"].Value as string))
            {
                query.Like(x => x.ShortName, df["Name"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["INN"].Value as string))
            {
                jQuery.Where(x => x.INN == df["INN"].Value as string);
                pQuery.Where(x => x.INN == df["INN"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["Address"].Value as string))
            {
                query.Like(x => x.Address, df["Address"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["OGRN"].Value as string))
            {
                jQuery.Where(x => x.OGRN == df["OGRN"].Value as string);
                pQuery.Where(x => x.OGRNIP == df["OGRN"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["OKPO"].Value as string))
            {
                jQuery.Where(x => x.OKPO == df["OKPO"].Value as string);
                pQuery = null;
            }

            if (!String.IsNullOrEmpty(df["KPP"].Value as string))
            {
                jQuery.Where(x => x.KPP == df["KPP"].Value as string);
                pQuery = null;
            }

            //Выбираем все организации, удовлетворяющие фильтру
            if (pQuery != null)
            {
                query.Or(x => x.PropertyIn(y => y.Id, jQuery), x => x.PropertyIn(y => y.Id, pQuery));
            }
            else
            {
                query.PropertyIn(y => y.Id, jQuery);
            }
        }
예제 #3
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций контрагента
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <DealQuota> query = (Infrastructure.Repositories.Criteria.ICriteria <DealQuota>)criteria;

            ParameterString df = parameterString;

            if (df["DealId"] != null && df["DealId"].Value != null)
            {
                string str = df["DealId"].Value is IList <string>?(df["DealId"].Value as IList <string>)[0] : df["DealId"].Value as string;
                if (str.Length > 0)
                {
                    var dealId   = ValidationUtils.TryGetInt(str);
                    var subQuery = SubQuery <Deal>().Where(x => x.Id == dealId);
                    subQuery.Restriction <DealQuota>(x => x.Quotas).Select(x => x.Id);

                    string modeStr = df["Mode"].Value is IList <string>?(df["Mode"].Value as IList <string>)[0] : df["Mode"].Value as string;

                    switch (modeStr)
                    {
                    case "Sale":
                        query.PropertyIn(x => x.Id, subQuery); break;

                    case "Deal":
                        query.PropertyNotIn(x => x.Id, subQuery); break;

                    default:
                        throw new Exception("Неверное значение входного параметра.");
                    }
                }
            }

            df.Delete("DealId");
            df.Delete("Mode");

            base.CreateFilter <T>(criteria);
        }
예제 #4
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций контрагента
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <ClientOrganization> query = (Infrastructure.Repositories.Criteria.ICriteria <ClientOrganization>)criteria;

            if (parameterString != null)
            {
                parameterString.MergeWith(new Utils.ParameterString(filter));
            }
            else
            {
                parameterString = new Utils.ParameterString(filter);
            }

            var jQuery = SubQuery <JuridicalPerson>().Select(x => x.Id);
            var pQuery = SubQuery <PhysicalPerson>().Select(x => x.Id);

            if (parameterString["INN"] != null && parameterString["INN"].Value != null)
            {
                var str = parameterString["INN"].Value is IList <string>?(parameterString["INN"].Value as IList <string>)[0] : parameterString["INN"].Value as string;

                jQuery.Where(x => x.INN == str);
                pQuery.Where(x => x.INN == str);
            }
            parameterString.Delete("INN");

            if (parameterString["Address"] != null && parameterString["Address"].Value != null)
            {
                var str = parameterString["Address"].Value is IList <string>?(parameterString["Address"].Value as IList <string>)[0] : parameterString["Address"].Value as string;

                query.Like(x => x.Address, str);
            }
            parameterString.Delete("Address");

            if (parameterString["OGRN"] != null && parameterString["OGRN"].Value != null)
            {
                var str = parameterString["OGRN"].Value is IList <string>?(parameterString["OGRN"].Value as IList <string>)[0] : parameterString["OGRN"].Value as string;

                jQuery.Where(x => x.OGRN == str);
                pQuery.Where(x => x.OGRNIP == str);
            }
            parameterString.Delete("OGRN");

            if (parameterString["OKPO"] != null && parameterString["OKPO"].Value != null)
            {
                var str = parameterString["OKPO"].Value is IList <string>?(parameterString["OKPO"].Value as IList <string>)[0] : parameterString["OKPO"].Value as string;

                jQuery.Where(x => x.OKPO == str);
                pQuery = null;
            }
            parameterString.Delete("OKPO");

            if (parameterString["KPP"] != null && parameterString["KPP"].Value != null)
            {
                var str = parameterString["KPP"].Value is IList <string>?(parameterString["KPP"].Value as IList <string>)[0] : parameterString["KPP"].Value as string;

                jQuery.Where(x => x.KPP == str);
                pQuery = null;
            }
            parameterString.Delete("KPP");

            //Выбираем все организации, удовлетворяющие фильтру
            if (pQuery != null)
            {
                query.Or(x => x.PropertyIn(y => y.EconomicAgent.Id, jQuery), x => x.PropertyIn(y => y.EconomicAgent.Id, pQuery));
            }
            else
            {
                query.PropertyIn(y => y.EconomicAgent.Id, jQuery);
            }

            filter = "";

            base.CreateFilter(query);

            parameterString.Delete("ShortName");
        }
        /// <summary>
        /// Определяем собственный метод фильтрации организаций контрагента
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <ContractorOrganization> query = (Infrastructure.Repositories.Criteria.ICriteria <ContractorOrganization>)criteria;

            ParameterString df = parameterString;

            var jQuery = SubQuery <JuridicalPerson>().Select(x => x.Id);
            var pQuery = SubQuery <PhysicalPerson>().Select(x => x.Id);

            if (df["Name"] != null && df["Name"].Value != null)
            {
                string str = df["Name"].Value is IList <string>?(df["Name"].Value as IList <string>)[0] : df["Name"].Value as string;
                if (str.Length > 0)
                {
                    query.Like(x => x.ShortName, str);
                }
            }

            if (df["INN"] != null && df["INN"].Value != null)
            {
                string str = df["INN"].Value is IList <string>?(df["INN"].Value as IList <string>)[0] : df["INN"].Value as string;
                if (str.Length > 0)
                {
                    jQuery.Where(x => x.INN == str);
                    pQuery.Where(x => x.INN == str);
                }
            }

            if (df["Address"] != null && df["Address"].Value != null)
            {
                string str = df["Address"].Value is IList <string>?(df["Address"].Value as IList <string>)[0] : df["Address"].Value as string;
                if (str.Length > 0)
                {
                    query.Like(x => x.Address, str);
                }
            }

            if (df["OGRN"] != null && df["OGRN"].Value != null)
            {
                string str = df["OGRN"].Value is IList <string>?(df["OGRN"].Value as IList <string>)[0] : df["OGRN"].Value as string;
                if (str.Length > 0)
                {
                    jQuery.Where(x => x.OGRN == str);
                    pQuery.Where(x => x.OGRNIP == str);
                }
            }

            if (df["OKPO"] != null && df["OKPO"].Value != null)
            {
                string str = df["OKPO"].Value is IList <string>?(df["OKPO"].Value as IList <string>)[0] : df["OKPO"].Value as string;
                if (str.Length > 0)
                {
                    jQuery.Where(x => x.OKPO == str);
                    pQuery = null;
                }
            }

            if (df["KPP"] != null && df["KPP"].Value != null)
            {
                string str = df["KPP"].Value is IList <string>?(df["KPP"].Value as IList <string>)[0] : df["KPP"].Value as string;
                if (str.Length > 0)
                {
                    jQuery.Where(x => x.KPP == str);
                    pQuery = null;
                }
            }

            //Выбираем все организации, удовлетворяющие фильтру
            if (pQuery != null)
            {
                query.Restriction <EconomicAgent>(x => x.EconomicAgent).Or(x => x.PropertyIn(y => y.Id, jQuery), x => x.PropertyIn(y => y.Id, pQuery));
            }
            else
            {
                query.Restriction <EconomicAgent>(x => x.EconomicAgent).PropertyIn(y => y.Id, jQuery);
            }

            if (df["Type"] != null)
            {
                if (df["Type"].Value is IList <string> )
                {
                    var list = df["Type"].Value as IList <string>;
                    if (list.Count > 0)
                    {
                        query.OneOf(x => x.Type, list);
                    }
                }
            }
        }