| | |
| | | using Dapper; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | |
| | | public static List<SqlParameter> listStr = new List<SqlParameter>(); //定义全局参数集合 |
| | | public static SqlParameter[] parameters; //定义全局SqlParameter参数数组 |
| | | public static string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; |
| | | //获取企业配置Enterprise |
| | | private static readonly string Enterprise = ConfigurationManager.AppSettings["Enterprise"]; |
| | | |
| | | #region [登录查询] |
| | | public static DataTable LoginSearch(string username, string password) |
| | |
| | | { |
| | | usercode = usercode, |
| | | oper_date = DateTime.Now.ToString(), |
| | | oper_type = "PC", |
| | | oper_type = "PC/APP", |
| | | description = username + "修改了密码", |
| | | origin = "PC" |
| | | origin = "PC/APP" |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[密码重置] |
| | | public static ToMessage ResettUserPassword(string usercode, string username) |
| | | { |
| | | var sql = ""; |
| | | List<object> list = new List<object>(); |
| | | var dynamicParams = new DynamicParameters(); |
| | | |
| | | //重置密码 |
| | | sql = @"update [dbo].[TUser] set password=@newpassword where usercode=@usercode and username=@username"; |
| | | list.Add(new { str = sql, parm = new { usercode = usercode, username = username,newpassword ="123456" } }); |
| | | //写入操作记录表 |
| | | sql = @"insert into T_Bas_User_Operlog(usercode,oper_date,oper_type,description,origin) values(@usercode,@oper_date,@oper_type,@description,@origin)"; |
| | | list.Add(new |
| | | { |
| | | str = sql, |
| | | parm = new |
| | | { |
| | | usercode = usercode, |
| | | oper_date = DateTime.Now.ToString(), |
| | | oper_type = "PC/APP", |
| | | description = username + "重置了密码", |
| | | origin = "PC/APP" |
| | | } |
| | | }); |
| | | bool aa = DapperHelper.DoTransaction(list); |
| | | if (aa) |
| | | { |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "重置密码成功!"; |
| | | mes.data = null; |
| | | } |
| | | else |
| | | { |
| | | mes.code = "300"; |
| | | mes.count = 0; |
| | | mes.Message = "重置密码失败!"; |
| | | mes.data = null; |
| | | } |
| | | |
| | | return mes; |
| | | } |
| | | #endregion |
| | | |
| | | #region[PC登出] |
| | | public static ToMessage LoginOut(int userid, string usercode, string username, string usertype) |
| | | { |
| | |
| | | cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | { |
| | | redis.Remove("LoginUserID" + usertype + userid, 0); //删除redis |
| | | redis.Remove(Enterprise + "LoginUserID" + usertype + userid, 0); //删除redis |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "登出成功!"; |
| | |
| | | cont = DapperHelper.SQL(sql, dynamicParams); |
| | | if (cont > 0) |
| | | { |
| | | redis.Remove("LoginUserID" + usertype + userid, 1); //删除redis |
| | | redis.Remove(Enterprise + "LoginUserID" + usertype + userid, 1); //删除redis |
| | | mes.code = "200"; |
| | | mes.count = 0; |
| | | mes.Message = "登出成功!"; |