//////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// public override void SetPropertyValues(SettingsContext sc, SettingsPropertyValueCollection properties) { string username = (string)sc["UserName"]; bool userIsAuthenticated = (bool)sc["IsAuthenticated"]; if (username == null || username.Length < 1 || properties.Count < 1) { return; } string names = String.Empty; string values = String.Empty; byte [] buf = null; ProfileModule.PrepareDataForSaving(ref names, ref values, ref buf, true, properties, userIsAuthenticated); if (names.Length == 0) { return; } try { SqlConnectionHolder holder = null; try { holder = SqlConnectionHelper.GetConnection(_sqlConnectionString, true); CheckSchemaVersion(holder.Connection); SqlCommand cmd = new SqlCommand("dbo.aspnet_Profile_SetProperties", 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("@PropertyNames", SqlDbType.NText, names)); cmd.Parameters.Add(CreateInputParam("@PropertyValuesString", SqlDbType.NText, values)); cmd.Parameters.Add(CreateInputParam("@PropertyValuesBinary", SqlDbType.Image, buf)); cmd.Parameters.Add(CreateInputParam("@IsUserAnonymous", SqlDbType.Bit, !userIsAuthenticated)); cmd.Parameters.Add(CreateInputParam("@CurrentTimeUtc", SqlDbType.DateTime, DateTime.UtcNow)); cmd.ExecuteNonQuery(); } finally { if (holder != null) { holder.Close(); holder = null; } } } catch { throw; } }
public override void SetPropertyValues(SettingsContext sc, SettingsPropertyValueCollection properties) { string objValue = (string)sc["UserName"]; bool userIsAuthenticated = (bool)sc["IsAuthenticated"]; if (((objValue != null) && (objValue.Length >= 1)) && (properties.Count >= 1)) { string allNames = string.Empty; string allValues = string.Empty; byte[] buf = null; ProfileModule.PrepareDataForSaving(ref allNames, ref allValues, ref buf, true, properties, userIsAuthenticated); if (allNames.Length != 0) { try { SqlConnectionHolder connection = null; try { connection = SqlConnectionHelper.GetConnection(this._sqlConnectionString, true); this.CheckSchemaVersion(connection.Connection); SqlCommand command = new SqlCommand("dbo.aspnet_Profile_SetProperties", 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, objValue)); command.Parameters.Add(this.CreateInputParam("@PropertyNames", SqlDbType.NText, allNames)); command.Parameters.Add(this.CreateInputParam("@PropertyValuesString", SqlDbType.NText, allValues)); command.Parameters.Add(this.CreateInputParam("@PropertyValuesBinary", SqlDbType.Image, buf)); command.Parameters.Add(this.CreateInputParam("@IsUserAnonymous", SqlDbType.Bit, !userIsAuthenticated)); command.Parameters.Add(this.CreateInputParam("@CurrentTimeUtc", SqlDbType.DateTime, DateTime.UtcNow)); command.ExecuteNonQuery(); } finally { if (connection != null) { connection.Close(); connection = null; } } } catch { throw; } } } }