重构代码:重新设计拒绝用户逻辑,增加RejectUsers数据表
This commit is contained in:
parent
cee319a110
commit
192aff391d
|
@ -49,18 +49,6 @@ namespace Bootstrap.DataAccess
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Period { get; set; }
|
public string Period { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得/设置 拒绝人
|
|
||||||
/// </summary>
|
|
||||||
public string RejectedBy { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 拒绝原因
|
|
||||||
/// </summary>
|
|
||||||
public string RejectedReason { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 拒绝时刻
|
|
||||||
/// </summary>
|
|
||||||
public string RejectedTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// 获得/设置 新密码
|
/// 获得/设置 新密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string NewPassword { get; set; }
|
public string NewPassword { get; set; }
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Bootstrap.DataAccess
|
||||||
{
|
{
|
||||||
return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key =>
|
return CacheManager.GetOrAdd(RetrieveNewUsersDataKey, key =>
|
||||||
{
|
{
|
||||||
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null and RejectedTime is null order by RegisterTime desc";
|
string sql = "select ID, UserName, DisplayName, RegisterTime, [Description] from Users Where ApprovedTime is null order by RegisterTime desc";
|
||||||
List<User> users = new List<User>();
|
List<User> users = new List<User>();
|
||||||
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
|
||||||
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
|
using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd))
|
||||||
|
@ -153,13 +153,12 @@ namespace Bootstrap.DataAccess
|
||||||
public static bool RejectUser(int id, string rejectBy)
|
public static bool RejectUser(int id, string rejectBy)
|
||||||
{
|
{
|
||||||
var ret = false;
|
var ret = false;
|
||||||
var sql = "update Users set RejectedTime = GETDATE(), RejectedBy = @rejectedBy, RejectedReason = @rejectedReason where ID = @id";
|
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.StoredProcedure, "Proc_RejectUsers"))
|
||||||
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
|
|
||||||
{
|
{
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@id", id));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", rejectBy));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedBy", rejectBy));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", "未填写"));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@rejectedReason", "未填写"));
|
||||||
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
|
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: id.ToString());
|
CacheCleanUtility.ClearCache(userIds: id.ToString());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -407,3 +407,41 @@ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'完成进度'
|
||||||
GO
|
GO
|
||||||
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分配时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Tasks', @level2type=N'COLUMN',@level2name=N'AssignTime'
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分配时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Tasks', @level2type=N'COLUMN',@level2name=N'AssignTime'
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
/****** Object: Table [dbo].[RejectUsers] Script Date: 09/08/2018 15:34:25 ******/
|
||||||
|
SET ANSI_NULLS ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
SET QUOTED_IDENTIFIER ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
SET ANSI_PADDING ON
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE TABLE [dbo].[RejectUsers](
|
||||||
|
[ID] [int] IDENTITY(1,1) NOT NULL,
|
||||||
|
[UserName] [varchar](50) NOT NULL,
|
||||||
|
[DisplayName] [nvarchar](50) NOT NULL,
|
||||||
|
[RegisterTime] [datetime] NOT NULL,
|
||||||
|
[RejectedBy] [varchar](50) NULL,
|
||||||
|
[RejectedTime] [datetime] NULL,
|
||||||
|
[RejectedReason] [nvarchar](50) NULL,
|
||||||
|
CONSTRAINT [PK_RejectUsers] PRIMARY KEY CLUSTERED
|
||||||
|
(
|
||||||
|
[ID] ASC
|
||||||
|
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||||
|
) ON [PRIMARY]
|
||||||
|
|
||||||
|
GO
|
||||||
|
|
||||||
|
SET ANSI_PADDING OFF
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RejectUsers', @level2type=N'COLUMN',@level2name=N'UserName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'显示名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RejectUsers', @level2type=N'COLUMN',@level2name=N'DisplayName'
|
||||||
|
GO
|
||||||
|
|
||||||
|
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'注册时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'RejectUsers', @level2type=N'COLUMN',@level2name=N'RegisterTime'
|
||||||
|
GO
|
|
@ -198,3 +198,40 @@ BEGIN
|
||||||
end
|
end
|
||||||
END
|
END
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
Drop PROCEDURE Proc_RejectUsers
|
||||||
|
GO
|
||||||
|
-- =============================================
|
||||||
|
-- Author: Argo
|
||||||
|
-- Create date: 2018-09-07
|
||||||
|
-- Description:
|
||||||
|
-- =============================================
|
||||||
|
CREATE PROCEDURE [dbo].[Proc_RejectUsers]
|
||||||
|
-- Add the parameters for the stored procedure here
|
||||||
|
@id int,
|
||||||
|
@rejectedBy varchar(50),
|
||||||
|
@rejectedReason nvarchar(50)
|
||||||
|
WITH ENCRYPTION
|
||||||
|
AS
|
||||||
|
BEGIN
|
||||||
|
-- SET NOCOUNT ON added to prevent extra result sets from
|
||||||
|
-- interfering with SELECT statements.
|
||||||
|
SET NOCOUNT ON;
|
||||||
|
SET XACT_ABORT ON;
|
||||||
|
-- Insert statements for procedure here
|
||||||
|
begin
|
||||||
|
declare @registerTime datetime
|
||||||
|
declare @userName varchar(50)
|
||||||
|
declare @displayName nvarchar(50)
|
||||||
|
select @registerTime = Registertime, @userName = UserName, @displayName = DisplayName from Users where ID = @id
|
||||||
|
|
||||||
|
if @userName is not null
|
||||||
|
begin
|
||||||
|
begin tran
|
||||||
|
insert into RejectUsers (UserName, DisplayName, RegisterTime, RejectedBy, RejectedTime, RejectedReason) values (@userName, @displayName, @registerTime, @rejectedBy, GETDATE(), @rejectedReason)
|
||||||
|
delete from users where ID = @id
|
||||||
|
commit tran
|
||||||
|
end
|
||||||
|
end
|
||||||
|
END
|
||||||
|
GO
|
||||||
|
|
Loading…
Reference in New Issue