예제 #1
0
 private NotSupportedException CreateUnsupportedNonAttributedCardinalityException(
     esriRelCardinality cardinality)
 {
     return(new NotSupportedException(
                string.Format(
                    "Unsupported cardinality '{0}' for non-attributed relationship class: {1}",
                    cardinality, DatasetUtils.GetName(_relClass))));
 }
예제 #2
0
 IRelationshipClass IFeatureWorkspace.CreateRelationshipClass(
     string relClassName, IObjectClass originClass, IObjectClass destinationClass,
     string forwardLabel, string backwardLabel,
     esriRelCardinality cardinality, esriRelNotification notification, bool isComposite,
     bool isAttributed, IFields relAttrFields, string originPrimaryKey,
     string destPrimaryKey, string originForeignKey, string destForeignKey)
 {
     throw new NotImplementedException();
 }
 public RelationshipClassFieldAttribute(string fieldName, string relationshipClass, string controllerNamespace,
                                        esriFieldType fieldType, int position)
     : base(fieldName, fieldType, position)
 {
     RelationshipClassName = relationshipClass;
     ControllerNamespace   = controllerNamespace;
     _isPrimary            = false;
     _isForeign            = true;
     Cardinality           = esriRelCardinality.esriRelCardinalityOneToMany;
 }
 public RelationshipClass(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this._cardinality           = (esriRelCardinality)Enum.Parse(typeof(esriRelCardinality), info.GetString(RelationshipClass.CARDINALITY), true);
     this._notification          = (esriRelNotification)Enum.Parse(typeof(esriRelNotification), info.GetString(RelationshipClass.NOTIFICATION), true);
     this._isComposite           = info.GetBoolean(RelationshipClass.ISCOMPOSITE);
     this._originClassNames      = info.GetString(RelationshipClass.ORIGINCLASSNAMES);
     this._destinationClassNames = info.GetString(RelationshipClass.DESTINATIONCLASSNAMES);
     this._keyType            = (esriRelKeyType)Enum.Parse(typeof(esriRelKeyType), info.GetString(RelationshipClass.KEYTYPE), true);
     this._classKey           = (esriRelClassKey)Enum.Parse(typeof(esriRelClassKey), info.GetString(RelationshipClass.CLASSKEY), true);
     this._forwardPathLabel   = info.GetString(RelationshipClass.FORWARDPATHLABEL);
     this._backwardPathLabel  = info.GetString(RelationshipClass.BACKWARDPATHLABEL);
     this._isReflexive        = info.GetBoolean(RelationshipClass.ISREFLEXIVE);
     this._originPrimary      = info.GetString(RelationshipClass.ORIGINPRIMARY);
     this._originForeign      = info.GetString(RelationshipClass.ORIGINFOREIGN);
     this._destinationPrimary = info.GetString(RelationshipClass.DESTINATIONPRIMARY);
     this._destinationForeign = info.GetString(RelationshipClass.DESTINATIONFOREIGN);
     this._relationshipRules  = (List <RelationshipRule>)info.GetValue(RelationshipClass.RELATIONSHIPRULES, typeof(List <RelationshipRule>));
 }
예제 #5
0
 public IRelationshipClass CreateRelationshipClass(string relClassName,
                                                   IObjectClass OriginClass,
                                                   IObjectClass DestinationClass,
                                                   string forwardLabel,
                                                   string backwardLabel,
                                                   esriRelCardinality Cardinality,
                                                   esriRelNotification
                                                   Notification,
                                                   bool IsComposite,
                                                   bool IsAttributed,
                                                   IFields relAttrFields,
                                                   string OriginPrimaryKey,
                                                   string destPrimaryKey,
                                                   string OriginForeignKey,
                                                   string destForeignKey)
 {
     throw new NotImplementedException();
 }
