/// <summary>
        /// Returns <see cref="Select"/> for section visas./>
        /// </summary>
        /// <returns>A <see cref="Select"/> instance.</returns>
        public override Select GetEntitiesSelect()
        {
            Select entitiesSelect = null;

            GetSysModuleSelect().ExecuteReader(reader => {
                Guid entitySchemaUId            = reader.GetColumnValue <Guid>("EntitySchemaUId");
                Guid visaSchemaUId              = reader.GetColumnValue <Guid>("VisaSchemaUId");
                Guid masterColumnUId            = reader.GetColumnValue <Guid>("MasterColumnUId");
                Guid sysModuleImage32Id         = reader.GetColumnValue <Guid>("Image32Id");
                EntitySchema visaSchema         = EntitySchemaManager.GetInstanceByUId(visaSchemaUId);
                EntitySchema entitySchema       = EntitySchemaManager.GetInstanceByUId(entitySchemaUId);
                EntitySchemaColumn masterColumn = visaSchema.Columns.GetByUId(masterColumnUId);
                var sysModuleVisaProvider       = new BaseVisaNotificationProvider(parameters)
                {
                    Name             = entitySchema.Name,
                    Caption          = entitySchema.Caption,
                    Visa             = visaSchema.Name,
                    VisaMasterColumn = masterColumn.ColumnValueName,
                    TitleColumn      = entitySchema.PrimaryDisplayColumn.ColumnValueName,
                    ImageId          = sysModuleImage32Id
                };
                Select sysModuleVisaSelect = sysModuleVisaProvider.GetEntitiesSelect();
                entitiesSelect             = entitiesSelect == null
                                        ? sysModuleVisaSelect
                                        : entitiesSelect.UnionAll(sysModuleVisaSelect) as Select;
            });
            return(entitiesSelect);
        }
        /// <summary>
        /// Creates rule criteria.
        /// </summary>
        /// <param name="serializedFilters">Serialized rule filters.</param>
        /// <param name="scoringObjectId">Unique identifier of score object.</param>
        /// <param name="userConnection">A <see cref="instance"/> of the current user connection.</param>
        /// <param name="generateQuery">True if requared query text; otherwise, false.</param>
        /// <returns></returns>
        public string CreateRuleCriteria(string serializedFilters, Guid scoringObjectId, UserConnection userConnection,
                                         bool generateQuery = false)
        {
            if (string.IsNullOrEmpty(serializedFilters))
            {
                return(string.Empty);
            }
            EntitySchemaManager entitySchemaManager = userConnection.EntitySchemaManager;

            DataContract.Filters jsonFilters
                = Json.Deserialize <DataContract.Filters>(serializedFilters);
            EntitySchema scoringObjectSchema = entitySchemaManager.GetInstanceByUId(scoringObjectId);
            IEntitySchemaQueryFilterItem esqFilters
                = jsonFilters.BuildEsqFilter(scoringObjectSchema.UId, userConnection);
            var scoringObjectEsq = new EntitySchemaQuery(userConnection.EntitySchemaManager, scoringObjectSchema.Name);

            scoringObjectEsq.UseAdminRights = false;
            scoringObjectEsq.PrimaryQueryColumn.IsVisible = true;
            scoringObjectEsq.Filters.Add(esqFilters);
            Select scoringObjectSelect = scoringObjectEsq.GetSelectQuery(userConnection);

            if (generateQuery)
            {
                string query = scoringObjectSelect.GetSqlText();
                return(query);
            }
            string serializedSelectQuery = SerializeSelectQuery(scoringObjectSelect);

            return(serializedSelectQuery);
        }
Esempio n. 3
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="sourceSchemaUId">Unique identifier 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, Guid sourceSchemaUId,
            bool disableEmptyFilters = false)
        {
            EntitySchemaManager entitySchemaManager = userConnection.EntitySchemaManager;
            EntitySchema        sourceSchema        = entitySchemaManager.GetInstanceByUId(sourceSchemaUId);

            return(GetFolderEsqFilters(userConnection, recordId, folderSchemaUId, sourceSchema.Name, disableEmptyFilters));
        }
