} // saveSessionData(Search) /// <summary> /// Save a view to the session data collection. Sets the SessionViewId on the view. /// </summary> public CswNbtSessionDataId saveSessionData( CswNbtView View, bool IncludeInQuickLaunch, bool KeepInQuickLaunch = false, bool UpdateCache = false ) { CswTableUpdate SessionViewsUpdate = _CswNbtResources.makeCswTableUpdate( "saveSessionView_update", SessionDataTableName ); DataTable SessionViewTable; if( View.SessionViewId != null && View.SessionViewId.isSet() ) //Get existing session view by SessionViewId SessionViewTable = SessionViewsUpdate.getTable( SessionDataColumn_PrimaryKey, View.SessionViewId.get(), "where sessionid = '" + SessionId + "'", false ); else if( View.ViewId != null && View.ViewId.isSet() ) //Get existing session view by ViewId SessionViewTable = SessionViewsUpdate.getTable( SessionDataColumn_ViewId, View.ViewId.get(), "where sessionid = '" + SessionId + "'", false ); else //Save new Session View SessionViewTable = SessionViewsUpdate.getEmptyTable(); if( SessionViewTable.Rows.Count == 0 ) { UpdateCache = true; } DataRow SessionViewRow = _getSessionViewRow( SessionViewTable, View.ViewName, CswEnumNbtSessionDataType.View, IncludeInQuickLaunch, KeepInQuickLaunch ); if( UpdateCache && false == ( _CswNbtResources.CurrentNbtUser is CswNbtSystemUser ) )//Overwrite { SessionViewRow[SessionDataColumn_ViewId] = CswConvert.ToDbVal( View.ViewId.get() ); SessionViewRow[SessionDataColumn_ViewMode] = View.ViewMode.ToString(); SessionViewRow[SessionDataColumn_ViewXml] = View.ToString(); SessionViewsUpdate.update( SessionViewTable ); } return new CswNbtSessionDataId( CswConvert.ToInt32( SessionViewRow[SessionDataColumn_PrimaryKey] ) ); } // saveSessionData(View)
public void testAddColumnValues(TestTableNamesReal TestTableName, TestColumnNamesFake TestColumnName) { Int32 TotalUpdated = 0; CswTableUpdate TestTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("testAddColumnValues_update", _TestTableNamesReal[TestTableName]); DataTable TestTable = TestTableUpdate.getTable(); foreach (DataRow CurrentRow in TestTable.Rows) { CurrentRow[_TestColumnNamesFake[TestColumnName]] = "Test val " + TestTable.Rows.IndexOf(CurrentRow).ToString(); TotalUpdated++; } TestTableUpdate.update(TestTable); Int32 TotalUpdatedInfact = 0; TestTable = TestTableUpdate.getTable(); foreach (DataRow CurrentRow in TestTable.Rows) { if ((getTestNameStem(TestNameStem.TestVal) + TestTable.Rows.IndexOf(CurrentRow)) == CurrentRow[_TestColumnNamesFake[TestColumnName]].ToString()) { TotalUpdatedInfact++; } } if (TotalUpdatedInfact != TotalUpdated) { throw (new CswDniException("Error adding column " + _TestColumnNamesFake[TestColumnName] + ": updated " + TotalUpdated.ToString() + " rows but retrieved " + TotalUpdatedInfact.ToString() + " with that value")); } }//_testAddColumnValues()
public Collection <ICswNbtMetaDataObject> getAll() { if (_All == null) { string WhereClause = string.Empty; addModuleWhereClause(ref WhereClause); DataTable Table = _TableUpdate.getTable(WhereClause); _All = _makeObjs(Table); } return(_All); } // getAll()
// Set value of filtersubfield, filtermode, and filtervalue from filter private void setNewFilterColumns( string TableName, Func<Int32, ICswNbtMetaDataProp> getProp ) { CswTableUpdate FilterUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31517_filter_update", TableName ); DataTable FilterTable = FilterUpdate.getTable( "where filter is not null" ); foreach( DataRow FilterRow in FilterTable.Rows ) { // adapted from CswNbtMetaDataNodeTypeProp.getFilter() if( FilterRow["filter"].ToString() != string.Empty ) { string[] filter = FilterRow["filter"].ToString().Split( FilterDelimiter ); ICswNbtMetaDataProp FilterProp = getProp( CswConvert.ToInt32( FilterRow["filterpropid"] ) ); if( FilterProp != null ) { CswNbtSubField SubField = FilterProp.getFieldTypeRule().SubFields[(CswEnumNbtPropColumn) filter[0]]; string FilterValue = string.Empty; if( filter.GetUpperBound( 0 ) > 1 ) { FilterValue = filter[2]; } if( null != SubField ) { FilterRow["filtersubfield"] = SubField.Name.ToString(); FilterRow["filtermode"] = (CswEnumNbtFilterMode) filter[1].ToString(); FilterRow["filtervalue"] = FilterValue; } } } } FilterUpdate.update( FilterTable ); } // update()
public override void update() { //Get all views with a category of "Lab Safety" and add '(demo)' to 'viewname' and 'category' CswTableSelect nodeViewsTS = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "select_by_category_26772", "node_views" ); DataTable nodeViews = nodeViewsTS.getTable( "where category = 'Lab Safety'" ); foreach( DataRow row in nodeViews.Rows ) { CswNbtView curView = _CswNbtSchemaModTrnsctn.restoreView( row["viewname"].ToString() ); if( null != curView ) //paranoid { curView.ViewName += " (demo)"; curView.Category += " (demo)"; curView.save(); } } //get all nodetypes with a category of 'Labe Safety' and add '(demo)' to 'category' and 'nodetypename' CswTableUpdate nodetypeTU = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "select_nt_category_26772", "nodetypes" ); DataTable nodeTypes = nodetypeTU.getTable( "where category = 'Lab Safety'" ); foreach( DataRow row in nodeTypes.Rows ) { row["nodetypename"] += " (demo)"; row["category"] += " (demo)"; } nodetypeTU.update( nodeTypes ); }//Update()
private static void _updateScheduledRulesTable(CswNbtResources NbtResources, IEnumerable <CswScheduleLogicDetail> ScheduledRules) { foreach (CswScheduleLogicDetail ScheduledRule in ScheduledRules) { CswTableUpdate RulesUpdate = NbtResources.makeCswTableUpdate("Scheduledrules_update_on_accessid_" + NbtResources.AccessId + "_for_" + ScheduledRule.RuleName, "scheduledrules"); DataTable RulesTable = RulesUpdate.getTable("where rulename = '" + ScheduledRule.RuleName + "'"); if (RulesTable.Rows.Count == 1) { DataRow ThisRule = RulesTable.Rows[0]; ThisRule["recurrence"] = ScheduledRule.Recurrence; ThisRule["interval"] = ScheduledRule.Interval; ThisRule["reprobatethreshold"] = ScheduledRule.ReprobateThreshold; ThisRule["reprobate"] = CswConvert.ToDbVal(ScheduledRule.Reprobate); ThisRule["maxruntimems"] = ScheduledRule.MaxRunTimeMs; ThisRule["totalroguecount"] = ScheduledRule.TotalRogueCount; ThisRule["failedcount"] = ScheduledRule.FailedCount; ThisRule["statusmessage"] = ScheduledRule.StatusMessage; ThisRule["priority"] = ScheduledRule.Priority; ThisRule["disabled"] = CswConvert.ToDbVal(ScheduledRule.Disabled); ThisRule["runstarttime"] = ScheduledRule.RunStartTime == DateTime.MinValue ? (object)DBNull.Value : ScheduledRule.RunStartTime; ThisRule["runendtime"] = ScheduledRule.RunEndTime == DateTime.MinValue ? (object)DBNull.Value : ScheduledRule.RunEndTime; ThisRule["lastrun"] = ScheduledRule.LastRun == DateTime.MinValue ? (object)DBNull.Value : ScheduledRule.LastRun; ThisRule["nextrun"] = ScheduledRule.NextRun == DateTime.MinValue ? (object)DBNull.Value : ScheduledRule.NextRun; ThisRule["threadid"] = ScheduledRule.ThreadId; ThisRule["loadcount"] = ScheduledRule.LoadCount; ThisRule["lastloadcheck"] = ScheduledRule.LastLoadCheck == DateTime.MinValue ? (object)DBNull.Value : ScheduledRule.LastLoadCheck; RulesUpdate.update(RulesTable); } else { NbtResources.CswLogger.reportAppState("Scheduled Rule " + ScheduledRule.RuleName + " does not exist in the database."); } } }
public override void update() { CswAuditMetaData CswAuditMetaData = new CswAuditMetaData(); foreach( CswNbtMetaDataNodeType CurrentNodeType in _CswNbtSchemaModTrnsctn.MetaData.getNodeTypes() ) { if( AuditLevel.NoAudit != CurrentNodeType.AuditLevel ) { string CurrentAuditLevel = CurrentNodeType.AuditLevel.ToString(); string Where = " where nodetypeid= " + CurrentNodeType.NodeTypeId.ToString() + " and " + CswAuditMetaData.AuditLevelColName + " <> '" + CurrentAuditLevel + "' "; CswTableUpdate CurrentNodesUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "update_nodes_case_27709", "nodes" ); DataTable NodesTable = CurrentNodesUpdate.getTable( Where ); foreach( DataRow CurrentRow in NodesTable.Rows ) { CurrentRow[CswAuditMetaData.AuditLevelColName] = CurrentAuditLevel; } CurrentNodesUpdate.update( NodesTable ); } } }//Update()
public override void update() { // Fix any remnants of the old Design Mode (Design.aspx) CswTableUpdate ActionUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31509_Action_Update", "actions" ); DataTable ActionTable = ActionUpdate.getTable( "where actionname = '" + CswEnumNbtActionName.Design + "'" ); if( ActionTable.Rows.Count > 0 ) { DataRow ActionRow = ActionTable.Rows[0]; // Fix the action row ActionRow["showinlist"] = CswConvert.ToDbVal( false ); ActionRow["url"] = DBNull.Value; ActionUpdate.update( ActionTable ); // Remove button from landing pages Int32 DesignActionId = CswConvert.ToInt32( ActionRow["actionid"] ); if( DesignActionId != Int32.MinValue ) { CswTableUpdate LandingPageUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31509_LandingPage_update", "landingpage" ); DataTable LandingPageTable = LandingPageUpdate.getTable( "to_actionid", DesignActionId ); foreach( DataRow LandingPageRow in LandingPageTable.Rows ) { LandingPageRow.Delete(); } LandingPageUpdate.update( LandingPageTable ); } } // if( ActionTable.Rows.Count > 0 ) } // update()
private void _updateGHSNodes( string Word, CswNbtNode Related, CswCommaDelimitedString NodeIds, CswNbtMetaDataObjectClass GHSOC ) { if( NodeIds.Count > 0 ) { Collection<int> NodesToUpdate = new Collection<int>(); string sql = "where nodeid in (" + NodeIds + ") and field1 = '" + Word + "'"; CswTableUpdate PropUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "UpdateSignalWordPropsWarning", "jct_nodes_props" ); DataTable PropsTbl = PropUpdate.getTable( sql ); foreach( DataRow row in PropsTbl.Rows ) { NodesToUpdate.Add( CswConvert.ToInt32( row["nodeid"] ) ); row["gestaltsearch"] = ""; row["gestalt"] = ""; row["field1"] = ""; row["field2"] = ""; } PropUpdate.update( PropsTbl ); //Now update the nodes to have the REAL value for the signal word prop foreach( CswNbtObjClassGHS GHSNode in GHSOC.getNodes( false, true, false, true ).Where( Node => NodesToUpdate.Contains( Node.NodeId.PrimaryKey ) ) ) { GHSNode.SignalWord.RelatedNodeId = Related.NodeId; GHSNode.postChanges( false ); } } }
public override void update() { CswTableUpdate CswTableUpdateAction = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "update_for_" + CaseNo.ToString(), "actions" ); DataTable ActionsTable = CswTableUpdateAction.getTable( "where actionname='Assign Inventory Groups'" ); if( 1 == ActionsTable.Rows.Count ) { ActionsTable.Rows[0]["actionname"] = "Manage Locations"; CswTableUpdateAction.update( ActionsTable ); } CswNbtMetaDataObjectClass CswNbtMetaDataObjClassLocation = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.LocationClass ); if( null != CswNbtMetaDataObjClassLocation ) { foreach( CswNbtMetaDataNodeType CurrentLocationNodeType in CswNbtMetaDataObjClassLocation.getNodeTypes() ) { _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswEnumNbtLayoutType.Preview, CurrentLocationNodeType.NodeTypeId, CurrentLocationNodeType.getNodeTypeProp( CswNbtObjClassLocation.PropertyName.AllowInventory ), false ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswEnumNbtLayoutType.Preview, CurrentLocationNodeType.NodeTypeId, CurrentLocationNodeType.getNodeTypeProp( CswNbtObjClassLocation.PropertyName.InventoryGroup ), false ); _CswNbtSchemaModTrnsctn.MetaData.NodeTypeLayout.updatePropLayout( CswEnumNbtLayoutType.Preview, CurrentLocationNodeType.NodeTypeId, CurrentLocationNodeType.getNodeTypeProp( CswNbtObjClassLocation.PropertyName.ControlZone ), false ); } } //_CswNbtSchemaModTrnsctn } // update()
public override void update() { CswNbtMetaDataObjectClass BatchOpOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.BatchOpClass ); CswNbtMetaDataObjectClassProp BatchOpOpNameOCP = BatchOpOC.getObjectClassProp( CswNbtObjClassBatchOp.PropertyName.OpName ); CswNbtMetaDataFieldType TextFieldType = _CswNbtSchemaModTrnsctn.MetaData.getFieldType( CswEnumNbtFieldType.Text ); // Update object_class_props CswTableUpdate ObjectClassPropsTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "object_class_props_tbl_update_case_30263", "object_class_props" ); DataTable OCPDataTable = ObjectClassPropsTableUpdate.getTable( "where objectclassid = " + BatchOpOC.ObjectClassId + " and propname = '" + BatchOpOpNameOCP.PropName + "'" ); if( OCPDataTable.Rows.Count > 0 ) { OCPDataTable.Rows[0]["fieldtypeid"] = TextFieldType.FieldTypeId; } ObjectClassPropsTableUpdate.update( OCPDataTable ); //Update nodetype_props foreach( CswNbtMetaDataNodeType BatchOpNT in BatchOpOC.getNodeTypes() ) { CswTableUpdate NodetypePropsTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "nodetype_props_tbl_update_case_30263", "nodetype_props" ); DataTable NTPDataTable = NodetypePropsTableUpdate.getTable( "where nodetypeid = " + BatchOpNT.NodeTypeId + " and objectclasspropid = '" + BatchOpOpNameOCP.PropId + "'" ); if( NTPDataTable.Rows.Count > 0 ) { NTPDataTable.Rows[0]["fieldtypeid"] = TextFieldType.FieldTypeId; } NodetypePropsTableUpdate.update( NTPDataTable ); } } // update()
public override void update() { string SQL = @"select jctnodepropid from (select j1.nodeid, j1.nodetypepropid, max(j1.jctnodepropid) jctnodepropid from jct_nodes_props j1 join jct_nodes_props j2 on (j1.nodetypepropid = j2.nodetypepropid and j1.nodeid = j2.nodeid and j1.jctnodepropid <> j2.jctnodepropid) group by j1.nodeid, j1.nodetypepropid)"; CswArbitrarySelect DupeSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "29797_select", SQL ); DataTable DupeTable = DupeSelect.getTable(); if( DupeTable.Rows.Count > 0 ) { CswCommaDelimitedString JctIds = new CswCommaDelimitedString(); foreach( DataRow DupeRow in DupeTable.Rows ) { JctIds.Add( DupeRow["jctnodepropid"].ToString() ); } CswTableUpdate JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "29797_update", "jct_nodes_props" ); DataTable JctTable = JctUpdate.getTable( "where jctnodepropid in (" + JctIds.ToString() + ")" ); foreach( DataRow JctRow in JctTable.Rows ) { JctRow.Delete(); } JctUpdate.update( JctTable ); } } // update()
public override void update() { // Reassign nodetype and object class icons Dictionary<Int32, string> OCImageDict = new Dictionary<int, string>(); CswTableUpdate OCUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "27493_oc_update", "object_class" ); DataTable OCTable = OCUpdate.getTable(); foreach( DataRow OCRow in OCTable.Rows ) { string NewImage = _getNewImageOC( OCRow["objectclass"].ToString() ); OCRow["iconfilename"] = NewImage; OCImageDict[CswConvert.ToInt32( OCRow["objectclassid"] )] = NewImage; } OCUpdate.update( OCTable ); CswTableUpdate NTUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "27493_nt_update", "nodetypes" ); DataTable NTTable = NTUpdate.getTable(); foreach( DataRow NTRow in NTTable.Rows ) { string NodeTypeName = NTRow["nodetypename"].ToString(); // NodeType special cases string NewImage = _getNewImageNT( NodeTypeName ); if( NewImage == string.Empty ) { NewImage = OCImageDict[CswConvert.ToInt32( NTRow["objectclassid"] )]; } NTRow["iconfilename"] = NewImage; } NTUpdate.update( NTTable ); } //Update()
public void ClearBlob() { //Clear Blobs from Blob_data CswTableUpdate blobDataTU = _CswNbtResources.makeCswTableUpdate("clearBlob", "blob_data"); DataTable blobDataTbl = blobDataTU.getTable("where jctnodepropid = " + JctNodePropId); foreach (DataRow Row in blobDataTbl.Rows) { if (false == Row.IsNull("blobdata")) { //WasModified = true; //WasModifiedForNotification = true; setSubFieldModified(CswEnumNbtSubFieldName.Blob); } Row.Delete(); } blobDataTU.update(blobDataTbl); //Clear blobs from mol_data CswTableUpdate molDataTU = _CswNbtResources.makeCswTableUpdate("clearBlobMol", "mol_data"); DataTable molDataTbl = molDataTU.getTable("where jctnodepropid = " + JctNodePropId); foreach (DataRow Row in molDataTbl.Rows) { Row.Delete(); } molDataTU.update(molDataTbl); }
public override void update() { CswNbtMetaDataObjectClass MaterialOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass ); NonChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.NonChemicalClass ); CswNbtMetaDataNodeType SupplyNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Supply" ); CswNbtMetaDataNodeType BiologicalNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Biological" ); Int32 SupplyId = 0, BiologicalId = 0; if( null != SupplyNT ) { SupplyId = SupplyNT.NodeTypeId; } if( null != BiologicalNT ) { BiologicalId = BiologicalNT.NodeTypeId; } //Change Supply and Biological's OC to NonChemical CswTableUpdate NTUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28690_nt_update", "nodetypes" ); DataTable NTTable = NTUpdate.getTable( "where objectclassid = " + MaterialOC.ObjectClassId ); foreach( DataRow NTRow in NTTable.Rows ) { if( NTRow["nodetypeid"].ToString() == SupplyId.ToString() || NTRow["nodetypeid"].ToString() == BiologicalId.ToString() ) { NTRow["objectclassid"] = NonChemicalOC.ObjectClassId; } } NTUpdate.update( NTTable ); _CswNbtSchemaModTrnsctn.MetaData.makeMissingNodeTypeProps(); } // update()
} //ctor public override void update() { _CswTstCaseRsrc = new CswTestCaseRsrc(_CswNbtSchemaModTrnsctn); _CswTstCaseRsrc_014.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn; CswTableSelect CswTableSelectNodeTypes = _CswNbtSchemaModTrnsctn.makeCswTableSelect(Description, "nodetypes"); DataTable NodetypesTable = CswTableSelectNodeTypes.getTable(" where lower(tablename)='materials'"); Int32 NodeTypeId = Convert.ToInt32(NodetypesTable.Rows[0]["nodetypeid"]); CswNbtMetaDataNodeType NodeType = _CswNbtSchemaModTrnsctn.MetaData.getNodeType(NodeTypeId); CswTableUpdate CswTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate(Description, NodeType.TableName); string PkColumnName = _CswNbtSchemaModTrnsctn.getPrimeKeyColName(NodeType.TableName); //bz # 9102: This is the way of getting the record that causes the updated record disappear CswCommaDelimitedString SelectColumns = null; //new CswCommaDelimitedString(); //foreach( CswNbtMetaDataNodeTypeProp CurrentNodeTypeProp in NodeType.getNodeTypeProps() ) //{ // foreach( CswNbtSubField CurrentSubField in CurrentNodeTypeProp.getFieldTypeRule().SubFields ) // { // if( CurrentSubField.RelationalColumn != string.Empty ) // SelectColumns.Add( CurrentSubField.RelationalColumn ); // } //}//iterate node type props to set up select columns DataTable DataTable = CswTableUpdate.getTable(SelectColumns, PkColumnName, _CswTstCaseRsrc_014.InsertedMaterialsRecordPk, string.Empty, false); DataTable.Rows[0]["materialname"] = "nu _CswTstCaseRsrc_014.Purpose"; CswTableUpdate.update(DataTable); }
}//afterWriteNode() private void _updateEquipment() { // For each equipment related to this assembly, mark matching properties as pending update if (CswEnumNbtNodeModificationState.Modified == _CswNbtNode.ModificationState) { CswStaticSelect PropRefsSelect = _CswNbtResources.makeCswStaticSelect("afterWriteNode_select", "getMatchingEquipPropsForAssembly"); CswStaticParam StaticParam = new CswStaticParam("getassemblynodeid", _CswNbtNode.NodeId.PrimaryKey); PropRefsSelect.S4Parameters.Add("getassemblynodeid", StaticParam); DataTable PropRefsTable = PropRefsSelect.getTable(); // Update the nodes.pendingupdate directly, to avoid having to fetch all the node info for every related node string PkString = String.Empty; foreach (DataRow PropRefsRow in PropRefsTable.Rows) { if (PkString != String.Empty) { PkString += ","; } PkString += PropRefsRow["nodeid"].ToString(); } if (PkString != String.Empty) { CswTableUpdate NodesUpdate = _CswNbtResources.makeCswTableUpdate("afterWriteNode_update", "nodes"); DataTable NodesTable = NodesUpdate.getTable("where nodeid in (" + PkString + ")"); foreach (DataRow NodesRow in NodesTable.Rows) { NodesRow["pendingupdate"] = "1"; } NodesUpdate.update(NodesTable); } } }
} // update() private void _deleteDuplicateRows( CswCommaDelimitedString NodeIds, CswCommaDelimitedString NTPIds ) { foreach( string id in NodeIds ) { string where = "where nodeid = " + id + " and nodetypepropid in (" + NTPIds.ToString() + ")"; CswTableUpdate jnpTU = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "RemoveDups" + id, "jct_nodes_props" ); DataTable tbl = jnpTU.getTable( where ); if( tbl.Rows.Count > 1 ) { bool skip = true; foreach( DataRow row in tbl.Rows ) { if( skip ) //leave one row for the prop { skip = false; } else { row.Delete(); } } jnpTU.update( tbl ); } } }
public override void update() { CswNbtMetaDataFieldType QuantityFT = _CswNbtSchemaModTrnsctn.MetaData.getFieldType(CswEnumNbtFieldType.Quantity); CswTableUpdate QtyUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("QuantityVal_kgLiters_Update", "jct_nodes_props"); DataTable QtyPropsTable = QtyUpdate.getTable("where nodetypepropid in (select nodetypepropid from nodetype_props where fieldtypeid = " + QuantityFT.FieldTypeId + ") "); foreach (DataRow Row in QtyPropsTable.Rows) { CswPrimaryKey UnitId = new CswPrimaryKey("nodes", CswConvert.ToInt32(Row["field1_fk"].ToString())); CswNbtObjClassUnitOfMeasure CurrentUnit = _CswNbtSchemaModTrnsctn.Nodes[UnitId]; if (null != CurrentUnit && (CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Weight.ToString() || CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Volume.ToString())) { Double Quantity = CswConvert.ToDouble(Row["field1_numeric"].ToString()); if (CswTools.IsDouble(Quantity)) { CswNbtObjClassUnitOfMeasure kgUnit = getUnit("kg", "Unit_Weight"); CswNbtObjClassUnitOfMeasure LitersUnit = getUnit("Liters", "Unit_Volume"); if (null != kgUnit && CurrentUnit.UnitType.Value == kgUnit.UnitType.Value) { Double Val_kg = Quantity * CurrentUnit.ConversionFactor.RealValue / kgUnit.ConversionFactor.RealValue; Row["field2_numeric"] = Val_kg.ToString(); } if (null != LitersUnit && CurrentUnit.UnitType.Value == LitersUnit.UnitType.Value) { Double Val_Liters = Quantity * CurrentUnit.ConversionFactor.RealValue / LitersUnit.ConversionFactor.RealValue; Row["field3_numeric"] = Val_Liters.ToString(); } } } } QtyUpdate.update(QtyPropsTable); }
/// <summary> /// If blobdata exists for the given file prop, creates a new row and copies the row and sets the new JctNodePropId /// </summary> public static void CopyBlobData(CswNbtResources NbtResources, int SourceJctNodePropId, int TargetJctNodePropId) { if (SourceJctNodePropId != TargetJctNodePropId) //Prevent users from copying themselves { //Clear existing blob data for the prop we're copying to DeleteBlobData(NbtResources, TargetJctNodePropId); CswTableUpdate blobDataTU = NbtResources.makeCswTableUpdate("CopyBlobData", "blob_data"); DataTable blobDataDT = blobDataTU.getTable("where jctnodepropid = " + SourceJctNodePropId); int totalRows = blobDataDT.Rows.Count; //to avoid infinate loop, since we're adding to rows for (int i = 0; i < totalRows; i++) { DataRow existingRow = blobDataDT.Rows[i]; DataRow newRow = blobDataDT.NewRow(); foreach (DataColumn col in blobDataDT.Columns) { if ("jctnodepropid" == col.ColumnName) { newRow["jctnodepropid"] = TargetJctNodePropId; } else if (col.ColumnName != "blobdataid") { newRow[col] = existingRow[col]; } } blobDataDT.Rows.Add(newRow); } blobDataTU.update(blobDataDT); } }
private Int32 _getNextAvailableRow(Int32 LandingPageId, Int32 RowNum, Int32 ColNum) { Int32 NextAvailableRow = RowNum; if (LandingPageId != Int32.MinValue) { bool availableCellFound = false; CswTableUpdate LandingPageUpdate = _CswNbtResources.makeCswTableUpdate("MoveLandingPageItem", "landingpage"); while (false == availableCellFound) { DataTable ExistingCellTable = LandingPageUpdate.getTable( "where display_row = " + NextAvailableRow + " and display_col = " + ColNum + "and for_roleid = (select for_roleid from landingpage where landingpageid = " + LandingPageId + ")" + "and for_actionid = (select for_actionid from landingpage where landingpageid = " + LandingPageId + ")" ); if (ExistingCellTable.Rows.Count == 0) { availableCellFound = true; } else { NextAvailableRow++; } } } return(NextAvailableRow); }
} // update() private void _migrateMaterialNodeTypePropsToNonChemical( CswNbtMetaDataNodeType MaterialNT ) { //Update the NodeTypeProps' OCPs to point to NonChemical's OCPs - if NonChemical does not have an OCP with the given NTP name, the NTP is deleted. CswNbtMetaDataObjectClass NonChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.NonChemicalClass ); List<int> DoomedNTPIds = new List<int>(); CswTableUpdate NTPUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28690_ntp_update", "nodetype_props" ); DataTable NTPTable = NTPUpdate.getTable( "where nodetypeid = " + MaterialNT.NodeTypeId + " and objectclasspropid is not null" ); foreach( DataRow NTPRow in NTPTable.Rows ) { string NTPropName = NTPRow["propname"].ToString(); bool MoveProp = ( NTPropName == CswNbtPropertySetMaterial.PropertyName.MaterialId || NTPropName == CswNbtPropertySetMaterial.PropertyName.TradeName || NTPropName == CswNbtPropertySetMaterial.PropertyName.Supplier || NTPropName == CswNbtPropertySetMaterial.PropertyName.PartNumber || NTPropName == CswNbtPropertySetMaterial.PropertyName.ApprovedForReceiving || NTPropName == CswNbtPropertySetMaterial.PropertyName.Receive || NTPropName == CswNbtPropertySetMaterial.PropertyName.Request || NTPropName == CswNbtPropertySetMaterial.PropertyName.C3ProductId || NTPropName == CswNbtPropertySetMaterial.PropertyName.C3SyncDate || NTPropName == CswNbtObjClass.PropertyName.Save || NTPropName == "Biological Name" );//Special Case if( MoveProp ) { if( NTPropName == "Biological Name" )//Special Case { NTPropName = CswNbtPropertySetMaterial.PropertyName.TradeName; } NTPRow["objectclasspropid"] = NonChemicalOC.getObjectClassProp( NTPropName ).ObjectClassPropId; } else { NTPRow["objectclasspropid"] = DBNull.Value; DoomedNTPIds.Add( CswConvert.ToInt32( NTPRow["nodetypepropid"] ) ); } } NTPUpdate.update( NTPTable ); foreach( int DoomedNTPId in DoomedNTPIds ) { CswNbtMetaDataNodeTypeProp DoomedNTP = _CswNbtSchemaModTrnsctn.MetaData.getNodeTypeProp( DoomedNTPId ); _CswNbtSchemaModTrnsctn.MetaData.DeleteNodeTypeProp( DoomedNTP ); } //special case - remove SDS grid prop CswNbtMetaDataNodeTypeProp AssignedSDSNTP = MaterialNT.getNodeTypeProp( "Assigned SDS" ); if( null != AssignedSDSNTP ) { _CswNbtSchemaModTrnsctn.MetaData.DeleteNodeTypeProp( AssignedSDSNTP ); } //remove hazards tab CswNbtMetaDataNodeTypeTab HazardsTab = MaterialNT.getNodeTypeTab( "Hazards" ); if( null != HazardsTab ) { _CswNbtSchemaModTrnsctn.MetaData.DeleteNodeTypeTab( HazardsTab ); } }
public override void update() { CswTableUpdate CswTableUpdateActions = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "update icon case 29918", "actions" ); DataTable ActionsTable = CswTableUpdateActions.getTable( " where lower(actionname) = 'manage locations' " ); if( 1 == ActionsTable.Rows.Count ) { ActionsTable.Rows[0]["iconfilename"] = "world.png"; CswTableUpdateActions.update( ActionsTable ); } } // update()
public override void update() { CswTableUpdate ConfigVarUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "orphan_defaultvalueid_update", "nodetype_props" ); DataTable ConfigVarTable = ConfigVarUpdate.getTable( " where defaultvalueid = 507071" ); foreach( DataRow ConfigVarRow in ConfigVarTable.Rows ) { ConfigVarRow["defaultvalueid"] = DBNull.Value; } ConfigVarUpdate.update( ConfigVarTable ); }
public override void update() { // Set field2 = field1 on any existing List values CswTableUpdate JctUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "30304_jct_update", "jct_nodes_props" ); { DataTable JctTable = JctUpdate.getTable( new CswCommaDelimitedString() { "jctnodepropid", "nodetypepropid", "field1", "field2" }, "", Int32.MinValue, @"where field1 is not null and field2 is null and nodetypepropid in (select nodetypepropid from nodetype_props where fieldtypeid in (select fieldtypeid from field_types where fieldtype = 'List'))", false ); foreach( DataRow Row in JctTable.Rows ) { Row["field2"] = Row["field1"]; } JctUpdate.update( JctTable ); } { // Don't forget the object class prop default values DataTable JctTable2 = JctUpdate.getTable( new CswCommaDelimitedString() { "jctnodepropid", "nodetypepropid", "objectclasspropid", "field1", "field2" }, "", Int32.MinValue, @"where field1 is not null and field2 is null and objectclasspropid in (select objectclasspropid from object_class_props where fieldtypeid in (select fieldtypeid from field_types where fieldtype = 'List'))", false ); foreach( DataRow Row2 in JctTable2.Rows ) { Row2["field2"] = Row2["field1"]; } JctUpdate.update( JctTable2 ); } } // update()
public override void update() { CswTableUpdate NTUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "update_ntnames", "nodetypes" ); DataTable NTTable = NTUpdate.getTable(); foreach( DataRow NTRow in NTTable.Rows ) { NTRow["nodetypename"] = CswFormat.MakeIntoValidName( NTRow["nodetypename"].ToString() ); } NTUpdate.update( NTTable ); } // update()
public override void update() { CswTableUpdate ConfigVarUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "loc_use_images_update", "configuration_variables" ); DataTable ConfigVarTable = ConfigVarUpdate.getTable( " where variablename = 'loc_use_images'" ); foreach( DataRow ConfigVarRow in ConfigVarTable.Rows ) { ConfigVarRow["issystem"] = "1"; } ConfigVarUpdate.update( ConfigVarTable ); }
public override void update() { CswTableUpdate NTPUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "update_nt_oraview_names", "nodetype_props" ); DataTable NTPTable = NTPUpdate.getTable("where oraviewcolname is null"); foreach( DataRow Prop in NTPTable.Rows ) { Prop["oraviewcolname"] = CswFormat.MakeOracleCompliantIdentifier( Prop["propname"].ToString() ); } NTPUpdate.update( NTPTable ); } // update()
private void _deleteDeficientInspectionActionFromTable( string actionId, string tableName ) { CswTableUpdate tableActionUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "DeleteDeficientInspectionsAction", tableName ); DataTable actTable = tableActionUpdate.getTable( "where actionid = " + actionId ); foreach( DataRow row in actTable.Rows ) { row.Delete(); } tableActionUpdate.update( actTable ); }
public override void update() { _CswNbtSchemaModTrnsctn.setConfigVariableValue( CswEnumConfigurationVariableNames.NodesProcessedPerCycle.ToString(), "10" ); CswTableUpdate SchedServiceUpdt = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "case31040", "scheduledrules" ); DataTable SchedServiceTable = SchedServiceUpdt.getTable( "where rulename = 'CAFImport'" ); if( SchedServiceTable.Rows.Count > 0 ) { SchedServiceTable.Rows[0]["maxruntimems"] = 3600000; } SchedServiceUpdt.update( SchedServiceTable ); } // update()