コード例 #1
0
        public override JsStoreData LoadList(ILoadListQuery clientQuery)
        {
            Contract.Requires(clientQuery != null);

            using (var session = _sessionFactory.OpenSession())
            {
                var query = session.Query <WmsReport2Entity>()
                            .Where(p => p.ObjectName_r == "CSTREQCUSTOMS")
                            .Select(p => p.Report_r);

                query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplyConditions(query, clientQuery.Conditions.OfType <IFieldValueCondition>(), Bindings);
                var count = _linqQueryBuilder.Count(query);

                query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplySorting(query, clientQuery.SortItems, Bindings);
                if (clientQuery.Page.IsDefined)
                {
                    query = (IQueryable <WmsReport>)_linqQueryBuilder.ApplyPaging(query, clientQuery.Page.StartRow, clientQuery.Page.Size);
                }

                var dynamicQuery = _linqQueryBuilder.ApplyProjection(query, Bindings);
                var listObj      = _linqQueryBuilder.List(dynamicQuery);

                var dataTable = _dataTableByBindingsFactory.CreateDataTable(Bindings);
                _bindingDataTableFiller.FillTableFromList(dataTable, listObj, Bindings);

                var dataPage = new DataPage(dataTable, count);
                return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
            }
        }
コード例 #2
0
        public JsStoreData LoadList(ILoadListQuery clientQuery)
        {
            Contract.Requires(clientQuery != null);
            using (var session = _sessionFactory.OpenSession())
            {
                var query = session.Query <WmsIWB>().Where(i => !session.Query <CstReqCustoms2WB>().Any(j => j.IWB.IWBID == i.IWBID));

                var mandantIDField = clientQuery.Conditions.OfType <IFieldValueCondition>().SingleOrDefault(f => f.Field.Name == "MandantID");
                if (mandantIDField != null)
                {
                    var mandantEntityID = (EntityReference)mandantIDField.Value.Single();
                    var mandantID       = mandantEntityID.GetConvertedId <Int32>();;
                    query = query.Where(i => i.Partner.PartnerID == mandantID);
                }
                else
                {
                    query = query.Where(i => 1 == 0);
                }

                var typeField = clientQuery.Conditions.OfType <IFieldValueCondition>().SingleOrDefault(f => f.Field.Name == "WBType");
                if (typeField != null && typeField.Value.Any())
                {
                    var valueType = typeField.Value.Single().ToString();
                    if (!string.IsNullOrEmpty(valueType))
                    {
                        query = query.Where(i => i.IWBType == valueType);
                    }
                }

                query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplyConditions(query, clientQuery.Conditions.OfType <IFieldValueCondition>(), Bindings);
                var count = _linqQueryBuilder.Count(query);

                query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplySorting(query, clientQuery.SortItems, Bindings);
                if (clientQuery.Page.IsDefined)
                {
                    query = (IQueryable <WmsIWB>)_linqQueryBuilder.ApplyPaging(query, clientQuery.Page.StartRow, clientQuery.Page.Size);
                }

                var dynamicQuery = _linqQueryBuilder.ApplyProjection(query, Bindings);
                var listObj      = _linqQueryBuilder.List(dynamicQuery);

                var dataTable = _dataTableByBindingsFactory.CreateDataTable(Bindings);
                _bindingDataTableFiller.FillTableFromList(dataTable, listObj, Bindings);

                var dataPage = new DataPage(dataTable, count);
                return(TableSerializer.Serialize(dataPage.Data, dataPage.Count));
            }
        }
コード例 #3
0
        private DataPage LoadLookupInternal(string queryText, bool encloseValueInPercent, string entityType, IEnumerable <IFieldBinding> bindings, IEnumerable <ISortItem> sortItems, IEnumerable <IFieldValueCondition> conditions, IPage page, bool needTotal = false)
        {
            using (var queryFactory = _queryableFactoryProvider.CreateFactory())
            {
                var query = queryFactory.CreateQuery(entityType);
                //query = ApplyReadPolicyToQuery(query, queryFactory);
                query = ApplyFilterFields(query, conditions);
                if (!string.IsNullOrEmpty(queryText))
                {
                    query = _linqQueryBuilder.ApplyLookupQuery(query, queryText, encloseValueInPercent, bindings.Where(b => b.Visible));
                }
                query = _linqQueryBuilder.ApplyConditions(query, conditions, bindings);

                var count = 0;
                if (needTotal)
                {
                    count = _linqQueryBuilder.Count(query);
                }

                query = _linqQueryBuilder.ApplySorting(query, sortItems, bindings);
                query = _linqQueryBuilder.ApplyProjection(query, bindings);

                if (page.IsDefined)
                {
                    query = _linqQueryBuilder.ApplyPaging(query, page.StartRow, page.Size);
                }

                var listObj = _linqQueryBuilder.List(query);

                var dataTable = _dataTableByBindingsFactory.CreateDataTable(bindings);
                // TODO: Сделать заполнение DataTable через Reflection
                dataTable.Columns.Add(LinqQueryBuilder.SELF_PROPERTY_NAME, typeof(EntityReference));

                _bindingDataTableFiller.FillTableFromList(dataTable, listObj, bindings);
                for (int i = 0; i < listObj.Count; i++)
                {
                    var obj        = listObj[i];
                    var properties = PropertyHelper.GetProperties(obj);
                    var selfProp   = properties[LinqQueryBuilder.SELF_PROPERTY_NAME];
                    var row        = dataTable.Rows[i];
                    row[LinqQueryBuilder.SELF_PROPERTY_NAME] = selfProp.GetValue(obj);
                }

                return(new DataPage(dataTable, count));
            }
        }