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()
// 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()
/// <summary> /// Add new Relationship entries to a definition (for use by CswNbtImporter) /// </summary> public static void addRelationshipEntries(CswNbtResources CswNbtResources, DataTable RelationshipsDataTable) { CswTableUpdate importRelationshipsUpdate = CswNbtResources.makeCswTableUpdate("storeDefinition_Relationships_update", CswNbtImportTables.ImportDefRelationships.TableName); foreach (DataRow RelRow in RelationshipsDataTable.Select()) { //set blank instances to min value if (RelRow["instance"] == DBNull.Value || String.IsNullOrEmpty(RelRow["instance"].ToString())) { RelRow["instance"] = Int32.MinValue; } string NodeTypeName = RelRow["nodetypename"].ToString(); string RelationshipName = RelRow["relationship"].ToString(); CswNbtMetaDataNodeType NodeType = CswNbtResources.MetaData.getNodeType(NodeTypeName); CswNbtMetaDataNodeTypeProp Relationship = NodeType.getNodeTypeProp(RelationshipName); if (null == NodeType) { throw new CswDniException(CswEnumErrorType.Error, "Error reading bindings", "Invalid NodeType defined in 'Relationships' sheet: " + NodeTypeName); } else if (null == Relationship) { throw new CswDniException(CswEnumErrorType.Error, "Error reading bindings", "Invalid Relationship defined in 'Relationships' sheet: " + RelRow["relationship"].ToString() + " (nodetype: " + NodeTypeName + ")"); } } // foreach( DataRow RelRow in RelationshipsDataTable.Rows ) //this is a hack, and the fact that we can even do this makes me sad importRelationshipsUpdate._DoledOutTables.Add(RelationshipsDataTable); importRelationshipsUpdate.update(RelationshipsDataTable); } // addRelationshipEntries()
public override void update() { CswNbtMetaDataPropertySet PhrasePS = _CswNbtSchemaModTrnsctn.MetaData.getPropertySet( CswEnumNbtPropertySetName.PhraseSet ); if( null == PhrasePS ) { PhrasePS = _CswNbtSchemaModTrnsctn.MetaData.makeNewPropertySet( CswEnumNbtPropertySetName.PhraseSet, "warning.png" ); //Update the DSD and GHS Phrases CswTableUpdate TableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "updatePhrasePropSets", "jct_propertyset_objectclass" ); DataTable ObjClassTbl = TableUpdate.getEmptyTable(); DataRow GHSRow = ObjClassTbl.NewRow(); DataRow DSDRow = ObjClassTbl.NewRow(); GHSRow["propertysetid"] = PhrasePS.PropertySetId; GHSRow["objectclassid"] = _CswNbtSchemaModTrnsctn.MetaData.getObjectClassId( CswEnumNbtObjectClass.GHSPhraseClass ); DSDRow["propertysetid"] = PhrasePS.PropertySetId; DSDRow["objectclassid"] = _CswNbtSchemaModTrnsctn.MetaData.getObjectClassId( CswEnumNbtObjectClass.DSDPhraseClass ); ObjClassTbl.Rows.Add( GHSRow ); ObjClassTbl.Rows.Add( DSDRow ); TableUpdate.update( ObjClassTbl ); } } // 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()
public override void update() { // Insert license into licenses table CswTableUpdate LicenseUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "30086_license_update", "license" ); DataTable LicenseTable = LicenseUpdate.getEmptyTable(); DataRow lRow = LicenseTable.NewRow(); lRow["activedate"] = DateTime.Now; lRow["licensetxt"] = @"These ""Terms of Use"" set forth the terms and conditions that apply to your use of ChemSWLive (the ""Web Site""). By using the Web Site (other than to read this page for the first time), you agree to comply with all of the Terms of Use set forth herein. The right to use the Web Site is personal to you and is not transferable to any other person or entity. Copyrights and Trademarks A. All materials contained on the Web Site are Copyright 2006-2013, ChemSW, Inc. All rights reserved. B. No person is authorized to use, copy or distribute any portion the Web Site including related graphics. C. ChemSWLive and other trademarks and/or service marks (including logos and designs) found on the Web Site are trademarks/service marks that identify ChemSW, Inc. and the goods and/or services provided by ChemSW, Inc.. Such marks may not be used under any circumstances without the prior written authorization of ChemSW, Inc. Links to Third-Party Web Site ChemSW, Inc. may provide hyperlinks to third-party web sites as a convenience to users of the Web Site. ChemSW, Inc. does not control third-party web sites and is not responsible for the contents of any linked-to, third-party web sites or any hyperlink in a linked-to web site. ChemSW, Inc. does not endorse, recommend or approve any third-party web site hyperlinked from the Web Site. ChemSW, Inc. will have no liability to any entity for the content or use of the content available through such hyperlink. No Representations or Warranties; Limitations on Liability The information and materials on the Web Site could include technical inaccuracies or typographical errors. Changes are periodically made to the information contained herein. ChemSW, Inc. MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO ANY INFORMATION, MATERIALS OR GRAPHICS ON THE WEB SITE, ALL OF WHICH IS PROVIDED ON A STRICTLY ""AS IS"" BASIS, WITHOUT WARRANTY OF ANY KIND AND HEREBY EXPRESSLY DISCLAIMS ALL WARRANTIES WITH REGARD TO ANY INFORMATION, MATERIALS OR GRAPHICS ON THE WEB SITE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. UNDER NO CIRCUMSTANCES SHALL THE SITE OWNER OR PUBLISHER BE LIABLE UNDER ANY THEORY OF RECOVERY, AT LAW OR IN EQUITY, FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION, SPECIAL, DIRECT, INCIDENTAL, CONSEQUENTIAL OR PUNITIVE DAMAGES (INCLUDING, BUT NOT LIMITED TO LOSS OF USE OR LOST PROFITS), ARISING OUT OF OR IN ANY MANNER CONNECTED WITH THE USE OF INFORMATION OR SERVICES, OR THE FAILURE TO PROVIDE INFORMATION OR SERVICES, FROM THE WEB SITE. Changes to These Terms of Use ChemSW, Inc. reserves the right to change these Terms of Use at any time by posting new Terms of Use at this location. You can send e-mail to ChemSW, Inc. with any questions relating to these Terms of Use at [email protected]."; LicenseTable.Rows.Add( lRow ); LicenseUpdate.update( LicenseTable ); }
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() { // 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()
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()
}//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); } } }
/// <summary> /// Add new Order entries to a definition (for use by CswNbtImporter) /// </summary> public static void addOrderEntries(CswNbtResources CswNbtResources, DataTable OrderDataTable) { CswTableUpdate importOrderUpdate = CswNbtResources.makeCswTableUpdate("CswNbtImportDefOrder_addOrderEntries_Update", CswNbtImportTables.ImportDefOrder.TableName); foreach (DataRow OrderRow in OrderDataTable.Select()) { //set blank instances to min value if (OrderRow["instance"] == DBNull.Value || String.IsNullOrEmpty(OrderRow["instance"].ToString())) { OrderRow["instance"] = Int32.MinValue; } string NTName = OrderRow["nodetypename"].ToString(); CswNbtMetaDataNodeType NodeType = CswNbtResources.MetaData.getNodeType(NTName); if (null == NodeType) { throw new CswDniException(CswEnumErrorType.Error, "Error reading definition", "Invalid NodeType defined in 'Order' sheet: " + NTName); } // if(false == string.IsNullOrEmpty(SheetName) ) } // foreach( DataRow OrderRow in OrderDataTable.Rows ) //this is a hack, and the fact that we can even do this makes me sad importOrderUpdate._DoledOutTables.Add(OrderDataTable); importOrderUpdate.update(OrderDataTable); } // addOrderEntries()
} //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); }
} // 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 void clear() //{ //}//clear() public void makeNewNodeEntry(CswNbtNode Node, bool SyncProps) { // Don't sync for temp nodes if (false == Node.IsTemp) { string TableName = Node.getNodeType().TableName; string PkColumnName = _CswNbtResources.getPrimeKeyColName(TableName); CswTableUpdate CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodeWriterRelationalDb.makeNewNodeEntry_update", TableName); DataTable NewNodeTable = CswTableUpdate.getEmptyTable(); DataRow NewNodeRow = NewNodeTable.NewRow(); NewNodeTable.Rows.Add(NewNodeRow); Node.RelationalId = new CswPrimaryKey(TableName, CswConvert.ToInt32(NewNodeTable.Rows[0][PkColumnName])); CswTableUpdate.update(NewNodeTable); if (SyncProps) { // It is possible for the node to have existed as a temp node, and therefore already have property values. // Now that the node has a relationalid, this will sync the current property values to the new relational row Node.Properties.update(Node, IsCopy: false, OverrideUniqueValidation: false, Creating: false, AllowAuditing: true, SkipEvents: false); } } }
/// <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); } }
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()
} // 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 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() { // 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 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 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() { 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); }
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 ); } } }
} // 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 ); } }
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() { 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() { // 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()
/// <summary> /// Toggles the favorite status of the node for the given user /// </summary> /// <param name="_CswResources">Resources</param> /// <param name="NodeId">NodeId to Favorite</param> /// <param name="UserId">UserId with which to associate Favorite</param> /// <param name="Add">When true, force Add; when false, force remove; when null, toggle</param> public static void toggleFavorite(CswNbtResources _CswNbtResources, Int32 NodeId, Int32 UserId, CswEnumTristate Add) { CswTableUpdate FavoritesUpdate = _CswNbtResources.makeCswTableUpdate("favoritesUpdate", "favorites"); DataTable FavoritesTable = FavoritesUpdate.getTable("where itemid = " + NodeId + " and userid = " + UserId); if (Add != CswEnumTristate.False && FavoritesTable.Rows.Count == 0) { DataRow FavoritesRow = FavoritesTable.NewRow(); FavoritesRow["userid"] = UserId; FavoritesRow["itemid"] = NodeId; FavoritesTable.Rows.Add(FavoritesRow); FavoritesUpdate.update(FavoritesTable); } else if (Add != CswEnumTristate.True && FavoritesTable.Rows.Count > 0) { FavoritesTable.Rows[0].Delete(); FavoritesUpdate.update(FavoritesTable); } }
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 ); }