本文整理汇总了C#中StringBuffer.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# StringBuffer.Remove方法的具体用法?C# StringBuffer.Remove怎么用?C# StringBuffer.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer.Remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildConditionsByFilter
private string BuildConditionsByFilter(SqlQuery query, AdminBlogCategoryFilter filter, IEnumerable<Guid> excludeRoleIDs, bool startWithWhere)
{
StringBuffer sqlConditions = new StringBuffer();
if (string.IsNullOrEmpty(filter.SearchKey) == false)
{
sqlConditions += " AND [Name] LIKE '%' + @SearchKey + '%'";
query.CreateParameter<string>("@SearchKey", filter.SearchKey, SqlDbType.NVarChar, 50);
}
if (filter.BeginDate != null)
{
sqlConditions += " AND [CreateDate] >= @BeginDate";
query.CreateParameter<DateTime?>("@BeginDate", filter.EndDate, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
sqlConditions += " AND [CreateDate] <= @EndDate";
query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
}
if (string.IsNullOrEmpty(filter.Username) == false)
{
sqlConditions += " AND [UserID] = (SELECT [UserID] FROM [bx_Users] WHERE [Username] = @Username)";
query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
}
string excludeRoleSQL = DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query);
if (string.IsNullOrEmpty(excludeRoleSQL) == false)
sqlConditions += " AND " + excludeRoleSQL;
sqlConditions += " AND [CategoryID] != 0";
if (sqlConditions.Length > 0)
{
sqlConditions.Remove(0, 5);
if (startWithWhere)
sqlConditions.InnerBuilder.Insert(0, " WHERE ");
}
return sqlConditions.ToString();
}
示例2: BuildConditionsByFilter
private string BuildConditionsByFilter(SqlQuery query, AdminCommentFilter filter, bool startWithWhere, int operatorUserID, IEnumerable<Guid> excludeRoleIds)
{
StringBuffer sqlCondition = new StringBuffer();
if (filter.Type != CommentType.All)
{
sqlCondition += " AND Type = @Type";
query.CreateParameter<int>("@Type", (int)filter.Type, SqlDbType.Int);
}
if (filter.IsApproved != null)
{
sqlCondition += " AND IsApproved = @IsApproved";
query.CreateParameter<bool?>("@IsApproved", filter.IsApproved, SqlDbType.Bit);
}
if (string.IsNullOrEmpty(filter.Username) == false)
{
sqlCondition += " AND UserID = (SELECT UserID FROM bx_Users WHERE Username = @Username)";
query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
}
if (string.IsNullOrEmpty(filter.TargetUsername) == false)
{
sqlCondition += " AND TargetUserID IN (SELECT UserID FROM bx_Users WHERE Username = @TargetUsername)";
query.CreateParameter<string>("@TargetUsername", filter.TargetUsername, SqlDbType.NVarChar, 50);
}
if (filter.BeginDate != null)
{
sqlCondition += " AND CreateDate >= @BeginDate";
query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
sqlCondition += " AND CreateDate <= @EndDate";
query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
}
if (!string.IsNullOrEmpty(filter.Content))
{
sqlCondition += " AND Content LIKE '%'[email protected]+'%'";
query.CreateParameter<string>("@Content", filter.Content, SqlDbType.NVarChar, 50);
}
if (!string.IsNullOrEmpty(filter.IP))
{
sqlCondition += " AND CreateIP = @CreateIP";
query.CreateParameter<string>("@CreateIP", filter.IP, SqlDbType.VarChar, 50);
}
string excludeRoleSQL = DaoUtil.GetExcludeRoleSQL("[UserID]", "[LastEditUserID]", operatorUserID, excludeRoleIds, query);
if (string.IsNullOrEmpty(excludeRoleSQL) == false)
{
sqlCondition += " AND " + excludeRoleSQL;
}
if (sqlCondition.Length != 0)
{
sqlCondition.Remove(0, 5);
}
if (startWithWhere && sqlCondition.Length > 0)
{
sqlCondition.InnerBuilder.Insert(0, " WHERE ");
}
return sqlCondition.ToString();
}
示例3: BuildConditionsByFilter
private string BuildConditionsByFilter(SqlQuery query, AdminTagFilter filter)
{
StringBuffer sqlConditions = new StringBuffer();
if (string.IsNullOrEmpty(filter.Name))
{
sqlConditions += " AND [Name] Like '%' + @Name + '%'";
query.CreateParameter<string>("@Name", filter.Name, SqlDbType.NVarChar, 50);
}
if (filter.Type != null)
{
sqlConditions += " AND ([ID] IN (SELECT [TagID] FROM [bx_TagRelation] WHERE [Type] = @Type))";
query.CreateParameter<TagType?>("@Type", filter.Type, SqlDbType.TinyInt);
}
if (filter.IsLock != null)
{
sqlConditions += " AND [IsLock] = @IsLock";
query.CreateParameter<bool?>("@IsLock", filter.IsLock, SqlDbType.Bit);
}
if (filter.TotalElementsScopeBegin != null && filter.TotalElementsScopeEnd != null)
{
sqlConditions += " AND ([TotalElements] >= @TotalElementsBegin AND [TotalElements] <= @TotalElementsEnd)";
query.CreateParameter<int?>("@TotalElementsBegin", filter.TotalElementsScopeBegin, SqlDbType.Int);
query.CreateParameter<int?>("@TotalElementsEnd", filter.TotalElementsScopeEnd, SqlDbType.Int);
}
if (sqlConditions.Length > 0)
sqlConditions.Remove(0, 5);
return sqlConditions.ToString();
}
示例4: BuildConditionsByFilter
private string BuildConditionsByFilter(SqlQuery query, AdminAlbumFilter filter, int operatorUserID, IEnumerable<Guid> excludeRoleIds, bool startWithWhere)
{
StringBuffer sqlConditions = new StringBuffer();
if (filter.AlbumID != null)
{
sqlConditions += " AND [AlbumID] = @AlbumID";
query.CreateParameter<int?>("@AlbumID", filter.AlbumID, SqlDbType.Int);
}
if (filter.AuthorID != null)
{
sqlConditions += " AND [UserID] = @UserID";
query.CreateParameter<int?>("@UserID", filter.AuthorID, SqlDbType.Int);
}
if (filter.PrivacyType != null)
{
sqlConditions += " AND [PrivacyType] = @PrivacyType";
query.CreateParameter<PrivacyType?>("@PrivacyType", filter.PrivacyType, SqlDbType.TinyInt);
}
if (filter.BeginDate != null)
{
sqlConditions += " AND [CreateDate] >= @BeginDate";
query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
sqlConditions += " AND [CreateDate] <= @EndDate";
query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
}
if (string.IsNullOrEmpty(filter.Username) == false)
{
sqlConditions += " AND [UserID] = (SELECT [UserID] FROM [bx_Users] WHERE [Username] = @Username)";
query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
}
if (string.IsNullOrEmpty(filter.Name) == false)
{
sqlConditions += " AND ([Name] LIKE '%' + @Key + '%')";
query.CreateParameter<string>("@Key", filter.Name, SqlDbType.NVarChar, 50);
}
string excludeRolesSql = DaoUtil.GetExcludeRoleSQL("[UserID]", "[LastEditUserID]", operatorUserID, excludeRoleIds, query);
if (string.IsNullOrEmpty(excludeRolesSql) == false)
sqlConditions += " AND " + excludeRolesSql;
if (sqlConditions.Length > 0)
{
sqlConditions.Remove(0, 5);
if (startWithWhere)
sqlConditions.InnerBuilder.Insert(0, " WHERE ");
}
return sqlConditions.ToString();
}
示例5: GetPhotosByFilter
/*
/// <summary>
/// 搜索相片
/// </summary>
public override PhotoCollection GetPhotosByFilter(PhotoFilter filter, bool isGetPrivacyType, int pageNumber, int pageSize, ref int? count)
{
using (SqlQuery query = new SqlQuery())
{
query.Pager.TableName = "bx_Photos";
query.Pager.SortField = "[PhotoID]";
query.Pager.PageNumber = pageNumber;
query.Pager.PageSize = pageSize;
query.Pager.SelectCount = true;
query.Pager.TotalRecords = count;
query.Pager.IsDesc = true;
query.Pager.Condition = BuildConditionsByFilter(query, filter);
using (XSqlDataReader reader = query.ExecuteReader())
{
SqlDataReaderWrap readerWrap = new SqlDataReaderWrap(reader);
PhotoCollection photos = new PhotoCollection(readerWrap);
if (count == null && readerWrap.NextResult())
{
if (readerWrap.Next)
{
count = readerWrap.Get<int>(0);
}
}
return photos;
}
}
}
*/
/// <summary>
/// 根据Filter来获得Sql用的条件,并填充参数
/// </summary>
/// <param name="query"></param>
/// <param name="filter"></param>
/// <returns></returns>
private string BuildConditionsByFilter(PhotoFilter filter, SqlQuery query)
{
StringBuffer sqlConditions = new StringBuffer();
if (filter.BeginDate != null)
{
sqlConditions += " AND [CreateDate] >= @BeginDate";
query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
sqlConditions += " AND [CreateDate] <= @EndDate";
query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
}
if (string.IsNullOrEmpty(filter.Usernames) == false)
{
sqlConditions += " AND [UserID] = (SELECT [UserID] FROM [bx_Users] WHERE [Username] = @Username)";
query.CreateParameter<string>("@Username", filter.Usernames, SqlDbType.NVarChar, 50);
}
if (string.IsNullOrEmpty(filter.SearchKey) == false)
{
sqlConditions += " AND ([Name] LIKE '%' + @Name + '%' OR [Description] LIKE '%' + @Name + '%')";
query.CreateParameter<string>("@Name", filter.SearchKey, SqlDbType.NVarChar, 50);
}
if (sqlConditions.Length > 0)
sqlConditions.Remove(0, 5);
return sqlConditions.ToString();
}
示例6: AdminGetSessions
public override ChatSessionCollection AdminGetSessions(ChatSessionFilter filter, int pageNumber, IEnumerable<Guid> excludeRoleIds)
{
ChatSessionCollection sessions;
using (SqlQuery query = new SqlQuery())
{
string excludeRoleCondition = DaoUtil.GetExcludeRoleSQL("UserID", excludeRoleIds, query);
StringBuffer buffer = new StringBuffer();
if (filter.UserID != null)
{
buffer += " AND UserID = @UserID";
query.CreateParameter<int>("@UserID", filter.UserID.Value, SqlDbType.Int);
}
if (!string.IsNullOrEmpty(filter.Username))
{
buffer += " AND UserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' ) OR TargetUserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' )";
query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
}
//if (!string.IsNullOrEmpty(filter.TargetUsername))
//{
// buffer += " AND TargetUserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'[email protected]+'%' )";
// query.CreateParameter<string>("@TargetUser", filter.TargetUsername, SqlDbType.NVarChar, 50);
//}
//if (!string.IsNullOrEmpty(filter.Contains))
//{
// buffer +=" AND ChatSessionID IN( SELECT ) "
//}
if (filter.BeginDate != null)
{
buffer += " AND CreateDate >= @BeginDate";
query.CreateParameter<DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
buffer += " AND UpdateDate <= @EndDate";
query.CreateParameter<DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
}
if (!string.IsNullOrEmpty(excludeRoleCondition))
{
buffer += " AND " + excludeRoleCondition;
excludeRoleCondition = DaoUtil.GetExcludeRoleSQL("TargetUserID", excludeRoleIds, query);
buffer += " AND " + excludeRoleCondition;
}
if (buffer.Length > 0)
buffer.Remove(0, 5);
//query.CommandText = "SELECT * FROM bx_ChatSessions";
query.Pager.TableName = "bx_ChatSessions";
query.Pager.PrimaryKey = "ChatSessionID";
query.Pager.PageNumber = pageNumber;
query.Pager.PageSize = filter.PageSize;
query.Pager.SortField = "ChatSessionID";
query.Pager.IsDesc = true;
query.Pager.SelectCount = true;
query.Pager.Condition = buffer.ToString();
using (XSqlDataReader reader = query.ExecuteReader())
{
sessions = new ChatSessionCollection(reader);
while (reader.NextResult())
if (reader.Read())
sessions.TotalRecords = reader.GetInt32(0);
}
}
return sessions;
}
示例7: GetInviteSerials
public override InviteSerialCollection GetInviteSerials(int operatorUserID, InviteSerialStatus status, string filter, int pageNumber, out int totalCount)
{
using (SqlQuery query = new SqlQuery())
{
StringBuffer Condition = new StringBuffer();
Condition += " AND UserID = @UserID";
query.CreateParameter<int>("@UserID", operatorUserID, SqlDbType.Int);
if (status != InviteSerialStatus.All)
{
if (status != InviteSerialStatus.Expires)
{
Condition += " AND [Status] = @Status";
query.CreateParameter<byte>("@Status", (byte)status, SqlDbType.TinyInt);
}
else if (status == InviteSerialStatus.Expires)
{
Condition += " AND Status <> 1 AND ExpiresDate <= GETDATE()";
}
}
if (string.IsNullOrEmpty(filter) == false)
{
Condition += " AND (Serial LIKE '%'+ @word +'%' OR ToUserID IN( SELECT UserID FROM bx_Users WHERE Username LIKE '%'+ @word +'%' OR Realname LIKE '%'+ @word +'%' ))";
query.CreateParameter<string>("@word", filter, SqlDbType.NVarChar, 50);
}
if (Condition.Length > 0)
Condition.Remove(0, 5);
query.Pager.SortField = "CreateDate";
query.Pager.IsDesc = true;
query.Pager.TableName = "[bx_InviteSerials]";
query.Pager.SelectCount = true;
query.Pager.PageSize = 20;
query.Pager.PageNumber = pageNumber > 0 ? pageNumber : 1;
query.Pager.Condition = Condition.ToString();
query.Pager.PrimaryKey = "[ID]";
totalCount = 0;
using (XSqlDataReader reader = query.ExecuteReader())
{
InviteSerialCollection Serials = new InviteSerialCollection(reader);
if (reader.NextResult())
{
if (reader.Read())
{
totalCount = reader.GetInt32(0);
Serials.TotalRecords = totalCount;
}
}
return Serials;
}
}
}
示例8: BuildConditionsByFilter
private string BuildConditionsByFilter(SqlQuery query, AdminDoingFilter filter, IEnumerable<Guid> excludeRoleIDs, bool startWithWhere)
{
StringBuffer sqlConditions = new StringBuffer();
if (filter.UserID != null && filter.UserID > 0)
{
sqlConditions += " AND UserID = @UserID";
query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int);
}
if (!string.IsNullOrEmpty(filter.Username))
{
sqlConditions += " AND UserID IN (SELECT UserID FROM bx_Users WHERE Username = @Username)";
query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
}
if (!string.IsNullOrEmpty(filter.Content))
{
sqlConditions += " AND Content LIKE '%'[email protected]+'%'";
query.CreateParameter<string>("@Content", filter.Content, SqlDbType.NVarChar, 200);
}
if (!string.IsNullOrEmpty(filter.IP))
{
sqlConditions += " AND CreateIP LIKE '%'[email protected]+'%'";
query.CreateParameter<string>("@IP", filter.IP, SqlDbType.VarChar, 50);
}
if (filter.BeginDate != null)
{
sqlConditions += " AND CreateDate >= @BeginDate";
query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
}
if (filter.EndDate != null)
{
sqlConditions += " AND CreateDate <= @EndDate";
query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
}
string excludeRoleSQL = DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query);
if (string.IsNullOrEmpty(excludeRoleSQL) == false)
{
sqlConditions += " AND " + excludeRoleSQL;
}
if (sqlConditions.Length > 0)
{
sqlConditions.Remove(0, 5);
if (startWithWhere)
sqlConditions.InnerBuilder.Insert(0, " WHERE ");
}
return sqlConditions.ToString();
}