protected void Application_End() { LogDbHelper.LogWarn("应用停止,IIS将应用回收", "Global => Application_End", OperationType.Other); Thread.Sleep(1000); try { //这里设置你的web地址,可以随便指向你的任意一个aspx页面甚至不存在的页面,目的是要激发Application_Start string url = Utils.GetConfigValuesByKey("EndAppTriggerRestartUrl"); HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Stream receiveStream = myHttpWebResponse.GetResponseStream();//得到回写的字节流 LogDbHelper.LogWarn("App Restart Success", "Global => Application_End", OperationType.Other); } catch (Exception ex) { LogDbHelper.LogError("App Restart Failure" + ex.Message, "Global => Application_End", OperationType.Other); } }
public LoginResult Login(string accountName, string password) { var userInfo = ((IUserDapperRepository)_dapperRepository).GetUserByAccountName(accountName); LoginResult loginResult = null; LoginResultType loginResultType; // 1. 判断是否存在用户 if (userInfo == null) { loginResultType = LoginResultType.InvalidUserNameAccount; loginResult = new LoginResult(loginResultType); LogDbHelper.LogWarn("登录失败,不存在用户{0}", GetType().FullName + "Login", OperationType.Account); return(loginResult); } // 2. 判断密码是否正确 else if (!AppUtils.VerifyPassword(accountName, password, userInfo.Password, userInfo.UserRegistType)) { loginResultType = LoginResultType.InvalidPassword; loginResult = new LoginResult(loginResultType); } // 3. 判断用户状态是否被激活 else if (!userInfo.IsActive) { loginResultType = LoginResultType.UserIsNotActive; loginResult = new LoginResult(loginResultType); } // 4.判断用户是否已经登录,如果登录了,提示用户不要重复登录 //else if (!string.IsNullOrWhiteSpace(userInfo.TokenId)) //{ // loginResultType = LoginResultType.UserAlreadyLogged; // loginResult = new LoginResult(loginResultType); //} else { loginResult = new LoginResult(userInfo, accountName, userInfo.UserRegistType); } try { if (loginResult.ResultType != LoginResultType.Success) { ((IUserDapperRepository)_dapperRepository).LoginFail(userInfo.Id, accountName, loginResult.ResultType); LogDbHelper.LogWarn("登录失败, 原因:" + loginResult.LoginResultMsg, GetType().FullName + "Login", OperationType.Account); } else { ((IUserDapperRepository)_dapperRepository).LoginSuccess(userInfo.Id, accountName, loginResult.ResultType, loginResult.TokenId, loginResult.LoginTime); // :todo 缓存TokenId LogDbHelper.LogInfo(loginResult.LoginResultMsg, GetType().FullName + "Login", OperationType.Account); } } catch (Exception ex) { ((IUserDapperRepository)_dapperRepository).LoginFail(userInfo.Id, accountName, loginResult.ResultType); LogDbHelper.LogError("登录失败, 原因:" + ex.ToString(), GetType().FullName + "Login", OperationType.Account); loginResult = new LoginResult(ex); } return(loginResult); }