Example #1
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);
            }
        }