Esempio n. 1
0
 public GroupMemberModel Get(
     Context context,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     bool distinct = false,
     int top       = 0)
 {
     where = where ?? Rds.GroupMembersWhereDefault(
         context: context,
         groupMemberModel: this);
     Set(context, Repository.ExecuteTable(
             context: context,
             statements: Rds.SelectGroupMembers(
                 tableType: tableType,
                 column: column ?? Rds.GroupMembersDefaultColumns(),
                 join: join ?? Rds.GroupMembersJoinDefault(),
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 distinct: distinct,
                 top: top)));
     return(this);
 }
Esempio n. 2
0
 public LinkCollection(
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     bool distinct    = false,
     int top          = 0,
     int offset       = 0,
     int pageSize     = 0,
     bool countRecord = false,
     IEnumerable <Aggregation> aggregationCollection = null,
     bool get = true)
 {
     if (get)
     {
         Set(Get(
                 column: column,
                 join: join,
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 tableType: tableType,
                 distinct: distinct,
                 top: top,
                 offset: offset,
                 pageSize: pageSize,
                 countRecord: countRecord,
                 aggregationCollection: aggregationCollection));
     }
 }
Esempio n. 3
0
 public GroupModel Get(
     Context context,
     SiteSettings ss,
     Sqls.TableTypes tableType = Sqls.TableTypes.Normal,
     SqlColumnCollection column = null,
     SqlJoinCollection join = null,
     SqlWhereCollection where = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param = null,
     bool distinct = false,
     int top = 0)
 {
     Set(context, ss, Rds.ExecuteTable(
         context: context,
         statements: Rds.SelectGroups(
             tableType: tableType,
             column: column ?? Rds.GroupsDefaultColumns(),
             join: join ??  Rds.GroupsJoinDefault(),
             where: where ?? Rds.GroupsWhereDefault(this),
             orderBy: orderBy,
             param: param,
             distinct: distinct,
             top: top)));
     return this;
 }
 public UserCollection(
     Context context,
     SiteSettings ss,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     bool distinct    = false,
     int top          = 0,
     int offset       = 0,
     int pageSize     = 0,
     bool countRecord = false,
     bool get         = true)
 {
     if (get)
     {
         Set(context, ss, Get(
                 context: context,
                 column: column,
                 join: join,
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 tableType: tableType,
                 distinct: distinct,
                 top: top,
                 offset: offset,
                 pageSize: pageSize,
                 countRecord: countRecord));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static DataSet Get(
     Context context,
     IEnumerable <string> searchIndexes,
     SqlColumnCollection column,
     IEnumerable <long> siteIdList = null,
     string dataTableName          = null,
     int offset       = 0,
     int pageSize     = 0,
     bool countRecord = false)
 {
     if (searchIndexes.Count() == 0)
     {
         return(null);
     }
     return(Rds.ExecuteDataSet(
                context: context,
                statements: SelectBySearchIndexes(
                    context: context,
                    searchIndexes: searchIndexes,
                    column: column,
                    orderBy: Rds.SearchIndexesOrderBy()
                    .SearchIndexesCount(SqlOrderBy.Types.desc)
                    .Priority(function: Sqls.Functions.Sum)
                    .UpdatedTime(SqlOrderBy.Types.desc, function: Sqls.Functions.Max),
                    siteIdList: siteIdList,
                    dataTableName: dataTableName,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: countRecord)));
 }
Esempio n. 6
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static SqlSelect SelectBySearchIndexes(
     Context context,
     IEnumerable <string> searchIndexes,
     SqlColumnCollection column,
     SqlOrderByCollection orderBy,
     IEnumerable <long> siteIdList,
     string dataTableName = null,
     int offset           = 0,
     int pageSize         = 0,
     bool countRecord     = false)
 {
     return(Rds.SelectSearchIndexes(
                dataTableName: dataTableName,
                column: column,
                join: Rds.SearchIndexesJoinDefault(),
                where : Rds.SearchIndexesWhere()
                .Word(searchIndexes, multiParamOperator: " or ")
                .Add(
                    raw: Def.Sql.CanRead,
                    _using: !context.HasPrivilege)
                .Add(
                    raw: "[Items].[SiteId] in ({0})".Params(siteIdList?.Join()),
                    _using: siteIdList?.Any() == true),
                groupBy: Rds.SearchIndexesGroupBy()
                .ReferenceId()
                .ReferenceType(),
                having: Rds.SearchIndexesHaving()
                .SearchIndexesCount(
                    Concordance(searchIndexes),
                    _operator: ">="),
                orderBy: orderBy,
                offset: offset,
                pageSize: pageSize,
                countRecord: countRecord));
 }
Esempio n. 7
0
 public GridData(
     Context context,
     SiteSettings ss,
     View view,
     Sqls.TableTypes?tableType  = null,
     SqlColumnCollection column = null,
     SqlJoinCollection join     = null,
     SqlWhereCollection where   = null,
     int top      = 0,
     int offset   = 0,
     int pageSize = 0)
 {
     Get(
         context: context,
         ss: ss,
         view: view,
         tableType: tableType ?? ((view.ShowHistory == true)
             ? Sqls.TableTypes.NormalAndHistory
             : ss.TableType),
         column: column,
         join: join,
         where : where,
         top: top,
         offset: offset,
         pageSize: pageSize);
 }
Esempio n. 8
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static SqlSelect SelectByFullText(
     Context context,
     SqlColumnCollection column,
     SqlOrderByCollection orderBy,
     IEnumerable <long> siteIdList,
     List <string> words,
     string dataTableName = null,
     int offset           = 0,
     int pageSize         = 0,
     bool countRecord     = false)
 {
     return(Rds.SelectItems(
                dataTableName: dataTableName,
                column: column,
                join: new SqlJoinCollection(
                    new SqlJoin(
                        tableBracket: "[Sites]",
                        joinType: SqlJoin.JoinTypes.Inner,
                        joinExpression: "[Items].[SiteId]=[Sites].[SiteId]")),
                where : Rds.ItemsWhere()
                .Add(raw: FullTextWhere(words))
                .Add(
                    raw: Def.Sql.CanRead,
                    _using: !context.HasPrivilege && !context.Publish)
                .Add(
                    raw: "[Items].[SiteId] in ({0})".Params(siteIdList?.Join()),
                    _using: siteIdList?.Any() == true),
                param: FullTextParam(words),
                orderBy: orderBy,
                offset: offset,
                pageSize: pageSize,
                countRecord: countRecord));
 }
 public MailAddressCollection(
     Context context,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     bool distinct = false,
     int top       = 0,
     int offset    = 0,
     int pageSize  = 0,
     bool get      = true)
 {
     if (get)
     {
         Set(
             context: context,
             dataRows: Get(
                 context: context,
                 column: column,
                 join: join,
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 tableType: tableType,
                 distinct: distinct,
                 top: top,
                 offset: offset,
                 pageSize: pageSize));
     }
 }
Esempio n. 10
0
 public GridData(
     Context context,
     SiteSettings ss,
     View view,
     SqlColumnCollection column = null,
     SqlJoinCollection join     = null,
     SqlWhereCollection where   = null,
     int top          = 0,
     int offset       = 0,
     int pageSize     = 0,
     bool countRecord = false,
     IEnumerable <Aggregation> aggregations = null)
 {
     Get(
         context: context,
         ss: ss,
         view: view,
         column: column,
         join: join,
         where : where,
         top: top,
         offset: offset,
         pageSize: pageSize,
         countRecord: countRecord,
         aggregations: aggregations);
 }
 /// <summary>
 /// Fixed:
 /// </summary>
 private static SqlSelect SelectByFullText(
     SqlColumnCollection column,
     SqlOrderByCollection orderBy,
     IEnumerable <long> siteIdList,
     List <string> words,
     string dataTableName = null,
     int offset           = 0,
     int pageSize         = 0,
     bool countRecord     = false,
     string paramName     = "@Words_Param")
 {
     return(Rds.SelectItems(
                dataTableName: dataTableName,
                column: column,
                join: Rds.ItemsJoinDefault()
                .Add(new SqlJoin(
                         tableName: "[Sites]",
                         joinType: SqlJoin.JoinTypes.Inner,
                         joinExpression: "[Items].[SiteId]=[Sites].[SiteId]")),
                where : Rds.ItemsWhere()
                .Add(raw: "contains(FullText, '" + words.Join(" and ") + "')")
                .Add(raw: Def.Sql.CanRead)
                .Add(
                    raw: "[Items].[SiteId] in ({0})".Params(siteIdList?.Join()),
                    _using: siteIdList?.Any() == true),
                orderBy: orderBy,
                offset: offset,
                pageSize: pageSize,
                countRecord: countRecord));
 }
Esempio n. 12
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static SqlSelect SelectByFullText(
     SqlColumnCollection column,
     SqlOrderByCollection orderBy,
     IEnumerable <long> siteIdList,
     List <string> words,
     string dataTableName = null,
     int offset           = 0,
     int pageSize         = 0,
     bool countRecord     = false,
     string paramName     = "@Words_Param")
 {
     return(Rds.SelectItems(
                dataTableName: dataTableName,
                column: column,
                join: new SqlJoinCollection(
                    new SqlJoin(
                        tableBracket: "[Sites]",
                        joinType: SqlJoin.JoinTypes.Inner,
                        joinExpression: "[Items].[SiteId]=[Sites].[SiteId]")),
                where : Rds.ItemsWhere()
                .Add(raw: "contains(FullText, @SearchText_Param#CommandCount#)")
                .Add(
                    raw: Def.Sql.CanRead,
                    _using: !Permissions.HasPrivilege())
                .Add(
                    raw: "[Items].[SiteId] in ({0})".Params(siteIdList?.Join()),
                    _using: siteIdList?.Any() == true),
                param: Rds.ItemsParam()
                .Add(name: "SearchText", value: words.Join(" and ")),
                orderBy: orderBy,
                offset: offset,
                pageSize: pageSize,
                countRecord: countRecord));
 }
Esempio n. 13
0
        private void Get(
            SiteSettings ss,
            View view,
            SqlColumnCollection column = null,
            SqlWhereCollection where   = null,
            Sqls.TableTypes tableType  = Sqls.TableTypes.Normal,
            int top          = 0,
            int offset       = 0,
            int pageSize     = 0,
            bool history     = false,
            bool countRecord = false,
            IEnumerable <Aggregation> aggregations = null)
        {
            column = column ?? SqlColumnCollection(ss, GridColumns(ss));
            var join = ss.Join(withColumn: true);

            where = view.Where(ss, where);
            var orderBy = view.OrderBy(ss);

            if (pageSize > 0 && orderBy?.Any() != true)
            {
                orderBy = new SqlOrderByCollection().Add(
                    tableName: ss.ReferenceType,
                    columnBracket: "[UpdatedTime]",
                    orderType: SqlOrderBy.Types.desc);
            }
            var statements = new List <SqlStatement>
            {
                Rds.Select(
                    tableName: ss.ReferenceType,
                    dataTableName: "Main",
                    column: column,
                    join: join,
                    where : where,
                    orderBy: orderBy,
                    tableType: tableType,
                    top: top,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: countRecord)
            };

            if (aggregations != null)
            {
                SetAggregations(
                    ss: ss,
                    aggregations: aggregations,
                    join: join,
                    where : where,
                    statements: statements);
            }
            var dataSet = Rds.ExecuteDataSet(
                transactional: false,
                statements: statements.ToArray());

            Aggregations.Set(dataSet, aggregations, ss);
            DataRows = dataSet.Tables["Main"].AsEnumerable();
            ss.SetChoiceHash(DataRows);
        }
Esempio n. 14
0
        private void Get(
            Context context,
            SiteSettings ss,
            View view,
            SqlColumnCollection column = null,
            SqlJoinCollection join     = null,
            SqlWhereCollection where   = null,
            int top          = 0,
            int offset       = 0,
            int pageSize     = 0,
            bool history     = false,
            bool countRecord = false,
            IEnumerable <Aggregation> aggregations = null)
        {
            column = column ?? SqlColumnCollection(ss, GridColumns(
                                                       context: context,
                                                       view: view,
                                                       ss: ss));
            join  = join ?? ss.Join(context: context, withColumn: true);
            where = view.Where(context: context, ss: ss, where : where);
            var orderBy    = view.OrderBy(context: context, ss: ss, pageSize: pageSize);
            var statements = new List <SqlStatement>
            {
                Rds.Select(
                    tableName: ss.ReferenceType,
                    tableType: ss.TableType,
                    dataTableName: "Main",
                    column: column,
                    join: join,
                    where : where,
                    orderBy: orderBy,
                    top: top,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: countRecord)
            };

            if (aggregations != null)
            {
                SetAggregations(
                    ss: ss,
                    aggregations: aggregations,
                    join: join,
                    where : where,
                    statements: statements);
            }
            var dataSet = Rds.ExecuteDataSet(
                context: context,
                transactional: false,
                statements: statements.ToArray());

            Aggregations.Set(
                context: context,
                ss: ss,
                dataSet: dataSet,
                aggregationCollection: aggregations);
            DataRows = dataSet.Tables["Main"].AsEnumerable();
            ss.SetChoiceHash(DataRows);
        }
Esempio n. 15
0
        public ImageLibData(
            Context context,
            SiteSettings ss,
            View view,
            int offset   = 0,
            int pageSize = 0)
        {
            var idColumnBracket = $"\"{Rds.IdColumn(ss.ReferenceType)}\"";
            var column          = new SqlColumnCollection()
                                  .Add(
                columnBracket: idColumnBracket,
                tableName: ss.ReferenceType,
                _as: "Id")
                                  .ItemTitle(ss.ReferenceType)
                                  .Add(tableName: "Binaries", columnBracket: "\"Guid\"");

            var where = view.Where(
                context: context,
                ss: ss)
                        .Binaries_BinaryType("Images");
            var orderBy = view.OrderBy(
                context: context,
                ss: ss);
            var joinExpression = $"\"Binaries\".\"ReferenceId\"=\"{ss.ReferenceType}\".{idColumnBracket}";
            var join           = ss.Join(
                context: context,
                join: new IJoin[]
            {
                column,
                where,
                orderBy
            })
                                 .Add(
                tableName: "\"Binaries\"",
                joinType: SqlJoin.JoinTypes.Inner,
                joinExpression: joinExpression);
            var dataSet = Repository.ExecuteDataSet(
                context: context,
                statements: new SqlStatement[]
            {
                Rds.Select(
                    tableName: ss.ReferenceType,
                    dataTableName: "Main",
                    column: column,
                    join: join,
                    where : where,
                    orderBy: orderBy,
                    offset: offset,
                    pageSize: pageSize),
                Rds.SelectCount(
                    tableName: ss.ReferenceType,
                    join: join,
                    where : where)
            });

            DataRows   = dataSet.Tables["Main"].AsEnumerable();
            TotalCount = Rds.Count(dataSet);
        }
Esempio n. 16
0
        private void Get(
            Context context,
            SiteSettings ss,
            View view,
            SqlColumnCollection column = null,
            SqlJoinCollection join     = null,
            SqlWhereCollection where   = null,
            int top      = 0,
            int offset   = 0,
            int pageSize = 0,
            bool history = false)
        {
            column = column ?? SqlColumnCollection(
                context: context,
                ss: ss,
                columns: GridColumns(
                    context: context,
                    view: view,
                    ss: ss));
            where = view.Where(
                context: context,
                ss: ss,
                where : where);
            var orderBy = view.OrderBy(
                context: context,
                ss: ss);
            var statements = new List <SqlStatement>
            {
                Rds.Select(
                    tableName: ss.ReferenceType,
                    tableType: ss.TableType,
                    dataTableName: "Main",
                    column: column,
                    join: join ?? ss.Join(
                        context: context,
                        join: new IJoin[]
                {
                    column,
                    where,
                    orderBy
                }),
                    where : where,
                    orderBy: orderBy,
                    top: top,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: true)
            };
            var dataSet = Rds.ExecuteDataSet(
                context: context,
                transactional: false,
                statements: statements.ToArray());

            DataRows   = dataSet.Tables["Main"].AsEnumerable();
            TotalCount = Rds.Count(dataSet);
            ss.SetChoiceHash(DataRows);
        }
Esempio n. 17
0
 /// <summary>
 /// Fixed:
 /// </summary>
 private static SqlSelect SelectByFullText(
     Context context,
     Dictionary <string, string> words,
     SqlColumnCollection column    = null,
     SqlOrderByCollection orderBy  = null,
     IEnumerable <long> siteIdList = null,
     string dataTableName          = null,
     int offset       = 0,
     int pageSize     = 0,
     bool countRecord = false)
 {
     return(!countRecord
         ? Rds.SelectItems(
                dataTableName : dataTableName,
                column : column,
                join : new SqlJoinCollection(
                    new SqlJoin(
                        tableBracket: "\"Sites\"",
                        joinType: SqlJoin.JoinTypes.Inner,
                        joinExpression: "\"Items\".\"SiteId\"=\"Sites\".\"SiteId\"")),
                where : Rds.ItemsWhere()
                .FullTextWhere(
                    context : context,
                    words : words)
                .Add(
                    raw : Def.Sql.CanRead,
                    _using : !context.HasPrivilege && !context.Publish)
                .Add(
                    raw : "\"Items\".\"SiteId\" in ({0})".Params(siteIdList?.Join()),
                    _using : siteIdList?.Any() == true)
                .Add(raw : $"{context.Sqls.IsNull}(\"Sites\".\"DisableCrossSearch\",'false')='false'")
                .Add(
                    raw : "\"Items\".\"ReferenceType\"<>'Sites'",
                    _using : Parameters.Search.DisableCrossSearchSites),
                param : FullTextParam(words),
                orderBy : orderBy,
                offset : offset,
                pageSize : pageSize)
            : Rds.SelectCount(
                tableName : "Items",
                join : new SqlJoinCollection(
                    new SqlJoin(
                        tableBracket : "\"Sites\"",
                        joinType : SqlJoin.JoinTypes.Inner,
                        joinExpression : "\"Items\".\"SiteId\"=\"Sites\".\"SiteId\"")),
                    where : Rds.ItemsWhere()
                .FullTextWhere(
                    context : context,
                    words : words)
                .Add(
                    raw : Def.Sql.CanRead,
                    _using : !context.HasPrivilege && !context.Publish)
                .Add(
                    raw : "\"Items\".\"SiteId\" in ({0})".Params(siteIdList?.Join()),
                    _using : siteIdList?.Any() == true),
                param : FullTextParam(words)));
 }
Esempio n. 18
0
        public ImageLibData(
            Context context,
            SiteSettings ss,
            View view,
            int offset   = 0,
            int pageSize = 0)
        {
            var idColumnBracket = $"[{Rds.IdColumn(ss.ReferenceType)}]";
            var column          = new SqlColumnCollection()
                                  .Add(
                columnBracket: idColumnBracket,
                tableName: ss.ReferenceType,
                _as: "Id")
                                  .ItemTitle(ss.ReferenceType, Rds.IdColumn(ss.ReferenceType))
                                  .Add(tableName: "Binaries", columnBracket: "[Guid]");

            var where = view.Where(
                context: context,
                ss: ss)
                        .Binaries_BinaryType("Images");
            var orderBy = view.OrderBy(
                context: context,
                ss: ss,
                pageSize: pageSize);
            var joinExpression = $"[Binaries].[ReferenceId]=[{ss.ReferenceType}].{idColumnBracket}";
            var dataSet        = Rds.ExecuteDataSet(
                context: context,
                statements: Rds.Select(
                    tableName: ss.ReferenceType,
                    dataTableName: "Main",
                    column: column,
                    join: ss.Join(
                        context: context,
                        join: new IJoin[]
            {
                column,
                where,
                orderBy
            })
                    .Add(
                        tableName: "Binaries",
                        joinType: SqlJoin.JoinTypes.Inner,
                        joinExpression: joinExpression),
                    where : where,
                    orderBy: orderBy,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: true));

            DataRows   = dataSet.Tables["Main"].AsEnumerable();
            TotalCount = Rds.Count(dataSet);
        }
Esempio n. 19
0
        private EnumerableRowCollection <DataRow> Get(
            SiteSettings ss,
            SqlColumnCollection column   = null,
            SqlJoinCollection join       = null,
            SqlWhereCollection where     = null,
            SqlOrderByCollection orderBy = null,
            SqlParamCollection param     = null,
            Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
            bool distinct    = false,
            int top          = 0,
            int offset       = 0,
            int pageSize     = 0,
            bool history     = false,
            bool countRecord = false,
            IEnumerable <Aggregation> aggregations = null)
        {
            var statements = new List <SqlStatement>
            {
                Rds.SelectIssues(
                    dataTableName: "Main",
                    column: column ?? Rds.IssuesDefaultColumns(),
                    join: join ?? Rds.IssuesJoinDefault(),
                    where : where,
                    orderBy: orderBy,
                    param: param,
                    tableType: tableType,
                    distinct: distinct,
                    top: top,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: countRecord)
            };

            if (aggregations != null)
            {
                statements.AddRange(Rds.IssuesAggregations(
                                        aggregations: aggregations,
                                        join: join ?? Rds.IssuesJoinDefault(),
                                        where : where));
            }
            var dataSet = Rds.ExecuteDataSet(
                transactional: false,
                statements: statements.ToArray());

            Aggregations.Set(dataSet, aggregations, ss);
            return(dataSet.Tables["Main"].AsEnumerable());
        }
Esempio n. 20
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public byte[] SiteImage(
            Libraries.Images.ImageData.SizeTypes sizeType, SqlColumnCollection column)
        {
            switch (Parameters.BinaryStorage.Provider)
            {
            case "Local":
                return(new Libraries.Images.ImageData(
                           ReferenceId, Libraries.Images.ImageData.Types.SiteImage)
                       .Read(sizeType));

            default:
                return(Rds.ExecuteScalar_bytes(statements:
                                               Rds.SelectBinaries(
                                                   column: column,
                                                   where : Rds.BinariesWhere().ReferenceId(ReferenceId))));
            }
        }
Esempio n. 21
0
        private SqlColumnCollection SetSqlColum(
            Context context,
            SiteSettings ss,
            string keyColumnName,
            string textColumnName)
        {
            var sqlColumn = new SqlColumnCollection();

            sqlColumn.Add(
                context: context,
                column: ss.GetColumn(
                    context: context,
                    columnName: keyColumnName),
                _as: "Key");
            if (textColumnName == "Title")
            {
                sqlColumn.ItemTitle(
                    tableName: ss.ReferenceType,
                    _as: "Text");
            }
            else
            {
                sqlColumn.Add(
                    context: context,
                    column: ss.GetColumn(
                        context: context,
                        columnName: textColumnName),
                    _as: "Text");
            }
            if (!SearchFormat.IsNullOrEmpty())
            {
                var columns = new List <Column>();
                ss.IncludedColumns(SearchFormat)
                .Where(column => column.CanRead(
                           context: context,
                           ss: ss,
                           mine: null))
                .ForEach(column => columns.Add(column));
                sqlColumn.AddRange(columns.SelectMany(column => column.SqlColumnCollection())
                                   .GroupBy(sql => sql.ColumnBracket + sql.As)
                                   .Select(sql => sql.First())
                                   .ToArray());
            }
            return(sqlColumn);
        }
Esempio n. 22
0
        private EnumerableRowCollection <DataRow> Get(
            Context context,
            SiteSettings ss,
            SqlColumnCollection column   = null,
            SqlJoinCollection join       = null,
            SqlWhereCollection where     = null,
            SqlOrderByCollection orderBy = null,
            SqlParamCollection param     = null,
            Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
            bool distinct = false,
            int top       = 0,
            int offset    = 0,
            int pageSize  = 0)
        {
            var statements = new List <SqlStatement>
            {
                Rds.SelectIssues(
                    dataTableName: "Main",
                    column: column ?? Rds.IssuesDefaultColumns(),
                    join: join ?? Rds.IssuesJoinDefault(),
                    where : where,
                    orderBy: orderBy,
                    param: param,
                    tableType: tableType,
                    distinct: distinct,
                    top: top,
                    offset: offset,
                    pageSize: pageSize),
                Rds.SelectCount(
                    tableName: "Issues",
                    tableType: tableType,
                    join: join ?? Rds.IssuesJoinDefault(),
                    where : where)
            };
            var dataSet = Repository.ExecuteDataSet(
                context: context,
                transactional: false,
                statements: statements.ToArray());

            TotalCount = Rds.Count(dataSet);
            return(dataSet.Tables["Main"].AsEnumerable());
        }
Esempio n. 23
0
 public BinaryModel Get(
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     bool distinct = false,
     int top       = 0)
 {
     Set(Rds.ExecuteTable(statements: Rds.SelectBinaries(
                              tableType: tableType,
                              column: column ?? Rds.BinariesDefaultColumns(),
                              join: join ?? Rds.BinariesJoinDefault(),
                              where : where ?? Rds.BinariesWhereDefault(this),
                              orderBy: orderBy,
                              param: param,
                              distinct: distinct,
                              top: top)));
     return(this);
 }
Esempio n. 24
0
        public static SqlColumnCollection SqlColumnCollection(
            Context context,
            SiteSettings ss,
            View view,
            List <Column> columns)
        {
            var sqlColumnCollection = new SqlColumnCollection();
            var sqlColumns          = Columns(
                context: context,
                ss: ss,
                view: view,
                columns: columns)
                                      .SelectMany(column => column.SqlColumnWithUpdatedTimeCollection())
                                      .GroupBy(o => o.ColumnBracket + o.As)
                                      .Select(o => o.First());

            return(sqlColumns.SetExtendedSqlSelectingColumn(
                       context: context,
                       ss: ss,
                       view: view));
        }
Esempio n. 25
0
 public UserModel Get(
     SiteSettings ss,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     bool distinct = false,
     int top       = 0)
 {
     Set(ss, Rds.ExecuteTable(statements: Rds.SelectUsers(
                                  tableType: tableType,
                                  column: column ?? Rds.UsersDefaultColumns(),
                                  join: join ?? Rds.UsersJoinDefault(),
                                  where : where ?? Rds.UsersWhereDefault(this),
                                  orderBy: orderBy ?? null,
                                  param: param ?? null,
                                  distinct: distinct,
                                  top: top)));
     return(this);
 }
        private IEnumerable <DataRow> Get(
            IContext context,
            SqlColumnCollection column   = null,
            SqlJoinCollection join       = null,
            SqlWhereCollection where     = null,
            SqlOrderByCollection orderBy = null,
            SqlParamCollection param     = null,
            Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
            bool distinct    = false,
            int top          = 0,
            int offset       = 0,
            int pageSize     = 0,
            bool history     = false,
            bool countRecord = false)
        {
            var statements = new List <SqlStatement>
            {
                Rds.SelectReminderSchedules(
                    dataTableName: "Main",
                    column: column ?? Rds.ReminderSchedulesDefaultColumns(),
                    join: join ?? Rds.ReminderSchedulesJoinDefault(),
                    where : where,
                    orderBy: orderBy,
                    param: param,
                    tableType: tableType,
                    distinct: distinct,
                    top: top,
                    offset: offset,
                    pageSize: pageSize,
                    countRecord: countRecord)
            };
            var dataSet = Rds.ExecuteDataSet(
                context: context,
                transactional: false,
                statements: statements.ToArray());

            TotalCount = Rds.Count(dataSet);
            return(dataSet.Tables["Main"].AsEnumerable());
        }
Esempio n. 27
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public byte[] TenantImage(
            Context context,
            Libraries.Images.ImageData.SizeTypes sizeType,
            SqlColumnCollection column)
        {
            switch (Parameters.BinaryStorage.Provider)
            {
            case "Local":
                return(new Libraries.Images.ImageData(
                           ReferenceId, Libraries.Images.ImageData.Types.TenantImage)
                       .Read(sizeType));

            default:
                return(Repository.ExecuteScalar_bytes(
                           context: context,
                           statements: Rds.SelectBinaries(
                               column: column,
                               where : Rds.BinariesWhere()
                               .ReferenceId(ReferenceId)
                               .BinaryType("TenantImage"))));
            }
        }
Esempio n. 28
0
 public GridData(
     Context context,
     SiteSettings ss,
     View view,
     SqlColumnCollection column = null,
     SqlJoinCollection join     = null,
     SqlWhereCollection where   = null,
     int top      = 0,
     int offset   = 0,
     int pageSize = 0)
 {
     Get(
         context: context,
         ss: ss,
         view: view,
         column: column,
         join: join,
         where : where,
         top: top,
         offset: offset,
         pageSize: pageSize);
 }
Esempio n. 29
0
 public IssueCollection(
     Context context,
     SiteSettings ss,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     bool distinct = false,
     int top       = 0,
     int offset    = 0,
     int pageSize  = 0,
     bool get      = true,
     List <FormData> formDataSet = null)
 {
     if (get)
     {
         Set(
             context: context,
             ss: ss,
             dataRows: Get(
                 context: context,
                 ss: ss,
                 column: column,
                 join: join,
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 tableType: tableType,
                 distinct: distinct,
                 top: top,
                 offset: offset,
                 pageSize: pageSize),
             formDataSet: formDataSet);
     }
 }
Esempio n. 30
0
        /// <summary>
        /// Fixed:
        /// </summary>
        public static DataSet Get(
            IEnumerable <string> searchIndexes,
            SqlColumnCollection column,
            long siteId      = 0,
            int offset       = 0,
            int pageSize     = 0,
            bool countRecord = false)
        {
            if (searchIndexes.Count() == 0)
            {
                return(null);
            }
            var concordance = Math.Ceiling(
                searchIndexes.Count() * Parameters.General.SearchConcordanceRate);

            return(Rds.ExecuteDataSet(statements:
                                      Rds.SelectSearchIndexes(
                                          dataTableName: "Main",
                                          column: column,
                                          join: Rds.SearchIndexesJoinDefault(),
                                          where : Rds.SearchIndexesWhere()
                                          .Word(searchIndexes, multiParamOperator: " or ")
                                          .PermissionType(0, _operator: "<>")
                                          .Items_SiteId(value: siteId, _using: siteId != 0),
                                          groupBy: Rds.SearchIndexesGroupBy()
                                          .ReferenceId()
                                          .ReferenceType(),
                                          having: Rds.SearchIndexesHaving()
                                          .SearchIndexesCount(concordance, _operator: ">="),
                                          orderBy: Rds.SearchIndexesOrderBy()
                                          .SearchIndexesCount(SqlOrderBy.Types.desc)
                                          .Priority(function: Sqls.Functions.Sum)
                                          .UpdatedTime(SqlOrderBy.Types.desc, function: Sqls.Functions.Max),
                                          offset: offset,
                                          pageSize: pageSize,
                                          countRecord: countRecord)));
        }