src/Misc/EFTools/EntityDesign/VisualStudio/ModelWizard/engine/ProgressDialogHelper.cs
// <summary>
//     Processes the sproc return type information stored in newFunctionSchemaProceduresMap to
//     add commands which create matching FunctionImports or delete Functions as necessary
// </summary>
// <param name="artifact"></param>
// <param name="newFunctionSchemaProceduresMap">
//     map of all processed EntityStoreSchemaFilterEntry for Functions to
//     their IDataSchemaProcedure (where data was collected) or null (where data was not collected because the data
//     collection process was interrupted)
// </param>
// <param name="commands">list of commands to which to add the create or delete commands</param>
// <param name="shouldCreateComposableFunctionImports">whether to create FunctionImports for composable Functions</param>
Processes the sproc return type information stored in newFunctionSchemaProceduresMap to
add commands which create matching FunctionImports or delete Functions as necessary
Processes the sproc return type information stored in newFunctionSchemaProceduresMap to add commands which create matching FunctionImports or delete Functions as necessary
private static void PopulateNewFunctionSchemaProcedures(
            Dictionary<EntityStoreSchemaFilterEntry, IDataSchemaProcedure> newFunctionSchemaProcedureMap,
            string designTimeProviderInvariantName,
            string designTimeProviderConnectionString,
            DoWorkEventArgs e = null,
            BackgroundWorker worker = null,
            int startingAmountOfProgressBar = 0,
            int amountOfProgressBarGiven = 100)
        {
            var dataConnectionManager = Services.ServiceProvider.GetService(typeof(IVsDataConnectionManager)) as IVsDataConnectionManager;
            Debug.Assert(dataConnectionManager != null, "Could not find IVsDataConnectionManager");
            var dataProviderManager = Services.ServiceProvider.GetService(typeof(IVsDataProviderManager)) as IVsDataProviderManager;
            Debug.Assert(dataProviderManager != null, "Could not find IVsDataProviderManager");
            IVsDataConnection dataConnection = null;
            if (null != dataConnectionManager
                && null != dataProviderManager)
            {
                dataConnection = DataConnectionUtils.GetDataConnection(
                    dataConnectionManager, dataProviderManager, designTimeProviderInvariantName, designTimeProviderConnectionString);
            }
            if (null == dataConnection)
            {
                throw new ProgressDialogException(
                    string.Format(
                        CultureInfo.CurrentCulture, Design.Resources.RetrievingSprocReturnTypeErrorMessage, "null IVsDataConnection"));
            }
            try
            {
                dataConnection.Open();
                var dataSchemaServer = new DataSchemaServer(dataConnection);
                var numFunctionFilterEntries = newFunctionSchemaProcedureMap.Count;
                var numFunctionFilterEntryCurrent = 0;
                foreach (var entry in newFunctionSchemaProcedureMap.Keys.ToList())
                {
                    numFunctionFilterEntryCurrent++;
                    if (worker != null
                        && e != null
                        && worker.CancellationPending)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        if (worker != null
                            && worker.WorkerReportsProgress)
                        {
                            var percentCompleted = startingAmountOfProgressBar +
                                                   ((int)
                                                       (((numFunctionFilterEntryCurrent - 1) / (float)numFunctionFilterEntries)
                                                        * amountOfProgressBarGiven));
                            var userState = new ProgressDialogUserState();
                            userState.NumberIterations = numFunctionFilterEntries;
                            userState.CurrentIteration = numFunctionFilterEntryCurrent;
                            userState.CurrentStatusMessage = string.Format(
                                CultureInfo.CurrentCulture,
                                Design.Resources.RetrievingSprocReturnTypeInfoMessage,
                                numFunctionFilterEntryCurrent,
                                numFunctionFilterEntries,
                                entry.Schema,
                                entry.Name);
                            worker.ReportProgress(percentCompleted, userState);
                        }
                        var schemaProcedure = dataSchemaServer.GetProcedureOrFunction(entry.Schema, entry.Name);
                        Debug.Assert(
                            null == newFunctionSchemaProcedureMap[entry],
                            "This entry has already been processed, Schema = " + entry.Schema + ", Name = " + entry.Name);
                        newFunctionSchemaProcedureMap[entry] = schemaProcedure;
                    }
                }
            }
            finally
            {
                if (null != dataConnection)
                {
                    dataConnection.Close();
                }
            }
        }