Esempio n. 4
0
        private Select CreateIdsSelect(string serializedFilters, Guid rootObjectUId)
        {
            EntitySchemaManager entitySchemaManager = _userConnection.EntitySchemaManager;
            var jsonFilters
                = Json.Deserialize <Nui.ServiceModel.DataContract.Filters>(serializedFilters);
            EntitySchema objectSchema = entitySchemaManager.GetInstanceByUId(rootObjectUId);
            IEntitySchemaQueryFilterItem esqFilters
                = jsonFilters.BuildEsqFilter(objectSchema.UId, _userConnection);
            var objectEsq = new EntitySchemaQuery(entitySchemaManager, objectSchema.Name)
            {
                UseAdminRights = false
            };

            objectEsq.PrimaryQueryColumn.IsVisible = true;
            objectEsq.Filters.Add(esqFilters);
            Select idsSelectQuery = objectEsq.GetSelectQuery(_userConnection);

            return(idsSelectQuery);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns SearchData of the folder.
        /// </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>
        /// <returns>Search data.</returns>
        public static byte[] GetFolderSearchData(UserConnection userConnection, Guid recordId, Guid folderSchemaUId)
        {
            EntitySchemaManager entitySchemaManager = userConnection.EntitySchemaManager;
            EntitySchema        schema = entitySchemaManager.GetInstanceByUId(folderSchemaUId);
            var    esq = new EntitySchemaQuery(schema);
            string searchDataColumnName = esq.AddColumn("SearchData").Name;

            esq.Filters.Add(
                esq.CreateFilterWithParameters(FilterComparisonType.Equal, false, "Id", recordId));
            EntityCollection entities = esq.GetEntityCollection(userConnection);

            if (!entities.Any())
            {
                return(null);
            }
            Entity folderEntity = entities.First();

            return(folderEntity.GetBytesValue(searchDataColumnName));
        }
        public Dictionary <string, string> GetColumnPathsAndEntityNames(Dictionary <Guid, List <string> > columnMetaPaths)
        {
            var response = new Dictionary <string, string>();

            EntitySchemaManager entitySchemaManager = UserConnection.EntitySchemaManager;

            foreach (KeyValuePair <Guid, List <string> > keyValuePair in columnMetaPaths)
            {
                Guid         entitySchemaUId = keyValuePair.Key;
                EntitySchema entitySchema    = entitySchemaManager.GetInstanceByUId(entitySchemaUId);
                response[entitySchemaUId.ToString()] = entitySchema.Name;
                List <string> metaPaths = keyValuePair.Value;
                foreach (string metaPath in metaPaths)
                {
                    string columnPath = entitySchema.GetSchemaColumnPathByMetaPath(metaPath);
                    response[metaPath] = columnPath;
                }
            }
            return(response);
        }
Esempio n. 7
0
        protected override bool InternalExecute(ProcessExecutingContext context)
        {
            EntitySchemaId.CheckArgumentEmpty("EntitySchemaId");
            EntitySchemaManager entitySchemaManager = UserConnection.EntitySchemaManager;
            EntitySchema        entitySchema        = entitySchemaManager.GetInstanceByUId(EntitySchemaId);
            var esq = new EntitySchemaQuery(entitySchemaManager, entitySchema.Name)
            {
                UseAdminRights = false
            };

            esq.AddAllSchemaColumns();
            esq.IgnoreDisplayValues = GlobalAppSettings.FeatureIgnoreDisplayValuesInDataUserTasks;
            ProcessUserTaskUtilities.SpecifyESQFilters(UserConnection, this, entitySchema, esq, DataSourceFilters);
            bool isEmptyFilter = esq.Filters.Count == 0;

            if (!isEmptyFilter && esq.Filters.Count == 1)
            {
                var filterGroup = esq.Filters[0] as EntitySchemaQueryFilterCollection;
                if (filterGroup != null && filterGroup.Count == 0)
                {
                    isEmptyFilter = true;
                }
            }
            if (isEmptyFilter)
            {
                throw new NullOrEmptyException(new LocalizableString("Terrasoft.Core",
                                                                     "ProcessSchemaDeleteDataUserTask.Exception.DeleteDataWithEmptyFilter"));
            }
            EntityCollection entities = esq.GetEntityCollection(UserConnection);

            while (entities.Count > 0)
            {
                Entity entity = entities.First.Value;
                entity.UseAdminRights = false;
                entities.RemoveFirst();
                entity.Delete();
            }
            return(true);
        }