Beispiel #1
0
        /// <summary>
        /// Method to check if selected feature is a parent feature
        /// </summary>
        /// <returns> true- if feature is an owner</returns>
        private bool CheckIfOwnerFeatureAndGetOwnedFeatures()
        {
            ChildFeatureInfo       oChildFeatureInfo;
            IGTKeyObjects          ownedFeatures = null;
            IGTRelationshipService oService      = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                int          fId            = m_selectedObject.FID;
                short        fNo            = m_selectedObject.FNO;
                IGTKeyObject oActiveFeature = m_dataContext.OpenFeature(fNo, fId);
                oService.DataContext   = m_dataContext;
                oService.ActiveFeature = oActiveFeature;
                try
                {
                    ownedFeatures = oService.GetRelatedFeatures(2);
                }
                catch
                {
                    return(false);
                }
                if (ownedFeatures.Count > 0)
                {
                    m_childFeatureInfoList = new List <ChildFeatureInfo>();
                    foreach (IGTKeyObject child in ownedFeatures)
                    {
                        oChildFeatureInfo             = new ChildFeatureInfo();
                        oChildFeatureInfo.GtKeyObject = child;
                        Recordset childRs = child.Components.GetComponent(1).Recordset;
                        childRs.MoveFirst();
                        Recordset parentRs = oActiveFeature.Components.GetComponent(1).Recordset;
                        parentRs.MoveFirst();
                        if (Convert.ToString(childRs.Fields["OWNER1_ID"].Value) == Convert.ToString(parentRs.Fields["G3E_ID"].Value))
                        {
                            oChildFeatureInfo.Owner1IdExists = true;
                        }
                        else if (Convert.ToString(childRs.Fields["OWNER2_ID"].Value) == Convert.ToString(parentRs.Fields["G3E_ID"].Value))
                        {
                            oChildFeatureInfo.Owner2IdExists = true;
                        }
                        m_childFeatureInfoList.Add(oChildFeatureInfo);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                oService.Dispose();
                oService = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// override After establish
        /// </summary>
        public override void AfterEstablish()
        {
            IGTRelationshipService gtRelationshipService = GTClassFactory.Create <IGTRelationshipService>() as IGTRelationshipService;

            try
            {
                if ((ActiveFeature.FNO == Capacitor_FNO) || (ActiveFeature.FNO == TransformerOH_FNO) || (ActiveFeature.FNO == PrimaryEnclosure_FNO) || (ActiveFeature.FNO == TransformerUG_FNO) || (ActiveFeature.FNO == TransformerOHN_FNO) || (ActiveFeature.FNO == TransformerUGN_FNO))
                {
                    gtRelationshipService.DataContext   = gtApplication.DataContext;
                    gtRelationshipService.ActiveFeature = this.ActiveFeature;

                    //Get related features
                    IGTKeyObjects relationshipcandidates = gtRelationshipService.GetRelatedFeatures(m_RNO);
                    if (relationshipcandidates != null)
                    {
                        for (int i = 0; i < relationshipcandidates.Count; i++)
                        {
                            // check if opposite nodes are connected otherwise .. change the node of the related feature
                            if ((relationshipcandidates.Count == 2) || (GetComponentType(relationshipcandidates[i].CNO).ToString() == "PolylineGeometry") && (GetComponentType(ActiveFeature.CNO) != GetComponentType(relationshipcandidates[i].CNO)))
                            {
                                if ((Convert.ToString(relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value)) == (Convert.ToString(relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value)))
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    //relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = 0;
                                    //gtRelationshipService.SilentEstablish(m_RNO, relationshipcandidates[i + 1], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                    break;
                                }
                                else
                                {
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    ActiveFeature.Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_1_ID"].Value = relationshipcandidates[i].Components.GetComponent(ConnectivityG3eCno).Recordset.Fields["NODE_2_ID"].Value;
                                    relationshipcandidates[i + 1].Components.GetComponent(ConnectivityG3eCno).Recordset.Update();
                                    // gtRelationshipService.SilentEstablish(m_RNO, relationshipcandidates[i + 1], GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (gtRelationshipService != null)
                {
                    gtRelationshipService.Dispose();
                    gtRelationshipService = null;
                }
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the owned feature for the input active feature
        /// </summary>
        /// <param name="activeFeature"></param>
        /// <returns>Collection of owned feature if any or null</returns>
        private List <Tuple <short, int> > GetOwnedFeatures(IGTKeyObject activeFeature)
        {
            IGTRelationshipService     gTRelationshipService = null;
            List <Tuple <short, int> > ownedFeatures         = null;
            IGTKeyObjects gTKeyObjects = null;

            try
            {
                gTRelationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                gTRelationshipService.DataContext   = DataContext;
                gTRelationshipService.ActiveFeature = activeFeature;

                try
                {
                    gTKeyObjects = gTRelationshipService.GetRelatedFeatures(2);
                }
                catch
                {
                    return(null);
                }

                if (gTKeyObjects != null && gTKeyObjects.Count > 0)
                {
                    ownedFeatures = new List <Tuple <short, int> >();

                    foreach (IGTKeyObject feature in gTKeyObjects)
                    {
                        if (!IsActiveFeatureIsLinear(feature.FNO))
                        {
                            ownedFeatures.Add(new Tuple <short, int>(feature.FNO, feature.FID));
                        }
                    }
                }
                return(ownedFeatures);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (gTRelationshipService != null)
                {
                    gTRelationshipService.Dispose();
                    gTRelationshipService = null;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Determines which node of the related feature is connected to the active feature.
        /// </summary>
        /// <param name="activeKO">Active feature to connect.</param>
        /// <param name="relatedKO">Related feature to connect.</param>
        /// <param name="relatedRelationshipOrdinal">Node on the related feature to connect.</param>
        /// <returns>Boolean indicating status</returns>
        public bool DetermineConnectivityNode(IGTKeyObject activeKO, IGTKeyObject relatedKO, ref GTRelationshipOrdinalConstants relatedRelationshipOrdinal)
        {
            bool returnValue = false;
            IGTRelationshipService relationshipService = null;
            IGTKeyObjects          m_relatedFeatures   = null;
            bool foundNode = false;

            try
            {
                relationshipService               = GTClassFactory.Create <IGTRelationshipService>();
                relationshipService.DataContext   = DataContext;
                relationshipService.ActiveFeature = relatedKO;

                m_relatedFeatures = relationshipService.GetRelatedFeatures(14, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);

                foreach (IGTKeyObject feature in m_relatedFeatures)
                {
                    if (feature.FID == activeKO.FID)
                    {
                        relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1;
                        foundNode = true;
                        break;
                    }
                }

                if (!foundNode)
                {
                    relatedRelationshipOrdinal = GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2;
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                returnValue = false;
                if (InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:DetermineConnectivityNode - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            relationshipService.Dispose();

            return(returnValue);
        }
Beispiel #6
0
        /// <summary>
        /// To find owners of a linear feature.
        /// </summary>
        /// <returns></returns>
        public IGTKeyObjects LocateOwnersOfActiveFeature()
        {
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();
            IGTKeyObjects          gTOwnerKeyObjects   = GTClassFactory.Create <IGTKeyObjects>();

            try
            {
                relationShipService.ActiveFeature = m_ActiveKeyObject;
                relationShipService.DataContext   = m_gTDataContext;
                if (m_ActiveKeyObject.FNO != 2400)
                {
                    gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(3);
                }
                else if (m_ActiveKeyObject.FNO == 2400)
                {
                    IGTKeyObjects gTFormationOwnerKeyObjects = relationShipService.GetRelatedFeatures(6);
                    if (gTFormationOwnerKeyObjects != null && gTFormationOwnerKeyObjects.Count > 0)
                    {
                        foreach (IGTKeyObject gTKeyObject in gTFormationOwnerKeyObjects)
                        {
                            relationShipService.ActiveFeature = gTKeyObject;
                            gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(122);
                            if (gTOwnerKeyObjects != null && gTOwnerKeyObjects.Count > 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            finally
            {
                relationShipService.Dispose();
                relationShipService = null;
            }
            return(gTOwnerKeyObjects);
        }
Beispiel #7
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;
            }
        }
Beispiel #8
0
        public void CreateDuct(string sASSIGNMENT, int iPOS_HORZ_FROM, int iPOS_VERT_FROM, int iPOS_HORZ_TO, int iPOS_VERT_TO, int iSTALE_FLAG_FROM, int iSTALE_FLAG_TO)
        {
            IGTKeyObject tmpFeatureDuct = null;

            try
            {
                object oMissing = System.Reflection.Missing.Value;

                //Create fORMATION
                tmpFeatureDuct = m_oDataContext.NewFeature(csConstant.SHORT_DUCT);
                //NETELEM
                tmpFeatureDuct.Components["COMMON_N"].Recordset.MoveFirst();
                //csGlobals.tmpFeatureFormation.Components["GC_NETELEM"].Recordset.Fields["FEATURE_STATE"].Value = dataGridViewExpansion.Rows[i].Cells["STATE"].Value.ToString();
                //MAIN COMPONENT
                tmpFeatureDuct.Components["DUCT_N"].Recordset.MoveFirst();
                //ASSIGNMENT,POS_HORZ_FROM,POS_HORZ_TO,POS_VERT_FROM,POS_VERT_TO,STALE_FLAG_FROM,STALE_FLAG_TO
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["ASSIGNMENT_ID"].Value   = sASSIGNMENT;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_HORZ"].Value   = iPOS_HORZ_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_HORZ"].Value     = iPOS_HORZ_TO;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_POS_VERT"].Value   = iPOS_VERT_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_POS_VERT"].Value     = iPOS_VERT_TO;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["FROM_STALE_FLAG"].Value = iSTALE_FLAG_FROM;
                tmpFeatureDuct.Components["DUCT_N"].Recordset.Fields["TO_STALE_FLAG"].Value   = iSTALE_FLAG_TO;

                IGTRelationshipService gServices = GTClassFactory.Create <IGTRelationshipService>();
                gServices.DataContext   = m_oDataContext;
                gServices.ActiveFeature = m_FormationFeature;
                gServices.SilentEstablish(csConstant.iContains, tmpFeatureDuct);
                gServices.Dispose();
                gServices = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Create Duct", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #9
0
        /// <summary>
        /// This method is used to validate the initial conditions of the relocate custom command.
        /// </summary>
        /// <param name="relatedFeaturesOWB"></param>
        /// <returns></returns>
        private bool ValidateCC(out IGTKeyObjects relatedFeaturesOWB)
        {
            bool      execute    = true;
            string    sql        = "";
            Recordset rsValidate = null;
            int       reCount    = 0;
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            relatedFeaturesOWB = GTClassFactory.Create <IGTKeyObjects>();
            try
            {
                //Validate conditions to run the custom command.

                // 1.  This command applies only to WR jobs.

                #region First Condition
                sql = "select G3E_JOBTYPE,G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER=?";
                //sql = "select JOB_TYPE,G3E_STATUS from G3E_JOB where G3E_IDENTIFIER=?";
                rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                       (int)ADODB.CommandTypeEnum.adCmdText, m_gtApplication.DataContext.ActiveJob);

                if (rsValidate.RecordCount > 0)
                {
                    rsValidate.MoveFirst();
                    if (!rsValidate.EOF && !rsValidate.BOF)
                    {
                        m_strJobtype = Convert.ToString(rsValidate.Fields[0].Value);
                        m_strStatus  = Convert.ToString(rsValidate.Fields[1].Value);
                    }
                }
                #endregion

                if (m_strJobtype == "NON-WR")
                {
                    MessageBox.Show("This command applies only to WR jobs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button1);
                    execute = false;
                }
                else
                {
                    //2. This command applies only to features with CUs.

                    #region Second Condition

                    m_gtDDCKeyObjects     = m_gtApplication.Application.SelectedObjects.GetObjects();
                    m_activeFeatureDDCKey = m_gtDDCKeyObjects[0];
                    m_selectedFno         = m_activeFeatureDDCKey.FNO;
                    m_selectedFid         = m_activeFeatureDDCKey.FID;

                    sql        = "SELECT count(*) FROM G3E_FEATURECOMPS_OPTABLE WHERE G3E_FNO=? AND G3E_CNO=21";
                    rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                           (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno);

                    if (rsValidate.RecordCount > 0)
                    {
                        rsValidate.MoveFirst();
                        if (!rsValidate.EOF && !rsValidate.BOF)
                        {
                            reCount = Convert.ToInt32(rsValidate.Fields[0].Value);
                        }
                    }

                    #endregion

                    if (reCount < 1)
                    {
                        MessageBox.Show("This command applies only to features with CUs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);

                        execute = false;
                    }
                    else
                    {
                        // 3. Cannot Relocate a feature that is not currently owned.
                        #region Third Condition
                        m_oActiveKeyObject = m_gtApplication.DataContext.OpenFeature(m_selectedFno, m_selectedFid);
                        relationShipService.ActiveFeature = m_oActiveKeyObject;
                        relationShipService.DataContext   = m_gtApplication.DataContext;
                        int ownFcount = 0;
                        try
                        {
                            relatedFeaturesOWB = relationShipService.GetRelatedFeatures(3);
                            ownFcount          = relatedFeaturesOWB.Count;
                        }
                        catch
                        {
                        }

                        #endregion
                        if (ownFcount <= 0)
                        {
                            MessageBox.Show("Cannot relocate a feature that is not currently owned.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                            MessageBoxDefaultButton.Button1);

                            execute = false;
                        }
                        else
                        {
                            // 4. This command applies only to point features.
                            #region Fourth Condition
                            sql        = "SELECT * FROM G3E_COMPONENTINFO_OPTABLE WHERE G3E_CNO IN(SELECT G3E_PRIMARYGEOGRAPHICCNO FROM G3E_FEATURES_OPTABLE WHERE G3E_FNO=?) AND UPPER(G3E_GEOMETRYTYPE) LIKE '%POINT%'";
                            rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                                   (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno);

                            #endregion
                            if (rsValidate.RecordCount <= 0)
                            {
                                MessageBox.Show("This command applies only to point features.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                MessageBoxDefaultButton.Button1);

                                execute = false;
                            }
                            else
                            {
                                //execute = true;
                                if (!CheckIfInstallAndActiveWrAreDifferent())
                                {
                                    MessageBox.Show("The same feature may not be installed and relocated in the same WR.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                    MessageBoxDefaultButton.Button1);
                                    execute = false;
                                }
                                else
                                {
                                    execute = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (rsValidate != null)
                {
                    if (rsValidate.State == 1)
                    {
                        rsValidate.Close();
                        rsValidate.ActiveConnection = null;
                    }
                    rsValidate = null;
                }

                if (relationShipService != null)
                {
                    relationShipService.Dispose();
                    relationShipService = null;
                }
            }

            return(execute);
        }
Beispiel #10
0
        /// <summary>
        /// Data Source of the datagridview.
        /// </summary>
        /// <returns></returns>
        public DataTable GetData()
        {
            DataTable gridDataTable = GridStructure();
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            try
            {
                int    count              = 0;
                string strAction          = "";
                string strEnergize        = "";
                int    Quantity           = 1;
                string strWattage         = "";
                string strLampType        = "";
                string strRateSchedule    = "";
                string strLuminaireStyle  = "";
                string strIdentifyingType = "";
                string strAddress         = "";
                string strESILocation     = "";
                string strOwnerType       = "";
                string strOwnerCU         = "";
                string strLocation        = "";

                int Latitude  = 0;
                int Longitude = 0;


                IGTComponent gTComponent;

                foreach (IGTKeyObject keyObject in m_SelectedKeyObjects)
                {
                    strESILocation = m_SelectedEsiLocations[count];

                    gTComponent = keyObject.Components["COMMON_N"];

                    GetCommonAttributes(ref strAction, ref strOwnerType, ref strLocation, ref Latitude, ref Longitude, gTComponent);

                    if (strAction == "PPI" || strAction == "ABI" || strAction == "INI")
                    {
                        strAction = "A";
                    }
                    else if (strAction == "PPR" || strAction == "ABO" || strAction == "OSR")
                    {
                        strAction = "R";
                    }
                    else
                    {
                        strAction = "";
                    }

                    if (strAction == "A")
                    {
                        Additions = Additions + 1;
                    }
                    else if (strAction == "R")
                    {
                        Removal = Removal + 1;
                    }

                    strEnergize = "Y";

                    gTComponent = keyObject.Components["STREETLIGHT_N"];

                    GetStreetLightAttributes(ref strWattage, ref strLampType, ref strLuminaireStyle, gTComponent);

                    strRateSchedule = GetRateSchedule(strRateSchedule, strESILocation);

                    gTComponent = keyObject.Components["COMP_UNIT_N"];

                    if (gTComponent != null && gTComponent.Recordset != null && gTComponent.Recordset.RecordCount > 0)
                    {
                        gTComponent.Recordset.MoveFirst();
                        if (!string.IsNullOrEmpty(Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value)))
                        {
                            strIdentifyingType = Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value);
                        }
                    }

                    relationShipService.ActiveFeature = keyObject;
                    relationShipService.DataContext   = m_gTDataContext;
                    IGTKeyObjects gTOwnerKeyObjects = relationShipService.GetRelatedFeatures(3);

                    if (gTOwnerKeyObjects.Count > 0)
                    {
                        foreach (IGTKeyObject keyOwner in gTOwnerKeyObjects)
                        {
                            gTComponent = keyOwner.Components["COMP_UNIT_N"];
                            if (gTComponent != null && gTComponent.Recordset != null && gTComponent.Recordset.RecordCount > 0)
                            {
                                gTComponent.Recordset.MoveFirst();
                                if (!string.IsNullOrEmpty(Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value)))
                                {
                                    strOwnerCU = Convert.ToString(gTComponent.Recordset.Fields["CU_C"].Value);
                                }
                            }
                        }
                    }


                    strIdentifyingType = strIdentifyingType + "\n" + strOwnerCU + "\n" + strOwnerType;

                    if (count <= 9)
                    {
                        strAddress = "0" + (count + 1);
                    }
                    else
                    {
                        strAddress = Convert.ToString(count);
                    }

                    strAddress = strAddress + "-" + Latitude + "/" + Longitude + "\n";
                    strAddress = strAddress + strLocation;


                    gridDataTable.Rows.Add(strESILocation, strAction, strEnergize, Quantity, strWattage, strLampType, strRateSchedule, strLuminaireStyle, strIdentifyingType, strAddress);

                    count++;
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                relationShipService.Dispose();
                relationShipService = null;
            }

            return(gridDataTable);
        }
Beispiel #11
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);
        }
Beispiel #12
0
        public void Validate(out string[] ErrorPriorityArray, out string[] ErrorMessageArray)
        {
            ErrorPriorityArray = new string[1];
            ErrorMessageArray  = new string[1];

            short iFNOActive = 0;
            int   iFIDActive = 0;

            short iFNORelated = 0;
            int   iFIDRelated;

            string sActivePhase = string.Empty;
            IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>();

            IGTKeyObject  oRelatedFeature        = null;
            IGTKeyObjects oRelatedFeatureOwnedBy = null;
            string        sPriCondNodeType       = string.Empty;

            IGTKeyObject  oActiveFeature        = null;
            IGTKeyObjects oActiveFeatureOwnedBy = null;
            int           activePhaseCount      = 0;

            GTValidationLogger gTValidationLogger = null;
            IGTComponent       activeComponent    = ActiveComponents[ActiveComponentName];
            int activeFID = 0;

            if (activeComponent != null)
            {
                activeComponent.Recordset.MoveFirst();
                activeFID = int.Parse(activeComponent.Recordset.Fields["G3E_FID"].Value.ToString());
            }

            IGTComponent relatedComponent = RelatedComponents[RelatedComponentName];
            int          relatedFID       = 0;

            if (relatedComponent != null)
            {
                relatedComponent.Recordset.MoveFirst();
                relatedFID = int.Parse(relatedComponent.Recordset.Fields["G3E_FID"].Value.ToString());
            }

            if (new gtLogHelper().CheckIfLoggingIsEnabled())
            {
                LogEntries logEntries = new LogEntries
                {
                    ActiveComponentName = ActiveComponentName,
                    ActiveFID           = activeFID,
                    ActiveFieldName     = ActiveFieldName,
                    ActiveFieldValue    = Convert.ToString(activeComponent.Recordset.Fields[ActiveFieldName].Value),
                    JobID = DataContext.ActiveJob,
                    RelatedComponentName    = RelatedComponentName,
                    RelatedFID              = relatedFID,
                    RelatedFieldName        = RelatedFieldName,
                    RelatedFieldValue       = Convert.ToString(relatedComponent.Recordset.Fields[RelatedFieldName].Value),
                    ValidationInterfaceName = "Conductor Validation",
                    ValidationInterfaceType = "RAI",
                };
                gTValidationLogger = new GTValidationLogger(logEntries);

                gTValidationLogger.LogEntry("TIMING", "START", "Conductor Validation Entry", "N/A", "");
            }



            try
            {
                if (m_oActiveComponents[m_sActiveComponentName].Recordset != null)
                {
                    if (!(m_oActiveComponents[m_sActiveComponentName].Recordset.EOF && m_oActiveComponents[m_sActiveComponentName].Recordset.BOF))
                    {
                        iFNOActive = Convert.ToInt16(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["g3e_fno"].Value);
                        iFIDActive = Convert.ToInt32(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["g3e_fid"].Value);

                        sActivePhase     = Convert.ToString(m_oActiveComponents[m_sActiveComponentName].Recordset.Fields["PHASE_ALPHA"].Value);
                        activePhaseCount = sActivePhase.Length;
                        oActiveFeature   = m_oDataContext.OpenFeature(iFNOActive, iFIDActive);
                    }
                }

                if (m_oRelatedComponents[m_sRelatedComponentName].Recordset != null)
                {
                    if (!(m_oRelatedComponents[m_sRelatedComponentName].Recordset.EOF && m_oRelatedComponents[m_sRelatedComponentName].Recordset.BOF))
                    {
                        iFNORelated = Convert.ToInt16(m_oRelatedComponents[m_sRelatedComponentName].Recordset.Fields["g3e_fno"].Value);
                        iFIDRelated = Convert.ToInt32(m_oRelatedComponents[m_sRelatedComponentName].Recordset.Fields["g3e_fid"].Value);

                        oRelatedFeature = m_oDataContext.OpenFeature(iFNORelated, iFIDRelated);

                        if (iFNORelated == 10) //Primary Conductor Node - Store the Type as well
                        {
                            oRelatedFeature.Components["PRI_COND_NODE_N"].Recordset.MoveFirst();
                            sPriCondNodeType = Convert.ToString(oRelatedFeature.Components["PRI_COND_NODE_N"].Recordset.Fields["TYPE_C"].Value);
                        }
                    }
                }

                if ((iFNOActive == 8 || iFNOActive == 9) && (iFNORelated == 13 || iFNORelated == 39) && activePhaseCount == 1)
                {
                    if (sActivePhase != "*")
                    {
                        relationShipService.DataContext   = m_oDataContext;
                        relationShipService.ActiveFeature = oRelatedFeature;
                        oRelatedFeatureOwnedBy            = relationShipService.GetRelatedFeatures(3);

                        if (oRelatedFeatureOwnedBy != null && oRelatedFeatureOwnedBy.Count > 0)
                        {
                            for (int i = 0; i < oRelatedFeatureOwnedBy.Count; i++)
                            {
                                if (oRelatedFeatureOwnedBy[i].FNO == 19)
                                {
                                    ErrorPriorityArray[0] = m_sPriority;
                                    ErrorMessageArray[0]  = "Single-phase conductor should not be connected to a switch gear";
                                }
                            }
                        }
                    }
                }

                if ((iFNOActive == 8 || iFNOActive == 9) && iFNORelated == 10 && sPriCondNodeType.Equals("DEADEND"))
                {
                    relationShipService.DataContext   = m_oDataContext;
                    relationShipService.ActiveFeature = oActiveFeature;
                    oActiveFeatureOwnedBy             = relationShipService.GetRelatedFeatures(3);

                    if (oActiveFeatureOwnedBy != null && oActiveFeatureOwnedBy.Count > 0)
                    {
                        for (int i = 0; i < oActiveFeatureOwnedBy.Count; i++)
                        {
                            if (oActiveFeatureOwnedBy[i].FNO == 110)
                            {
                                IGTKeyObject  oPoleOwner          = null;
                                bool          bGuyFound           = false;
                                IGTKeyObjects oFeatureOwnedByPole = null;

                                oPoleOwner = m_oDataContext.OpenFeature(oActiveFeatureOwnedBy[i].FNO, oActiveFeatureOwnedBy[i].FID);

                                relationShipService.DataContext   = m_oDataContext;
                                relationShipService.ActiveFeature = oPoleOwner;
                                oFeatureOwnedByPole = relationShipService.GetRelatedFeatures(2);

                                if (oFeatureOwnedByPole != null && oFeatureOwnedByPole.Count > 0)
                                {
                                    for (int j = 0; j < oFeatureOwnedByPole.Count; j++)
                                    {
                                        if (oFeatureOwnedByPole[j].FNO == 105)
                                        {
                                            bGuyFound = true;
                                            break;
                                        }
                                    }
                                }
                                if (!bGuyFound)
                                {
                                    ErrorPriorityArray[0] = m_sPriority;
                                    ErrorMessageArray[0]  = "Primary Conductor with a dead end should have a guy present";
                                }
                            }
                        }
                    }
                }

                if (gTValidationLogger != null)
                {
                    gTValidationLogger.LogEntry("TIMING", "END", "Conductor Validation Exit", "N/A", "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Conductor Validation Relationship Attribute Interface \n" + ex.Message, "G/Technology");
            }
            finally
            {
                if (relationShipService != null)
                {
                    relationShipService.Dispose();
                    relationShipService = null;
                }
            }
        }