Ejemplo n.º 1
0
 public CswSchemaVersion TargetVersion( CswNbtResources CswNbtResources )
 {
     CswSchemaVersion ret = null;
     CswSchemaVersion myCurrentVersion = CurrentVersion( CswNbtResources );
     if( myCurrentVersion == MinimumVersion )
         ret = new CswSchemaVersion( LatestVersion.CycleIteration, LatestVersion.ReleaseIdentifier, 1 );
     else
         ret = new CswSchemaVersion( myCurrentVersion.CycleIteration, myCurrentVersion.ReleaseIdentifier, myCurrentVersion.ReleaseIteration + 1 );
     return ret;
 }
Ejemplo n.º 2
0
        }//Next()

        public CswSchemaUpdateDriver this[CswSchemaVersion CswSchemaVersion]
        {
            get
            {
                CswSchemaUpdateDriver ReturnVal = null;

                if( _UpdateDrivers.ContainsKey( CswSchemaVersion ) )
                {
                    ReturnVal = _UpdateDrivers[CswSchemaVersion];
                }

                return ( ReturnVal );
            }
        }
Ejemplo n.º 3
0
        public void GetAccessIdInfo(string AccessId)
        {
            try
            {
                SetStatus("Initializing Selected Schema");

                CswNbtResources CswNbtResources = null;
                _InitSessionResources(AccessId, ref CswNbtResources);

                SchemaInfoEventArgs e = new SchemaInfoEventArgs();

                // Initialize CswSchemaScriptsProd -- we must do this here so that database resources are also initialized
                _CswSchemaScriptsProd = new CswSchemaScriptsProd(_CswNbtResources);

                _CswSchemaUpdater      = new CswSchemaUpdater(AccessId, new CswSchemaUpdater.ResourcesInitHandler(_InitSessionResources), _CswSchemaScriptsProd);
                e.MinimumSchemaVersion = _CswSchemaUpdater.MinimumVersion;
                e.LatestSchemaVersion  = _CswSchemaUpdater.LatestVersion;

                CswSchemaVersion CurrentVersion = new CswSchemaVersion(CswNbtResources.ConfigVbls.getConfigVariableValue("schemaversion").ToString());
                e.CurrentSchemaVersion = CurrentVersion;

                CswTableSelect UpdateHistorySelect = CswNbtResources.makeCswTableSelect("SchemaUpdater_updatehistory_select", "update_history");
                DataTable      UpdateHistoryTable  = UpdateHistorySelect.getTable(string.Empty, new Collection <OrderByClause> {
                    new OrderByClause("updatehistoryid", CswEnumOrderByType.Descending)
                });
                e.UpdateHistoryTable = UpdateHistoryTable;

                if (OnGetSchemaInfo != null)
                {
                    OnGetSchemaInfo(e);
                }

                _CloseSessionResources(CswNbtResources);

                SetStatus("Initializing Selected Schema: Done");
            }
            catch (Exception ex)
            {
                SetStatus("ERROR: " + ex.Message);
            }
        }
Ejemplo n.º 4
0
        }//_updateHistoryTable()

        public void DoUpdate(string AccessId)
        {
            try
            {
                SetStatus("Updating Selected Schema");

                CswNbtResources CswNbtResources = null;
                _InitSessionResources(AccessId, ref CswNbtResources);
                SchemaInfoEventArgs SchemaInfoEventArgs = new SchemaInfoEventArgs();


                _CswSchemaUpdater = new CswSchemaUpdater(AccessId, new CswSchemaUpdater.ResourcesInitHandler(_InitSessionResources), _CswSchemaScriptsProd);     //wait to create updater until resource initiation is thoroughly done

                // RunBeforeScripts -- Run Non Versioned Scripts
                bool UpdateSucceeded = _runNonVersionScripts(_CswSchemaScriptsProd.RunBeforeScripts, CswNbtResources, SchemaInfoEventArgs);

                if (UpdateSucceeded)
                {
                    CswSchemaVersion CurrentVersion = _CswSchemaUpdater.CurrentVersion(CswNbtResources);

                    for (int i = 0; (UpdateSucceeded && !Cancel &&
                                     ((CurrentVersion != _CswSchemaUpdater.LatestVersion) || (i < _CswSchemaUpdater.UpdateDrivers.Count))); i++)
                    {
                        CswSchemaVersion UpdateToVersion = _CswSchemaUpdater.SchemaVersions[i];
                        SetStatus("Updating to " + UpdateToVersion);

                        UpdateSucceeded = _CswSchemaUpdater.runNextVersionedScript();

                        CswNbtResources.AccessId = AccessId; //cases 23787,9751: you have to re-init after the release() that is done in the Updater
                        CswNbtResources.ClearCache();

                        SchemaInfoEventArgs.MinimumSchemaVersion = _CswSchemaUpdater.MinimumVersion;
                        SchemaInfoEventArgs.LatestSchemaVersion  = _CswSchemaUpdater.LatestVersion;

                        CurrentVersion = _CswSchemaUpdater.CurrentVersion(CswNbtResources);
                        SchemaInfoEventArgs.CurrentSchemaVersion = CurrentVersion;

                        _updateHistoryTable(CswNbtResources, SchemaInfoEventArgs);

                        if (UpdateSucceeded)
                        {
                            SetStatus("Update successful: " + _CswSchemaUpdater.getDriver(UpdateToVersion).SchemaVersion + ": " + _CswSchemaUpdater.getDriver(UpdateToVersion).Description);
                        }
                    } //iterate
                }     //if pre-process scripts succeded

                if (UpdateSucceeded)
                {
                    UpdateSucceeded = _runNonVersionScripts(_CswSchemaScriptsProd.RunAfterScripts, CswNbtResources, SchemaInfoEventArgs);
                }

                if (Cancel)
                {
                    SetStatus("Update process stopped");
                }
                else if (!UpdateSucceeded)
                {
                    if (OnUpdateFailed != null)
                    {
                        OnUpdateFailed();
                    }
                    SetStatus("Update failed");
                }
                else
                {
                    SetStatus("Update process completed");
                }

                _CloseSessionResources(CswNbtResources);
            }
            catch (Exception ex)
            {
                SetStatus("ERROR: " + ex.Message);
            }
        }//iterate versions
