コード例 #1
0
        } // addModuleWhereClause()

        /// <summary>
        ///  Add an ICswNbtMetaDataObject to the Cache
        ///  (for use by MetaData for newly created objects)
        /// </summary>
        public void AddToCache(ICswNbtMetaDataObject NewObj)
        {
            if (false == _Cache.ContainsKey(NewObj.UniqueId))
            {
                _Cache.Add(NewObj.UniqueId, NewObj);
            }
        }
コード例 #2
0
        }     // 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);
        }
コード例 #3
0
        public ICswNbtMetaDataObject getByPk(Int32 Pk, bool BypassModuleCheck = false)
        {
            ICswNbtMetaDataObject ret = null;

            if (Pk != Int32.MinValue)
            {
                if (_ByPk == null)
                {
                    _ByPk = new Dictionary <Int32, ICswNbtMetaDataObject>();
                }
                if (false == _ByPk.ContainsKey(Pk) || null == _ByPk[Pk])
                {
                    string WhereClause = string.Empty;
                    if (false == BypassModuleCheck)
                    {
                        addModuleWhereClause(ref WhereClause);
                    }

                    DataTable Table = _TableUpdate.getTable(_PkColumnName, Pk, WhereClause, false);
                    if (Table.Rows.Count > 0)
                    {
                        _ByPk[Pk] = _makeObj(Table.Rows[0]);
                    }
                    else
                    {
                        _ByPk[Pk] = null;
                    }
                }
                ret = _ByPk[Pk];
            } // if( Pk != Int32.MinValue )
            return(ret);
        }     // getByPk()
コード例 #4
0
        private bool _addSystemViewFilterRecursive(IEnumerable <CswNbtViewRelationship> Relationships, SystemViewPropFilterDefinition FilterDefinition, ICswNbtMetaDataDefinitionObject MatchObj = null)
        {
            bool Ret = false;
            ICswNbtMetaDataDefinitionObject ExpectedObjectClass = MatchObj ?? _EnforceObjectClassRelationship;

            foreach (CswNbtViewRelationship PotentialSystemViewRelationship in Relationships)
            {
                if (null == ExpectedObjectClass || PotentialSystemViewRelationship.SecondMatches(MatchObj))
                {
                    Ret = true;
                    if (null != FilterDefinition.ObjectClassProp)
                    {
                        SystemView.AddViewPropertyAndFilter(PotentialSystemViewRelationship,
                                                            FilterDefinition.ObjectClassProp,
                                                            FilterDefinition.FilterValue,
                                                            FilterMode: FilterDefinition.FilterMode,
                                                            SubFieldName: FilterDefinition.SubFieldName,
                                                            ShowInGrid: FilterDefinition.ShowInGrid);
                    }
                    else if (FilterDefinition.FieldType == CswEnumNbtFieldType.Barcode)
                    {
                        ICswNbtMetaDataObject Object = PotentialSystemViewRelationship.SecondMetaDataDefinitionObject();
                        SystemView.AddViewPropertyByFieldType(PotentialSystemViewRelationship, Object, FilterDefinition.FieldType);
                    }
                }
                if (PotentialSystemViewRelationship.ChildRelationships.Count > 0)
                {
                    Ret = Ret || _addSystemViewFilterRecursive(PotentialSystemViewRelationship.ChildRelationships, FilterDefinition, MatchObj);
                }
            }
            return(Ret);
        }
コード例 #5
0
        } // getWhere(Where,Date)

        public ICswNbtMetaDataObject getWhereFirst(string WhereClause, CswDateTime Date = null, bool BypassModuleCheck = false)
        {
            ICswNbtMetaDataObject ret = null;
            Collection <ICswNbtMetaDataObject> Coll = getWhere(WhereClause, Date, BypassModuleCheck);

            if (Coll.Count > 0)
            {
                ret = Coll[0];
            }
            return(ret);
        } // getWhereFirst()
コード例 #6
0
        }         // addSingleNodeProp()

        private void _getRelationshipSecondTypeRecursive(Collection <CswNbtViewRelationship> Relationships,
                                                         Dictionary <Int32, Int32> SecondTypes)
        {
            foreach (CswNbtViewRelationship Relationship in Relationships)
            {
                if (Relationship.ChildRelationships.Count == 0)
                {
                    ICswNbtMetaDataObject MetaObj = Relationship.SecondMetaDataDefinitionObject();
                    if (MetaObj.UniqueIdFieldName == CswNbtMetaDataObjectClass.MetaDataUniqueType)
                    {
                        if (SecondTypes.Count == 0 ||
                            SecondTypes.ContainsValue(Relationship.SecondId))
                        {
                            CswNbtMetaDataObjectClass ObjClass = _CswNbtResources.MetaData.getObjectClass(MetaObj.UniqueId);
                            foreach (CswNbtMetaDataNodeType NodeType in ObjClass.getLatestVersionNodeTypes())
                            {
                                if (false == SecondTypes.ContainsKey(NodeType.NodeTypeId))
                                {
                                    SecondTypes.Add(NodeType.NodeTypeId, Relationship.SecondId);
                                }
                            }
                        }
                    }
                    else
                    {
                        CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(MetaObj.UniqueId);
                        if (null != NodeType &&
                            false == SecondTypes.ContainsKey(NodeType.getNodeTypeLatestVersion().NodeTypeId) &&
                            (SecondTypes.Count == 0 || SecondTypes.ContainsValue(NodeType.ObjectClassId)))
                        {
                            SecondTypes.Add(NodeType.getNodeTypeLatestVersion().NodeTypeId, NodeType.ObjectClassId);
                        }
                    }
                }
                else
                {
                    _getRelationshipSecondTypeRecursive(Relationship.ChildRelationships, SecondTypes);
                }
            }
        }
コード例 #7
0
        private ICswNbtMetaDataObject _makeObj(DataRow Row, CswDateTime Date = null, bool useCache = true)
        {
            ICswNbtMetaDataObject ret = null;
            Int32 PkValue             = CswConvert.ToInt32(Row[_PkColumnName]);

            if (useCache && _Cache.ContainsKey(PkValue))
            {
                // In order to guarantee only one reference per row, use the existing reference
                // and, to prevent dirty writes, remove the row
                ret = _Cache[PkValue];
                Row.Table.Rows.Remove(Row);
            }
            else
            {
                ret = _MetaDataObjectMaker(_CswNbtMetaDataResources, Row, Date);
                if (useCache)
                {
                    _Cache[PkValue] = ret;
                }
            }
            return(ret);
        }