private static void PopulateNewFunctionSchemaProcedures ( Dictionary < EntityStoreSchemaFilterEntry , IDataSchemaProcedure > newFunctionSchemaProcedureMap , string designTimeProviderInvariantName , string designTimeProviderConnectionString , DoWorkEventArgs e = null , BackgroundWorker worker = null , int startingAmountOfProgressBar = 0 , int amountOfProgressBarGiven = 100 ) { var dataConnectionManager = Services . ServiceProvider . GetService ( typeof ( IVsDataConnectionManager ) ) as IVsDataConnectionManager ; Debug . Assert ( dataConnectionManager != null , " " ) ; var dataProviderManager = Services . ServiceProvider . GetService ( typeof ( IVsDataProviderManager ) ) as IVsDataProviderManager ; Debug . Assert ( dataProviderManager != null , " " ) ; IVsDataConnection dataConnection = null ; if ( null != dataConnectionManager && null != dataProviderManager ) { dataConnection = DataConnectionUtils . GetDataConnection ( dataConnectionManager , dataProviderManager , designTimeProviderInvariantName , designTimeProviderConnectionString ) ; } if ( null == dataConnection ) { throw new ProgressDialogException ( string . Format ( CultureInfo . CurrentCulture , Design . Resources . RetrievingSprocReturnTypeErrorMessage , " " ) ) ; } try { dataConnection . Open ( ) ; var dataSchemaServer = new DataSchemaServer ( dataConnection ) ; var numFunctionFilterEntries = newFunctionSchemaProcedureMap . Count ; var numFunctionFilterEntryCurrent = 0 ; foreach ( var entry in newFunctionSchemaProcedureMap . Keys . ToList ( ) ) { numFunctionFilterEntryCurrent ++ ; if ( worker != null && e != null && worker . CancellationPending ) { e . Cancel = true ; } else { if ( worker != null && worker . WorkerReportsProgress ) { var percentCompleted = startingAmountOfProgressBar + ( ( int ) ( ( ( numFunctionFilterEntryCurrent - 1 ) / ( float ) numFunctionFilterEntries ) * amountOfProgressBarGiven ) ) ; var userState = new ProgressDialogUserState ( ) ; userState . NumberIterations = numFunctionFilterEntries ; userState . CurrentIteration = numFunctionFilterEntryCurrent ; userState . CurrentStatusMessage = string . Format ( CultureInfo . CurrentCulture , Design . Resources . RetrievingSprocReturnTypeInfoMessage , numFunctionFilterEntryCurrent , numFunctionFilterEntries , entry . Schema , entry . Name ) ; worker . ReportProgress ( percentCompleted , userState ) ; } var schemaProcedure = dataSchemaServer . GetProcedureOrFunction ( entry . Schema , entry . Name ) ; Debug . Assert ( null == newFunctionSchemaProcedureMap [ entry ] , " " + entry . Schema + " " + entry . Name ) ; newFunctionSchemaProcedureMap [ entry ] = schemaProcedure ; } } } finally { if ( null != dataConnection ) { dataConnection . Close ( ) ; } } }
Processes the sproc return type information stored in newFunctionSchemaProceduresMap to
add commands which create matching FunctionImports or delete Functions as necessary
Processes the sproc return type information stored in newFunctionSchemaProceduresMap to add commands which create matching FunctionImports or delete Functions as necessary
// set up database connection // open the database connection and collect info for each Function // now loop over all entries adding return type information // user requested interrupt of this process // report progress so ProgressDialog can update its status // now retrieve and store the return type information
newFunctionSchemaProcedureMap
Dictionary<EntityStoreSchemaFilterEntry, IDataSchemaProcedure>
designTimeProviderInvariantName
string
designTimeProviderConnectionString
string
e
DoWorkEventArgs
worker
BackgroundWorker
startingAmountOfProgressBar
int
amountOfProgressBarGiven
int
artifact
None
newFunctionSchemaProceduresMap
map of all processed EntityStoreSchemaFilterEntry for Functions to
their IDataSchemaProcedure (where data was collected) or null (where data was not collected because the data
collection process was interrupted)
map of all processed EntityStoreSchemaFilterEntry for Functions to their IDataSchemaProcedure ( where data was collected ) or null ( where data was not collected because the data collection process was interrupted )
commands
list of commands to which to add the create or delete commands
list of commands to which to add the create or delete commands
shouldCreateComposableFunctionImports
whether to create FunctionImports for composable Functions
whether to create FunctionImports for composable Functions