예제 #6
0
 private static void old_acctor_mc()
 {
     m_pFeatureDataset = null;
     m_pWorkspace      = null;
     relClassName      = "";
     OriginClass       = null;
     DestinationClass  = null;
     forwardLabel      = "";
     backwardLabel     = "";
     Cardinality       = esriRelCardinality.esriRelCardinalityOneToOne;
     Notification      = esriRelNotification.esriRelNotificationNone;
     IsComposite       = false;
     IsAttributed      = false;
     relAttrFields     = new FieldsClass();
     OriginPrimaryKey  = "";
     destPrimaryKey    = "";
     OriginForeignKey  = "";
     destForeignKey    = "";
 }
예제 #7
0
        protected override string GetJoinCondition(JoinType joinType)
        {
            if (RelationshipClassUtils.UsesRelationshipTable(_relClass))
            {
                return(GetBridgeTableJoinCondition(joinType));
            }

            // deal with non-attributed relationship classes

            esriRelCardinality cardinality = _relClass.Cardinality;

            switch (cardinality)
            {
            case esriRelCardinality.esriRelCardinalityOneToOne:
                return(GetForeignKeyJoinCondition(joinType));

            case esriRelCardinality.esriRelCardinalityOneToMany:
                return(GetForeignKeyJoinCondition(joinType));

            default:
                throw CreateUnsupportedNonAttributedCardinalityException(cardinality);
            }
        }
        public RelationshipClass(RelationshipClass prototype) : base(prototype)
        {
            this._cardinality           = prototype.Cardinality;
            this._notification          = prototype.Notification;
            this._isComposite           = prototype.IsComposite;
            this._originClassNames      = prototype.OriginClassName;
            this._destinationClassNames = prototype.DestinationClassName;
            this._keyType            = prototype.KeyType;
            this._classKey           = prototype.ClassKey;
            this._forwardPathLabel   = prototype.ForwardPathLabel;
            this._backwardPathLabel  = prototype.BackwardPathLabel;
            this._isReflexive        = prototype.IsReflexive;
            this._originPrimary      = prototype.OriginPrimary;
            this._originForeign      = prototype.OriginForeign;
            this._destinationPrimary = prototype.DestinationPrimary;
            this._destinationForeign = prototype.DestinationForeign;

            // Add Cloned Relationship Rules
            this._relationshipRules = new List <RelationshipRule>();
            foreach (RelationshipRule relationshipRule in prototype.RelationshipRules)
            {
                this._relationshipRules.Add((RelationshipRule)relationshipRule.Clone());
            }
        }
        //
        // CONSTRUCTOR
        //
        public RelationshipClass(IXPathNavigable path) : base(path)
        {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // Get Model
            SchemaModel model = (SchemaModel)base.Container;

            // <Cardinality></Cardinality>
            XPathNavigator navigatorCardinality = navigator.SelectSingleNode(Xml.CARDINALITY);

            if (navigatorCardinality != null)
            {
                this._cardinality = (esriRelCardinality)Enum.Parse(typeof(esriRelCardinality), navigatorCardinality.Value, true);
            }

            // <Notification></Notification>
            XPathNavigator navigatorNotification = navigator.SelectSingleNode(Xml.NOTIFICATION);

            if (navigatorNotification != null)
            {
                this._notification = (esriRelNotification)Enum.Parse(typeof(esriRelNotification), navigatorNotification.Value, true);
            }

            // <IsComposite>false</IsComposite>
            XPathNavigator navigatorIsComposite = navigator.SelectSingleNode(Xml.ISCOMPOSITE);

            if (navigatorIsComposite != null)
            {
                this._isComposite = navigatorIsComposite.ValueAsBoolean;
            }

            // <OriginClassNames></OriginClassNames>
            XPathNavigator navigatorOriginClassNames = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.ORIGINCLASSNAMES, Xml.NAME)); //  "OriginClassNames/Name");

            if (navigatorOriginClassNames != null)
            {
                this._originClassNames = navigatorOriginClassNames.Value;
            }

            // <DestinationClassNames></DestinationClassNames>
            XPathNavigator navigatorDestinationClassNames = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.DESTINATIONCLASSNAMES, Xml.NAME)); //"DestinationClassNames/Name");

            if (navigatorDestinationClassNames != null)
            {
                this._destinationClassNames = navigatorDestinationClassNames.Value;
            }

            // <KeyType></KeyType>
            XPathNavigator navigatorKeyType = navigator.SelectSingleNode(Xml.KEYTYPE);

            if (navigatorKeyType != null)
            {
                this._keyType = (esriRelKeyType)Enum.Parse(typeof(esriRelKeyType), navigatorKeyType.Value, true);
            }

            // <ClassKey></ClassKey>
            XPathNavigator navigatorClassKey = navigator.SelectSingleNode(Xml.CLASSKEY);

            if (navigatorClassKey != null)
            {
                this._classKey = (esriRelClassKey)Enum.Parse(typeof(esriRelClassKey), navigatorClassKey.Value, true);
            }

            // <ForwardPathLabel></ForwardPathLabel>
            XPathNavigator navigatorForwardPathLabel = navigator.SelectSingleNode(Xml.FORWARDPATHLABEL);

            if (navigatorForwardPathLabel != null)
            {
                this._forwardPathLabel = navigatorForwardPathLabel.Value;
            }

            // <BackwardPathLabel></BackwardPathLabel>
            XPathNavigator navigatorBackwardPathLabel = navigator.SelectSingleNode(Xml.BACKWARDPATHLABEL);

            if (navigatorBackwardPathLabel != null)
            {
                this._backwardPathLabel = navigatorBackwardPathLabel.Value;
            }

            // <IsReflexive></IsReflexive>
            XPathNavigator navigatorIsReflexive = navigator.SelectSingleNode(Xml.ISREFLEXIVE);

            if (navigatorIsReflexive != null)
            {
                this._isReflexive = navigatorIsReflexive.ValueAsBoolean;
            }

            // <OriginClassKeys><RelationshipClassKey></RelationshipClassKey></OriginClassKeys>
            // <DestinationClassKeys><RelationshipClassKey></RelationshipClassKey></DestinationClassKeys>
            string            xpath = string.Format("{0}/{2} | {1}/{2}", Xml.ORIGINCLASSKEYS, Xml.DESTINATIONCLASSKEYS, Xml.RELATIONSHIPCLASSKEY);
            XPathNodeIterator interatorClassKeys = navigator.Select(xpath); // "OriginClassKeys/RelationshipClassKey | DestinationClassKeys/RelationshipClassKey");

            while (interatorClassKeys.MoveNext())
            {
                // Get <RelationshipClassKey>
                XPathNavigator navigatorClassKeys = interatorClassKeys.Current;

                // Get <KeyRole>
                XPathNavigator navigatorKeyRole = navigatorClassKeys.SelectSingleNode(Xml.KEYROLE);
                if (navigatorKeyRole == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(navigatorKeyRole.Value))
                {
                    continue;
                }
                string keyRole = navigatorKeyRole.Value;

                // Get <ObjectKeyName>
                XPathNavigator navigatorObjectKeyName = navigatorClassKeys.SelectSingleNode(Xml.OBJECTKEYNAME);
                if (navigatorObjectKeyName == null)
                {
                    continue;
                }

                // Set Relationship Keys
                if (keyRole == esriRelKeyRole.esriRelKeyRoleOriginPrimary.ToString())
                {
                    this._originPrimary = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleOriginForeign.ToString())
                {
                    this._originForeign = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleDestinationPrimary.ToString())
                {
                    this._destinationPrimary = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleDestinationForeign.ToString())
                {
                    this._destinationForeign = navigatorObjectKeyName.Value;
                }
            }

            // <RelationshipRules><RelationshipRule></RelationshipRule></RelationshipRules>
            this._relationshipRules = new List <RelationshipRule>();
            XPathNodeIterator interatorRelationshipRule = navigator.Select(string.Format("{0}/{1}", Xml.RELATIONSHIPRULES, Xml.RELATIONSHIPRULE)); // "RelationshipRules/RelationshipRule");

            while (interatorRelationshipRule.MoveNext())
            {
                // Get <RelationshipRule>
                XPathNavigator navigatorRelationshipRule = interatorRelationshipRule.Current;

                // Create Relationship Rule
                RelationshipRule relationshipRule = new RelationshipRule(navigatorRelationshipRule);

                // Add Rule to Collection
                this._relationshipRules.Add(relationshipRule);
            }
        }
