예제 #1
0
        /// <summary>
        /// Returns collection of the folder filters.
        /// </summary>
        /// <param name="userConnection">Instance of the <see cref="Terrasoft.Core.UserConnection"/>.</param>
        /// <param name="recordId">Unique identifier of the folder.</param>
        /// <param name="folderSchemaUId">Unique identifier of the folder schema.</param>
        /// <param name="sourceSchemaName">Name of the source filters schema.</param>
        /// <param name="disableEmptyFilters">Determines whether to disable empty filters or not.</param>
        /// <returns><see cref="IEntitySchemaQueryFilterItem"/> filters collection.</returns>
        public static IEntitySchemaQueryFilterItem GetFolderEsqFilters(
            UserConnection userConnection, Guid recordId, Guid folderSchemaUId, string sourceSchemaName,
            bool disableEmptyFilters = false)
        {
            byte[] searchData = GetFolderSearchData(userConnection, recordId, folderSchemaUId);
            if (searchData?.IsEmpty() != false)
            {
                return(null);
            }

            var disableEmptyFilterBeforeBuildEsq = userConnection.GetIsFeatureEnabled("DisableEmptyFilterBeforeBuildEsq");
            var filters = DeserializeFilters(searchData);

            if (disableEmptyFilters && disableEmptyFilterBeforeBuildEsq)
            {
                DisableEmptyFilters(new[] { filters });
            }

            var selectQuery = new Terrasoft.Nui.ServiceModel.DataContract.SelectQuery {
                RootSchemaName = sourceSchemaName,
                Filters        = filters
            };
            EntitySchemaQueryFilterCollection esqFilters = selectQuery.BuildEsq(userConnection).Filters;

            if (disableEmptyFilters && !disableEmptyFilterBeforeBuildEsq)
            {
                DisableEmptyEntitySchemaQueryFilters(esqFilters);
            }
            return(esqFilters);
        }
        private Guid[] GetPrimaryColumnValuesFromFilters(string schemaName, string filterConfig)
        {
            var filters = JsonConvert.DeserializeObject <Terrasoft.Nui.ServiceModel.DataContract.Filters>(filterConfig);
            var select  = new Terrasoft.Nui.ServiceModel.DataContract.SelectQuery {
                RootSchemaName  = schemaName,
                Filters         = filters,
                UseLocalization = true
            };
            var esq = select.BuildEsq(UserConnection);
            var primaryColumnName     = esq.RootSchema.GetPrimaryColumnName();
            EntityCollection entities = esq.GetEntityCollection(UserConnection);

            return(entities.Select(x => x.GetTypedColumnValue <Guid>(primaryColumnName)).ToArray());
        }
예제 #3
0
        /// <summary>
        /// Returns array of primary column values from filters.
        /// </summary>
        /// <param name="rootSchema">Root schema name.</param>
        /// <param name="filterConfigs">Serialized filters config.</param>
        /// <returns></returns>
        public virtual string[] GetPrimaryColumnValuesFromFilters(string rootSchema,
                                                                  string filterConfigs)
        {
            var filters = JsonConvert.DeserializeObject <Terrasoft.Nui.ServiceModel.DataContract.Filters>(filterConfigs);
            var select  = new Terrasoft.Nui.ServiceModel.DataContract.SelectQuery {
                RootSchemaName = rootSchema,
                Filters        = filters
            };
            var esq = select.BuildEsq(_userConnection);
            var primaryColumnName     = esq.RootSchema.GetPrimaryColumnName();
            EntityCollection entities = esq.GetEntityCollection(_userConnection);

            return(entities.Select(x => x.GetTypedColumnValue <string>(primaryColumnName)).ToArray());
        }
        /// <summary>
        /// Returns array of primary column values from filters.
        /// </summary>
        /// <param name="filterConfigs">Serialized filters config.</param>
        /// <returns>Array of primary column values.</returns>
        private Guid[] InnerGetUserIds(string filterConfigs)
        {
            var select = new Terrasoft.Nui.ServiceModel.DataContract.SelectQuery {
                RootSchemaName = "SysAdminUnit"
            };

            if (!string.IsNullOrEmpty(filterConfigs))
            {
                var filters =
                    JsonConvert.DeserializeObject <Terrasoft.Nui.ServiceModel.DataContract.Filters>(filterConfigs);
                select.Filters = filters;
            }
            var esq = select.BuildEsq(UserConnection);

            esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal,
                                                           "SysAdminUnitTypeValue", Terrasoft.Core.DB.SysAdminUnitType.User));
            EntityCollection entities = esq.GetEntityCollection(UserConnection);

            return(entities.Select(x => x.PrimaryColumnValue).ToArray());
        }