/// <summary> /// Removes all rows flagged isdemo=1 /// </summary> public void RemoveDemoData() { if ("1" == _CswNbtResources.ConfigVbls.getConfigVariableValue("is_demo")) { String AllDemoTablesSQL = " select distinct tablename from data_dictionary where columnname='isdemo' and tablename <> 'nodes' and tablename <> 'statistics' order by tablename "; CswArbitrarySelect AllDemoTables = _CswNbtResources.makeCswArbitrarySelect("Fetch Tables With Demo Data", AllDemoTablesSQL); DataTable DemosDataTable = AllDemoTables.getTable(); CswCommaDelimitedString TablesToPrune = new CswCommaDelimitedString(); for (Int32 i = 0; i < DemosDataTable.Rows.Count; i++) { TablesToPrune.Add(DemosDataTable.Rows[i]["tablename"].ToString()); } TablesToPrune.Sort(); //As of 01H-17, executing this in alphabetical order (minus nodes/statistics) will work foreach (String TableName in TablesToPrune) { String NukeDemoDataSQL = "delete from " + TableName + " where isdemo = '" + CswConvert.ToDbVal(true) + "'"; try { _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql(NukeDemoDataSQL); _CswNbtSchemaModTrnsctn.commitTransaction(); } catch (Exception ex) { throw new CswDniException(CswEnumErrorType.Error, "Before records from the " + TableName + " table can be deleted, child records must be deleted first.", "Oracle threw an " + ex + " exception."); } } // We just happen to know that these are the only 2 tables which have constraints and need to be dealt with separately try { _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql("delete from nodes where isdemo= '" + CswConvert.ToDbVal(true) + "'"); _CswNbtSchemaModTrnsctn.commitTransaction(); _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql("delete from statistics where isdemo= '" + CswConvert.ToDbVal(true) + "'"); _CswNbtSchemaModTrnsctn.commitTransaction(); } catch (Exception ex) { throw new CswDniException(CswEnumErrorType.Error, "Before records from the nodes/statistics table(s) can be deleted, child records must be deleted first.", "Oracle threw an " + ex + " exception."); } _CswNbtResources.ConfigVbls.setConfigVariableValue("is_demo", "0"); }//if( "1" == _CswNbtResources.ConfigVbls.getConfigVariableValue( "is_demo" ) ) }
public void update() { try { _CswNbtSchemaModTrnsctn.refreshDataDictionary(); _CswNbtSchemaModTrnsctn.beginTransaction(); _CswUpdateSchemaTo.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn; _CswUpdateSchemaTo.update(); _CswUpdateSchemaTo.CswNbtSchemaModTrnsctn = null; _CswNbtSchemaModTrnsctn.commitTransaction(); } catch (CswDniExceptionIgnoreDeliberately) { _UpdateSucceeded = true; try { _CswNbtSchemaModTrnsctn.rollbackTransaction(); } catch (Exception CommitException) { _RollbackSucceeded = false; _Message += "Rollback failed: " + CommitException.Message + " at " + CommitException.StackTrace.ToString() + ". \r\n"; } // } //catch catch (Exception Exception) { _Message += "Script for case " + _CswUpdateSchemaTo.getCaseLink() + " authored by " + _CswUpdateSchemaTo.Author + " failed. \r\n"; _Message += Exception.Message + " at: " + Exception.StackTrace.ToString() + ". \r\n"; _UpdateSucceeded = false; try { _CswNbtSchemaModTrnsctn.rollbackTransaction(); } catch (Exception CommitException) { _RollbackSucceeded = false; _Message += "Rollback failed: " + CommitException.Message + " at " + CommitException.StackTrace.ToString() + ". \r\n"; } // } // } //beginUpdate()