예제 #10
0
        /// <summary>
        ///     Joins the specified foreign class with the source class to create an in memory relationship.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="foreignClass">The foreign class.</param>
        /// <param name="primaryKeyField">The primary key field.</param>
        /// <param name="foreignKeyField">The foreign key field.</param>
        /// <param name="cardinality">The cardinality.</param>
        /// <param name="name">The name.</param>
        /// <returns>
        ///     Returns a <see cref="IRelationshipClass" /> representing the relationship between the two classes.
        /// </returns>
        public static IRelationshipClass Join(this IObjectClass source, IObjectClass foreignClass, string primaryKeyField, string foreignKeyField, esriRelCardinality cardinality, string name)
        {
            var joinName = name ?? string.Format("{0}_{1}", ((IDataset)source).Name, ((IDataset)foreignClass).Name);

            var factory = new MemoryRelationshipClassFactory();

            return(factory.Open(joinName, source, primaryKeyField, foreignClass, foreignKeyField, "Forward", "Backward", cardinality));
        }
 public RelationshipClass(SerializationInfo info, StreamingContext context) : base(info, context) {
     this._cardinality = (esriRelCardinality)Enum.Parse(typeof(esriRelCardinality), info.GetString(RelationshipClass.CARDINALITY), true);
     this._notification = (esriRelNotification)Enum.Parse(typeof(esriRelNotification), info.GetString(RelationshipClass.NOTIFICATION), true);
     this._isComposite = info.GetBoolean(RelationshipClass.ISCOMPOSITE);
     this._originClassNames = info.GetString(RelationshipClass.ORIGINCLASSNAMES);
     this._destinationClassNames = info.GetString(RelationshipClass.DESTINATIONCLASSNAMES);
     this._keyType = (esriRelKeyType)Enum.Parse(typeof(esriRelKeyType), info.GetString(RelationshipClass.KEYTYPE), true);
     this._classKey = (esriRelClassKey)Enum.Parse(typeof(esriRelClassKey), info.GetString(RelationshipClass.CLASSKEY), true);
     this._forwardPathLabel = info.GetString(RelationshipClass.FORWARDPATHLABEL);
     this._backwardPathLabel = info.GetString(RelationshipClass.BACKWARDPATHLABEL);
     this._isReflexive = info.GetBoolean(RelationshipClass.ISREFLEXIVE);
     this._originPrimary = info.GetString(RelationshipClass.ORIGINPRIMARY);
     this._originForeign = info.GetString(RelationshipClass.ORIGINFOREIGN);
     this._destinationPrimary = info.GetString(RelationshipClass.DESTINATIONPRIMARY);
     this._destinationForeign = info.GetString(RelationshipClass.DESTINATIONFOREIGN);
     this._relationshipRules = (List<RelationshipRule>)info.GetValue(RelationshipClass.RELATIONSHIPRULES, typeof(List<RelationshipRule>));
 }
