Esempio n. 1
0
        public ViewDataAdapter.FetchResult CustomFetchEntities(ViewConfiguration viewConfiguration)
        {
            CustomFetchXml converter = new CustomFetchXml(_serviceContext, new XrmConnection());

            viewConfiguration = converter.CustomFilterViews(viewConfiguration);

            OrganizationServiceContext serviceContext = this.Dependencies.GetServiceContext();
            Fetch fetch = FilterGlobalRecords(viewConfiguration);

            fetch = FilterSharedEntityScope(fetch, viewConfiguration);
            this.AddSelectableFilterToFetchEntity(fetch.Entity, this.Configuration, this.Filter);
            this.AddWebsiteFilterToFetchEntity(fetch.Entity, this.Configuration);
            this.AddOrderToFetch(fetch.Entity, this.Order);
            Fetch  fetch2           = fetch;
            bool?  dataPagerEnabled = this.Configuration.DataPagerEnabled;
            int    num1             = dataPagerEnabled.HasValue ? (dataPagerEnabled.GetValueOrDefault() ? 1 : 0) : 1;
            string pagingCookie     = fetch.PagingCookie;
            int    page             = this.Page;
            int    pageSize         = this.Configuration.PageSize;
            int    num2             = 1;

            this.AddPaginationToFetch(fetch2, num1 != 0, pagingCookie, page, pageSize, num2 != 0);
            this.AddSearchFilterToFetchEntity(fetch.Entity, this.Configuration, this.Search, (IEnumerable <string>)null);
            this.AddMetadataFilterToFetch(fetch, this.Configuration, base.MetaFilter);
            if (this.ApplyRecordLevelFilters)
            {
                this.AddRecordLevelFiltersToFetch(fetch, this.Configuration, CrmEntityPermissionRight.Read);
            }
            else
            {
                this.TryAssert(fetch, this.Configuration, CrmEntityPermissionRight.Read);
            }
            if (this.ApplyRelatedRecordFilter)
            {
                this.AddRelatedRecordFilterToFetch(fetch, this.FilterRelationshipName, this.FilterEntityName, this.FilterValue);
            }
            if (((IEnumerable <AttributeMetadata>) this.EntityMetadata.Attributes).Any <AttributeMetadata>((Func <AttributeMetadata, bool>)(a => a.LogicalName == "statecode")))
            {
                ViewDataAdapter.AddAttributesToFetchEntity(fetch.Entity, (IEnumerable <string>) new List <string>()
                {
                    "statecode"
                });
                if (((IEnumerable <AttributeMetadata>) this.EntityMetadata.Attributes).Any <AttributeMetadata>((Func <AttributeMetadata, bool>)(a => a.LogicalName == "statuscode")))
                {
                    ViewDataAdapter.AddAttributesToFetchEntity(fetch.Entity, (IEnumerable <string>) new List <string>()
                    {
                        "statuscode"
                    });
                }
            }

            return(base.FetchEntities(_dependencies.GetServiceContext(), fetch));

            //   return records;
        }
Esempio n. 2
0
 public CustomViewAdapter(ViewConfiguration configuration, Adxstudio.Xrm.Cms.IDataAdapterDependencies dependencies, int page = 1, string search = null, string order = null, string filter = null, string metaFilter = null, bool applyRecordLevelFilters = true, EntityMetadata entityMetadata = null)
     : base(configuration, dependencies, page, search, order, filter, metaFilter, applyRecordLevelFilters, entityMetadata)
 {
     _configuration  = configuration;
     _dependencies   = dependencies;
     _serviceContext = dependencies.GetServiceContext();
     this.ApplyRecordLevelFilters = applyRecordLevelFilters;
 }
Esempio n. 3
0
        public CustomViewAdapter(ViewConfiguration configuration, Adxstudio.Xrm.Cms.IDataAdapterDependencies dependencies, string filterRelationshipName, string filterEntityName, string filterAttributeName, Guid filterValue, int page = 1, string search = null, string order = null, string filter = null, string metaFilter = null, bool applyRecordLevelFilters = true, EntityMetadata entityMetadata = null)
            : base(configuration, dependencies, filterRelationshipName, filterEntityName, filterAttributeName, filterValue, page, search, order, filter, metaFilter, applyRecordLevelFilters, entityMetadata)
        {
            _configuration  = configuration;
            _serviceContext = dependencies.GetServiceContext();
            _dependencies   = dependencies;

            this.ApplyRecordLevelFilters  = applyRecordLevelFilters;
            this.ApplyRelatedRecordFilter = !string.IsNullOrWhiteSpace(filterRelationshipName) && !string.IsNullOrWhiteSpace(filterEntityName) && filterValue != Guid.Empty;
            this.FilterRelationshipName   = filterRelationshipName;
            this.FilterEntityName         = filterEntityName;
            this.FilterAttributeName      = filterAttributeName;
            this.FilterValue = filterValue;
        }