예제 #1
0
        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));
        }
예제 #2
0
파일: Session.cs 프로젝트: zeta1999/bemux
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
파일: Session.cs 프로젝트: zeta1999/bemux
 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);
     }
 }
예제 #6
0
        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)
 {
 }
예제 #9
0
 public bool Start()
 {
     this._sessionState = SessionStateType.started;
     return(true);
 }
예제 #10
0
 public static void UninstallSessionState(string customDatabase, SessionStateType type, string connectionString)
 {
 }
예제 #11
0
        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);
        }
예제 #12
0
 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);
 }
예제 #13
0
        /// <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;
                }
            }
        }
예제 #14
0
        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)
 {
 }
예제 #16
0
        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;
                    }
                }
            }
        }
예제 #17
0
        // 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);
        }
예제 #18
0
        // 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);
        }
예제 #19
0
 public bool Start()
 {
     this._sessionState = SessionStateType.started;
     return true;
 }
 public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase)
 {
   return default(string);
 }
예제 #21
0
 // 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;
 }
예제 #23
0
 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);
 }
 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;
             }
         }
     }
 }
예제 #25
0
        /// <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);
 }
예제 #27
0
 /// <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);
 }
예제 #29
0
 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);
 }
예제 #31
0
 public bool OpenService(string uri)
 {
     this._sessionState = SessionStateType.serviceOpened;
     return(true);
 }
        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;
                    }
                }
            }
        }
 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 string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase)
 {
 }
 public static void UninstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type)
 {
     SetupSessionState(server, user, password, false, null, customDatabase, type, false);
 }
예제 #37
0
 public void OpenServiceAsync(string uri, CorrelationID correlationId)
 {
     this._sessionUri = SessionUriType.mktData;
     this._sessionState = SessionStateType.serviceOpened;
     this._asyncOpenCorrelation = correlationId;
 }
        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);
        }
예제 #39
0
 public bool OpenService(string uri)
 {
     this._sessionState = SessionStateType.serviceOpened;
     return true;
 }
예제 #40
0
        //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();
            }
        }
예제 #41
0
 public static void InstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type) {
     SetupSessionState(server, user, password, false, null, customDatabase, type, true);
 }
예제 #42
0
 public abstract void ChangeState( SessionStateType newState );
예제 #43
0
 // For connection using connection string
 public static void UninstallSessionState(string customDatabase, SessionStateType type, string connectionString) {
     SetupSessionState(null, null, null, true, connectionString, customDatabase, type, false);
 }
예제 #44
0
 public static string GenerateSessionStateScripts(bool install, SessionStateType type, string customDatabase)
 {
     return(default(string));
 }
예제 #45
0
        // 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;
        }
예제 #46
0
 public static void InstallSessionState(string server, string customDatabase, SessionStateType type)
 {
 }
예제 #47
0
        // 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);
        }
예제 #48
0
 public static void UninstallSessionState(string server, string user, string password, string customDatabase, SessionStateType type)
 {
 }
예제 #49
0
        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;
                    }
                }
            }

        }
예제 #50
0
 public ISessionState GetState( SessionStateType sessionStateType )
 {
     return States.Where( v => v.Metadata.SessionStateType.Equals( sessionStateType ) ).Single().Value;
 }