예제 #12
0
        private IList <string> GetTableNames(
            [NotNull] IRelationshipClass relationshipClass,
            [CanBeNull] out IFeatureClass baseFeatureClass,
            out int featureClassCount)
        {
            Assert.ArgumentNotNull(relationshipClass, nameof(relationshipClass));

            var result = new List <string>();

            IObjectClass originClass      = relationshipClass.OriginClass;
            IObjectClass destinationClass = relationshipClass.DestinationClass;

            var originFeatureClass      = originClass as IFeatureClass;
            var destinationFeatureClass = destinationClass as IFeatureClass;

            featureClassCount = GetInvolvedFeatureClassCount(relationshipClass);

            string originClassName = ((IDataset)originClass).Name;
            string destClassName   = ((IDataset)destinationClass).Name;
            string relClassName    = ((IDataset)relationshipClass).Name;

            esriRelCardinality cardinality = relationshipClass.Cardinality;

            if (RelationshipClassUtils.UsesRelationshipTable(relationshipClass))
            {
                // BUG in 9.3 SP1:
                // Geometries get assigned to wrong features if the order in table list
                // is not table, bridge-table, featureclass

                if (originFeatureClass != null && destinationFeatureClass != null)
                {
                    // if two feature classes are involved, the one that
                    // the shape field is taken from must be first in the list

                    baseFeatureClass = destinationFeatureClass;

                    result.Add(destClassName);
                    result.Add(relClassName);
                    result.Add(originClassName);
                }
                else if (originFeatureClass != null)
                {
                    baseFeatureClass = originFeatureClass;

                    result.Add(destClassName);
                    result.Add(relClassName);
                    result.Add(originClassName);
                }
                else if (destinationFeatureClass != null)
                {
                    baseFeatureClass = destinationFeatureClass;

                    result.Add(originClassName);
                    result.Add(relClassName);
                    result.Add(destClassName);
                }
                else
                {
                    // no feature class involved

                    baseFeatureClass = null;

                    result.Add(originClassName);
                    result.Add(relClassName);
                    result.Add(destClassName);
                }
            }
            else
            {
                // handle non-attributed relationships (i.e. fk is on destination table)
                switch (cardinality)
                {
                case esriRelCardinality.esriRelCardinalityOneToOne:
                case esriRelCardinality.esriRelCardinalityOneToMany:
                    if (originFeatureClass != null && destinationFeatureClass != null)
                    {
                        baseFeatureClass = destinationFeatureClass;

                        // TODO inverted. Not sure if appropriate for 1:n/1:1 relationships
                        result.Add(destClassName);
                        result.Add(originClassName);
                    }
                    else if (originFeatureClass != null)
                    {
                        baseFeatureClass = originFeatureClass;

                        result.Add(originClassName);
                        result.Add(destClassName);
                    }
                    else if (destinationFeatureClass != null)
                    {
                        baseFeatureClass = destinationFeatureClass;

                        // TODO inverted. Not sure if appropriate for 1:n/1:1 relationships
                        result.Add(destClassName);
                        result.Add(originClassName);
                    }
                    else
                    {
                        // no feature class is involved
                        baseFeatureClass = null;

                        result.Add(originClassName);
                        result.Add(destClassName);
                    }

                    break;

                default:
                    throw CreateUnsupportedNonAttributedCardinalityException(cardinality);
                }
            }

            return(result);
        }
