public ResultCollection( 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); } }
private EnumerableRowCollection <DataRow> Get( 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.SelectOrders( dataTableName: "Main", column: column ?? Rds.OrdersDefaultColumns(), join: join ?? Rds.OrdersJoinDefault(), where : where, orderBy: orderBy, param: param, tableType: tableType, distinct: distinct, top: top, offset: offset, pageSize: pageSize, countRecord: countRecord) }; var dataSet = Rds.ExecuteDataSet( transactional: false, statements: statements.ToArray()); TotalCount = Rds.Count(dataSet); return(dataSet.Tables["Main"].AsEnumerable()); }
private SqlStatement CopyToStatement(SqlWhereCollection where, Sqls.TableTypes tableType) { var column = new Rds.DemosColumnCollection(); var param = new Rds.DemosParamCollection(); column.DemoId(function: Sqls.Functions.SingleColumn); param.DemoId(); column.Ver(function: Sqls.Functions.SingleColumn); param.Ver(); column.TenantId(function: Sqls.Functions.SingleColumn); param.TenantId(); column.Title(function: Sqls.Functions.SingleColumn); param.Title(); column.LoginId(function: Sqls.Functions.SingleColumn); param.LoginId(); column.Passphrase(function: Sqls.Functions.SingleColumn); param.Passphrase(); column.MailAddress(function: Sqls.Functions.SingleColumn); param.MailAddress(); column.Initialized(function: Sqls.Functions.SingleColumn); param.Initialized(); column.Comments(function: Sqls.Functions.SingleColumn); param.Comments(); column.Creator(function: Sqls.Functions.SingleColumn); param.Creator(); column.Updator(function: Sqls.Functions.SingleColumn); param.Updator(); column.CreatedTime(function: Sqls.Functions.SingleColumn); param.CreatedTime(); column.UpdatedTime(function: Sqls.Functions.SingleColumn); param.UpdatedTime(); return(Rds.InsertDemos( tableType: tableType, param: param, select: Rds.SelectDemos(column: column, where : where), addUpdatorParam: false)); }
public GridData( 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 countRecord = false, IEnumerable <Aggregation> aggregations = null) { Get( ss: ss, view: view, column: column, where : where, tableType: tableType, top: top, offset: offset, pageSize: pageSize, countRecord: countRecord, aggregations: aggregations); }
public Error.Types Create( RdsUser rdsUser = null, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false, bool get = true) { Size = Bin.Length; var statements = new List <SqlStatement>(); CreateStatements(statements, tableType, param, otherInitValue); var response = Rds.ExecuteScalar_response( rdsUser: rdsUser, transactional: true, selectIdentity: true, statements: statements.ToArray()); BinaryId = (response.Identity ?? BinaryId).ToLong(); if (get) { Get(); } return(Error.Types.None); }
public List <SqlStatement> CreateStatements( Context context, string dataTableName = null, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false) { var statements = new List <SqlStatement>(); statements.AddRange(new List <SqlStatement> { Rds.InsertMailAddresses( dataTableName: dataTableName, tableType: tableType, selectIdentity: true, param: param ?? Rds.MailAddressesParamDefault( context: context, mailAddressModel: this, setDefault: true, otherInitValue: otherInitValue)) }); statements.AddRange(UpdateAttachmentsStatements(context: context)); return(statements); }
public MailAddressModel 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) { Set(context, Rds.ExecuteTable( context: context, statements: Rds.SelectMailAddresses( tableType: tableType, column: column ?? Rds.MailAddressesDefaultColumns(), join: join ?? Rds.MailAddressesJoinDefault(), where : where ?? Rds.MailAddressesWhereDefault(this), orderBy: orderBy, param: param, distinct: distinct, top: top))); return(this); }
public static SiteSettings WikisSiteSettings( this SiteModel siteModel, long referenceId, bool setSiteIntegration = false, bool setAllChoices = false, Sqls.TableTypes tableType = Sqls.TableTypes.Normal) { var ss = siteModel.SiteSettings ?? new SiteSettings(); ss.TableType = tableType; ss.SiteId = siteModel.SiteId; ss.ReferenceId = referenceId; ss.Title = siteModel.Title.Value; ss.ReferenceType = "Wikis"; ss.ParentId = siteModel.ParentId; ss.InheritPermission = siteModel.InheritPermission; ss.AccessStatus = siteModel.AccessStatus; ss.Init(); ss.SetLinkedSiteSettings(); ss.SetPermissions(referenceId); ss.SetJoinedSsHash(); ss.SetChoiceHash(all: setAllChoices); return(ss); }
public Error.Types Create( Context context, SiteSettings ss, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false, bool get = true) { var statements = new List <SqlStatement>(); CreateStatements(context, statements, tableType, param, otherInitValue); var response = Rds.ExecuteScalar_response( context: context, transactional: true, selectIdentity: true, statements: statements.ToArray()); HealthId = (response.Identity ?? HealthId).ToLong(); if (get) { Get(context: context); } return(Error.Types.None); }
internal static IEnumerable <IndexInfo> IndexInfoCollection( ISqlObjectFactory factory, string generalTableName, string sourceTableName, Sqls.TableTypes tableType) { var tableIndexCollection = new List <IndexInfo>(); switch (tableType) { case Sqls.TableTypes.Normal: General(factory: factory, generalTableName: generalTableName, sourceTableName: sourceTableName, tableIndexCollection: tableIndexCollection); Unique(factory: factory, generalTableName: generalTableName, tableIndexCollection: tableIndexCollection); break; case Sqls.TableTypes.Deleted: General(factory: factory, generalTableName: generalTableName, sourceTableName: sourceTableName, tableIndexCollection: tableIndexCollection); break; case Sqls.TableTypes.History: History(factory: factory, generalTableName: generalTableName, sourceTableName: sourceTableName, tableIndexCollection: tableIndexCollection); break; } return(tableIndexCollection); }
public List <SqlStatement> CreateStatements( List <SqlStatement> statements, SiteSettings ss, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false) { statements.AddRange(new List <SqlStatement> { Rds.InsertGroups( tableType: tableType, selectIdentity: true, param: param ?? Rds.GroupsParamDefault( this, setDefault: true, otherInitValue: otherInitValue)), Rds.InsertGroupMembers( tableType: tableType, param: param ?? Rds.GroupMembersParam() .GroupId(raw: Def.Sql.Identity) .UserId(Sessions.UserId()) .Admin(true)), StatusUtilities.UpdateStatus(StatusUtilities.Types.GroupsUpdated) }); return(statements); }
public static SiteSettings ResultsSiteSettings( this SiteModel siteModel, Context context, long referenceId, bool setSiteIntegration = false, bool setAllChoices = false, Sqls.TableTypes tableType = Sqls.TableTypes.Normal) { var ss = siteModel.SiteSettings ?? new SiteSettings(); ss.LockedTime = siteModel.LockedTime; ss.LockedUser = siteModel.LockedUser; ss.TableType = tableType; ss.SiteId = siteModel.SiteId; ss.ReferenceId = referenceId; ss.Title = siteModel.Title.Value; ss.Body = siteModel.Body; ss.GridGuide = siteModel.GridGuide; ss.EditorGuide = siteModel.EditorGuide; ss.ReferenceType = "Results"; ss.ParentId = siteModel.ParentId; ss.InheritPermission = siteModel.InheritPermission; ss.Publish = siteModel.Publish; ss.AccessStatus = siteModel.AccessStatus; ss.ApiCount = siteModel.ApiCount; ss.ApiCountDate = siteModel.ApiCountDate; ss.Init(context: context); ss.SetLinkedSiteSettings(context: context); ss.SetPermissions(context: context, referenceId: referenceId); if (setSiteIntegration) { ss.SetSiteIntegration(context: context); } ss.SetChoiceHash(context: context, all: setAllChoices); return(ss); }
public List <SqlStatement> CreateStatements( Context context, SiteSettings ss, List <SqlStatement> statements, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false) { statements.AddRange(new List <SqlStatement> { Rds.InsertDepts( tableType: tableType, setIdentity: true, param: param ?? Rds.DeptsParamDefault( context: context, deptModel: this, setDefault: true, otherInitValue: otherInitValue)), StatusUtilities.UpdateStatus( tenantId: context.TenantId, type: StatusUtilities.Types.DeptsUpdated), }); return(statements); }
public Error.Types Create( SiteSettings ss, RdsUser rdsUser = null, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool otherInitValue = false, bool get = true) { var statements = new List <SqlStatement>(); CreateStatements(ss, statements, tableType, param, otherInitValue); var response = Rds.ExecuteScalar_response( rdsUser: rdsUser, transactional: true, selectIdentity: true, statements: statements.ToArray()); GroupId = (response.Identity ?? GroupId).ToInt(); if (get) { Get(ss); } return(Error.Types.None); }
private SqlStatement CopyToStatement(SqlWhereCollection where, Sqls.TableTypes tableType) { var column = new Rds.BinariesColumnCollection(); var param = new Rds.BinariesParamCollection(); column.BinaryId(function: Sqls.Functions.SingleColumn); param.BinaryId(); column.TenantId(function: Sqls.Functions.SingleColumn); param.TenantId(); column.ReferenceId(function: Sqls.Functions.SingleColumn); param.ReferenceId(); column.Ver(function: Sqls.Functions.SingleColumn); param.Ver(); column.Creator(function: Sqls.Functions.SingleColumn); param.Creator(); column.Updator(function: Sqls.Functions.SingleColumn); param.Updator(); column.CreatedTime(function: Sqls.Functions.SingleColumn); param.CreatedTime(); column.UpdatedTime(function: Sqls.Functions.SingleColumn); param.UpdatedTime(); if (!Guid.InitialValue()) { column.Guid(function: Sqls.Functions.SingleColumn); param.Guid(); } if (!BinaryType.InitialValue()) { column.BinaryType(function: Sqls.Functions.SingleColumn); param.BinaryType(); } if (!Title.InitialValue()) { column.Title(function: Sqls.Functions.SingleColumn); param.Title(); } if (!Body.InitialValue()) { column.Body(function: Sqls.Functions.SingleColumn); param.Body(); } if (!Bin.InitialValue()) { column.Bin(function: Sqls.Functions.SingleColumn); param.Bin(); } if (!Thumbnail.InitialValue()) { column.Thumbnail(function: Sqls.Functions.SingleColumn); param.Thumbnail(); } if (!Icon.InitialValue()) { column.Icon(function: Sqls.Functions.SingleColumn); param.Icon(); } if (!FileName.InitialValue()) { column.FileName(function: Sqls.Functions.SingleColumn); param.FileName(); } if (!Extension.InitialValue()) { column.Extension(function: Sqls.Functions.SingleColumn); param.Extension(); } if (!Size.InitialValue()) { column.Size(function: Sqls.Functions.SingleColumn); param.Size(); } if (!ContentType.InitialValue()) { column.ContentType(function: Sqls.Functions.SingleColumn); param.ContentType(); } if (!BinarySettings.InitialValue()) { column.BinarySettings(function: Sqls.Functions.SingleColumn); param.BinarySettings(); } if (!Comments.InitialValue()) { column.Comments(function: Sqls.Functions.SingleColumn); param.Comments(); } return(Rds.InsertBinaries( tableType: tableType, param: param, select: Rds.SelectBinaries(column: column, where : where), addUpdatorParam: false)); }
private void BuildCommandText( SqlContainer sqlContainer, SqlCommand sqlCommand, StringBuilder commandText, Sqls.TableTypes tableType, Sqls.UnionTypes unionType, bool orderBy, bool countRecord, int?commandCount) { if (!Using) { return; } if (!DataTableName.IsNullOrEmpty()) { sqlContainer.DataTableNames.Add(DataTableName); } AddUnion(commandText, unionType); SqlColumnCollection?.BuildCommandText( sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount, distinct: Distinct, top: Top); var from = From(tableType, As); commandText.Append(from); SqlJoinCollection?.BuildCommandText(commandText: commandText); SqlWhereCollection?.BuildCommandText( sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount, select: true); SqlGroupByCollection?.BuildCommandText( commandText: commandText); SqlHavingCollection?.BuildCommandText( sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount); if (orderBy) { SqlOrderByCollection?.BuildCommandText( commandText: commandText, pageSize: PageSize, tableType: TableType, commandCount: commandCount); } AddTermination(commandText); if (countRecord) { sqlContainer.DataTableNames.Add("Count"); commandText.Append("select count(*) from ( select 1 as [c] "); commandText.Append(from); SqlJoinCollection?.BuildCommandText(commandText: commandText); SqlWhereCollection?.BuildCommandText( sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount, select: true); SqlGroupByCollection?.BuildCommandText( commandText: commandText); SqlHavingCollection?.BuildCommandText( sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount); commandText.Append(") as [table_count]"); AddTermination(commandText); } AddParams_Where(sqlCommand, commandCount); AddParams_Having(sqlCommand, commandCount); AddParams_Paging(sqlCommand, commandCount); AddParams_Param(sqlCommand, commandCount); }
private void Get( Context context, SiteSettings ss, View view, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlColumnCollection column = null, SqlJoinCollection join = null, SqlWhereCollection where = null, int top = 0, int offset = 0, int pageSize = 0, bool count = true) { column = column ?? ColumnUtilities.SqlColumnCollection( context: context, ss: ss, view: view, columns: ss.GetGridColumns( context: context, view: view, includedColumns: true)); where = view.Where( context: context, ss: ss, where : where); var orderBy = view.OrderBy( context: context, ss: ss); join = join ?? ss.Join( context: context, join: new IJoin[] { column, where, orderBy }); var param = view.Param( context: context, ss: ss); var statements = new List <SqlStatement>(); statements.Add(Rds.Select( tableName: ss.ReferenceType, tableType: tableType, dataTableName: "Main", column: column, join: join, where : where, orderBy: orderBy, param: param, top: top, offset: offset, pageSize: pageSize)); if (count) { statements.Add(Rds.SelectCount( tableName: ss.ReferenceType, tableType: tableType, join: join, where : where)); } DataSet dataSet; try { dataSet = Repository.ExecuteDataSet( context: context, transactional: false, statements: statements.ToArray()); } catch (System.Exception e) { Views.SetSession( context: context, ss: ss, view: new View(), setSession: true, key: "View", useUsersView: ss.SaveViewType == SiteSettings.SaveViewTypes.User); throw e; } DataRows = dataSet.Tables["Main"].AsEnumerable(); TotalCount = Rds.Count(dataSet); ss.SetChoiceHash( context: context, dataRows: DataRows); }
private void Get( Context context, SiteSettings ss, View view, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlColumnCollection column = null, SqlJoinCollection join = null, SqlWhereCollection where = null, int top = 0, int offset = 0, int pageSize = 0) { column = column ?? ColumnUtilities.SqlColumnCollection( context: context, ss: ss, columns: ss.GetGridColumns( context: context, view: view)); where = view.Where( context: context, ss: ss, where : where); var orderBy = view.OrderBy( context: context, ss: ss); join = join ?? ss.Join( context: context, join: new IJoin[] { column, where, orderBy }); var statements = new List <SqlStatement> { Rds.Select( tableName: ss.ReferenceType, tableType: tableType, dataTableName: "Main", column: column, join: join, where : where, orderBy: orderBy, top: top, offset: offset, pageSize: pageSize), Rds.SelectCount( tableName: ss.ReferenceType, tableType: tableType, join: join, where : where) }; var dataSet = Rds.ExecuteDataSet( context: context, transactional: false, statements: statements.ToArray()); DataRows = dataSet.Tables["Main"].AsEnumerable(); TotalCount = Rds.Count(dataSet); ss.SetChoiceHash(dataRows: DataRows); }
private SqlStatement CopyToStatement(SqlWhereCollection where, Sqls.TableTypes tableType) { var column = new Rds.OutgoingMailsColumnCollection(); var param = new Rds.OutgoingMailsParamCollection(); column.ReferenceType(function: Sqls.Functions.SingleColumn); param.ReferenceType(); column.ReferenceId(function: Sqls.Functions.SingleColumn); param.ReferenceId(); column.ReferenceVer(function: Sqls.Functions.SingleColumn); param.ReferenceVer(); column.OutgoingMailId(function: Sqls.Functions.SingleColumn); param.OutgoingMailId(); column.Ver(function: Sqls.Functions.SingleColumn); param.Ver(); column.Creator(function: Sqls.Functions.SingleColumn); param.Creator(); column.Updator(function: Sqls.Functions.SingleColumn); param.Updator(); column.CreatedTime(function: Sqls.Functions.SingleColumn); param.CreatedTime(); column.UpdatedTime(function: Sqls.Functions.SingleColumn); param.UpdatedTime(); if (!Host.InitialValue()) { column.Host(function: Sqls.Functions.SingleColumn); param.Host(); } if (!Port.InitialValue()) { column.Port(function: Sqls.Functions.SingleColumn); param.Port(); } if (!From.InitialValue()) { column.From(function: Sqls.Functions.SingleColumn); param.From(); } if (!To.InitialValue()) { column.To(function: Sqls.Functions.SingleColumn); param.To(); } if (!Cc.InitialValue()) { column.Cc(function: Sqls.Functions.SingleColumn); param.Cc(); } if (!Bcc.InitialValue()) { column.Bcc(function: Sqls.Functions.SingleColumn); param.Bcc(); } if (!Title.InitialValue()) { column.Title(function: Sqls.Functions.SingleColumn); param.Title(); } if (!Body.InitialValue()) { column.Body(function: Sqls.Functions.SingleColumn); param.Body(); } if (!SentTime.InitialValue()) { column.SentTime(function: Sqls.Functions.SingleColumn); param.SentTime(); } if (!Comments.InitialValue()) { column.Comments(function: Sqls.Functions.SingleColumn); param.Comments(); } return Rds.InsertOutgoingMails( tableType: tableType, param: param, select: Rds.SelectOutgoingMails(column: column, where: where), addUpdatorParam: false); }
public Error.Types Create( Context context, SiteSettings ss, Sqls.TableTypes tableType = Sqls.TableTypes.Normal, SqlParamCollection param = null, bool extendedSqls = true, bool notice = false, bool otherInitValue = false, bool get = true) { var statements = new List <SqlStatement>(); if (extendedSqls) { statements.OnCreatingExtendedSqls(SiteId); } CreateStatements(context, ss, statements, tableType, param, otherInitValue); var response = Rds.ExecuteScalar_response( context: context, transactional: true, selectIdentity: true, statements: statements.ToArray()); WikiId = (response.Identity ?? WikiId).ToLong(); if (context.ContractSettings.Notice != false && notice) { SetTitle(context: context, ss: ss); CheckNotificationConditions(context: context, ss: ss); Notice(context: context, ss: ss, type: "Created"); } if (get) { Get(context: context, ss: ss); } var fullText = FullText(context, ss: ss, onCreating: true); statements = new List <SqlStatement>(); statements.Add(Rds.UpdateItems( param: Rds.ItemsParam() .Title(Title.DisplayValue) .FullText(fullText, _using: fullText != null) .SearchIndexCreatedTime(DateTime.Now, _using: fullText != null), where : Rds.ItemsWhere().ReferenceId(WikiId))); statements.Add(BinaryUtilities.UpdateReferenceId( context: context, ss: ss, referenceId: WikiId, values: fullText)); if (extendedSqls) { statements.OnCreatedExtendedSqls(SiteId, WikiId); } Rds.ExecuteNonQuery( context: context, transactional: true, statements: statements.ToArray()); Libraries.Search.Indexes.Create(context, ss, this); if (get && Rds.ExtendedSqls(SiteId, WikiId)?.Any(o => o.OnCreated) == true) { Get(context: context, ss: ss); } return(Error.Types.None); }
private void BuildCommandText( ISqlObjectFactory factory, SqlContainer sqlContainer, ISqlCommand sqlCommand, StringBuilder commandText, Sqls.TableTypes tableType, Sqls.UnionTypes unionType, bool orderBy, int?commandCount) { if (!Using) { return; } AddUnion(commandText, unionType); SqlColumnCollection?.BuildCommandText( factory: factory, sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount, distinct: Distinct, top: Top); var from = From(tableType, As); commandText.Append(from); SqlJoinCollection?.BuildCommandText(commandText: commandText); SqlWhereCollection?.BuildCommandText( factory: factory, sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount, select: true); SqlGroupByCollection?.BuildCommandText( commandText: commandText); SqlHavingCollection?.BuildCommandText( factory: factory, sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, commandCount: commandCount); if (orderBy) { SqlOrderByCollection?.BuildCommandText( factory: factory, sqlContainer: sqlContainer, sqlCommand: sqlCommand, commandText: commandText, pageSize: PageSize, tableType: TableType, commandCount: commandCount); } commandText.Append( factory.SqlCommandText.CreateLimitClause(limit: Top)); AddTermination(commandText); AddParams_Where(factory, sqlCommand, commandCount); AddParams_Having(factory, sqlCommand, commandCount); AddParams_Paging(factory, sqlCommand, commandCount); AddParams_Param(factory, sqlCommand, commandCount); }