示例#1
0
        /// <summary>
        /// Returns information of dependent entity.
        /// </summary>
        /// <param name="dependentEntity">Information of dependent entity.</param>
        /// <returns>Information of dependent entity.</returns>
        private DependentInfo GetDependenInfo(KeyValuePair <string, List <Guid> > dependentEntity)
        {
            var           count           = 0;
            var           recordIds       = new List <Guid>();
            string        schemaName      = dependentEntity.Key;
            EntitySchema  entitySchema    = EntitySchemaManager.GetInstanceByName(schemaName);
            string        caption         = entitySchema.Caption;
            Guid          entitySchemaUId = entitySchema.UId;
            List <string> columnsName     = GetColumnsNameByUIds(entitySchema, dependentEntity.Value);

            if (columnsName.Count == 0)
            {
                return(null);
            }
            var dependentInfo = new DependentInfo {
                EntitySchemaUId     = entitySchemaUId,
                EntitySchemaName    = schemaName,
                EntitySchemaCaption = caption,
                ColumnsName         = columnsName
            };

            try {
                if (_isLoadRecordId)
                {
                    recordIds = GetRecordIds(schemaName, columnsName);
                    if (recordIds != null)
                    {
                        count = recordIds.Count;
                    }
                }
                else
                {
                    count = CountRecords(schemaName, columnsName);
                }
            } catch (SecurityException) {
                dependentInfo.CanRead = false;
                return(dependentInfo);
            }
            if (count > 0)
            {
                dependentInfo.CanRead      = true;
                dependentInfo.RecordsCount = count;
                if (_isLoadRecordId)
                {
                    dependentInfo.RecordIds = recordIds;
                }
                return(dependentInfo);
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Adds to dictionary the information of dependent entity.
        /// </summary>
        /// <param name="dependentEntites">Collection of dependent entites.</param>
        /// <returns>Collection of entites which has a records.</returns>
        protected virtual List <DependentInfo> GetEntitiesContainRecords(
            Dictionary <string, List <Guid> > dependentEntites)
        {
            var result = new List <DependentInfo>();

            foreach (KeyValuePair <string, List <Guid> > dependentEntity in dependentEntites)
            {
                DependentInfo info = GetDependenInfo(dependentEntity);
                if (info != null)
                {
                    result.Add(info);
                }
            }
            return(result);
        }