예제 #13
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            _indexLayer = 0;

            _breakCount = int.Parse(txtBreakCount.EditValue.ToString());
            _maxValue = double.Parse(txtMax.EditValue.ToString());
            _minValue = double.Parse(txtMin.EditValue.ToString());
            _thuaName = DataNameTemplate.Thua_Gia_Dat;
            int intloaidat = cbxLoaiDat.SelectedIndex;
            string strLoaiDat = "";
            string tblGiaDat = "";
            switch (intloaidat)
            {
                case 0:
                    tblGiaDat =DataNameTemplate.Thua_Gia_Dat;
                    //strLoaiDat = "Đất nông nghiệp";
                    break;
                case 1:
                    tblGiaDat = DataNameTemplate.Thua_Gia_Dat;
                    strLoaiDat = "Đất phi nông nghiệp tại đô thị";
                    break;
                case 2:
                    tblGiaDat = DataNameTemplate.Thua_Gia_Dat;
                    strLoaiDat = "Đất phi nông nghiệp tại nông thôn";
                    break;
                default:
                    tblGiaDat = DataNameTemplate.Thua_Gia_Dat;
                    strLoaiDat = "Đất nông nghiệp";
                    break;
            }
            _giadatName = string.Format("{0}_{1}",tblGiaDat,spnNam.EditValue);

            int fieldName = cbxField.SelectedIndex;
            switch (fieldName)
            {
                case 0:
                    _fieldName = string.Format("{0}.{1}", _giadatName, "giadat");
                    break;
                case 1:
                    _fieldName = string.Format("{0}.{1}", _giadatName, "dongia");
                    break;
                default:
                    _fieldName = string.Format("{0}.{1}", _giadatName, "dongia");
                    break;
            }

            SdeConnection conn = new SdeConnection();
            ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
            IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
            //ITable giadatTable = fw.OpenTable(_giadatName);
            _giadatLayer=new FeatureLayerClass();
            string tgdName = string.Format("{0}_{1}", DataNameTemplate.Thua_Gia_Dat, spnNam.EditValue);
            _giadatLayer.FeatureClass = fw.OpenFeatureClass(tgdName);
            _giadatLayer.Name = string.Format("{0} năm {1}", "Giá đất", spnNam.EditValue);
            //IFeatureLayer flThua = (IFeatureLayer)_mapControl.get_Layer(_indexLayer);

            _joinFieldOnLayer = "mathua";
            _joinFieldOnTable = "mathua";
            //_layer4Join = flThua;
            //_table4Join = giadatTable;
            int joinType = cbxType.SelectedIndex;
            switch (joinType)
            {
                case 0:
                    _type = esriJoinType.esriLeftInnerJoin;
                    break;
                case 1:
                    _type = esriJoinType.esriLeftOuterJoin;
                    break;
                default:
                    _type = esriJoinType.esriLeftInnerJoin;
                    break;
            }
            _cardinality = esriRelCardinality.esriRelCardinalityOneToMany;

            _controller = new ThematicController(_thematic, this);
            _controller.SingleRender() ;
            closeParent();
        }
        public RelationshipClass(RelationshipClass prototype) : base(prototype) {
            this._cardinality = prototype.Cardinality;
            this._notification = prototype.Notification;
            this._isComposite = prototype.IsComposite;
            this._originClassNames = prototype.OriginClassName;
            this._destinationClassNames = prototype.DestinationClassName;
            this._keyType = prototype.KeyType;
            this._classKey = prototype.ClassKey;
            this._forwardPathLabel = prototype.ForwardPathLabel;
            this._backwardPathLabel = prototype.BackwardPathLabel;
            this._isReflexive = prototype.IsReflexive;
            this._originPrimary = prototype.OriginPrimary;
            this._originForeign = prototype.OriginForeign;
            this._destinationPrimary = prototype.DestinationPrimary;
            this._destinationForeign = prototype.DestinationForeign;

            // Add Cloned Relationship Rules
            this._relationshipRules = new List<RelationshipRule>();
            foreach (RelationshipRule relationshipRule in prototype.RelationshipRules) {
                this._relationshipRules.Add((RelationshipRule)relationshipRule.Clone());
            }
        }
