public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase) { SessionStateParamCheck(type, ref customDatabase); string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, install ? SESSION_STATE_INSTALL_FILE : SESSION_STATE_UNINSTALL_FILE); string content = File.ReadAllText(fullpath); return(FixContent(content, customDatabase, null, true, type)); }
public bool OpenService(string uri) { if (uri == "//blp/refdata") { this._sessionState = SessionStateType.serviceOpened; return(true); } else { return(false); } }
private static void SessionStateParamCheck(SessionStateType type, ref string customDatabase) { if ((type == SessionStateType.Custom) && string.IsNullOrEmpty(customDatabase)) { throw new ArgumentException(System.Web.SR.GetString("SQL_Services_Error_missing_custom_database"), "customDatabase"); } if ((type != SessionStateType.Custom) && (customDatabase != null)) { throw new ArgumentException(System.Web.SR.GetString("SQL_Services_Error_Cant_use_custom_database"), "customDatabase"); } CheckDatabaseName(ref customDatabase); }
static void ExecuteSessionFile( string file, string server, string database, string dbFileName, SqlConnection connection, bool isInstall, SessionStateType sessionStatetype ) { ExecuteFile(file, server, database, dbFileName, connection, true, isInstall, sessionStatetype); }
public bool Start() { if (this._sessionOptions.ServerPort == 8194 && (this._sessionOptions.ServerHost == "localhost" || this._sessionOptions.ServerHost == "127.0.0.1")) { this._sessionState = SessionStateType.started; return(true); } else { this._sessionState = SessionStateType.connectionError; return(false); } }
public bool StartAsync() { this._sessionState = SessionStateType.started; MarketDataRequest.EventMarket evtSessionStatus = new MarketDataRequest.EventMarket(Event.EventType.SESSION_STATUS, null, null); MarketDataRequest.EventMarket evtServiceStatus = new MarketDataRequest.EventMarket(Event.EventType.SERVICE_STATUS, new CorrelationID(), null); if (this._asyncHandler != null) { this._asyncHandler(evtSessionStatus, this); this._asyncHandler(evtServiceStatus, this); } return(true); }
public static void UninstallSessionState(string customDatabase, SessionStateType type, string connectionString) { }
public static void InstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type) { }
public bool Start() { this._sessionState = SessionStateType.started; return(true); }
static void SessionStateParamCheck(SessionStateType type, ref string customDatabase) { if (type == SessionStateType.Custom && String.IsNullOrEmpty(customDatabase)) { throw new ArgumentException( SR.GetString(SR.SQL_Services_Error_missing_custom_database), "customDatabase"); } if (type != SessionStateType.Custom && customDatabase != null) { throw new ArgumentException( SR.GetString(SR.SQL_Services_Error_Cant_use_custom_database), "customDatabase"); } CheckDatabaseName(ref customDatabase); }
public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase) { SessionStateParamCheck(type, ref customDatabase); string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, install ? SESSION_STATE_INSTALL_FILE : SESSION_STATE_UNINSTALL_FILE); string content = File.ReadAllText(fullpath); return FixContent(content, customDatabase, null, true, type); }
/// <summary> /// The constructor for the DiskInformation class. It parses the information from the /// memory buffer that contains the raw SCSI result. /// </summary> /// <param name="buffer">The buffer containing the raw SCSI result</param> /// <param name="size">The size of the raw SCSI result buffer</param> public DiskInformation(IntPtr buffer, int size) : base(buffer, size) { ushort len = Get16(0); byte b = Get8(2); if ((b & 0x10) != 0) { m_erasable = true; } else { m_erasable = false; } m_session_state = (SessionStateType)((b >> 2) & 0x03); m_disk_status = (DiskStatusType)(b & 0x03); m_first_track = Get8(3); m_session_count = (ushort)(Get8(4) | (Get8(9) << 8)); m_first_track_in_last_session = (ushort)(Get8(5) | (Get8(10) << 8)); m_last_track_in_last_session = (ushort)(Get8(6) | (Get8(11) << 8)); b = Get8(7); if ((b & 0x80) != 0) { m_disk_id_valid = true; m_disk_identification = Get32(12); } else { m_disk_id_valid = false; } if ((b & 0x40) != 0) { m_disk_bar_code_valid = true; m_disk_bar_code = new byte[8]; for (int i = 24; i <= 31; i++) { m_disk_bar_code[i - 24] = Get8(i); } } else { m_disk_bar_code_valid = false; m_disk_bar_code = null; } if ((b & 0x20) != 0) { m_unrestricted_disk_use = true; } else { m_unrestricted_disk_use = false; } if ((b & 0x10) != 0) { m_disk_application_code_valid = true; m_disk_application_code = Get8(32); } else { m_disk_application_code_valid = false; } if ((b & 0x04) != 0) { m_dirty_bit = true; } else { m_dirty_bit = false; } m_background_format_status = (BackgroundFormatStatusType)(b & 0x03); m_last_session_lead_in_start_address = new MinuteSecondFrame(Get8(16) * 60 + Get8(17), Get8(18), Get8(19)); m_last_possible_leadout_start_address = new MinuteSecondFrame(Get8(20) * 60 + Get8(21), Get8(22), Get8(23)); OpcTable = new List <OpcTableEntry>(); if (BufferSize > 33) { byte cnt = Get8(33); int offset = 34; for (byte i = 0; i < cnt && offset < BufferSize; i++) { OpcTableEntry entry = new OpcTableEntry(Buffer, BufferSize, offset); OpcTable.Add(entry); offset += 8; } } }
public bool StartAsync() { this._sessionState = SessionStateType.started; MarketDataRequest.EventMarket evtSessionStatus = new MarketDataRequest.EventMarket(Event.EventType.SESSION_STATUS, null, null); MarketDataRequest.EventMarket evtServiceStatus = new MarketDataRequest.EventMarket(Event.EventType.SERVICE_STATUS, new CorrelationID(), null); if (this._asyncHandler != null) { this._asyncHandler(evtSessionStatus, this); this._asyncHandler(evtServiceStatus, this); } return true; }
public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase) { }
static void SetupSessionState(string server, string user, string password, bool trusted, string connectionString, string customDatabase, SessionStateType type, bool install) { SqlConnection sqlConnection = null; Debug.Trace("SqlServices", "SetupSessionState called: server=" + server + ", customDatabase=" + customDatabase + ", user="******", password="******", trusted=" + trusted + ", connectionString=" + connectionString + ", type=" + type + ", install=" + install); SessionStateParamCheck(type, ref customDatabase); try { sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString); if (!install && type == SessionStateType.Custom) { EnsureDatabaseExists(customDatabase, sqlConnection); } // Load and run the sql file for each feature ExecuteSessionFile(install ? SESSION_STATE_INSTALL_FILE : SESSION_STATE_UNINSTALL_FILE, server, customDatabase, null, sqlConnection, install, type); } finally { if (sqlConnection != null) { try { sqlConnection.Close(); } catch { } finally { sqlConnection = null; } } } }
// Load the SQL file, change the database name within, and execute it. static void ExecuteFile( string file, string server, string database, string dbFileName, SqlConnection connection, bool sessionState, bool isInstall, SessionStateType sessionStatetype ) { string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, file); string content = File.ReadAllText(fullpath); StringReader sr; string cmdText = null; string cur; SqlCommand sqlCmd; Debug.Trace("SqlServices", "Execute File: about to run " + fullpath); // We need to replace the name of the database with the one specified by the caller if (file.Equals(INSTALL_COMMON_SQL)) { content = FixContent(content, database, dbFileName, sessionState, sessionStatetype); } else { content = FixContent(content, database, null, sessionState, sessionStatetype); } sr = new StringReader(content); sqlCmd = new SqlCommand(null, connection); do { bool run = false; // Read a line from a file. If it's not a "GO", batch it up. // It it's a "GO" (or the last line), send over all batched // commands over to SQL. cur = sr.ReadLine(); if (cur == null) { run = true; } else { if (StringUtil.EqualsIgnoreCase(cur.Trim(), "GO")) { run = true; } else { if (cmdText != null) { cmdText += "\n"; } cmdText += cur; } } if (run & cmdText != null) { sqlCmd.CommandText = cmdText; try { sqlCmd.ExecuteNonQuery(); } catch (Exception e) { SqlException sqlExpt = e as SqlException; if (sqlExpt != null) { Debug.Trace("SqlServices", "Error executing command. SqlException:" + "\nMessage=" + sqlExpt.Message + "\nNumber=" + sqlExpt.Number); int expectedError = -1; // There are some errors we might expect. // See VSWhidbey 376433 if (cmdText.IndexOf("sp_add_category", StringComparison.Ordinal) > -1) { expectedError = 14261; /* already exists */ } else if (cmdText.IndexOf("sp_delete_job", StringComparison.Ordinal) > -1) { expectedError = 14262; /* doesn't exists */ if (sessionState && !isInstall) { throw new SqlExecutionException(SR.GetString(SR.SQL_Services_Error_Deleting_Session_Job), server, database, file, cmdText, sqlExpt); } } if (sqlExpt.Number == expectedError) { Debug.Trace("SqlServices", "Got expected error: " + expectedError + "; not throwing"); } else { throw new SqlExecutionException( SR.GetString(SR.SQL_Services_Error_Executing_Command, file, sqlExpt.Number.ToString(CultureInfo.CurrentCulture), sqlExpt.Message), server, database, file, cmdText, sqlExpt); } } } #pragma warning disable 1058 catch { throw; } #pragma warning restore 1058 cmdText = null; } } while (cur != null); }
// Replace the name of the database with the one specified by the caller static string FixContent( string content, string database, string dbFileName, bool sessionState, SessionStateType sessionStatetype ) { if (database != null) { database = RemoveSquareBrackets(database); } if (sessionState) { if (sessionStatetype == SessionStateType.Temporary) { // No change } else if (sessionStatetype == SessionStateType.Persisted) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_PERSISTED + "'"); content = content.Replace("[tempdb]", "[" + ASPSTATE_DB + "]"); } else if (sessionStatetype == SessionStateType.Custom) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_CUSTOM + "'"); content = content.Replace("[tempdb]", "[" + database + "]"); content = content.Replace("'ASPState'", "'" + database + "'"); content = content.Replace("[ASPState]", "[" + database + "]"); } } else { content = content.Replace("'aspnetdb'", "'" + database.Replace("'", "''") + "'"); content = content.Replace("[aspnetdb]", "[" + database + "]"); } if (dbFileName != null) { if (dbFileName.Contains("[") || dbFileName.Contains("]") || dbFileName.Contains("'")) { throw new ArgumentException(SR.GetString(SR.DbFileName_can_not_contain_invalid_chars)); } database = database.TrimStart('['); database = database.TrimEnd(']'); string logicalFileName = database + "_DAT"; if (!char.IsLetter(logicalFileName[0])) { logicalFileName = "A" + logicalFileName; } // // Build the database options string for SQL Express database // string dbOptions = "ON ( NAME = " + logicalFileName + ", FILENAME = ''" + dbFileName + "'', " + "SIZE = 10MB, FILEGROWTH = 5MB )"; content = content.Replace("SET @dboptions = N'/**/'", "SET @dboptions = N'" + dbOptions + "'"); } return(content); }
public bool Start() { this._sessionState = SessionStateType.started; return true; }
public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase) { return default(string); }
// For trusted connection public static void UninstallSessionState(string server, string customDatabase, SessionStateType type) { SetupSessionState(server, null, null, true, null, customDatabase, type, false); }
private static string FixContent(string content, string database, string dbFileName, bool sessionState, SessionStateType sessionStatetype) { if (database != null) { database = RemoveSquareBrackets(database); } if (sessionState) { if (sessionStatetype != SessionStateType.Temporary) { if (sessionStatetype == SessionStateType.Persisted) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_PERSISTED + "'"); content = content.Replace("[tempdb]", "[" + ASPSTATE_DB + "]"); } else if (sessionStatetype == SessionStateType.Custom) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_CUSTOM + "'"); content = content.Replace("[tempdb]", "[" + database + "]"); content = content.Replace("'ASPState'", "'" + database + "'"); content = content.Replace("[ASPState]", "[" + database + "]"); } } } else { content = content.Replace("'aspnetdb'", "'" + database.Replace("'", "''") + "'"); content = content.Replace("[aspnetdb]", "[" + database + "]"); } if (dbFileName != null) { if ((dbFileName.Contains("[") || dbFileName.Contains("]")) || dbFileName.Contains("'")) { throw new ArgumentException(System.Web.SR.GetString("DbFileName_can_not_contain_invalid_chars")); } database = database.TrimStart(new char[] { '[' }); database = database.TrimEnd(new char[] { ']' }); string str = database + "_DAT"; if (!char.IsLetter(str[0])) { str = "A" + str; } content = content.Replace("SET @dboptions = N'/**/'", "SET @dboptions = N'" + ("ON ( NAME = " + str + ", FILENAME = ''" + dbFileName + "'', SIZE = 10MB, FILEGROWTH = 5MB )") + "'"); } return content; }
private static void SetupSessionState(string server, string user, string password, bool trusted, string connectionString, string customDatabase, SessionStateType type, bool install) { SqlConnection sqlConnection = null; SessionStateParamCheck(type, ref customDatabase); try { sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString); if (!install && (type == SessionStateType.Custom)) { EnsureDatabaseExists(customDatabase, sqlConnection); } ExecuteSessionFile(install ? SESSION_STATE_INSTALL_FILE : SESSION_STATE_UNINSTALL_FILE, server, customDatabase, null, sqlConnection, install, type); } finally { if (sqlConnection != null) { try { sqlConnection.Close(); } catch { } finally { sqlConnection = null; } } } }
/// <summary> /// The constructor for the DiskInformation class. It parses the information from the /// memory buffer that contains the raw SCSI result. /// </summary> /// <param name="buffer">The buffer containing the raw SCSI result</param> /// <param name="size">The size of the raw SCSI result buffer</param> public DiskInformation(IntPtr buffer, int size) : base(buffer, size) { ushort len = Get16(0); byte b = Get8(2); if ((b & 0x10) != 0) m_erasable = true; else m_erasable = false; m_session_state = (SessionStateType)((b >> 2) & 0x03); m_disk_status = (DiskStatusType)(b & 0x03); m_first_track = Get8(3); m_session_count = (ushort)(Get8(4) | (Get8(9) << 8)); m_first_track_in_last_session = (ushort)(Get8(5) | (Get8(10) << 8)); m_last_track_in_last_session = (ushort)(Get8(6) | (Get8(11) << 8)); b = Get8(7); if ((b & 0x80) != 0) { m_disk_id_valid = true; m_disk_identification = Get32(12); } else m_disk_id_valid = false; if ((b & 0x40) != 0) { m_disk_bar_code_valid = true; m_disk_bar_code = new byte[8]; for (int i = 24; i <= 31; i++) m_disk_bar_code[i - 24] = Get8(i); } else { m_disk_bar_code_valid = false; m_disk_bar_code = null; } if ((b & 0x20) != 0) m_unrestricted_disk_use = true; else m_unrestricted_disk_use = false; if ((b & 0x10) != 0) { m_disk_application_code_valid = true; m_disk_application_code = Get8(32); } else m_disk_application_code_valid = false; if ((b & 0x04) != 0) m_dirty_bit = true; else m_dirty_bit = false; m_background_format_status = (BackgroundFormatStatusType)(b & 0x03); m_last_session_lead_in_start_address = new MinuteSecondFrame(Get8(16) * 60 + Get8(17), Get8(18), Get8(19)); m_last_possible_leadout_start_address = new MinuteSecondFrame(Get8(20) * 60 + Get8(21), Get8(22), Get8(23)); OpcTable = new List<OpcTableEntry>(); if (BufferSize > 33) { byte cnt = Get8(33); int offset = 34; for(byte i = 0 ; i < cnt && offset < BufferSize ; i++) { OpcTableEntry entry = new OpcTableEntry(Buffer, BufferSize, offset); OpcTable.Add(entry); offset += 8; } } }
private static void ExecuteFile(string file, string server, string database, string dbFileName, SqlConnection connection, bool sessionState, bool isInstall, SessionStateType sessionStatetype) { string str4; string content = File.ReadAllText(Path.Combine(HttpRuntime.AspInstallDirectory, file)); string commands = null; if (file.Equals(INSTALL_COMMON_SQL)) { content = FixContent(content, database, dbFileName, sessionState, sessionStatetype); } else { content = FixContent(content, database, null, sessionState, sessionStatetype); } StringReader reader = new StringReader(content); SqlCommand command = new SqlCommand(null, connection); do { bool flag = false; str4 = reader.ReadLine(); if (str4 == null) { flag = true; } else if (StringUtil.EqualsIgnoreCase(str4.Trim(), "GO")) { flag = true; } else { if (commands != null) { commands = commands + "\n"; } commands = commands + str4; } if (flag & (commands != null)) { command.CommandText = commands; try { command.ExecuteNonQuery(); } catch (Exception exception) { SqlException sqlException = exception as SqlException; if (sqlException != null) { int num = -1; if (commands.IndexOf("sp_add_category", StringComparison.Ordinal) > -1) { num = 0x37b5; } else if (commands.IndexOf("sp_delete_job", StringComparison.Ordinal) > -1) { num = 0x37b6; if (sessionState && !isInstall) { throw new SqlExecutionException(System.Web.SR.GetString("SQL_Services_Error_Deleting_Session_Job"), server, database, file, commands, sqlException); } } if (sqlException.Number != num) { throw new SqlExecutionException(System.Web.SR.GetString("SQL_Services_Error_Executing_Command", new object[] { file, sqlException.Number.ToString(CultureInfo.CurrentCulture), sqlException.Message }), server, database, file, commands, sqlException); } } } catch { throw; } commands = null; } } while (str4 != null); }
/// <summary> /// Call this method to set which player you want to be the primary decision maker of this DDDServerConnection. You can find out what players are available from The AvailablePlayers property. /// The method does not do a full DDD login and a DDDClient UI is still able to login as this player. /// </summary> /// <param name="dm"></param> public void SetLocalPlayer(String dm) { m_playerID = dm; m_sessionState = SessionStateType.LOGGED_IN; }
private static string FixContent(string content, string database, string dbFileName, bool sessionState, SessionStateType sessionStatetype) { if (database != null) { database = RemoveSquareBrackets(database); } if (sessionState) { if (sessionStatetype != SessionStateType.Temporary) { if (sessionStatetype == SessionStateType.Persisted) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_PERSISTED + "'"); content = content.Replace("[tempdb]", "[" + ASPSTATE_DB + "]"); } else if (sessionStatetype == SessionStateType.Custom) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_CUSTOM + "'"); content = content.Replace("[tempdb]", "[" + database + "]"); content = content.Replace("'ASPState'", "'" + database + "'"); content = content.Replace("[ASPState]", "[" + database + "]"); } } } else { content = content.Replace("'aspnetdb'", "'" + database.Replace("'", "''") + "'"); content = content.Replace("[aspnetdb]", "[" + database + "]"); } if (dbFileName != null) { if ((dbFileName.Contains("[") || dbFileName.Contains("]")) || dbFileName.Contains("'")) { throw new ArgumentException(System.Web.SR.GetString("DbFileName_can_not_contain_invalid_chars")); } database = database.TrimStart(new char[] { '[' }); database = database.TrimEnd(new char[] { ']' }); string str = database + "_DAT"; if (!char.IsLetter(str[0])) { str = "A" + str; } content = content.Replace("SET @dboptions = N'/**/'", "SET @dboptions = N'" + ("ON ( NAME = " + str + ", FILENAME = ''" + dbFileName + "'', SIZE = 10MB, FILEGROWTH = 5MB )") + "'"); } return(content); }
public void OpenServiceAsync(string uri, CorrelationID correlationId) { this._sessionUri = SessionUriType.mktData; this._sessionState = SessionStateType.serviceOpened; this._asyncOpenCorrelation = correlationId; }
public static void InstallSessionState(string server, string customDatabase, SessionStateType type) { SetupSessionState(server, null, null, true, null, customDatabase, type, true); }
public bool OpenService(string uri) { this._sessionState = SessionStateType.serviceOpened; return(true); }
public static void UninstallSessionState(string server, string customDatabase, SessionStateType type) { }
public static void UninstallSessionState(string customDatabase, SessionStateType type, string connectionString) { SetupSessionState(null, null, null, true, connectionString, customDatabase, type, false); }
public static void UninstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type) { SetupSessionState(server, user, password, false, null, customDatabase, type, false); }
private static void ExecuteFile(string file, string server, string database, string dbFileName, SqlConnection connection, bool sessionState, bool isInstall, SessionStateType sessionStatetype) { string str4; string content = File.ReadAllText(Path.Combine(HttpRuntime.AspInstallDirectory, file)); string commands = null; if (file.Equals(INSTALL_COMMON_SQL)) { content = FixContent(content, database, dbFileName, sessionState, sessionStatetype); } else { content = FixContent(content, database, null, sessionState, sessionStatetype); } StringReader reader = new StringReader(content); SqlCommand command = new SqlCommand(null, connection); do { bool flag = false; str4 = reader.ReadLine(); if (str4 == null) { flag = true; } else if (StringUtil.EqualsIgnoreCase(str4.Trim(), "GO")) { flag = true; } else { if (commands != null) { commands = commands + "\n"; } commands = commands + str4; } if (flag & (commands != null)) { command.CommandText = commands; try { command.ExecuteNonQuery(); } catch (Exception exception) { SqlException sqlException = exception as SqlException; if (sqlException != null) { int num = -1; if (commands.IndexOf("sp_add_category", StringComparison.Ordinal) > -1) { num = 0x37b5; } else if (commands.IndexOf("sp_delete_job", StringComparison.Ordinal) > -1) { num = 0x37b6; if (sessionState && !isInstall) { throw new SqlExecutionException(System.Web.SR.GetString("SQL_Services_Error_Deleting_Session_Job"), server, database, file, commands, sqlException); } } if (sqlException.Number != num) { throw new SqlExecutionException(System.Web.SR.GetString("SQL_Services_Error_Executing_Command", new object[] { file, sqlException.Number.ToString(CultureInfo.CurrentCulture), sqlException.Message }), server, database, file, commands, sqlException); } } } catch { throw; } commands = null; } }while (str4 != null); }
public bool OpenService(string uri) { this._sessionState = SessionStateType.serviceOpened; return true; }
//public void HttpResponseBodyRequested( Action<byte[], ISessionContext> bodyAvailableCallback ) //{ // _bodyAvailableCallback = bodyAvailableCallback; // ServerParser.BodyAvailable += HandleServerParserBodyAvailable; //} public void ChangeState( SessionStateType newState ) { ServiceLog.Logger.Verbose( () => string.Format( "{0} Changing state to {1}", Id, newState ) ); _stateUpdateLock.EnterWriteLock(); try { if ( State != null ) { State.TransitionFromState( this ); } State = _registry.GetState( newState ); State.TransitionToState( this ); } catch ( Exception ex ) { ServiceLog.Logger.Exception( string.Format( "{0} Unhandled exception when changing session state", Id ), ex ); ChangeState( SessionStateType.Error ); } finally { _stateUpdateLock.ExitWriteLock(); } }
public static void InstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type) { SetupSessionState(server, user, password, false, null, customDatabase, type, true); }
public abstract void ChangeState( SessionStateType newState );
// For connection using connection string public static void UninstallSessionState(string customDatabase, SessionStateType type, string connectionString) { SetupSessionState(null, null, null, true, connectionString, customDatabase, type, false); }
public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase) { return(default(string)); }
// Replace the name of the database with the one specified by the caller static string FixContent( string content, string database, string dbFileName, bool sessionState, SessionStateType sessionStatetype ) { if (database != null) { database = RemoveSquareBrackets(database); } if (sessionState) { if (sessionStatetype == SessionStateType.Temporary) { // No change } else if (sessionStatetype == SessionStateType.Persisted) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_PERSISTED + "'"); content = content.Replace("[tempdb]", "[" + ASPSTATE_DB + "]"); } else if (sessionStatetype == SessionStateType.Custom) { content = content.Replace("'sstype_temp'", "'" + SSTYPE_CUSTOM + "'"); content = content.Replace("[tempdb]", "[" + database + "]"); content = content.Replace("'ASPState'", "'" + database + "'"); content = content.Replace("[ASPState]", "[" + database + "]"); } } else { content = content.Replace("'aspnetdb'", "'" + database.Replace("'", "''") + "'"); content = content.Replace("[aspnetdb]", "[" + database + "]"); } if( dbFileName != null ) { if (dbFileName.Contains("[") || dbFileName.Contains("]") || dbFileName.Contains("'")) throw new ArgumentException(SR.GetString(SR.DbFileName_can_not_contain_invalid_chars)); database = database.TrimStart( '[' ); database = database.TrimEnd( ']' ); string logicalFileName = database + "_DAT"; if (!char.IsLetter(logicalFileName[0])) logicalFileName = "A" + logicalFileName; // // Build the database options string for SQL Express database // string dbOptions = "ON ( NAME = " + logicalFileName + ", FILENAME = ''" + dbFileName + "'', " + "SIZE = 10MB, FILEGROWTH = 5MB )"; content = content.Replace("SET @dboptions = N'/**/'", "SET @dboptions = N'" + dbOptions + "'"); } return content; }
public static void InstallSessionState(string server, string customDatabase, SessionStateType type) { }
// Load the SQL file, change the database name within, and execute it. static void ExecuteFile( string file, string server, string database, string dbFileName, SqlConnection connection, bool sessionState, bool isInstall, SessionStateType sessionStatetype ) { string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, file); string content = File.ReadAllText(fullpath); StringReader sr; string cmdText = null; string cur; SqlCommand sqlCmd; Debug.Trace("SqlServices", "Execute File: about to run " + fullpath); // We need to replace the name of the database with the one specified by the caller if( file.Equals( INSTALL_COMMON_SQL ) ) { content = FixContent(content, database, dbFileName, sessionState, sessionStatetype); } else { content = FixContent(content, database, null, sessionState, sessionStatetype); } sr = new StringReader(content); sqlCmd = new SqlCommand(null, connection); do { bool run = false; // Read a line from a file. If it's not a "GO", batch it up. // It it's a "GO" (or the last line), send over all batched // commands over to SQL. cur = sr.ReadLine(); if (cur == null) { run = true; } else { if (StringUtil.EqualsIgnoreCase(cur.Trim(), "GO")) { run = true; } else { if (cmdText != null) { cmdText += "\n"; } cmdText += cur; } } if (run & cmdText != null) { sqlCmd.CommandText = cmdText; try { sqlCmd.ExecuteNonQuery(); } catch (Exception e) { SqlException sqlExpt = e as SqlException; if (sqlExpt != null) { Debug.Trace("SqlServices", "Error executing command. SqlException:" + "\nMessage=" + sqlExpt.Message + "\nNumber=" + sqlExpt.Number); int expectedError = -1; // There are some errors we might expect. // See VSWhidbey 376433 if (cmdText.IndexOf("sp_add_category", StringComparison.Ordinal) > -1) { expectedError = 14261; /* already exists */ } else if (cmdText.IndexOf("sp_delete_job", StringComparison.Ordinal) > -1) { expectedError = 14262; /* doesn't exists */ if (sessionState && !isInstall) { throw new SqlExecutionException(SR.GetString(SR.SQL_Services_Error_Deleting_Session_Job), server, database, file, cmdText, sqlExpt); } } if (sqlExpt.Number == expectedError) { Debug.Trace("SqlServices", "Got expected error: " + expectedError + "; not throwing"); } else { throw new SqlExecutionException( SR.GetString(SR.SQL_Services_Error_Executing_Command, file, sqlExpt.Number.ToString(CultureInfo.CurrentCulture), sqlExpt.Message), server, database, file, cmdText, sqlExpt); } } } #pragma warning disable 1058 catch { throw; } #pragma warning restore 1058 cmdText = null; } } while (cur != null); }
public static void UninstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type) { }
public ISessionState GetState( SessionStateType sessionStateType ) { return States.Where( v => v.Metadata.SessionStateType.Equals( sessionStateType ) ).Single().Value; }