Ejemplo n.º 5
0
 //public override CswSchemaVersion SchemaVersion { get { return ( _CswSchemaVersion ); } }
 public CswTestCase_014_02(CswSchemaVersion CswSchemaVersion, object CswTstCaseRsc)
 {
     _CswSchemaVersion   = CswSchemaVersion;
     _CswTstCaseRsrc_014 = (CswTstCaseRsrc_014)CswTstCaseRsc;
 }        //ctor
Ejemplo n.º 6
0
        public CswSchemaScriptsProd( CswNbtResources CswNbtResources )
        {
            _CswNbtResources = CswNbtResources;

            // This is where you manually set to the last version of the previous release (the one currently in production)
            _MinimumVersion = new CswSchemaVersion( 2, 'L', 42 );

            // Set the global variable values
            CurrentReleaseIdentifier = _getNextReleaseIdentifier();
            CurrentReleaseIteration = _getNextSuperCycle( CurrentReleaseIdentifier );

            #region Populate Scripts

            Collection<ICswSchemaScripts> AllScripts = new Collection<ICswSchemaScripts>()
                {
                    new CswSchemaScriptsMagnolia()
                };

            // DDL
            foreach( ICswSchemaScripts ScriptColl in AllScripts )
            {
                foreach( CswUpdateSchemaTo Script in ScriptColl._DDLScripts() )
                {
                    _addVersionedScript( Script );
                }
            }
            // MetaData
            foreach( ICswSchemaScripts ScriptColl in AllScripts )
            {
                foreach( CswUpdateSchemaTo Script in ScriptColl._MetaDataScripts() )
                {
                    _addVersionedScript( Script );
                }
            }

            // This is the MakeMissingNodeTypeProps script. If you have a script which contains OC changes, put it before this script.
            _addVersionedScript( new RunAlways_MakeMissingNodeTypePropsProps() );

            // Schema
            foreach( ICswSchemaScripts ScriptColl in AllScripts )
            {
                foreach( CswUpdateSchemaTo Script in ScriptColl._SchemaScripts() )
                {
                    _addVersionedScript( Script );
                }
            }

            #endregion Populate Scripts

            #region Calculate the Latest Version

            _setLatestVersion( CswNbtResources );

            #endregion Calculate the Latest Version

            #region Before Scripts
            // Before scripts that always run.
            _addRunBeforeScript( new RunBeforeEveryExecutionOfUpdater_02SQL() );
            #endregion Before Scripts

            #region After Script
            // After scripts that always run.
            _addRunAfterScript( new RunAfterEveryExecutionOfUpdater_01() );
            _addRunAfterScript( new RunAfterEveryExecutionOfUpdater_02AuditSql() );
            _addRunAfterScript( new RunAfterEveryExecutionOfUpdater_DBViews() );
            #endregion After Script

        }//ctor
Ejemplo n.º 7
0
 public CswSchemaUpdateDriver getDriver(CswSchemaVersion CswSchemaVersion)
 {
     return(_CswSchemaScripts[CswSchemaVersion]);
 }//getDriver()
Ejemplo n.º 8
0
 //public override CswSchemaVersion SchemaVersion { get { return ( _CswSchemaVersion ); } }
 public CswTestCase_010_01(CswSchemaVersion CswSchemaVersion, object CswTstCaseRsc)
 {
     _CswSchemaVersion   = CswSchemaVersion;
     _CswTstCaseRsrc_010 = (CswTstCaseRsrc_010)CswTstCaseRsc;
 }//ctor