/// <summary> /// Execute query and return a datatable. /// </summary> /// <param name="str_sqlID"> id of sqlMapping</param> /// <returns>data as hash table</returns> public DataTable ExecuteQueryForDataTable(string str_sqlID, object parameter) { logger.Start("ExecuteQueryForDataTable"); logger.Param("SQLMap_ID", str_sqlID); //ghi log cua cac parameter ShowParam(parameter); //Convert cac ki tu dac biet trong param dua vao cho dung chuan Ingres. ConvertUtilities.ConvertToDBValue(parameter); if (parameter == null) { parameter = new Hashtable(); } //(parameter as Hashtable)["DB"] = Global.CST_DATABSENAME; DataTable table = null; try { IList list = sqlMapEmployee.QueryForList(str_sqlID, parameter); table = ConvertUtilities.ToDataTable("table", list); if (table != null) { logger.Debug("So dong lay duoc" + table.Rows.Count.ToString()); } } catch (SqlException ex) { error = ex; logger.Error(ex.ToString()); logger.End("ExecuteQueryForDataTable"); throw ex; } logger.End("ExecuteQueryForDataTable"); return(table); }
static void Main(string[] args) { Console.WriteLine("Hello World!"); Log4Net.Debug("test"); Log.Debug("woding"); }
// GET: Home public ActionResult Index() { Log4Net.Info(this, "信息"); Log4Net.Debug(this, "调试"); Log4Net.Error(this, "错误"); Log4Net.Fatal(this, "失败"); Log4Net.Warn(this, "警告"); return(View()); }
private void TestLog4Net() { Log4Net.Debug("debug log"); Log4Net.Info("info log"); Log4Net.Warn("Warn log"); Log4Net.Error("Error log"); Log4Net.Fatal("Fatal log"); Log4Net.DebugInfo("Debug log{0}", 2); }
/// <summary> /// 后端用户登录操作 /// </summary> /// <param name="model">AccountViewModel实体</param> /// <returns></returns> public ResponsResult Login(BackstageUserAdd model) { ResponsResult result = new ResponsResult(); string sessionCode = string.Empty; try { var code = CookieUtility.GetCookie(TbConstant.WEBSITE_VERIFICATION_CODE); if (code != null) { sessionCode = ServiceCollectionExtension.Decrypt(code); } } catch (Exception ex) { Log4Net.Debug(ex); } if (model.ErrCount >= 3) { if (!model.VerCode.ToString().ToLower().Equals(sessionCode.ToLower())) { return(result.SetStatus(ErrorCode.NotFound, "验证码输入不正确!")); } } BackstageUser account = this.First <BackstageUser>(t => t.LoginName == model.LoginName); if (account == null) { return(result.SetStatus(ErrorCode.NotFound, "账号不存在!")); } string pwd = Security.MD5(model.Password); if (!account.Password.Equals(pwd, StringComparison.OrdinalIgnoreCase)) { return(result.SetStatus(ErrorCode.InvalidPassword)); } switch (account.AccountStatus) { case (int)AccountStatus.Disabled: return(result.SetStatus(ErrorCode.AccountDisabled, "账号不可用!")); } account.LastLoginTime = DateTime.Now; account.LastLoginIp = ""; this.Update(account, true); MvcIdentity identity = new MvcIdentity(account.Id, account.LoginName, account.LoginName, account.Email, (int)account.AccountType, null, account.LastLoginTime); identity.Login(TbConstant.WEBSITE_AUTHENTICATION_SCHEME, x => { x.Expires = DateTime.Now.AddHours(25);//滑动过期时间 x.HttpOnly = true; }); return(result); }
public void Debug(object message) { Count(Level.Debug); Log4Net.Debug(message); }
public void Debug(object message, Exception exception) { Count(Level.Debug); Log4Net.Debug(message, exception); }
public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) { try { #region var userAgent = context.HttpContext.Request.Headers["User-Agent"].ToString(); if (userAgent.Contains("MicroMessenger")) { SourceType = SourceType.WeChatApp; ApiKey = TbConstant.WeChatApp_ApiKey; } else if (userAgent.Contains("iPhone") || userAgent.Contains("iPod") || userAgent.Contains("iPad")) { SourceType = SourceType.IOS; ApiKey = TbConstant.iOS_ApiKey; } else if (userAgent.Contains("Android")) { SourceType = SourceType.Android; ApiKey = TbConstant.Android_ApiKey; } foreach (var kv in context.HttpContext.Request.Query) { RequestParams[kv.Key] = kv.Value.ToString(); } if (context.HttpContext.Request.HasFormContentType) { foreach (var kv in context.HttpContext.Request.Form) { RequestParams[kv.Key] = kv.Value.ToString(); } } var values = context.HttpContext.GetValues(); foreach (var kv in values) { RequestParams[kv.Key] = kv.Value.ToString(); } var dict = new Dictionary <string, string>(); foreach (var kv in RequestParams) { if (kv.Value.Length > 500) { dict[kv.Key] = kv.Value.Substring(0, 500); } else { dict[kv.Key] = kv.Value; } } if (SourceType != SourceType.Unknown) { //context.Result = new ObjectResult(new Result().SetStatus(ErrorCode.Unauthorized, "请设置User-Agent请求头: 如:iPhone 或者 Android")); } else { var token = string.Empty; if (RequestParams.ContainsKey(TOKEN_Name)) { token = RequestParams[TOKEN_Name]; } if (string.IsNullOrEmpty(token)) { token = context.HttpContext.Request.Cookies["token"]; //token = CookieUtility.GetCookie("token"); } if (!context.ActionDescriptor.FilterDescriptors.Any(t => t.Filter is AllowAnonymousFilter)) { if (string.IsNullOrEmpty(token)) { context.Result = new ObjectResult(new ResponsResult(ErrorCode.Unauthorized, "The request is not contains parameter 'token'")); } else { var model = CheckToken(token); if (model.Success) { if (string.IsNullOrEmpty(this.TokenModel.Id)) { model.SetStatus(ErrorCode.Relogin, "请登录"); } else { //检查用户的token是否匹配 //var _db = ContextHelper.New<DataContext>(); //if (!_db.Account.Any(t => t.Id == Token.Id && t.Token == Token.UserToken)) //{ // model.SetError("你的账户已在其他设备登录,请重新登录!", ResponseStatus.Relogin); //} } } if (!model.Success) { context.Result = new ObjectResult(model); } } } else { string json = ServiceCollectionExtension.Decrypt(token); if (string.IsNullOrEmpty(json)) { this.TokenModel = new TokenModel(); } else { this.TokenModel = json.GetModel <TokenModel>(); } } } #endregion } catch (Exception ex) { Log4Net.Debug(ex); } return(base.OnActionExecutionAsync(context, next)); }