예제 #15
0
        /// <summary>
        ///     Sets a join based on the specified relationship class and join type.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="table">The table.</param>
        /// <param name="foreignClass">The join.</param>
        /// <param name="layerKeyField">Name of the layer field.</param>
        /// <param name="foreignKeyField">Name of the join field.</param>
        /// <param name="cardinality">The cardinality.</param>
        /// <param name="joinType">Type of the join.</param>
        /// <returns>
        /// Returns a <see cref="IRelQueryTable" /> represents the table and feature join.
        /// </returns>
        public static IRelQueryTable Add(this IFeatureLayer source, IRelQueryTable table, IObjectClass foreignClass, string layerKeyField, string foreignKeyField, esriRelCardinality cardinality, esriJoinType joinType)
        {
            if (source != null)
            {
                var factory = new RelQueryTableFactoryClass();
                var origin  = factory.Open(table.RelationshipClass, true, null, null, "", true, ((IRelQueryTableInfo)table).JoinType == esriJoinType.esriLeftInnerJoin);

                var join   = ((IObjectClass)origin).Join(foreignClass, string.Format("{0}.{1}", ((IDataset)table.SourceTable).Name, layerKeyField), foreignKeyField, cardinality, null);
                var result = factory.Open(join, true, null, null, "", true, joinType == esriJoinType.esriLeftInnerJoin);

                IDisplayRelationshipClass display = (IDisplayRelationshipClass)source;
                display.DisplayRelationshipClass(result.RelationshipClass, joinType);

                return(result);
            }

            return(null);
        }
