コード例 #1
0
        public ScripterResult ScriptObjects(IEnumerable <ScriptObject> objects)
        {
            ScripterResult result = new ScripterResult();

            try
            {
                var context = GetDatabaseContext(false);

                ScriptTables(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Table));
                ScriptViews(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.View));
                ScriptStoredProcedures(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Procedure));
                ScriptFunctions(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Function));
                ScriptSynonyms(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Synonym));
                ScriptUserDefinedTypes(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Type));

                WarnUndefinedObjects(objects.Where(o => o.ObjectType == ObjectTypeEnum.Undefined));
            }
            catch (Exception ex)
            {
                result.Successful = false;
                result.Error      = ex;
            }

            return(result);
        }
コード例 #2
0
        public ScripterResult ScriptAll()
        {
            ScripterResult result = new ScripterResult();

            try
            {
                //When scripting all object, do scripting in parallel so it will go faster.
                //We need a DbServerContext for each scripting task since SMO is not thread safe.

                var tablesScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllTables(context);
                });

                var viewsScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllViews(context);
                });

                var storedProceduresScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllStoredProcedures(context);
                });

                var synonymsScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllSynonyms(context);
                });

                var udtScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserDefinedTypes(context);
                });

                Task.WaitAll(
                    tablesScriptTask,
                    viewsScriptTask,
                    storedProceduresScriptTask,
                    synonymsScriptTask,
                    udtScriptTask
                    );
            }
            catch (Exception ex)
            {
                result.Successful = false;
                result.Error      = ex;
            }

            return(result);
        }
コード例 #3
0
        public ScripterResult ScriptAll()
        {
            ScripterResult result = new ScripterResult();

            try
            {
                //When scripting all object, do scripting in parallel so it will go faster.
                //We need a DbServerContext for each scripting task since SMO is not thread safe.

                var tablesScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllTables(context);
                });

                var viewsScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllViews(context);
                });

                var storedProceduresScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllStoredProcedures(context);
                });

                var functionsScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllFunctions(context);
                });

                var synonymsScriptTask = Task.Run(() =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllSynonyms(context);
                });

                Task.WaitAll(
                    tablesScriptTask,
                    viewsScriptTask,
                    storedProceduresScriptTask,
                    functionsScriptTask
                );
            }
            catch (Exception ex)
            {
                result.Successful = false;
                result.Error = ex;
            }

            return result;
        }
コード例 #4
0
        public ScripterResult ScriptObjects(IEnumerable<ScriptObject> objects)
        {
            ScripterResult result = new ScripterResult();

            try
            {
                var context = GetDatabaseContext(false);

                ScriptTables(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Table));
                ScriptViews(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.View));
                ScriptStoredProcedures(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Procedure));
                ScriptFunctions(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Function));
                ScriptSynonyms(context, objects.Where(o => o.ObjectType == ObjectTypeEnum.Synonym));
            }
            catch (Exception ex)
            {
                result.Successful = false;
                result.Error = ex;
            }

            return result;
        }
コード例 #5
0
        protected ScripterResult ScriptAllModifiedSince(DateTime modifiedSince)
        {
            var result = new ScripterResult();

            try
            {
                // When scripting all object, do scripting in parallel so it will go faster.
                // We need a DbServerContext for each scripting task since SMO is not thread safe.
                var tablesScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserTablesModifiedSince(context, modifiedSince);
                });

                var viewsScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserViewsModifiedSince(context, modifiedSince);
                });

                var storedProceduresScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserStoredProceduresModifiedSince(context, modifiedSince);
                });

                var functionScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserFunctionsModifiedSince(context, modifiedSince);
                });

                var synonymsScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllSynonymsModifiedSince(context, modifiedSince);
                });

                var udtScriptTask = Task.Run(
                    () =>
                {
                    var context = GetDatabaseContext(true);
                    ScriptAllUserDefinedTypesModifiedSince(context, modifiedSince);
                });

                Task.WaitAll(
                    tablesScriptTask,
                    viewsScriptTask,
                    storedProceduresScriptTask,
                    functionScriptTask,
                    synonymsScriptTask,
                    udtScriptTask);
            }
            catch (Exception ex)
            {
                result.Successful = false;
                result.Error      = ex;
            }

            return(result);
        }