示例#1
0
        /// <summary>
        /// Adds an ADO Resource Manager to the transaction.
        /// </summary>
        /// <param name="adoResourceManager">Manages an ADO data store in a transaction.</param>
        /// <returns>The resource manager that was added to the transaction.</returns>
        public AdoResourceManager Add(AdoResourceManager adoResourceManager)
        {
            // Adds the resource manager to the transaction.
            this.resourceTable.Add(adoResourceManager.Name, adoResourceManager);

            // Enlists the resource manager as part of the transaction.
            this.EnlistVolatile(adoResourceManager, EnlistmentOptions.None);

            // This is provided as a notiational convinience.
            return(adoResourceManager);
        }
示例#2
0
        /// <summary>
        /// Executes a batch of commands as a series of transactions that are committed or rejected as a unit.
        /// </summary>
        static BatchProcessor()
        {
            try
            {
                // The 'resourceSection' section of the configuration file contains about the resource managers available for the
                // transaction processor. Volatile Resource Managers provide an API and housekeeping data for managing the memory
                // based data while the Durable Resource Managers govern the handling of the data that resides on a disk
                // somewhere.  This section of the configuration file describes the resource managers available and their
                // properties.
                BatchProcessor.resourceDescriptionList = (List <ResourceDescription>)ConfigurationManager.GetSection("resourceSection");

                // This will read through each of the descriptions of the resource managers found in the configuratino file and
                // initialize the static properties.
                foreach (ResourceDescription resourceDescription in BatchProcessor.resourceDescriptionList)
                {
                    if (resourceDescription is SqlResourceDescription)
                    {
                        SqlResourceDescription sqlResourceDescription = resourceDescription as SqlResourceDescription;
                        SqlResourceManager.AddConnection(sqlResourceDescription.Name, sqlResourceDescription.ConnectionString);
                    }
                }

                // This will read through each of the descriptions of the resource managers found in the configuratino file and
                // initialize the static properties.
                foreach (ResourceDescription resourceDescription in BatchProcessor.resourceDescriptionList)
                {
                    if (resourceDescription is AdoResourceDescription)
                    {
                        AdoResourceDescription adoResourceDescription = resourceDescription as AdoResourceDescription;
                        MethodInfo             methodInfo             = adoResourceDescription.Type.GetMethod("GetDataSet");
                        AdoResourceManager.AddDataSet(adoResourceDescription.Name, methodInfo.Invoke(null, null) as DataSet);
                    }
                }
            }
            catch (Exception exception)
            {
                // Any problems initializing should be sent to the Event Log.
                EventLog.Error("{0}: {1}", exception.Message, exception.StackTrace);
            }
        }