예제 #1
0
        DemographicCompilerContext ReadContextGrid(SqlMapper.GridReader gridReader)
        {
            var queryCtx  = gridReader.ReadFirstOrDefault <QueryContext>();
            var demoQuery = gridReader.ReadFirstOrDefault <DemographicQuery>();

            return(new DemographicCompilerContext
            {
                QueryContext = queryCtx,
                DemographicQuery = demoQuery
            });
        }
예제 #2
0
        DatasetCompilerContext ReadRequestGrid(SqlMapper.GridReader gridReader, DatasetExecutionRequest request)
        {
            var queryCtx           = gridReader.ReadFirstOrDefault <QueryContext>();
            var datasetQueryRecord = gridReader.ReadFirstOrDefault <DatasetQueryRecord>();
            var datasetQuery       = datasetQueryRecord.DatasetQuery();

            return(new DatasetCompilerContext
            {
                DatasetQuery = datasetQuery,
                QueryContext = queryCtx,
                EarlyBound = request.EarlyBound,
                LateBound = request.LateBound
            });
        }
예제 #3
0
            public static AdminDatasetQuery Read(SqlMapper.GridReader grid)
            {
                var query = grid.ReadFirstOrDefault <DatasetQueryRecord>();

                if (query == null)
                {
                    return(null);
                }
                var tags = grid.Read <DatasetQueryTag>();
                var cons = grid.Read <DatasetQueryConstraintRecord>();

                return(new AdminDatasetQuery
                {
                    Id = query.Id,
                    UniversalId = DatasetQueryUrn.From(query.UniversalId),
                    Shape = (Shape)query.Shape,
                    Name = query.Name,
                    CategoryId = query.CategoryId,
                    Description = query.Description,
                    IsEncounterBased = query.IsEncounterBased,
                    SqlStatement = query.SqlStatement,
                    SqlFieldDate = query.SqlFieldDate,
                    SqlFieldValueString = query.SqlFieldValueString,
                    SqlFieldValueNumeric = query.SqlFieldValueNumeric,
                    Schema = DynamicDatasetSchemaFieldSerde.Deserialize(query.Schema),
                    Created = query.Created,
                    CreatedBy = query.CreatedBy,
                    Updated = query.Updated,
                    UpdatedBy = query.UpdatedBy,
                    Tags = tags.Select(t => t.Tag),
                    Constraints = cons.Select(c => c.Constraint())
                });
            }
        /// <summary>
        /// 获取用户基本信息 好友列表等
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public override CommonResult GetInitInfo(long userId)
        {
            return(_storage.UseConnection <CommonResult>(connection =>
            {
                string sql = @"SELECT pk_id AS id,name AS username,[sign],avatar FROM dbo.[user] WHERE pk_id=@uid
SELECT pk_id AS id,name AS groupname FROM dbo.friend_group WHERE [user_id]=@uid
SELECT a.pk_id AS gid,c.pk_id AS id,c.name as username,c.[sign],c.avatar FROM dbo.friend_group A INNER JOIN dbo.friend_group_detail B ON a.pk_id=B.group_id LEFT JOIN dbo.[user] C ON B.[user_id]=c.pk_id WHERE a.[user_id]=@uid
  SELECT b.pk_id AS id,name AS groupname,avatar FROM dbo.big_group_detail A LEFT JOIN dbo.big_group B ON A.group_id=b.pk_id WHERE [user_id]=@uid";

                SqlMapper.GridReader reader = connection.QueryMultiple(sql, new { uid = userId });

                var result = new BaseListResult();
                result.mine = reader.ReadFirstOrDefault <UserModel>();
                //处理friend逻辑 start
                var friend = reader.Read <FriendGroupModel>();
                var groupUsers = reader.Read <GroupUserModel>();

                friend.ToList().ForEach(f =>
                {
                    //每一组的人分配给各个组
                    f.list = groupUsers?.Where(x => x.gid == f.id);
                });
                result.friend = friend;
                //处理friend逻辑 end
                //读取用户所在群
                result.group = reader.Read <BigGroupModel>();


                return new CommonResult {
                    code = result.mine == null ? 1 : 0, msg = result.mine == null ? "用户不存在" : "", data = result
                };
            }));
        }
