public override void AfterExecute(int operatorUserID, string param, bool success, int totalCount, int finishedCount, out string title) { if (success) { StringList paramData = StringList.Parse(param); title = "删除" + (paramData[2] == "share" ? "分享" : "收藏") + "成功,共删除 " + finishedCount + " 个" + (paramData[2] == "share" ? "分享" : "收藏"); ShareFilter filter = ShareFilter.Parse(paramData[0]); if (success) { User operatorUser = UserBO.Instance.GetUser(operatorUserID, GetUserOption.WithAll); if (paramData[2] == "share") { Logs.LogManager.LogOperation( new Share_DeleteShareBySearch(operatorUserID, operatorUser.Name, IPUtil.GetCurrentIP(), filter, finishedCount) ); } else { Logs.LogManager.LogOperation( new Favorite_DeleteFavoriteBySearch(operatorUserID, operatorUser.Name, IPUtil.GetCurrentIP(), filter, finishedCount) ); } } } else { title = "删除分享失败"; } }
protected void Page_Load(object sender, EventArgs e) { m_Filter = ShareFilter.GetFromFilter("filter"); if (_Request.Get("type") != "share") { m_Filter.PrivacyType = PrivacyType.SelfVisible; } if (_Request.IsClick("searchshares")) { SearchShares(); } else if (_Request.IsClick("deletechecked")) { DeleteChecked(); } else if (_Request.IsClick("deleteallsearch")) { DeleteAllSearch(); } int page = _Request.Get <int>("page", Method.Get, 1); m_ShareList = ShareBO.Instance.GetSharesForAdmin(MyUserID, m_Filter, page); if (m_ShareList != null) { m_ShareTotalCount = m_ShareList.TotalRecords; UserBO.Instance.WaitForFillSimpleUsers <Share>(m_ShareList, 0); } }
public override bool BeforeExecute(int operatorUserID, string param, ref long offset, ref int totalCount, out string title) { StringList paramData = StringList.Parse(param); ShareFilter filter = ShareFilter.Parse(paramData[0]); //只取一条数据测试下就可以 filter.PageSize = 1; ShareCollection shares = null; if (paramData[2] == "share") { shares = ShareBO.Instance.GetSharesForAdmin(operatorUserID, filter, 1); } else { shares = FavoriteBO.Instance.GetSharesForAdmin(operatorUserID, filter, 1); } if (shares == null || shares.Count == 0) { title = "没有数据可以删除"; return(false); } totalCount = shares.TotalRecords; title = "将删除 " + totalCount + " 条" + (paramData[2] == "share" ? "分享" : "收藏"); return(true); }
private void SearchShares() { ShareFilter filter = ShareFilter.GetFromForm(); if (_Request.Get("type") != "share") { filter.PrivacyType = PrivacyType.SelfVisible; } filter.Apply("filter", "page"); }
public async Task <IActionResult> GetShareByUser([FromQuery] ShareFilter shareFilter) { StatusCode <List <ShareForUserOut> > status = await _shareService.GetShareForUserByUserAndFilter(shareFilter, _userManager.GetUserName(User)); if (status.Code == StatusCodes.Status404NotFound) { return(NotFound(status.Message)); } return(Ok(status.Body)); }
public override bool StepExecute(int operatorUserID, string param, ref long offset, ref int totalCount, ref int finishedCount, out string title, out bool isLastStep) { StringList paramData = StringList.Parse(param); ShareFilter filter = ShareFilter.Parse(paramData[0]); int stepCount; if (ShareBO.Instance.DeleteSharesForAdmin(operatorUserID, filter, paramData[1] == "1", stepDeleteCount, out stepCount)) // .DeleteDoingsBySearch(filter, 200); { finishedCount += stepCount; isLastStep = stepCount < stepDeleteCount; title = "正在删除" + (paramData[2] == "share" ? "分享" : "收藏") + ",总数 " + totalCount + ",已删 " + finishedCount; } else { isLastStep = true; title = string.Empty; } return(true); }
public async Task <StatusCode <List <ShareForUserOut> > > GetShareForUserByUserAndFilter(ShareFilter shareFilter, string username) { string userId = (await _databaseContext.Users .FirstOrDefaultAsync(_ => _.UserName == username))? .Id; List <ShareForUser> shareForUsers = await _databaseContext.ShareForUsers .Include(_ => _.Owner) .Include(_ => _.Resource) .Where(_ => _.SharedForUserID == userId && _.Resource.ResourceType == shareFilter.ResourceType && (_.ExpirationDateTime == null || (_.ExpirationDateTime != null && _.ExpirationDateTime > DateTime.Now))) .ToListAsync(); if (shareForUsers == null || !shareForUsers.Any()) { return(new StatusCode <List <ShareForUserOut> >(StatusCodes.Status404NotFound, $"Shared resources not found")); } List <ShareForUserOut> result = _mapper.Map <List <ShareForUserOut> >(shareForUsers); return(new StatusCode <List <ShareForUserOut> >(StatusCodes.Status200OK, result)); }
public override DeleteResult DeleteSearchShares(ShareFilter filter, IEnumerable<Guid> excludeRoleIDs, bool getDeleteResult) { using (SqlQuery query = new SqlQuery()) { //string condition = @" 1 = 1 " // + (filter.UserID == null ? "" : ("AND [UserID] = @UserID ")) // + (filter.ShareID == null ? "" : ("AND [ShareID] = @ShareID ")) // + (filter.ShareCatagory == ShareCatagory.All ? "" : ("AND [Type] = @Type ")) // + (filter.PrivacyType == null ? "" : ("AND [PrivacyType] = @PrivacyType ")) // + (filter.BeginDate == null ? "" : ("AND [CreateDate] > @BeginDate ")) // + (filter.EndDate == null ? "" : ("AND [CreateDate] < @EndDate ")) // + "AND " + DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query); SqlConditionBuilder condition = new SqlConditionBuilder(SqlConditionStart.Where); condition += (filter.UserID == null ? "" : ("AND [UserID] = @UserID ")); condition += (filter.ShareID == null ? "" : ("AND [ShareID] = @ShareID ")); condition += (filter.ShareType == ShareType.All ? "" : ("AND [Type] = @Type ")); condition += (filter.PrivacyType == null ? "" : ("AND [PrivacyType] = @PrivacyType ")); condition += (filter.BeginDate == null ? "" : ("AND [CreateDate] > @BeginDate ")); condition += (filter.EndDate == null ? "" : ("AND [CreateDate] < @EndDate ")); condition.AppendAnd(DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query)); if (getDeleteResult) { query.CommandText = @" SELECT [UserID],COUNT(*) AS [Count] FROM [bx_SharesView] " + condition.ToString() + " GROUP BY [UserID];"; } else query.CommandText = string.Empty; query.CommandText = query.CommandText + @" DELETE [bx_SharesView] " + condition.ToString(); query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int); query.CreateParameter<int?>("@ShareID", filter.ShareID, SqlDbType.Int); query.CreateParameter<int>("@Type", (int)filter.ShareType, SqlDbType.Int); query.CreateParameter<int?>("@PrivacyType", filter.PrivacyType == null ? 0 : (int)filter.PrivacyType, SqlDbType.Int); query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime); query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime); using (XSqlDataReader reader = query.ExecuteReader()) { DeleteResult deleteResult = new DeleteResult(); while (reader.Read()) { deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count")); } return deleteResult; } } }
public override ShareCollection SearchShares(int pageNumber, ShareFilter filter, IEnumerable<Guid> excludeRoleIDs, ref int totalCount) { using (SqlQuery query = new SqlQuery()) { query.Pager.IsDesc = filter.IsDesc; if (filter.Order == ShareFilter.OrderBy.ShareID) query.Pager.SortField = filter.Order.ToString(); query.Pager.PageNumber = pageNumber; query.Pager.PageSize = filter.PageSize; query.Pager.TotalRecords = totalCount; query.Pager.SelectCount = true; query.Pager.TableName = "[bx_SharesView]"; SqlConditionBuilder condition = new SqlConditionBuilder(SqlConditionStart.None); condition += (filter.UserID == null ? "" : ("AND [UserID] = @UserID ")); condition += (filter.ShareID == null ? "" : ("AND [ShareID] = @ShareID ")); condition += (filter.ShareType == ShareType.All ? "" : ("AND [Type] = @Type ")); condition += (filter.PrivacyType == null ? "" : ("AND [PrivacyType] = @PrivacyType ")); condition += (filter.BeginDate == null ? "" : ("AND [CreateDate] > @BeginDate ")); condition += (filter.EndDate == null ? "" : ("AND [CreateDate] < @EndDate ")); condition.AppendAnd(DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query)); query.Pager.Condition = condition.ToString(); query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int); query.CreateParameter<int?>("@ShareID", filter.ShareID, SqlDbType.Int); query.CreateParameter<int>("@Type", (int)filter.ShareType, SqlDbType.Int); query.CreateParameter<int?>("@PrivacyType", filter.PrivacyType == null ? 0 : (int)filter.PrivacyType, SqlDbType.Int); query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime); query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime); using (XSqlDataReader reader = query.ExecuteReader()) { ShareCollection shares = new ShareCollection(reader); if (reader.NextResult()) { while (reader.Read()) { totalCount = reader.Get<int>(0); } } return shares; } } }
private string BuildConditionsByFilter(SqlQuery query, ShareFilter filter, IEnumerable<Guid> excludeRoleIDs, bool startWithWhere) { SqlConditionBuilder condition = new SqlConditionBuilder(startWithWhere ? SqlConditionStart.Where : SqlConditionStart.None); if (filter.UserID != null) { condition.AppendAnd("[UserID] = @UserID"); query.CreateParameter<int?>("@UserID", filter.UserID, SqlDbType.Int); } if (filter.ShareID != null) { condition.AppendAnd("[ShareID] = @ShareID"); query.CreateParameter<int?>("@ShareID", filter.ShareID, SqlDbType.Int); } if (filter.ShareType != null) { condition.AppendAnd("[Type] = @Type"); query.CreateParameter<ShareType?>("@Type", filter.ShareType, SqlDbType.Int); } if (filter.PrivacyType != null) { condition.AppendAnd("[PrivacyType] = @PrivacyType"); query.CreateParameter<PrivacyType?>("@PrivacyType", filter.PrivacyType, SqlDbType.Int); } if (filter.BeginDate != null) { condition.AppendAnd("[CreateDate] > @BeginDate"); query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime); } if (filter.EndDate != null) { condition.AppendAnd("[CreateDate] < @EndDate"); query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime); } condition.AppendAnd(DaoUtil.GetExcludeRoleSQL("[UserID]", excludeRoleIDs, query)); return condition.ToString(); }
public override DeleteResult DeleteSharesBySearch(ShareFilter filter, IEnumerable<Guid> excludeRoleIDs, int topCount, out int deletedCount) { deletedCount = 0; using (SqlQuery query = new SqlQuery()) { string conditions = BuildConditionsByFilter(query, filter, excludeRoleIDs, true); StringBuffer sql = new StringBuffer(); sql += @" DECLARE @DeleteData table (UserID int, ShareID int); INSERT INTO @DeleteData SELECT TOP (@TopCount) [UserID],[ShareID] FROM [bx_SharesView] " + conditions + @"; DELETE [bx_Shares] WHERE [ShareID] IN (SELECT [ShareID] FROM @DeleteData); SELECT @@ROWCOUNT; SELECT [UserID],COUNT(*) AS [Count] FROM @DeleteData GROUP BY [UserID];"; query.CreateTopParameter("@TopCount", topCount); query.CommandText = sql.ToString(); using (XSqlDataReader reader = query.ExecuteReader()) { DeleteResult deleteResult = new DeleteResult(); if (reader.Read()) deletedCount = reader.Get<int>(0); if (reader.NextResult()) { while (reader.Read()) { deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count")); } } return deleteResult; } } }
public override ShareCollection GetSharesBySearch(Guid[] excludeRoleIDs, ShareFilter filter, int pageNumber) { using (SqlQuery query = new SqlQuery()) { string sqlCondition = BuildConditionsByFilter(query, filter, excludeRoleIDs, false); query.Pager.TableName = "[bx_SharesView]"; query.Pager.SortField = filter.Order.ToString(); if (filter.Order != ShareFilter.OrderBy.ShareID) { query.Pager.PrimaryKey = "ShareID"; } query.Pager.PageNumber = pageNumber; query.Pager.PageSize = filter.PageSize; query.Pager.SelectCount = true; query.Pager.IsDesc = filter.IsDesc; query.Pager.Condition = sqlCondition; using (XSqlDataReader reader = query.ExecuteReader()) { ShareCollection shares = new ShareCollection(reader); if (reader.NextResult()) { if (reader.Read()) { shares.TotalRecords = reader.Get<int>(0); } } return shares; } } }
/// <summary> /// 删除搜索结果 /// </summary> /// <param name="filter">搜索条件</param> /// <param name="operatorID">操作者ID</param> /// <param name="excludeRoleIDs">操作者没有权限管理的用户组ID</param> /// <param name="isGetDeleteResult">是否获取删除结果</param> /// <param name="topCount">删除搜索结果的前几条</param> /// <param name="deletedCount">真实删除的条数</param> /// <returns></returns> public abstract DeleteResult DeleteSharesBySearch(ShareFilter filter, IEnumerable <Guid> excludeRoleIDs, int topCount, out int deletedCount);
/// <summary> /// 通过搜索获取分享 /// </summary> /// <param name="excludeRoleIDs"></param> /// <param name="filter"></param> /// <param name="pageNumber"></param> /// <returns></returns> public abstract ShareCollection GetSharesBySearch(Guid[] excludeRoleIDs, ShareFilter filter, int pageNumber);
public abstract DeleteResult DeleteSearchShares(ShareFilter filter, IEnumerable <Guid> excludeRoleIDs, bool getDeleteResult);
public abstract ShareCollection SearchShares(int pageNumber, ShareFilter filter, IEnumerable <Guid> excludeRoleIDs, ref int totalCount);