Esempio n. 1
0
        public void Reload(ProjectConfigItem projectConfig)
        {
            projectConfig.ThrowIfNull(nameof(projectConfig));

            using (ArtifactExtractor _currentArtifactExtractor = _artifactExtractorFactory.Create(projectConfig))
            {
                using (var dbCommands = _dbCommandsFactory.CreateDBCommand(projectConfig.DBConnectionInfo))
                {
                    IncrementalScriptFilesComparer = _scriptFilesComparerFactory.CreateScriptFilesComparer <IncrementalScriptFileType>(dbCommands, projectConfig.IncrementalScriptsFolderPath);
                    ScriptFilesComparers[IncrementalScriptFilesComparer.ScriptFileType.FileTypeCode] = IncrementalScriptFilesComparer;

                    RepeatableScriptFilesComparer = _scriptFilesComparerFactory.CreateScriptFilesComparer <RepeatableScriptFileType>(dbCommands, projectConfig.RepeatableScriptsFolderPath);
                    ScriptFilesComparers[RepeatableScriptFilesComparer.ScriptFileType.FileTypeCode] = RepeatableScriptFilesComparer;

                    if (projectConfig.DevEnvironment)
                    {
                        DevDummyDataScriptFilesComparer = _scriptFilesComparerFactory.CreateScriptFilesComparer <DevDummyDataScriptFileType>(dbCommands, projectConfig.DevDummyDataScriptsFolderPath);
                        ScriptFilesComparers[DevDummyDataScriptFilesComparer.ScriptFileType.FileTypeCode] = DevDummyDataScriptFilesComparer;
                    }
                    else
                    {
                        DevDummyDataScriptFilesComparer = null;
                    }
                }
            }
        }
Esempio n. 2
0
        public override void Execute(DBVersionsProcessContext processContext)
        {
            processContext.ThrowIfNull(nameof(processContext));


            using (ArtifactExtractor _currentArtifactExtractor = _artifactExtractorFactory.Create(processContext.ProjectConfig))
            {
                List <ActionStepBase> internalSteps = new List <ActionStepBase>();

                using (var dbCommands = _dbCommandsFactory.CreateDBCommand(processContext.ProjectConfig.DBConnectionInfo))
                {
                    ScriptFileTypeBase       incrementalFileType = ScriptFileTypeBase.Create <IncrementalScriptFileType>();
                    ExecuteScriptsByTypeStep incrementalExecuteScriptsByTypeStep = _executeScriptsByTypeStepFactory.Create(incrementalFileType.FileTypeCode, dbCommands);
                    internalSteps.Add(incrementalExecuteScriptsByTypeStep);


                    string lastIncStriptFilename = GetLastIncFilename(processContext);

                    TargetScripts targetScripts = null;
                    if (processContext.ProcessArgs != null)
                    {
                        targetScripts = (processContext.ProcessArgs as DBVersionsProcessArgs).TargetScripts;
                    }

                    //Comment: We run the repeatable files and ddd files, onlyif we have all the schema on the DB. mean, only if we executed all incremiental files.
                    if (targetScripts.IncScriptFileName.Trim().ToUpperInvariant() == lastIncStriptFilename.Trim().ToUpperInvariant() ||
                        targetScripts.IncScriptFileName.Trim().ToUpperInvariant() == RuntimeScriptFile.TargetLastScriptFileName.Trim().ToUpperInvariant())
                    {
                        ScriptFileTypeBase       repeatableFileType = ScriptFileTypeBase.Create <RepeatableScriptFileType>();
                        ExecuteScriptsByTypeStep repeatableFileTypeExecuteScriptsByTypeStep = _executeScriptsByTypeStepFactory.Create(repeatableFileType.FileTypeCode, dbCommands);
                        internalSteps.Add(repeatableFileTypeExecuteScriptsByTypeStep);


                        if (processContext.ScriptFilesState.DevDummyDataScriptFilesComparer != null)
                        {
                            ScriptFileTypeBase       devDummyDataFileType = ScriptFileTypeBase.Create <DevDummyDataScriptFileType>();
                            ExecuteScriptsByTypeStep devDummyDataFileTypeExecuteScriptsByTypeStep = _executeScriptsByTypeStepFactory.Create(devDummyDataFileType.FileTypeCode, dbCommands);
                            internalSteps.Add(devDummyDataFileTypeExecuteScriptsByTypeStep);
                        }
                    }


                    ExecuteInternalSteps(internalSteps, false);
                }
            }
        }