예제 #16
0
 public IRelationshipClass CreateRelationshipClass(string relClassName, IObjectClass OriginClass, IObjectClass DestinationClass, string forwardLabel, string backwardLabel, esriRelCardinality Cardinality, esriRelNotification Notification, bool IsComposite, bool IsAttributed, IFields relAttrFields, string OriginPrimaryKey, string destPrimaryKey, string OriginForeignKey, string destForeignKey)
 {
     // I don't think this needs to be implemented for now.
     throw new NotImplementedException();
 }
예제 #17
0
        /// <summary>
        /// Sets a join based on the specified relationship class and join type.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="foreignClass">The join.</param>
        /// <param name="layerKeyField">Name of the layer field.</param>
        /// <param name="foreignKeyField">Name of the join field.</param>
        /// <param name="cardinality">The cardinality.</param>
        /// <param name="joinType">Type of the join.</param>
        /// <returns>
        /// Returns a <see cref="IRelQueryTable" /> represents the table and feature join.
        /// </returns>
        public static IRelQueryTable Add(this IFeatureLayer source, IObjectClass foreignClass, string layerKeyField, string foreignKeyField, esriRelCardinality cardinality, esriJoinType joinType)
        {
            IRelQueryTable     result;
            IRelationshipClass relClass;
            var table = ((IDisplayTable)source).DisplayTable as IRelQueryTable;

            if (table != null)
            {
                result   = source.Add(table, foreignClass, string.Format("{0}.{1}", ((IDataset)source.FeatureClass).Name, layerKeyField), foreignKeyField, cardinality, joinType);
                relClass = result.RelationshipClass;
            }
            else
            {
                var layer = (IFeatureClass)((IDisplayTable)source).DisplayTable;
                relClass = layer.Join(foreignClass, layerKeyField, foreignKeyField, cardinality, null);

                var factory = new RelQueryTableFactoryClass();
                result = factory.Open(relClass, true, null, null, "", true, joinType == esriJoinType.esriLeftInnerJoin);
            }

            IDisplayRelationshipClass display = (IDisplayRelationshipClass)source;

            display.DisplayRelationshipClass(relClass, joinType);

            return(result);
        }
        //
        // CONSTRUCTOR
        //
        public RelationshipClass(IXPathNavigable path) : base(path) {
            // Get Navigator
            XPathNavigator navigator = path.CreateNavigator();

            // Get Model
            SchemaModel model = (SchemaModel)base.Container;

            // <Cardinality></Cardinality>
            XPathNavigator navigatorCardinality = navigator.SelectSingleNode(Xml.CARDINALITY);
            if (navigatorCardinality != null) {
                this._cardinality = (esriRelCardinality)Enum.Parse(typeof(esriRelCardinality), navigatorCardinality.Value, true);
            }

            // <Notification></Notification> 
            XPathNavigator navigatorNotification = navigator.SelectSingleNode(Xml.NOTIFICATION);
            if (navigatorNotification != null) {
                this._notification = (esriRelNotification)Enum.Parse(typeof(esriRelNotification), navigatorNotification.Value, true);
            }

            // <IsComposite>false</IsComposite> 
            XPathNavigator navigatorIsComposite = navigator.SelectSingleNode(Xml.ISCOMPOSITE);
            if (navigatorIsComposite != null) {
                this._isComposite = navigatorIsComposite.ValueAsBoolean;
            }

            // <OriginClassNames></OriginClassNames>
            XPathNavigator navigatorOriginClassNames = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.ORIGINCLASSNAMES, Xml.NAME)); //  "OriginClassNames/Name");
            if (navigatorOriginClassNames != null) {
                this._originClassNames = navigatorOriginClassNames.Value;
            }

            // <DestinationClassNames></DestinationClassNames>
            XPathNavigator navigatorDestinationClassNames = navigator.SelectSingleNode(string.Format("{0}/{1}", Xml.DESTINATIONCLASSNAMES, Xml.NAME)); //"DestinationClassNames/Name");
            if (navigatorDestinationClassNames != null) {
                this._destinationClassNames = navigatorDestinationClassNames.Value;
            }

            // <KeyType></KeyType> 
            XPathNavigator navigatorKeyType = navigator.SelectSingleNode(Xml.KEYTYPE);
            if (navigatorKeyType != null) {
                this._keyType = (esriRelKeyType)Enum.Parse(typeof(esriRelKeyType), navigatorKeyType.Value, true);
            }

            // <ClassKey></ClassKey> 
            XPathNavigator navigatorClassKey = navigator.SelectSingleNode(Xml.CLASSKEY);
            if (navigatorClassKey != null) {
                this._classKey = (esriRelClassKey)Enum.Parse(typeof(esriRelClassKey), navigatorClassKey.Value, true);
            }

            // <ForwardPathLabel></ForwardPathLabel> 
            XPathNavigator navigatorForwardPathLabel = navigator.SelectSingleNode(Xml.FORWARDPATHLABEL);
            if (navigatorForwardPathLabel != null) {
                this._forwardPathLabel = navigatorForwardPathLabel.Value;
            }

            // <BackwardPathLabel></BackwardPathLabel> 
            XPathNavigator navigatorBackwardPathLabel = navigator.SelectSingleNode(Xml.BACKWARDPATHLABEL);
            if (navigatorBackwardPathLabel != null) {
                this._backwardPathLabel = navigatorBackwardPathLabel.Value;
            }

            // <IsReflexive></IsReflexive>
            XPathNavigator navigatorIsReflexive = navigator.SelectSingleNode(Xml.ISREFLEXIVE);
            if (navigatorIsReflexive != null) {
                this._isReflexive = navigatorIsReflexive.ValueAsBoolean;
            }

            // <OriginClassKeys><RelationshipClassKey></RelationshipClassKey></OriginClassKeys>
            // <DestinationClassKeys><RelationshipClassKey></RelationshipClassKey></DestinationClassKeys>
            string xpath = string.Format("{0}/{2} | {1}/{2}", Xml.ORIGINCLASSKEYS, Xml.DESTINATIONCLASSKEYS, Xml.RELATIONSHIPCLASSKEY);
            XPathNodeIterator interatorClassKeys = navigator.Select(xpath); // "OriginClassKeys/RelationshipClassKey | DestinationClassKeys/RelationshipClassKey");
            while (interatorClassKeys.MoveNext()) {
                // Get <RelationshipClassKey>
                XPathNavigator navigatorClassKeys = interatorClassKeys.Current;

                // Get <KeyRole>
                XPathNavigator navigatorKeyRole = navigatorClassKeys.SelectSingleNode(Xml.KEYROLE);
                if (navigatorKeyRole == null){continue;}
                if (string.IsNullOrEmpty(navigatorKeyRole.Value)){continue;}
                string keyRole = navigatorKeyRole.Value;

                // Get <ObjectKeyName>
                XPathNavigator navigatorObjectKeyName = navigatorClassKeys.SelectSingleNode(Xml.OBJECTKEYNAME);
                if (navigatorObjectKeyName == null){continue;}

                // Set Relationship Keys
                if (keyRole == esriRelKeyRole.esriRelKeyRoleOriginPrimary.ToString()){
                    this._originPrimary = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleOriginForeign.ToString()){
                    this._originForeign = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleDestinationPrimary.ToString()){
                    this._destinationPrimary = navigatorObjectKeyName.Value;
                }
                else if (keyRole == esriRelKeyRole.esriRelKeyRoleDestinationForeign.ToString()){
                    this._destinationForeign = navigatorObjectKeyName.Value;
                }
            }

            // <RelationshipRules><RelationshipRule></RelationshipRule></RelationshipRules>
            this._relationshipRules = new List<RelationshipRule>();
            XPathNodeIterator interatorRelationshipRule = navigator.Select(string.Format("{0}/{1}", Xml.RELATIONSHIPRULES, Xml.RELATIONSHIPRULE)); // "RelationshipRules/RelationshipRule");
            while (interatorRelationshipRule.MoveNext()) {
                // Get <RelationshipRule>
                XPathNavigator navigatorRelationshipRule = interatorRelationshipRule.Current;

                // Create Relationship Rule
                RelationshipRule relationshipRule = new RelationshipRule(navigatorRelationshipRule);

                // Add Rule to Collection
                this._relationshipRules.Add(relationshipRule);
            }
        }