//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// private void GetPropertyValuesFromDatabase(string userName, SettingsPropertyValueCollection svc) { HttpContext context = HttpContext.Current; if (context != null && HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(EtwTraceLevel.Information, EtwTraceFlags.AppSvc)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_PROFILE_BEGIN, HttpContext.Current.WorkerRequest); } string[] names = null; string values = null; byte[] buf = null; string sName = null; if (context != null) { sName = (context.Request.IsAuthenticated ? context.User.Identity.Name : context.Request.AnonymousID); } try { SqlConnectionHolder holder = null; SqlDataReader reader = null; try { holder = SqlConnectionHelper.GetConnection(_sqlConnectionString, true); CheckSchemaVersion(holder.Connection); SqlCommand cmd = new SqlCommand("dbo.aspnet_Profile_GetProperties", holder.Connection); cmd.CommandTimeout = CommandTimeout; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(CreateInputParam("@ApplicationName", SqlDbType.NVarChar, ApplicationName)); cmd.Parameters.Add(CreateInputParam("@UserName", SqlDbType.NVarChar, userName)); cmd.Parameters.Add(CreateInputParam("@CurrentTimeUtc", SqlDbType.DateTime, DateTime.UtcNow)); reader = cmd.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { names = reader.GetString(0).Split(':'); values = reader.GetString(1); int size = (int)reader.GetBytes(2, 0, null, 0, 0); buf = new byte[size]; reader.GetBytes(2, 0, buf, 0, size); } } finally { if (holder != null) { holder.Close(); holder = null; } if (reader != null) { reader.Close(); } } ProfileModule.ParseDataFromDB(names, values, buf, svc); if (context != null && HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(EtwTraceLevel.Information, EtwTraceFlags.AppSvc)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_PROFILE_END, HttpContext.Current.WorkerRequest, userName); } } catch { throw; } }
private void GetPropertyValuesFromDatabase(string userName, SettingsPropertyValueCollection svc) { if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(4, 8)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_PROFILE_BEGIN, HttpContext.Current.WorkerRequest); } HttpContext current = HttpContext.Current; string[] names = null; string values = null; byte[] buffer = null; if (current != null) { if (!current.Request.IsAuthenticated) { string anonymousID = current.Request.AnonymousID; } else { string name = current.User.Identity.Name; } } try { SqlConnectionHolder connection = null; SqlDataReader reader = null; try { connection = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true); this.CheckSchemaVersion(connection.Connection); SqlCommand command = new SqlCommand("dbo.aspnet_Profile_GetProperties", connection.Connection) { CommandTimeout = this.CommandTimeout, CommandType = CommandType.StoredProcedure }; command.Parameters.Add(this.CreateInputParam("@ApplicationName", SqlDbType.NVarChar, this.ApplicationName)); command.Parameters.Add(this.CreateInputParam("@UserName", SqlDbType.NVarChar, userName)); command.Parameters.Add(this.CreateInputParam("@CurrentTimeUtc", SqlDbType.DateTime, DateTime.UtcNow)); reader = command.ExecuteReader(CommandBehavior.SingleRow); if (reader.Read()) { names = reader.GetString(0).Split(new char[] { ':' }); values = reader.GetString(1); int length = (int)reader.GetBytes(2, 0L, null, 0, 0); buffer = new byte[length]; reader.GetBytes(2, 0L, buffer, 0, length); } } finally { if (connection != null) { connection.Close(); connection = null; } if (reader != null) { reader.Close(); } } ProfileModule.ParseDataFromDB(names, values, buffer, svc); if (HostingEnvironment.IsHosted && EtwTrace.IsTraceEnabled(4, 8)) { EtwTrace.Trace(EtwTraceType.ETW_TYPE_PROFILE_END, HttpContext.Current.WorkerRequest, userName); } } catch { throw; } }