private static int InsertRefererTable(Dictionary <string, string> OnlineUserValue) { /* * @ServerName varchar(10), * @UserId int, * @GameId varchar(32), * @ClientIP varchar(20), * @Country varchar(20), * @City varchar(20), * @Refer varchar(500), * @WebRefer varchar(500), * @Visit int, * @WebAgent varchar(500) */ UAParser.ClientInfo agentInfo = null; try { UAParser.Parser userAgentParser = UAParser.Parser.GetDefault(); agentInfo = userAgentParser.Parse(Utils.safeStr(OnlineUserValue["WebAgent"])); } catch { } using (SqlConnection con = Utils.GetNewConnection()) { con.Open(); using (SqlCommand cmd = new SqlCommand("STAT_setOnlineGames_05042014", con)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ServerName", Utils.SERVER_NAME); cmd.Parameters.AddWithValue("@UserId", Utils.safeInt(OnlineUserValue["UserId"])); cmd.Parameters.AddWithValue("@GameId", Utils.safeStr(OnlineUserValue["GameId"])); cmd.Parameters.AddWithValue("@ClientIP", Utils.safeStr(OnlineUserValue["ClientIP"])); cmd.Parameters.AddWithValue("@Country", Utils.safeStr(OnlineUserValue["Country"])); cmd.Parameters.AddWithValue("@City", Utils.safeStr(OnlineUserValue["City"])); cmd.Parameters.AddWithValue("@Refer", Utils.safeStr(OnlineUserValue["Refer"])); cmd.Parameters.AddWithValue("@WebRefer", Utils.safeStr(OnlineUserValue["WebRefer"])); cmd.Parameters.AddWithValue("@Visit", Utils.safeInt(OnlineUserValue["Visit"])); cmd.Parameters.AddWithValue("@VisitState", Utils.safeInt(OnlineUserValue["VisitState"])); cmd.Parameters.AddWithValue("@WebAgent", Utils.safeStr(OnlineUserValue["WebAgent"])); cmd.Parameters.AddWithValue("@Browser", Utils.safeStr(agentInfo.UserAgent)); cmd.Parameters.AddWithValue("@Device", Utils.safeStr(agentInfo.Device)); cmd.Parameters.AddWithValue("@OS", Utils.safeStr(agentInfo.OS)); SqlParameter prid = cmd.Parameters.Add("@RETURN_VALUE", SqlDbType.Int); prid.Direction = ParameterDirection.ReturnValue; cmd.ExecuteNonQuery(); return(Convert.ToInt32(prid.Value)); } catch { return(0); } } } }
/// <summary> /// Initializes a new instance of the <see cref="BrowserInfo"/> class. /// </summary> /// <param name="userAgent">The user agent.</param> public BrowserInfo(string userAgent) { UAParser.Parser uaParser = UAParser.Parser.GetDefault(); _client = uaParser.Parse(userAgent); }
/// <summary> /// Initializes a new instance of the <see cref="BrowserInfo"/> class. /// </summary> /// <param name="userAgent">The user agent.</param> public BrowserInfo(string userAgent) { _client = uaParser.Parse(userAgent); }