Пример #1
0
        /// <summary>
        /// Initializes the static members of this class.
        /// </summary>
        static WebTransaction()
        {
            // Log the start of the service.
            EventLog.Information("Web Transaction Service is starting.");

            try
            {
                // The PersistentStoreSection contains information about what databases and other 'persistent' storage is
                // available.  For example, an SQL Database would have a unique short name, used to identify the database, and a
                // connection string.  This data would be used to establish a connection to the store for queries, inserts, updates
                // and deletes.  Each library class that can participate in a transaction to this store will specify the short name
                // of the store in a 'PersistentStore' field.
                WebTransaction.resourceDescriptionList =
                    (List <ResourceDescription>)ConfigurationManager.GetSection("resourceSection");
            }
            catch (Exception exception)
            {
                // Any problems initializing should be sent to the Event Log.
                EventLog.Error("{0}: {1}", exception.Message, exception.StackTrace);
            }

            // The transactions handled by this server can access a combination of one or more volatile or durable data repositories.  This
            // will read the description of the recognized resources from the configuration file.
            foreach (ResourceDescription resourceDescription in WebTransaction.resourceDescriptionList)
            {
                // This will tell the SQL Resource Manager which database connection parameters are associated with a friendly
                // name for that resource.
                if (resourceDescription is SqlResourceDescription)
                {
                    SqlResourceDescription sqlResourceDescription = resourceDescription as SqlResourceDescription;
                    SqlResourceManager.AddConnection(sqlResourceDescription.Name, sqlResourceDescription.ConnectionString);
                }
            }
        }