//mark any property references to this property on other nodes as pending update private void _markExternalPropRefsDirty(CswNbtNodePropWrapper CurrentProp) { if (CswTools.IsPrimaryKey(CurrentProp.NodeId)) { CswNbtFieldTypeRulePropertyReference PropRefFTR = (CswNbtFieldTypeRulePropertyReference)_CswNbtResources.MetaData.getFieldTypeRule(CswEnumNbtFieldType.PropertyReference); CswEnumNbtPropColumn PropRefColumn = PropRefFTR.CachedValueSubField.Column; string SQL = @"update jct_nodes_props set pendingupdate = '" + CswConvert.ToDbVal(true) + @"', " + PropRefColumn.ToString() + @" = '' where jctnodepropid in (select j.jctnodepropid from jct_nodes_props j join nodes n on n.nodeid = j.nodeid join nodetype_props p on p.nodetypepropid = j.nodetypepropid join field_types f on p.fieldtypeid = f.fieldtypeid left outer join jct_nodes_props jntp on (jntp.nodetypepropid = p.fkvalue and jntp.nodeid = n.nodeid and jntp.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @") left outer join (select jx.jctnodepropid, ox.objectclasspropid, jx.nodeid from jct_nodes_props jx join nodetype_props px on jx.nodetypepropid = px.nodetypepropid join object_class_props ox on px.objectclasspropid = ox.objectclasspropid where jx.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @") jocp on (jocp.objectclasspropid = p.fkvalue and jocp.nodeid = n.nodeid) where f.fieldtype = 'PropertyReference' and ((lower(p.fktype) = 'nodetypepropid' and jntp.jctnodepropid is not null) or (lower(p.fktype) = 'objectclasspropid' and jocp.jctnodepropid is not null)) and ((lower(p.valueproptype) = 'nodetypepropid' and p.valuepropid = " + CurrentProp.NodeTypePropId.ToString() + @") or (lower(p.valueproptype) = 'objectclasspropid' and p.valuepropid = " + CurrentProp.ObjectClassPropId + @")))"; // We're not doing this in a CswTableUpdate because it might be a large operation, // and we don't care about auditing for this change. _CswNbtResources.execArbitraryPlatformNeutralSql(SQL); } }
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."); } } }
private void _addObjClassPropsToPropertySetPermission(DataTable JctPSOCPTable, string ObjClassName, int PropertySetId) { CswNbtMetaDataObjectClass PermissionObjectClass = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass(ObjClassName); foreach (CswNbtMetaDataObjectClassProp ObjectClassProp in PermissionObjectClass.getObjectClassProps()) { bool doInsert = ( ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.PermissionGroup || ObjectClassProp.PropName == "Inventory Group" || //Special Case ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.WorkUnit || ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.ApplyToAllWorkUnits || ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.Role || ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.ApplyToAllRoles || ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.View || ObjectClassProp.PropName == CswNbtPropertySetPermission.PropertyName.Edit ); if (doInsert) { DataRow NewJctPSOCPRow = JctPSOCPTable.NewRow(); NewJctPSOCPRow["objectclasspropid"] = ObjectClassProp.PropId; NewJctPSOCPRow["propertysetid"] = CswConvert.ToDbVal(PropertySetId); JctPSOCPTable.Rows.Add(NewJctPSOCPRow); } } }
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()
} // 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() { string SQL = "update actions set showinlist=" + CswConvert.ToDbVal( false ) + " where actionname='" + CswNbtActionName.Receiving + "'"; _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql( SQL ); }//Update()
protected override void afterPromoteNodeLogic() { // ------------------------------------------------------------ // This logic from makeNewTab in CswNbtMetaData.cs // ------------------------------------------------------------ if (CswTools.IsPrimaryKey(RelationalId)) { Int32 TabId = RelationalId.PrimaryKey; //CswTableUpdate TabsUpdate = _CswNbtResources.makeCswTableUpdate( "DesignNodeTypeTab_afterCreateNode_TabsUpdate", "nodetype_tabset" ); //DataTable TabsTable = TabsUpdate.getTable( "nodetypetabsetid", TabId ); //if( TabsTable.Rows.Count > 0 ) //{ // Version, if necessary //NodeType = CheckVersioning( NodeType ); //DataRow Row = TabsTable.Rows[0]; DataRow Row = RelationalNodeTypeTab._DataRow; if (null != Row) { Row["firsttabversionid"] = CswConvert.ToDbVal(TabId); //TabsUpdate.update( TabsTable ); } CswNbtMetaDataNodeTypeProp SaveNtp = NodeType.getNodeTypeProp(CswNbtObjClass.PropertyName.Save); if (null != SaveNtp) //Case 29181 - Save prop on new tabs { //Note - when first creating a new NodeType and creating its first tab this will be null, which is expected SaveNtp.updateLayout(CswEnumNbtLayoutType.Edit, false, TabId: TabId, DisplayColumn: 1, DisplayRow: Int32.MaxValue); } //} // if( TabsTable.Rows.Count > 0 ) } // if( CswTools.IsPrimaryKey( RelationalId ) ) } // afterPromoteNode()
} // saveSessionData(View) private DataRow _getSessionViewRow( DataTable SessionViewTable, object Name, CswEnumNbtSessionDataType DataType, bool IncludeInQuickLaunch, bool KeepInQuickLaunch ) { DataRow SessionViewRow = null; if( SessionViewTable.Rows.Count > 0 ) { SessionViewRow = SessionViewTable.Rows[0]; } else { SessionViewRow = SessionViewTable.NewRow(); SessionViewTable.Rows.Add( SessionViewRow ); } SessionViewRow[SessionDataColumn_Name] = CswConvert.ToString( Name ); SessionViewRow[SessionDataColumn_SessionId] = SessionId; SessionViewRow[SessionDataColumn_SessionDataType] = DataType.ToString(); if( CswConvert.ToBoolean( SessionViewRow[SessionDataColumn_QuickLaunch] ) == false ) { // Only set false to true, not true to false. See case 23999. SessionViewRow[SessionDataColumn_QuickLaunch] = CswConvert.ToDbVal( IncludeInQuickLaunch ); } SessionViewRow[SessionDataColumn_KeepInQuickLaunch] = CswConvert.ToDbVal( KeepInQuickLaunch ); return SessionViewRow; } // _getSessionViewRow()
/// <summary> /// Update logic /// </summary> public override void update() { CswNbtMetaDataNodeType TimeNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Unit (Time)" ); if( null != TimeNT ) { foreach( CswNbtObjClassUnitOfMeasure TimeNode in TimeNT.getNodes( false, false ) ) { if( "Months" == TimeNode.Name.Text ) { //According to Google, 1 month = 30.4368 days (based on averages, I'm assuming) TimeNode.ConversionFactor.Base = 3.285496; TimeNode.ConversionFactor.Exponent = -2; TimeNode.postChanges( false ); } } } CswNbtMetaDataObjectClass MaterialOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MaterialClass ); foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp SpecificGravityNtp = MaterialNt.getNodeTypePropByObjectClassProp( CswNbtObjClassMaterial.PropertyName.SpecificGravity ); if( null != SpecificGravityNtp ) { SpecificGravityNtp.Attribute1 = CswConvert.ToDbVal( true ).ToString(); } } }
}//makeNewNodeEntry() public void write(CswNbtNode Node, bool ForceSave, bool IsCopy, bool OverrideUniqueValidation, bool Creating, bool AllowAuditing, bool SkipEvents) { if (CswEnumNbtNodeSpecies.Plain == Node.NodeSpecies && (ForceSave || CswEnumNbtNodeModificationState.Modified == Node.ModificationState)) { //When CswNbtNode.NodeId is Int32.MinValue, we know that the node data was not //filled from an existing node and therefore needs to be written to //the db, after which it will have a node id if (null == Node.NodeId) { makeNewNodeEntry(Node); //makeNewNodeEntry( Node, IsCopy, OverrideUniqueValidation ); } //bz # 5878 //propcoll knows whether or not he's got new values to update (presumably) Node.Properties.update(Node, IsCopy, OverrideUniqueValidation, Creating, AllowAuditing, SkipEvents); //set nodename with updated prop values _synchNodeName(Node); // save nodename and pendingupdate if (Node.NodeId.TableName != "nodes") { throw new CswDniException(CswEnumErrorType.Error, "Internal data error", "CswNbtNodeWriterNative attempted to write a node in table: " + Node.NodeId.TableName); } DataTable NodesTable = CswTableUpdateNodes.getTable("nodeid", Node.NodeId.PrimaryKey); if (1 != NodesTable.Rows.Count) { throw (new CswDniException(CswEnumErrorType.Error, "Internal data errors", "There are " + NodesTable.Rows.Count.ToString() + " node table records for node id (" + Node.NodeId.ToString() + ")")); } NodesTable.Rows[0]["nodename"] = Node.NodeName; NodesTable.Rows[0]["pendingupdate"] = CswConvert.ToDbVal(Node.PendingUpdate); NodesTable.Rows[0]["readonly"] = CswConvert.ToDbVal(Node.ReadOnlyPermanent); NodesTable.Rows[0]["locked"] = CswConvert.ToDbVal(Node.Locked); NodesTable.Rows[0]["isdemo"] = CswConvert.ToDbVal(Node.IsDemo); NodesTable.Rows[0]["istemp"] = CswConvert.ToDbVal(Node.IsTemp); NodesTable.Rows[0]["sessionid"] = CswConvert.ToDbVal(Node.SessionId); NodesTable.Rows[0][_CswAuditMetaData.AuditLevelColName] = Node.AuditLevel; NodesTable.Rows[0]["hidden"] = CswConvert.ToDbVal(Node.Hidden); NodesTable.Rows[0]["iconfilename"] = Node.IconFileNameOverride; NodesTable.Rows[0]["searchable"] = CswConvert.ToDbVal(Node.Searchable); NodesTable.Rows[0]["legacyid"] = CswConvert.ToDbVal(Node.LegacyId); // case 29311 - Sync with relational data if (Node.getNodeType().DoRelationalSync) { _CswNbtNodeWriterRelationalDb.write(Node, ForceSave, IsCopy, AllowAuditing); } if (null != Node.RelationalId) { NodesTable.Rows[0]["relationalid"] = Node.RelationalId.PrimaryKey; NodesTable.Rows[0]["relationaltable"] = Node.RelationalId.TableName; } CswTableUpdateNodes.update(NodesTable); } //if node was modified } //write()
public void getQuickLaunchJson( ref ViewSelect.Response.Category Category ) { CswTableSelect SessionDataSelect = _CswNbtResources.makeCswTableSelect( "getQuickLaunchXml_select", "session_data" ); Collection<OrderByClause> OrderBy = new Collection<OrderByClause>(); OrderBy.Add( new OrderByClause( SessionDataColumn_PrimaryKey, CswEnumOrderByType.Descending ) ); string WhereClause = @"where " + SessionDataColumn_SessionId + "='" + _CswNbtResources.Session.SessionId + "' and " + SessionDataColumn_QuickLaunch + " = '" + CswConvert.ToDbVal( true ).ToString() + "'"; DataTable SessionDataTable = SessionDataSelect.getTable( WhereClause, OrderBy ); Int32 RowCount = 0; foreach( DataRow Row in SessionDataTable.Rows ) { bool KeepInQuickLaunch = CswConvert.ToBoolean( Row[SessionDataColumn_KeepInQuickLaunch] ); if( KeepInQuickLaunch ) { _addQuickLaunchProp( Row, Category ); } else if( RowCount < 5 ) { _addQuickLaunchProp( Row, Category ); RowCount++; } } } // getQuickLaunchJson()
public void updateRelationsToThisNode(CswNbtNode Node) { if (Node.NodeId.TableName != "nodes") { throw new CswDniException(CswEnumErrorType.Error, "Internal System Error", "CswNbtNodeWriterNative.updateRelationsToThisNode() called on a non-native node"); } string SQL = @"update jct_nodes_props set pendingupdate = '" + CswConvert.ToDbVal(true) + @"' where jctnodepropid in (select j.jctnodepropid from jct_nodes_props j join nodetype_props p on j.nodetypepropid = p.nodetypepropid join field_types f on p.fieldtypeid = f.fieldtypeid where (f.fieldtype = 'Relationship' or f.fieldtype = 'Location' or f.fieldtype = 'Quantity') and j.field1_fk = " + Node.NodeId.PrimaryKey.ToString() + ")"; // We're not doing this in a CswTableUpdate because it might be a large operation, // and we don't care about auditing for this change. _CswNbtResources.execArbitraryPlatformNeutralSql(SQL); //// case 29311 - Sync with relational data //if( Node.getNodeType().DoRelationalSync ) //{ // _CswNbtNodeWriterRelationalDb.updateRelationsToThisNode( Node ); //} }
public override void setDBValuesFromRequest(LandingPageData.Request Request) { CswEnumNbtViewType ViewType = (CswEnumNbtViewType)Request.ViewType; if (ViewType == CswEnumNbtViewType.View) { _ItemRow["to_nodeviewid"] = CswConvert.ToDbVal(new CswNbtViewId(Request.PkValue).get()); } else if (ViewType == CswEnumNbtViewType.Action) { _ItemRow["to_actionid"] = CswConvert.ToDbVal(Request.PkValue); } else if (ViewType == CswEnumNbtViewType.Report) { CswPrimaryKey ReportPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_reportid"] = CswConvert.ToDbVal(ReportPk.PrimaryKey); } else if (ViewType == CswEnumNbtViewType.Search) { CswPrimaryKey SearchPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_searchid"] = CswConvert.ToDbVal(SearchPk.PrimaryKey); } else { throw new CswDniException(CswEnumErrorType.Warning, "You must select a view", "No view was selected for new Link LandingPage Item"); } _setCommonDbValuesFromRequest(Request); }
public override void update() { CswNbtMetaDataObjectClass materialOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MaterialClass ); foreach( CswNbtMetaDataNodeType materialNT in materialOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp documentNTP = materialNT.getNodeTypeProp( "Documents" ); if( null != documentNTP ) { CswNbtView documentsPropView = _CswNbtSchemaModTrnsctn.restoreView( documentNTP.ViewId ); foreach( CswNbtViewProperty viewProp in documentsPropView.getOrderedViewProps( true ) ) { if( viewProp.Name.Equals( CswNbtObjClassDocument.PropertyName.Archived ) ) { documentsPropView.AddViewPropertyFilter( viewProp, Conjunction: CswNbtPropFilterSql.PropertyFilterConjunction.Or, SubFieldName: CswNbtSubField.SubFieldName.Checked, FilterMode: CswNbtPropFilterSql.PropertyFilterMode.Equals, Value: CswConvert.ToDbVal( true ).ToString() ); } } documentsPropView.save(); } // if( null != documentNTP ) } //foreach( CswNbtMetaDataNodeType materialNT in materialOC.getNodeTypes() ) } //Update()
} // GetNodeCountForNodeType /// <summary> /// Returns the number of locked nodes for an object class /// </summary> public Int32 GetLockedNodeCountForObjectClass( Int32 ObjectClassId ) { CswTableSelect NodesSelect = _CswNbtResources.makeCswTableSelect( "CswNbtActQuotas_SelectLockedNodes", "nodes" ); string WhereClause = @"where nodetypeid in (select nodetypeid from nodetypes where objectclassid = " + ObjectClassId.ToString() + @") and locked = '" + CswConvert.ToDbVal( true ).ToString() + @"'"; return NodesSelect.getRecordCount( WhereClause ); } // GetLockedNodeCountForObjectClass()
private void _addObjClassToPropertySetPermission(DataTable JctPSOCTable, string ObjClassName, int PropertySetId) { DataRow NewJctPSOCRow = JctPSOCTable.NewRow(); NewJctPSOCRow["objectclassid"] = _CswNbtSchemaModTrnsctn.MetaData.getObjectClassId(ObjClassName); NewJctPSOCRow["propertysetid"] = CswConvert.ToDbVal(PropertySetId); JctPSOCTable.Rows.Add(NewJctPSOCRow); }
/// <summary> /// Update logic /// </summary> public override void update() { CswNbtMetaDataObjectClass SizeOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.SizeClass ); CswNbtMetaDataNodeType SizeNt = SizeOc.FirstNodeType; if( null != SizeNt ) { CswNbtMetaDataNodeTypeProp InitialQuantityNtp = SizeNt.getNodeTypePropByObjectClassProp( CswNbtObjClassSize.PropertyName.InitialQuantity ); InitialQuantityNtp.Attribute1 = CswConvert.ToDbVal( true ).ToString(); } }
} // updatePropLayout() public void updatePropLayout(CswEnumNbtLayoutType LayoutType, CswNbtMetaDataNodeTypeProp Prop, CswNbtMetaDataNodeTypeProp InsertAfterProp, bool DoMove) { bool Added = false; if (DoMove) { removePropFromLayout(LayoutType, Prop, Int32.MinValue); } if (InsertAfterProp != null) { Dictionary <Int32, NodeTypeLayout> InsertAfterPropLayouts = getLayout(LayoutType, InsertAfterProp, null); if (InsertAfterPropLayouts.Values.Count > 0) { foreach (Int32 TabId in InsertAfterPropLayouts.Keys) { NodeTypeLayout InsertAfterPropLayout = InsertAfterPropLayouts[TabId]; // Make space for the new prop CswTableUpdate LayoutUpdate = _CswNbtMetaDataResources.CswNbtResources.makeCswTableUpdate("makeSpaceForProp_Update", "nodetype_layout"); string WhereClause = "where layouttype = '" + LayoutType.ToString() + "' and nodetypeid = " + InsertAfterProp.NodeTypeId.ToString(); if (TabId != Int32.MinValue && LayoutType == CswEnumNbtLayoutType.Edit) { WhereClause += " and nodetypetabsetid = " + TabId.ToString(); } DataTable LayoutTable = LayoutUpdate.getTable(WhereClause); foreach (DataRow Row in LayoutTable.Rows) { if (CswConvert.ToInt32(Row["display_column"]) == InsertAfterPropLayout.DisplayColumn && CswConvert.ToInt32(Row["display_row"]) > InsertAfterPropLayout.DisplayRow) { Row["display_row"] = CswConvert.ToDbVal(CswConvert.ToInt32(Row["display_row"]) + 1); } } LayoutUpdate.update(LayoutTable); // Add new prop to the layout updatePropLayout(LayoutType, Prop.NodeTypeId, Prop, false, TabId, InsertAfterPropLayout.DisplayRow + 1, InsertAfterPropLayout.DisplayColumn, InsertAfterPropLayout.TabGroup); Added = true; } // foreach( Int32 TabId in InsertAfterPropLayouts.Keys ) } // if( InsertAfterPropLayouts.Values.Count > 0 ) } // if( InsertAfterProp != null ) if (false == Added) { // Just add it somewhere updatePropLayout(LayoutType, Prop.NodeTypeId, Prop, false, Prop.getNodeType().getFirstNodeTypeTab().TabId); } if (_Cache.ContainsKey(Prop.NodeTypeId)) { _Cache.Remove(Prop.NodeTypeId); } } // updatePropLayout()
public void ToggleScheduledRule(CswEnumNbtScheduleRuleNames RuleName, bool Disabled) { CswTableUpdate RuleUpdate = _CswNbtResources.makeCswTableUpdate("toggleScheduledRule", "scheduledrules"); DataTable RuleDt = RuleUpdate.getTable("where lower(rulename) = '" + RuleName.ToString().ToLower() + "'"); foreach (DataRow row in RuleDt.Rows) { row["disabled"] = CswConvert.ToDbVal(Disabled); } RuleUpdate.update(RuleDt); }
private void _makeNewStatisticsNodeTypesRow(DataTable Table, Int32 StatisticsId, Int32 NodeTypeId, Int32 HitCount, string Action) { DataRow Row = Table.NewRow(); Row["statisticsid"] = CswConvert.ToDbVal(StatisticsId); Row["nodetypeid"] = CswConvert.ToDbVal(NodeTypeId); Row["nodetypename"] = _CswNbtResources.MetaData.getNodeType(NodeTypeId).NodeTypeName; Row["hitcount"] = CswConvert.ToDbVal(HitCount); Row["action"] = Action; Table.Rows.Add(Row); }
private void _makeNewStatisticsActionsRow(DataTable Table, Int32 StatisticsId, Int32 ActionId, Int32 HitCount, string Action) { DataRow Row = Table.NewRow(); Row["statisticsid"] = CswConvert.ToDbVal(StatisticsId); Row["actionid"] = ActionId.ToString(); Row["actionname"] = _CswNbtResources.Actions[ActionId].Name; Row["hitcount"] = CswConvert.ToDbVal(HitCount); Row["action"] = Action; Table.Rows.Add(Row); }
} // ValueForNameTemplate public static string toLogicalGestalt(CswEnumTristate Tristate) { object val = CswConvert.ToDbVal(Tristate); string Ret = string.Empty; if (val != DBNull.Value) { Ret = CswConvert.ToDisplayString(Tristate); } return(Ret); }
public override void update() { CswNbtMetaDataFieldType FormulaFT = _CswNbtSchemaModTrnsctn.MetaData.getFieldType( CswEnumNbtFieldType.Formula ); CswTableUpdate FieldTypeUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31076_update_fieldtypes", "field_types" ); DataTable FieldTypeTable = FieldTypeUpdate.getTable( "fieldtypeid", FormulaFT.FieldTypeId ); if( FieldTypeTable.Rows.Count > 0 ) { FieldTypeTable.Rows[0]["searchable"] = CswConvert.ToDbVal( true ); FieldTypeUpdate.update( FieldTypeTable ); } } // update()
}//createBiologicalOC() private void _linkBiologicalOCtoPS() { //Update the NodeTypeProps' OCPs to point to Biological's OCPs - if NonChemical does not have an OCP with the given NTP name, the NTP is deleted. CswNbtMetaDataObjectClass BiologicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.BiologicalClass ); // Populate jct_propertyset_objectclass CswTableUpdate JctOCUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28160_jct_update", "jct_propertyset_objectclass" ); DataTable JctOCTable = JctOCUpdate.getEmptyTable(); DataRow NewRow = JctOCTable.NewRow(); NewRow["objectclassid"] = BiologicalOC.ObjectClassId; NewRow["propertysetid"] = CswConvert.ToDbVal( _CswNbtSchemaModTrnsctn.MetaData.getPropertySetId( CswEnumNbtPropertySetName.MaterialSet ) ); JctOCTable.Rows.Add( NewRow ); JctOCUpdate.update( JctOCTable ); // Populate jct_propertyset_objectclassprop CswTableUpdate JctOCPUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "28160_jct2_update", "jct_propertyset_ocprop" ); DataTable JctOCPTable = JctOCPUpdate.getEmptyTable(); foreach( CswNbtMetaDataObjectClassProp ObjectClassProp in BiologicalOC.getObjectClassProps() ) { string[] PropsToAdd = new string[] { CswNbtObjClassBiological.PropertyName.TradeName, CswNbtObjClassBiological.PropertyName.LegacyMaterialId, CswNbtObjClassBiological.PropertyName.ApprovedForReceiving, CswNbtObjClassBiological.PropertyName.C3ProductId, CswNbtObjClassBiological.PropertyName.ContainerExpirationLocked, CswNbtObjClassBiological.PropertyName.MaterialId, CswNbtObjClassBiological.PropertyName.Supplier, CswNbtObjClassBiological.PropertyName.PartNumber, CswNbtObjClassBiological.PropertyName.Receive, CswNbtObjClassBiological.PropertyName.Request, CswNbtObjClassBiological.PropertyName.IsConstituent, CswNbtObjClassBiological.PropertyName.Documents, CswNbtObjClassBiological.PropertyName.Synonyms }; if( PropsToAdd.Contains( ObjectClassProp.PropName ) ) { NewRow = JctOCPTable.NewRow(); NewRow["objectclasspropid"] = ObjectClassProp.PropId; NewRow["propertysetid"] = CswConvert.ToDbVal( _CswNbtSchemaModTrnsctn.MetaData.getPropertySetId( CswEnumNbtPropertySetName.MaterialSet ) ); JctOCPTable.Rows.Add( NewRow ); }// if the prop is a PSP, insert a jct record } // foreach property in the biological class JctOCPUpdate.update( JctOCPTable ); }//linkBiologicalOCtoPS
public void ToggleAction(bool showInList, CswEnumNbtActionName actionName) { string databaseActionName = CswNbtAction.ActionNameEnumToString(actionName); CswTableUpdate actionTU = _CswNbtResources.makeCswTableUpdate("toggleActionVisibility", "actions"); DataTable actionsDT = actionTU.getTable("where actionname = '" + databaseActionName + "'"); foreach (DataRow row in actionsDT.Rows) { row["showinlist"] = CswConvert.ToDbVal(showInList); } actionTU.update(actionsDT); }
public override void update() { CswNbtMetaDataObjectClass MailReportOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.MailReportClass ); foreach( CswNbtMetaDataNodeType MailReportNT in MailReportOC.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp DueDateIntervalNTP = MailReportNT.getNodeTypePropByObjectClassProp( CswNbtObjClassMailReport.PropertyName.DueDateInterval ); if( null != DueDateIntervalNTP ) { DueDateIntervalNTP.Attribute1 = CswConvert.ToDbVal( true ).ToString(); } } }
public override void update() { CswTableUpdate TableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "DisableCAFImportRule_30913", "scheduledrules" ); DataTable ScheduleRules = TableUpdate.getTable( "where rulename='" + CswEnumNbtScheduleRuleNames.CAFImport + "'" ); if( ScheduleRules.Rows.Count > 0 ) { ScheduleRules.Rows[0]["disabled"] = CswConvert.ToDbVal( true ); ScheduleRules.Rows[0]["reprobate"] = CswConvert.ToDbVal( false ); ScheduleRules.Rows[0]["StatusMessage"] = CswConvert.ToDbVal( "" ); TableUpdate.update( ScheduleRules ); } } // update()
public void threadCallBack(ICswResources CswResources) { _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running; CswNbtResources CswNbtResources = (CswNbtResources)CswResources; //CswNbtResources.AuditContext = "Scheduler Task: Update MTBF"; CswNbtResources.AuditContext = "Scheduler Task: " + RuleName; if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus) { try { // BZ 6779 // Set all MTBF fields pendingupdate = 1 Int32 MTBFId = CswNbtResources.MetaData.getFieldType(ChemSW.Nbt.MetaData.CswEnumNbtFieldType.MTBF).FieldTypeId; CswTableSelect NTPSelect = CswNbtResources.makeCswTableSelect("UpdateMTBF_NTP_Select", "nodetype_props"); DataTable NTPTable = NTPSelect.getTable("fieldtypeid", MTBFId); string NTPIds = string.Empty; foreach (DataRow NTPRow in NTPTable.Rows) { if (NTPIds != string.Empty) { NTPIds += ","; } NTPIds += CswConvert.ToInt32(NTPRow["nodetypepropid"]); } if (NTPIds != string.Empty) { CswTableUpdate JNPUpdate = CswNbtResources.makeCswTableUpdate("UpdateMTBF_JNP_Update", "jct_nodes_props"); DataTable JNPTable = JNPUpdate.getTable("where nodetypepropid in (" + NTPIds + ")"); foreach (DataRow JNPRow in JNPTable.Rows) { JNPRow["pendingupdate"] = CswConvert.ToDbVal(true); } JNPUpdate.update(JNPTable); } _CswScheduleLogicDetail.StatusMessage = "Completed without error"; _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; //last line }//try catch (Exception Exception) { _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicNbtUpdtMTBF::GetUpdatedItems() exception: " + Exception.Message + "; " + Exception.StackTrace; CswNbtResources.logError(new CswDniException(_CswScheduleLogicDetail.StatusMessage)); _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed; } //catch } //if we're not shutting down } //threadCallBack()
/// <summary> /// Enable/disable a module in an ORNy safe fashion /// </summary> private void _updateModule(CswEnumNbtModuleName Module, bool Enable) { int moduleid = GetModuleId(Module); if (false == _RulesAreInitialized) { initModules(); } bool ModuleEnabled = false; if (Enable) { string ErrorMsg = _ModuleRules[Module].CanModuleBeEnabled(); if (false == String.IsNullOrEmpty(ErrorMsg)) { throw new CswDniException(CswEnumErrorType.Warning, "The " + Module.Value + " module cannot be enabled because: " + ErrorMsg, "The Module was not able to be enabled because an error message was returned from the CanModuleBeEnabled functuon"); } } CswTableUpdate ModuleUpdate = _CswNbtResources.makeCswTableUpdate("ModuleManager.UpdateModule", "modules"); DataTable ModulesTbl = ModuleUpdate.getTable("moduleid", moduleid); foreach (DataRow row in ModulesTbl.Rows) //should only ever get one row { ModuleEnabled = CswConvert.ToBoolean(row["enabled"]); row["enabled"] = CswConvert.ToDbVal(Enable); _ModuleRules[Module].Enabled = Enable; } //Case 31546 - if we're DISABLING a module, we have to call Disable() BEFORE reseting available metadata or metadata objects hidden by the module will not be fetchable in the toggle events if (false == Enable && ModuleEnabled) { _ModuleRules[Module].Disable(); } ModuleUpdate.update(ModulesTbl); _CswNbtResources.MetaData.ResetEnabledNodeTypes(); _CswNbtResources.finalize(); _CswNbtResources.MetaData.refreshAll(); //Case 31546 - if we ENABLING a module, we have to call Enable() AFTER reseting available metadata or modules won't be able to find their child metadata objects if (Enable && false == ModuleEnabled) { _ModuleRules[Module].Enable(); } //We have to clear Session data or the view selects recent views will have non-accesible views and break _CswNbtResources.SessionDataMgr.removeAllSessionData(_CswNbtResources.Session.SessionId); }
/// <summary> /// Save an action to the session data collection. /// </summary> public CswNbtSessionDataId saveSessionData( CswNbtAction Action, bool IncludeInQuickLaunch, bool KeepInQuickLaunch = false ) { CswTableUpdate SessionViewsUpdate = _CswNbtResources.makeCswTableUpdate( "saveSessionView_update", SessionDataTableName ); DataTable SessionViewTable = null; SessionViewTable = SessionViewsUpdate.getTable( SessionDataColumn_ActionId, Action.ActionId, "where sessionid = '" + SessionId + "'", false ); DataRow SessionViewRow = _getSessionViewRow( SessionViewTable, Action.DisplayName, CswEnumNbtSessionDataType.Action, IncludeInQuickLaunch && Action.ShowInList, KeepInQuickLaunch ); SessionViewRow[SessionDataColumn_ActionId] = CswConvert.ToDbVal( Action.ActionId ); SessionViewsUpdate.update( SessionViewTable ); return new CswNbtSessionDataId( CswConvert.ToInt32( SessionViewRow[SessionDataColumn_PrimaryKey] ) ); } // saveSessionData(Action)