} // getByPk() public ICswNbtMetaDataObject getByPk(Int32 Pk, CswDateTime Date, bool BypassModuleCheck = false) { ICswNbtMetaDataObject ret = null; if (false == CswTools.IsDate(Date)) { ret = getByPk(Pk, BypassModuleCheck); } else { string Sql = "select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, _TableSelect.TableName, Date) + " " + _TableSelect.TableName; string Where = " where " + _PkColumnName + " = " + Pk.ToString(); if (false == BypassModuleCheck) { addModuleWhereClause(ref Where); } Sql += Where; CswArbitrarySelect AuditSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("MetaDataCollectionImpl_getbypk_audit_select", Sql); DataTable Table = AuditSelect.getTable(); if (Table.Rows.Count > 0) { ret = _makeObj(Table.Rows[0], Date, useCache: false); } } return(ret); }
} // getLayout() /// <summary> /// Returns a layout for a property on a tab. /// If edit, be sure to supply a valid TabId. /// </summary> public NodeTypeLayout getLayout(CswEnumNbtLayoutType LayoutType, Int32 NodeTypeId, Int32 PropId, Int32 TabId, CswDateTime Date) { NodeTypeLayout ret = null; if (false == CswTools.IsDate(Date)) { _CacheLayout(NodeTypeId); ret = _Cache[NodeTypeId].FirstOrDefault(Layout => Layout.LayoutType == LayoutType && Layout.PropId == PropId && (LayoutType != CswEnumNbtLayoutType.Edit || Layout.TabId == TabId)); } else { string Sql = @"select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, "nodetype_layout", Date) + " where nodetypeid = " + NodeTypeId + " " + " and layouttype = '" + LayoutType.ToString() + "' " + " and nodetypepropid = " + PropId + " "; if (LayoutType == CswEnumNbtLayoutType.Edit) { Sql += " and nodetypetabsetid = " + TabId; } CswArbitrarySelect LayoutSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("getLayout_Audit_Select", Sql); DataTable LayoutTable = LayoutSelect.getTable(); if (LayoutTable.Rows.Count > 0) { ret = new NodeTypeLayout(LayoutTable.Rows[0]); } } return(ret); } // getLayout()
/// <summary> /// Returns a dictionary of layout by tab /// </summary> public Dictionary <Int32, NodeTypeLayout> getLayout(CswEnumNbtLayoutType LayoutType, Int32 NodeTypeId, Int32 PropId, CswDateTime Date) { Dictionary <Int32, NodeTypeLayout> LayoutByTab = new Dictionary <Int32, NodeTypeLayout>(); if (false == CswTools.IsDate(Date)) { _CacheLayout(NodeTypeId); foreach (NodeTypeLayout Layout in _Cache[NodeTypeId].Where(Layout => Layout.LayoutType == LayoutType && Layout.PropId == PropId)) { LayoutByTab[Layout.TabId] = Layout; } } else { string Sql = @"select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, "nodetype_layout", Date) + " where nodetypeid = " + NodeTypeId + " " + " and layouttype = '" + LayoutType.ToString() + "' " + " and nodetypepropid = " + PropId; CswArbitrarySelect LayoutSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("getLayout_Audit_Select", Sql); DataTable LayoutTable = LayoutSelect.getTable(); foreach (DataRow LayoutRow in LayoutTable.Rows) { NodeTypeLayout Layout = new NodeTypeLayout(LayoutRow); LayoutByTab.Add(Layout.TabId, Layout); } } return(LayoutByTab); } // getLayout()
protected override void afterPopulateProps() { if (Type.RelatedNodeId != null) { CswNbtNode TypeNode = _CswNbtResources.Nodes[Type.RelatedNodeId]; if (TypeNode != null) { CswNbtObjClassEquipmentType TypeNodeAsType = (CswNbtObjClassEquipmentType)TypeNode; CswDelimitedString PartsString = new CswDelimitedString('\n'); PartsString.FromString(TypeNodeAsType.Parts.Text.Replace("\r", "")); this.Parts.YValues = PartsString; } } if (false == CswTools.IsDate(_Date)) { SyncEquipmentToAssembly(); } }//afterPopulateProps()
}//delete() public void fill() { if (NodeSpecies == CswEnumNbtNodeSpecies.Plain) { //bool NodeInfoFetched = false; if (CswTools.IsPrimaryKey(NodeId) && (NodeTypeId <= 0 || NodeName == String.Empty)) { DataTable NodesTable = null; if (CswTools.IsDate(_Date)) { string NodesSql = "select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtResources, "nodes", _Date, NodeId.PrimaryKey); CswArbitrarySelect NodesTableSelect = _CswNbtResources.makeCswArbitrarySelect("fetchNodeInfo_Select", NodesSql); NodesTable = NodesTableSelect.getTable(); } else { CswTableSelect NodesTableSelect = _CswNbtResources.makeCswTableSelect("CswNbtNode.fill_nodes", "nodes"); NodesTable = NodesTableSelect.getTable("nodeid", NodeId.PrimaryKey); } if (NodesTable.Rows.Count > 0) { read(NodesTable.Rows[0]); RelationalId = new CswPrimaryKey(NodesTable.Rows[0]["relationaltable"].ToString(), CswConvert.ToInt32(NodesTable.Rows[0]["relationalid"])); } CswTimer Timer = new CswTimer(); if (getNodeType() != null) { Properties.fill(false); } _CswNbtResources.logTimerResult("Filled in node property data for node (" + NodeId.ToString() + "): " + NodeName, Timer.ElapsedDurationInSecondsAsString); if (CswTools.IsDate(_Date)) { setReadOnly(value: true, SaveToDb: false); } } } _NodeModificationState = CswEnumNbtNodeModificationState.Unchanged; }//fill()
} // getWhere(Where) public Collection <ICswNbtMetaDataObject> getWhere(string Where, CswDateTime Date, bool BypassModuleCheck = false) { Collection <ICswNbtMetaDataObject> ret = null; if (false == CswTools.IsDate(Date)) { ret = getWhere(Where, BypassModuleCheck); } else { string Sql = "select * from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, _TableSelect.TableName, Date) + " " + _TableSelect.TableName + " " + Where; if (false == BypassModuleCheck) { addModuleWhereClause(ref Sql); } CswArbitrarySelect AuditSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("MetaDataCollectionImpl_getWhere_audit_select", Sql); DataTable Table = AuditSelect.getTable(); ret = _makeObjs(Table, Date, useCache: false); } return(ret); } // getWhere(Where,Date)
/// <summary> /// Fetch a node from the collection. If the node isn't loaded from the database already, it will be. /// NodeTypeId is only required if you don't provide a good NodeId (so that we can still fetch Property info). /// </summary> /// <param name="NodeId">Primary Key of Node (if not provided, make sure NodeTypeId is)</param> /// <param name="NodeTypeId">Primary Key of NodeTypeId (only required if NodeId is invalid)</param> /// <param name="Species"><see cref="CswEnumNbtNodeSpecies" /></param> /// <param name="Date"></param> public CswNbtNode GetNode(CswPrimaryKey NodeId, Int32 NodeTypeId, CswEnumNbtNodeSpecies Species, CswDateTime Date) { //bz # 7816: Return NULL rather than throwing CswNbtNode Node = null; if (NodeId != null && NodeId.PrimaryKey != Int32.MinValue) // BZ 8753 { NodeHashKey HashKey = new NodeHashKey(NodeId, Species); if (false == CswTools.IsDate(Date) && _NodeHash.ContainsKey(HashKey)) { Node = (CswNbtNode)_NodeHash[HashKey]; } else { Node = _getExistingNode(HashKey, NodeTypeId, Date); //if( false == CswTools.IsDate( Date ) && null != Node ) //{ // Node = (CswNbtNode) _NodeHash[HashKey]; //} } } return(Node); }//GetNode()
} // getPks(Where) public Collection <Int32> getPks(string Where, CswDateTime Date) { Collection <Int32> ret = null; if (false == CswTools.IsDate(Date)) { ret = getPks(Where); } else { string Sql = "select " + _PkColumnName + " from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, _TableSelect.TableName, Date) + " " + _TableSelect.TableName + " "; addModuleWhereClause(ref Where); Sql += Where; CswArbitrarySelect AuditSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("MetaDataCollectionImpl_getpks_audit_select", Sql); DataTable Table = AuditSelect.getTable(); ret = new Collection <Int32>(); foreach (DataRow Row in Table.Rows) { ret.Add(CswConvert.ToInt32(Row[_PkColumnName])); } } return(ret); } // getPks(Where)