예제 #5
0
            public static AdminDatasetQuery Read(SqlMapper.GridReader grid)
            {
                var query = grid.ReadFirstOrDefault <DatasetQueryRecord>();

                if (query == null)
                {
                    return(null);
                }
                var tags = grid.Read <DatasetQueryTag>();
                var cons = grid.Read <DatasetQueryConstraintRecord>();

                return(new AdminDatasetQuery
                {
                    Id = query.Id,
                    UniversalId = DatasetQueryUrn.From(query.UniversalId),
                    Shape = (Shape)query.Shape,
                    Name = query.Name,
                    CategoryId = query.CategoryId,
                    Description = query.Description,
                    SqlStatement = query.SqlStatement,
                    Created = query.Created,
                    CreatedBy = query.CreatedBy,
                    Updated = query.Updated,
                    UpdatedBy = query.UpdatedBy,
                    Tags = tags.Select(t => t.Tag),
                    Constraints = cons.Select(c => c.Constraint())
                });
            }
예제 #6
0
        DatasetCompilerContext ReadRequestGrid(SqlMapper.GridReader gridReader, DatasetExecutionRequest request)
        {
            var queryCtx           = gridReader.ReadFirstOrDefault <QueryContext>();
            var datasetQueryRecord = request.DatasetRef.Shape == Shape.Dynamic
                ? gridReader.ReadFirstOrDefault <DynamicDatasetQueryRecord>()
                : gridReader.ReadFirstOrDefault <DatasetQueryRecord>();
            var datasetQuery = datasetQueryRecord.DatasetQuery();

            return(new DatasetCompilerContext
            {
                DatasetQuery = datasetQuery,
                QueryContext = queryCtx,
                EarlyBound = request.EarlyBound,
                LateBound = request.LateBound,
                Panel = GetPanel(queryCtx.Definition, request.PanelIndex)
            });
        }
예제 #7
0
        public virtual IEnumerable <T1> ExecutePageList <T1>(string sql, int page, int resultsPerPage, out long count, IDictionary <string, object> param = null) where T1 : class
        {
            param = param == null ? new Dictionary <string, object>() : param;
            string pageSQL  = DapperExtensions.DapperExtensions.SqlDialect.GetPagingSql(sql, page, resultsPerPage, param);
            string countSQL = string.Format("SELECT COUNT(1)  FROM ({0}) t", sql);

            SqlMapper.GridReader reader = Connection.QueryMultiple(pageSQL + ";" + countSQL, param, commandTimeout: commandTimeout);
            IEnumerable <T1>     list   = reader.Read <T1>();

            count = reader.ReadFirstOrDefault <long>();
            return(list);
        }
예제 #8
0
        public static SpecializationGroup ReadSingle(SqlMapper.GridReader grid)
        {
            var group = grid.ReadFirstOrDefault <SpecializationGroup>();

            if (group == null)
            {
                return(null);
            }
            var specs = grid.Read <SpecializationRecord>();

            group.Specializations = specs.Select(s => s.Specialization());
            return(group);
        }
예제 #9
0
        public static Concept Read(SqlMapper.GridReader grid)
        {
            var cr = grid.ReadFirstOrDefault <ConceptRecord>();

            if (cr == null)
            {
                return(null);
            }
            var groups = grid.Read <SpecializationGroupRelationship>();
            var ccr    = grid.Read <ConceptConstraintRecord>();

            return(cr.Concept(groups, ccr));
        }
예제 #10
0
            public static ImportMetadata Read(SqlMapper.GridReader grid)
            {
                var meta = grid.ReadFirstOrDefault <ImportMetadataRecord>();

                if (meta == null)
                {
                    return(null);
                }
                var cons = grid.Read <ImportMetadataConstraintRecord>();

                return(new ImportMetadata
                {
                    Constraints = cons.Select(c => c.Constraint()),
                    Created = meta.Created,
                    Id = meta.Id,
                    SourceId = meta.SourceId,
                    StructureJson = meta.Structure,
                    Type = meta.Type,
                    Updated = meta.Updated
                });
            }
예제 #11
0
        public BaseListResult Handle(SqlMapper.GridReader reader)
        {
            var result = new BaseListResult();

            //用户本人数据
            result.mine = reader.ReadFirstOrDefault <UserEntity>();
            //处理friend逻辑 start
            var friend     = reader.Read <FriendGroupEntity>();
            var groupUsers = reader.Read <GroupUserEntity>();

            friend.ToList().ForEach(f =>
            {
                //每一组的人分配给各个组
                f.list = groupUsers?.Where(x => x.groupid == f.id);
            });
            result.friend = friend;
            //处理friend逻辑 end
            //读取用户所在群
            result.group = reader.Read <GroupEntity>();
            return(result);
        }