}//_updateAccessId() private void _describe(CswNbtResources CswNbtResources, CswSchemaUpdater CswSchemaUpdater, CswConsoleOutput CswConsoleOutput) { List <string> Descriptions = new List <string>(); foreach (CswSchemaUpdateDriver CurrentDriver in CswSchemaUpdater.UpdateDrivers.Values) { string CurrentDescription = CurrentDriver.SchemaVersion.ToString() + ": " + CurrentDriver.Description; if (false == Descriptions.Contains(CurrentDescription)) { Descriptions.Add(CurrentDescription); } } CswConsoleOutput.write(_VersionInfo); if ((null != CswSchemaUpdater) && (string.Empty != CswNbtResources.AccessId)) { CswConsoleOutput.write(_Separator_NuLine + _Separator_NuLine + "Minimum schema version: " + CswSchemaUpdater.MinimumVersion); CswConsoleOutput.write(_Separator_NuLine + "Latest schema version: " + CswSchemaUpdater.LatestVersion); } CswConsoleOutput.write(_Separator_NuLine + _Separator_NuLine + "Script inventory:"); foreach (string CurrentDescription in Descriptions) { CswConsoleOutput.write(_Separator_NuLine + CurrentDescription); } }//_describe
}//_doUpdateOpThreadWrapper() /// <summary> /// CAUTION: in concurrent mode ( -maxconcurrentschemata > 0 ), this method will be multi-threaded /// </summary> /// <param name="CurrentAccessId"></param> /// <param name="CswNbtResources"></param> /// <param name="ResourcesInitHandler"></param> /// <param name="CswConsoleOutput"></param> private bool _doUpdateOp(string CurrentAccessId, CswNbtResources CswNbtResources, CswSchemaUpdater.ResourcesInitHandler ResourcesInitHandler, CswConsoleOutput CswConsoleOutput, bool SuppressRealTimeProgressTics, bool ContinueOnError) { bool ReturnVal = true; // Do the update on the current accessid CswSchemaScriptsProd CswSchemaScripts = null; //if( _UserArgs.ContainsKey( _ArgKey.Mode ) && _ArgVal_Test == _UserArgs[_ArgKey.Mode] ) //{ //// Use test cases //Int32 StartAtTestCase = 0; //if( _UserArgs.ContainsKey( _ArgKey.StartAtTestCase ) ) //{ // StartAtTestCase = CswConvert.ToInt32( _UserArgs[_ArgKey.StartAtTestCase] ); //} //Int32 EndAtTestCase = 0; //if( _UserArgs.ContainsKey( _ArgKey.EndAtTestCase ) ) //{ // EndAtTestCase = CswConvert.ToInt32( _UserArgs[_ArgKey.EndAtTestCase] ); //} //List<string> TestCasesToIgnore = new List<string>(); //if( _UserArgs.ContainsKey( _ArgKey.IgnoreTestCasesCsv ) ) //{ // CswCommaDelimitedString CswCommaDelimitedString = new CswCommaDelimitedString(); // CswCommaDelimitedString.FromString( _UserArgs[_ArgKey.IgnoreTestCasesCsv] ); // TestCasesToIgnore = CswCommaDelimitedString.ToList<string>(); //} //CswSchemaScripts = new CswSchemaScriptsTest( StartAtTestCase, EndAtTestCase, TestCasesToIgnore ); //} //else //{ // Use production scripts CswSchemaScripts = new CswSchemaScriptsProd(CswNbtResources); //} CswSchemaUpdater CswSchemaUpdater = new CswSchemaUpdater(CurrentAccessId, ResourcesInitHandler, CswSchemaScripts); if (false == _UserArgs.ContainsKey(_ArgKey.Describe)) { ReturnVal = _updateAccessId(CurrentAccessId, CswNbtResources, CswSchemaUpdater, CswConsoleOutput, SuppressRealTimeProgressTics, ContinueOnError); } else if (_UserArgs.ContainsKey(_ArgKey.Mode) && _ArgVal_Test == _UserArgs[_ArgKey.Mode]) { CswConsoleOutput.write("Ach. The iteration model for production scripts so woefully different than for test scripts that verily do I say unto the brother, uh, yay: it is easier for a camel to pass through the eye of a needle than is to give an inventory of production test scripts. Of course, since the production test scripts don't deploy the Description property of CswRequestDriver in as a rich a way as do the test scripts, it probably doesn't matter. See case 21739"); } else { _describe(CswNbtResources, CswSchemaUpdater, CswConsoleOutput); } return(ReturnVal); }
}//_runConcurrentSchemaUpdates() private bool _runNonVersionScripts(CswSchemaUpdater CswSchemaUpdater, List <CswSchemaUpdateDriver> ScriptCollection, CswConsoleOutput CswConsoleOutput) { bool ReturnVal = true; for (int idx = 0; ReturnVal && (idx < ScriptCollection.Count); idx++) { CswSchemaUpdateDriver CurrentUpdateDriver = ScriptCollection[idx]; string ScriptDescription = CurrentUpdateDriver.SchemaVersion.ToString() + ": " + CurrentUpdateDriver.Description + ": "; ReturnVal = CswSchemaUpdater.runArbitraryScript(CurrentUpdateDriver); if (ReturnVal) { CswConsoleOutput.write(ScriptDescription + "succeeded" + _Separator_NuLine); } else { CswConsoleOutput.write(ScriptDescription + "failed: " + CurrentUpdateDriver.Message + _Separator_NuLine); } } return(ReturnVal); }//_runNonVersionScripts()
}//_runNonVersionScripts() private bool _updateAccessId(string AccessId, CswNbtResources CswNbtResources, CswSchemaUpdater CswSchemaUpdater, CswConsoleOutput CswConsoleOutput, bool SuppressRealTimeProgressTics, bool ContinueOnError) { CswSchemaUpdateThread CswSchemaUpdateThread = new CswSchemaUpdateThread(CswSchemaUpdater); CswConsoleOutput.write("Running Non-Versioned Pre-Scripts" + _Separator_NuLine + _Separator_NuLine); CswSchemaScriptsProd CswSchemaScriptsProd = new CswSchemaScriptsProd(CswNbtResources); bool UpdateSucceeded = _runNonVersionScripts(CswSchemaUpdater, CswSchemaScriptsProd.RunBeforeScripts, CswConsoleOutput); if (UpdateSucceeded) { CswSchemaVersion CurrentVersion = CswSchemaUpdater.CurrentVersion(CswNbtResources); // refresh current version in case it was altered CswNbtResources.ConfigVbls.refresh(); CurrentVersion = CswSchemaUpdater.CurrentVersion(CswNbtResources); CswConsoleOutput.write("Updating from " + CurrentVersion.ToString() + " to " + CswSchemaUpdater.LatestVersion.ToString() + _Separator_NuLine + _Separator_NuLine); for (int i = 0; ((UpdateSucceeded || ContinueOnError) && ((CurrentVersion != CswSchemaUpdater.LatestVersion) || (i < CswSchemaUpdater.UpdateDrivers.Count))); i++) { if (CurrentVersion < CswSchemaUpdater.MinimumVersion) { UpdateSucceeded = false; CswConsoleOutput.write("AccessId " + AccessId + ": "); CswConsoleOutput.write(" failed: Schema version (" + CurrentVersion.ToString() + ") is below minimum version (" + CswSchemaUpdater.MinimumVersion.ToString() + ")" + _Separator_NuLine); } else { CswSchemaVersion UpdateToVersion = CswSchemaUpdater.SchemaVersions[i]; string UpdateDescription = CswSchemaUpdater.getDriver(UpdateToVersion).SchemaVersion + ": " + CswSchemaUpdater.getDriver(UpdateToVersion).Description; CswSchemaUpdateThread.start(); if (false == SuppressRealTimeProgressTics) { CswConsoleOutput.write(UpdateDescription + ": "); } while (CswEnumSchemaUpdateState.Running == CswSchemaUpdateThread.UpdateState) { if (false == SuppressRealTimeProgressTics) { CswConsoleOutput.write("."); } Thread.Sleep(1000); } UpdateSucceeded = (CswEnumSchemaUpdateState.Succeeded == CswSchemaUpdateThread.UpdateState); if (UpdateSucceeded) { string Message = string.Empty; if (false == SuppressRealTimeProgressTics) { Message = " succeeded" + _Separator_NuLine; } else { Message = UpdateDescription + " succeeded" + _Separator_NuLine; } CswConsoleOutput.write(Message); } else { string Message = string.Empty; if (false == SuppressRealTimeProgressTics) { Message = " failed: " + CswSchemaUpdateThread.Message + _Separator_NuLine; } else { Message = UpdateDescription + " failed: " + CswSchemaUpdateThread.Message + _Separator_NuLine; } CswConsoleOutput.write(Message, ForceWrite: true, SuppressAccessId: false); } CswNbtResources.ClearCache(); CurrentVersion = CswSchemaUpdater.CurrentVersion(CswNbtResources); } } // for() } //if pre-scripts succeded if (UpdateSucceeded) { UpdateSucceeded = _runNonVersionScripts(CswSchemaUpdater, CswSchemaScriptsProd.RunAfterScripts, CswConsoleOutput); } return(UpdateSucceeded); }//_updateAccessId()
private void _doVersionOp(string CurrentAccessId, CswNbtResources CswNbtResources, CswConsoleOutput CswConsoleOutput) { CswSchemaUpdater CswSchemaUpdater = new CswSchemaUpdater(CurrentAccessId, _makeResources, new CswSchemaScriptsProd(CswNbtResources)); CswConsoleOutput.write(CurrentAccessId + ", " + CswSchemaUpdater.CurrentVersion(CswNbtResources)); }
public CswSchemaUpdateThread(CswSchemaUpdater CswSchemaUpdater) { _CswSchemaUpdater = CswSchemaUpdater; }//ctor