示例#1
0
        public bool EstablishConnectivity(IGTKeyObject activeKO, IGTKeyObject relatedKO, GTRelationshipOrdinalConstants activeRelationshipOrdinal, GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            Int32     node1  = 0;
            Int32     node2  = 0;
            Recordset connRS = null;

            try
            {
                connRS = relatedKO.Components.GetComponent(11).Recordset;
                if (connRS.RecordCount > 0)
                {
                    connRS.MoveFirst();
                    node1 = Convert.ToInt32(connRS.Fields["NODE_1_ID"].Value);
                    node2 = Convert.ToInt32(connRS.Fields["NODE_2_ID"].Value);
                }

                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = m_dataContext;
                relationshipService.ActiveFeature = activeKO;

                if (relationshipService.AllowSilentEstablish(relatedKO))
                {
                    relationshipService.SilentEstablish(14, relatedKO, activeRelationshipOrdinal, relatedRelationshipOrdinal);
                }

                returnValue = true;
            }
            catch
            {
                //returnValue = false;
                returnValue = true;

                // Reset connectivity
                if (connRS != null)
                {
                    if (connRS.RecordCount > 0)
                    {
                        connRS.MoveFirst();
                        connRS.Fields["NODE_1_ID"].Value = node1;
                        connRS.Fields["NODE_2_ID"].Value = node2;
                    }
                }
            }

            relationshipService.Dispose();
            return(returnValue);
        }
示例#2
0
        /// <summary>
        /// Establish ownership between street light and Miscellaneous Structure.
        /// </summary>
        /// <param name="gtStreetLightKObject"></param>
        private void EstablishOwnership(IGTKeyObject gtStreetLightKObject)
        {
            IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                Recordset ownerRNORecords = m_oGTDataContext.MetadataRecordset("G3E_RELATIONSHIPS_OPTABLE", "G3E_TYPE = 3 AND G3E_TABLE = 'G3E_OWNERSHIP_ELEC' AND G3E_USERNAME = '******'");
                ownerRNORecords.MoveFirst();
                gtRelationshipService.DataContext   = m_oGTDataContext;
                gtRelationshipService.ActiveFeature = gtStreetLightKObject;
                if (gtRelationshipService.AllowSilentEstablish(gTOwnerKeyObject))
                {
                    gtRelationshipService.SilentEstablish(Convert.ToInt16(ownerRNORecords.Fields["G3E_RNO"].Value), gTOwnerKeyObject);
                }
            }
            catch
            {
                throw;
            }
        }
示例#3
0
        public void EstablishOwnerShip(IGTKeyObject activeKO, IGTKeyObject isolationPoint)
        {
            IGTRelationshipService relationshipService = null;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = activeKO;
                IGTKeyObjects m_relatedFeatures = relationshipService.GetRelatedFeatures(3);

                foreach (IGTKeyObject ownerFeature in m_relatedFeatures)
                {
                    relationshipService.ActiveFeature = isolationPoint;

                    if (relationshipService.AllowSilentEstablish(ownerFeature))
                    {
                        try
                        {
                            relationshipService.SilentEstablish(3, ownerFeature);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                relationshipService.Dispose();
                relationshipService = null;
            }
        }
示例#4
0
        /// <summary>
        /// Establishes the connectivity relationship for the input features.
        /// </summary>
        /// <param name="activeKO">Active feature to connect.</param>
        /// <param name="relatedKO">Related feature to connect.</param>
        /// <param name="activeRelationshipOrdinal">Node on the active feature to connect.</param>
        /// <param name="relatedRelationshipOrdinal">Node on the related feature to connect.</param>
        /// <returns>Boolean indicating status</returns>
        public bool EstablishConnectivity(IGTKeyObject activeKO, IGTKeyObject relatedKO, GTRelationshipOrdinalConstants activeRelationshipOrdinal, GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            Int32     node1  = 0;
            Int32     node2  = 0;
            Recordset connRS = null;

            try
            {
                // Get current connectivity for active feature.
                // This is needed to reset the connectivity if establish connectivity fails.
                // Establish connectivity may fail if data violates the rule defined in metadata.
                //     For example, Feature A is connected to Node 1 of the Transformer.
                //     When the FI fires and creates an Isolation Point at the Transformer,
                //     then all features currently at node 1 of the Transformer are connected to node 1 of the Isolation Point
                //     and the Transformer is connected to node 2 of the Isolation Point.
                //     The FI will attempt to connect Feature A to the Isolation Point which may not be allowed in metadata. This would throw an error.
                // There are many other reasons why the establish could fail, so best to catch any errors and reset the connectivity.
                connRS = relatedKO.Components.GetComponent(11).Recordset;
                if (connRS.RecordCount > 0)
                {
                    connRS.MoveFirst();
                    node1 = Convert.ToInt32(connRS.Fields["NODE_1_ID"].Value);
                    node2 = Convert.ToInt32(connRS.Fields["NODE_2_ID"].Value);
                }

                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = activeKO;

                if (relationshipService.AllowSilentEstablish(relatedKO))
                {
                    //relationshipService.SilentDelete(14, activeRelationshipOrdinal);
                    relationshipService.SilentEstablish(14, relatedKO, activeRelationshipOrdinal, relatedRelationshipOrdinal);
                }

                returnValue = true;
            }
            catch
            {
                //returnValue = false;
                returnValue = true;

                // Reset connectivity
                if (connRS != null)
                {
                    if (connRS.RecordCount > 0)
                    {
                        connRS.MoveFirst();
                        connRS.Fields["NODE_1_ID"].Value = node1;
                        connRS.Fields["NODE_2_ID"].Value = node2;
                    }
                }

                //if (InteractiveMode)
                //{
                //    MessageBox.Show("Error in Isolation Scenario FI:EstablishConnectivity - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                //}
            }

            relationshipService.Dispose();

            return(returnValue);
        }