예제 #1
0
        /// <summary>
        /// Method to process the replacement
        /// </summary>
        private void ProcessReplacement()
        {
            try
            {
                DetermineNewFeatureState();
                IdentifyActivity();

                try
                {
                    CreateNewFeature();
                }
                catch (Exception)
                {
                    throw;
                }

                try
                {
                    m_TransactionManager.Begin("Process Old Feature Modification in Replace feature");
                    ModifyExistingFeature();
                    m_TransactionManager.Commit();

                    m_TransactionManager.Begin("WP Synchronization...");
                    IGTKeyObject feature = m_iGtApplication.DataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID);
                    SynchronizeWP(feature);

                    if (m_oIsolationScenario)
                    {
                        oIsolationScenario.UpdateIsolationPointConnectivity(m_selectedObject.FNO, m_selectedObject.FID, oFeatureCreator.m_newFeature);
                    }

                    m_TransactionManager.Commit();
                }
                catch (Exception)
                {
                    m_TransactionManager.Rollback();
                    throw;
                }

                oFeatureCreator.m_modifiedActivityOldFeature = m_modifiedActivityOldFeature;

                try
                {
                    m_TransactionManager.Begin("Process Reowning in Replace feature");
                    if (CheckIfOwnerFeatureAndGetOwnedFeatures())
                    {
                        ReOwnToNewFeatureAndSetActivity();
                    }
                    if (oHelper.CheckForCorrectionModeProperty())
                    {
                        oHelper.RemoveCorrectionModeProperty();
                    }
                    m_TransactionManager.Commit();
                    m_TransactionManager.RefreshDatabaseChanges();

                    if (m_childFeatureInfoList != null)
                    {
                        foreach (ChildFeatureInfo info in m_childFeatureInfoList)
                        {
                            m_TransactionManager.Begin("Process Synchronize WorkPoints in Replace Feature");
                            SynchronizeWP(m_dataContext.OpenFeature(info.GtKeyObject.FNO, info.GtKeyObject.FID));
                            m_TransactionManager.Commit();
                        }
                    }
                }
                catch (Exception)
                {
                    m_TransactionManager.Rollback();
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Fix for ALM-1586
        /// Sets the Normal and As-Operated status to the values per business rules.
        /// </summary>
        /// <param name="gtKeyObject"></param>
        /// <param name="isoPtNumber"></param>
        /// <returns></returns>
        public void SetNormalAndAsOperatedStatus(IGTKeyObject gtKeyObject, int isoPtNumber = -1)
        {
            Recordset componentRS             = null;
            string    defaultNormalStatus     = string.Empty;
            string    defaultAsOperatedStatus = string.Empty;

            try
            {
                componentRS = gtKeyObject.Components.GetComponent(1).Recordset;

                if (componentRS != null && componentRS.RecordCount > 0)
                {
                    componentRS.MoveFirst();

                    string featureState = Convert.ToString(componentRS.Fields["FEATURE_STATE_C"].Value);
                    componentRS = gtKeyObject.Components.GetComponent(11).Recordset;

                    if (featureState.Equals("PPI") || featureState.Equals("ABI")) // Feature is placed with PPI or ABI
                    {
                        if (isoPtNumber != -1)
                        {
                            if (isoPtNumber == 1 || isoPtNumber == 2)
                            {
                                defaultNormalStatus     = "CLOSED";
                                defaultAsOperatedStatus = "OPEN";
                            }
                        }
                        else
                        {
                            defaultNormalStatus     = "OPEN";
                            defaultAsOperatedStatus = "CLOSED";
                        }

                        if (!string.IsNullOrEmpty(defaultNormalStatus) && !string.IsNullOrEmpty(defaultAsOperatedStatus))
                        {
                            componentRS.Fields["STATUS_NORMAL_C"].Value   = defaultNormalStatus;
                            componentRS.Fields["STATUS_OPERATED_C"].Value = defaultAsOperatedStatus;
                        }
                    }

                    else if (featureState.Equals("INI")) // Feature is placed in INI state (Job type - WR-MAPCOR)
                    {
                        if (isoPtNumber != -1)
                        {
                            if (isoPtNumber == 1 || isoPtNumber == 2)
                            {
                                defaultNormalStatus     = "CLOSED";
                                defaultAsOperatedStatus = "OPEN";
                            }
                        }
                        else
                        {
                            defaultNormalStatus     = "OPEN";
                            defaultAsOperatedStatus = "CLOSED";
                        }
                        componentRS = gtKeyObject.Components.GetComponent(11).Recordset;

                        if (!defaultAsOperatedStatus.Equals(defaultNormalStatus))
                        {
                            componentRS.Fields["STATUS_OPERATED_C"].Value = defaultNormalStatus;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        /// <summary>
        /// Method the to read the CU information of selected feature
        /// </summary>
        private void ReadCUsWithActivity()
        {
            int wireRsCount = 0;

            try
            {
                IGTKeyObject sourceFeature         = m_iGtApplication.DataContext.OpenFeature(m_originalObject.FNO, m_originalObject.FID);
                IGTComponent sFeatureWireComponent = sourceFeature.Components.GetComponent(m_wireAttributesCno);
                m_SourceCuInfoList = new List <CuInformation>();
                if (sFeatureWireComponent != null)
                {
                    Recordset wireComponentRs = sFeatureWireComponent.Recordset;
                    wireRsCount = wireComponentRs.RecordCount;
                    if (wireComponentRs != null && wireComponentRs.RecordCount > 0)
                    {
                        wireComponentRs.Sort = "G3E_CID";
                        wireComponentRs.MoveFirst();
                        while (!wireComponentRs.EOF)
                        {
                            oCuInformation = new CuInformation();
                            if (m_isPrimaryConductor)
                            {
                                oCuInformation.Phase = Convert.ToString(wireComponentRs.Fields["PHASE_C"].Value);
                                try
                                {
                                    oCuInformation.PhasePosition = Convert.ToString(wireComponentRs.Fields["PHASE_POS_C"].Value);
                                }
                                catch (Exception)
                                {
                                }
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(Convert.ToString(wireComponentRs.Fields["NEUTRAL_YN"].Value)) || Convert.ToString(wireComponentRs.Fields["NEUTRAL_YN"].Value) == "X")
                                {
                                    oCuInformation.isNeutral = false;
                                }
                                else
                                {
                                    oCuInformation.isNeutral = Convert.ToString(wireComponentRs.Fields["NEUTRAL_YN"].Value) == "Y" ? true : false;
                                }
                            }
                            if (Convert.IsDBNull(wireComponentRs.Fields["G3E_CID"].Value))
                            {
                                if (m_oGTTransactionManager.TransactionInProgress)
                                {
                                    m_oGTTransactionManager.Rollback();
                                }
                                ExitCommand();
                                return;
                            }
                            oCuInformation.SourceCid = Convert.ToInt16(wireComponentRs.Fields["G3E_CID"].Value);
                            m_SourceCuInfoList.Add(oCuInformation);
                            wireComponentRs.MoveNext();
                        }
                        m_SourceCuInfoList.OrderBy(a => a.TargetCid);
                    }
                }
                if (oCuInformation == null || m_SourceCuInfoList.Count == 0)
                {
                    if (m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Rollback();
                    }
                    ExitCommand();
                    return;
                }
                IGTComponent sCuComponent = sourceFeature.Components.GetComponent(21);
                if (sCuComponent != null)
                {
                    Recordset sCuComponentRs = sCuComponent.Recordset;
                    int       cuRsCount      = sCuComponentRs.RecordCount;
                    if (cuRsCount != wireRsCount)
                    {
                        if (m_oGTTransactionManager.TransactionInProgress)
                        {
                            m_oGTTransactionManager.Rollback();
                        }
                        ExitCommand();
                        return;
                    }
                    if (sCuComponentRs != null && sCuComponentRs.RecordCount > 0)
                    {
                        sCuComponentRs.Sort = "G3E_CID";
                        sCuComponentRs.MoveFirst();
                        //CU_C
                        int i = 0;
                        while (!sCuComponentRs.EOF)
                        {
                            m_SourceCuInfoList[i].CuCode   = Convert.ToString(sCuComponentRs.Fields["CU_C"].Value);
                            m_SourceCuInfoList[i].Activity = Convert.ToString(sCuComponentRs.Fields["ACTIVITY_C"].Value);
                            if (!Convert.IsDBNull(sCuComponentRs.Fields["REPLACED_CID"].Value))
                            {
                                m_SourceCuInfoList[i].ReplacedCID = Convert.ToInt32(sCuComponentRs.Fields["REPLACED_CID"].Value);
                                m_SourceCuInfoList[i].UnitCID     = Convert.ToInt32(sCuComponentRs.Fields["UNIT_CID"].Value);
                            }
                            i = i + 1;
                            sCuComponentRs.MoveNext();
                        }
                    }
                }
                m_changeOutCount = m_SourceCuInfoList.Where(a => a.Activity == "R" || a.Activity == "S").ToList().Count;
                if (m_changeOutCount == 0)
                {
                    MessageBox.Show("This command applies only to features that have changed wires (i.e.- those with removal or salvage activity).", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Rollback();
                    }
                    ExitCommand();
                    return;
                }
                if (m_isPrimaryConductor && (m_SourceCuInfoList.Where(a => a.Activity == "R" || a.Activity == "S").Where(a => string.IsNullOrEmpty(a.Phase)).ToList().Count() == m_changeOutCount))
                {
                    if (m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Rollback();
                    }
                    MessageBox.Show("Selected conductor does not have 'Phase' populated.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ExitCommand();
                    return;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #4
0
 public WorkPointCommonFunctions(IGTKeyObject ActiveKeyObject, IGTDataContext gTDataContext)
 {
     m_ActiveKeyObject = ActiveKeyObject;
     m_gTDataContext   = gTDataContext;
 }
예제 #5
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);
        }
예제 #6
0
 public bool ApproveMerge(IGTKeyObject MergeCandidate, IGTKeyObjects MergeCandidateRelatedFeatures, out string[] MessageArray)
 {
     MessageArray = new string[0];
     return(true);
 }
예제 #7
0
 public void BeforeEstablish(IGTKeyObject EstablishToFeature, bool ProcessingBreak)
 {
 }
예제 #8
0
        /// <summary>
        /// StartPlacement
        /// </summary>
        /// <param name="PTHelper"></param>
        /// <param name="KeyObject"></param>
        /// <param name="KeyObjectCollection"></param>
        /// <returns></returns>
        public override void StartPlacement(IGTPlacementTechniqueHelper PTHelper, IGTKeyObject KeyObject, IGTKeyObjects KeyObjectCollection)
        {
            try
            {
                m_PTHelper = PTHelper;
                IGTKeyObject        m_KeyObject = KeyObject;
                IGTPoint            m_gtOrigin;
                IGTGraphicComponent relativeComponent = GTClassFactory.Create <IGTGraphicComponent>();
                m_KeyObjectCollection = KeyObjectCollection;

                //get current Key object
                currentKeyObject = GetcurrentKeyObject(KeyObject.FNO);

                if (bSilent)
                {
                    m_gtApplication.BeginWaitCursor();

                    // Disable construction aids and status bar prompts for silent placement techinque.
                    m_PTHelper.ConstructionAidsEnabled        = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
                    m_PTHelper.ConstructionAidDynamicsEnabled = false;
                    m_PTHelper.StatusBarPromptsEnabled        = true;
                    m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, currentKeyObject + " Point placement is in Progress......");

                    IGTComponents gtComponents = KeyObject.Components;
                    m_PTHelper.StartPlacement(KeyObject, KeyObjectCollection);

                    //Read arguments
                    ReadArgument();

                    //Find the relative component defined in the placement technique arguments.
                    if ((Convert.ToString(m_GComp.Arguments.GetArgument(0)) != "") && (m_GComps.Count > 0) && (m_GComp != null))
                    {
                        relativeComponent = AccessRelativeComponent.RetrieveRelativeComponent(Convert.ToString(m_GComp.Arguments.GetArgument(0)), m_GComps, m_GComp);
                        //get the origin
                        m_gtOrigin = GetOrigin(m_KeyObject, gtComponents, relativeComponent, xOffset, pointLocation);

                        if ((m_gtOrigin != null) && (relativeComponent != null))
                        {
                            //Set Attribute values
                            SetAttributeValues(gtComponents, m_KeyObject, relativeComponent);

                            //Create new point geometry aligned to the linear feature
                            IGTOrientedPointGeometry newPointGeometry = (IGTOrientedPointGeometry)PTHelper.CreateGeometry();
                            //newPointGeometry.Orientation = VectorByAngle(ang);
                            newPointGeometry.Origin = m_gtOrigin;
                            m_PTHelper.SetGeometry(newPointGeometry);
                            m_PTHelper.EndPlacement();
                        }
                        else
                        {
                            AbortPlacement();
                        }
                    }
                    else
                    {
                        if (pointLocation == "R")
                        {
                            MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        AbortPlacement();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points \n" + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                AbortPlacement();
            }
            finally
            {
                m_KeyObjectCollection = null;
                m_GComps = null;
                m_GComp  = null;
                if (pointLocation == "R")
                {
                    m_gtApplication.EndWaitCursor();
                    m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Feature Placement Completed");
                    m_gtApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpNWArrow;
                    m_PTHelper.ConstructionAidsEnabled           = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
                    m_PTHelper.ConstructionAidDynamicsEnabled    = false;
                }
                Exitcommand();
            }
        }
예제 #9
0
        /// <summary>
        /// Get the pole attributes and populates Ticket Attributes class
        /// </summary>
        /// <returns>True, if Ticket Attributes are populated successfully. Else returns false</returns>
        private bool GetPoleAttributes()
        {
            string serviceAreaCode        = string.Empty;
            string countyBoundaryId       = string.Empty;
            int    nearestServicePointFid = 0;
            Dictionary <int, double> servicePointsDictionary = null;

            try
            {
                m_TicketAttributes = new TicketAttributes();
                IGTKeyObject gTKeyObject = m_DataContext.OpenFeature(110, m_PoleFid);
                Recordset    rs          = gTKeyObject.Components.GetComponent(1).Recordset;
                if (rs != null && rs.RecordCount > 0)
                {
                    rs.MoveFirst();
                    m_TicketAttributes.POLE_FID         = m_PoleFid;
                    m_TicketAttributes.POLE_NUMBER      = Convert.ToString(rs.Fields["STRUCTURE_ID"].Value);
                    m_TicketAttributes.MISCELLANEOUS_ID = m_WrNumber;
                    m_TicketAttributes.LATITUDE         = Convert.ToString(rs.Fields["LATITUDE"].Value);
                    m_TicketAttributes.LONGITUDE        = Convert.ToString(rs.Fields["LONGITUDE"].Value);
                }
                IGTGeometry geometry = gTKeyObject.Components.GetComponent(11002).Geometry;
                IGTPoint    point    = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                point.Z = geometry.FirstPoint.Z;
                customBoundaryQuery boundaryQuery = new customBoundaryQuery(point, 235);// County boundary  FNO 235
                Recordset           resultRs1     = boundaryQuery.PerformPointInPolygon();
                if (resultRs1 != null && resultRs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature        = m_DataContext.OpenFeature(Convert.ToInt16(resultRs1.Fields["G3E_FNO"].Value), Convert.ToInt32(resultRs1.Fields["G3E_FID"].Value));
                    Recordset    boundaryAttributesRs = countyFeature.Components.GetComponent(23501).Recordset; // // County Boundary Attributes
                    if (boundaryAttributesRs != null && boundaryAttributesRs.RecordCount > 0)
                    {
                        boundaryAttributesRs.MoveFirst();
                        m_TicketAttributes.COUNTY = Convert.ToString(boundaryAttributesRs.Fields["NAME"].Value);
                        if (!string.IsNullOrEmpty(Convert.ToString(boundaryAttributesRs.Fields["ID"].Value)))
                        {
                            countyBoundaryId = Convert.ToString(boundaryAttributesRs.Fields["ID"].Value).Replace("TX", string.Empty).Trim();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(countyBoundaryId))
                {
                    int nJunsMemberId = 0;

                    Recordset contactRs = GetRecordSet(string.Format("SELECT NJUNS_MEMBER_ID,CONTACT_NAME,CONTACT_PHONE FROM NJUNS_CONTACTS WHERE COUNTY_N_ID = {0}", countyBoundaryId));
                    if (contactRs != null && contactRs.RecordCount > 0)
                    {
                        contactRs.MoveFirst();
                        m_TicketAttributes.CONTACT_NAME  = Convert.ToString(contactRs.Fields["CONTACT_NAME"].Value);
                        m_TicketAttributes.CONTACT_PHONE = Convert.ToString(contactRs.Fields["CONTACT_PHONE"].Value);
                        // m_TicketAttributes.PLACE = Convert.ToString(contactRs.Fields["NJUNS_PLACE_NAME"].Value);
                        nJunsMemberId = Convert.ToInt32(contactRs.Fields["NJUNS_MEMBER_ID"].Value);
                        contactRs.Close();
                        contactRs = null;
                    }
                    contactRs = GetRecordSet(string.Format("SELECT NJUNS_MEMBER FROM NJUNS_MEMBER WHERE NJUNS_MEMBER_ID = {0}", nJunsMemberId));
                    if (contactRs != null && contactRs.RecordCount > 0)
                    {
                        contactRs.MoveFirst();
                        m_TicketAttributes.CREATED_MEMBER = Convert.ToString(contactRs.Fields["NJUNS_MEMBER"].Value);
                        m_TicketAttributes.POLE_OWNER     = Convert.ToString(contactRs.Fields["NJUNS_MEMBER"].Value);
                    }
                }

                customBufferQuery oCustomBufferQuery = new customBufferQuery(point, m_DistanceFromPoleInFeet, 55); //Closest Premise feature within 300 feet of the Pole. Service point FNO 55
                servicePointsDictionary = oCustomBufferQuery.PerformBufferQuery();
                if (servicePointsDictionary != null && servicePointsDictionary.Count > 0)
                {
                    servicePointsDictionary.OrderBy(key => key.Value);
                    nearestServicePointFid = servicePointsDictionary.First().Key;
                    IGTKeyObject servicePointFeature = m_DataContext.OpenFeature(55, nearestServicePointFid);
                    Recordset    premiseAttributesRs = servicePointFeature.Components.GetComponent(5504).Recordset; // PREMISE_N
                    if (premiseAttributesRs != null && premiseAttributesRs.RecordCount > 0)
                    {
                        premiseAttributesRs.MoveFirst();
                        m_TicketAttributes.HOUSE_NUMBER = Convert.ToString(premiseAttributesRs.Fields["HOUSE_NBR"].Value);
                        m_TicketAttributes.STREET_NAME  = Convert.ToString(premiseAttributesRs.Fields["DIR_LEADING_C"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["STREET_NM"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["STREET_TYPE_C"].Value) + " "
                                                          + Convert.ToString(premiseAttributesRs.Fields["DIR_TRAILING_C"].Value);
                    }
                }

                // Set default vaues
                m_TicketAttributes.TICKET_NUMBER   = string.Empty;
                m_TicketAttributes.TICKET_TYPE     = "Transfer";
                m_TicketAttributes.TICKET_STATUS   = "OPEN";
                m_TicketAttributes.STATE           = "TX";
                m_TicketAttributes.PRIORITY_CODE   = "3";
                m_TicketAttributes.NJUNS_TICKET_ID = -1;
                m_TicketAttributes.DAYS_INTERVAL   = "30";
                m_TicketAttributes.JOB_TYPE        = "Transfer";
                m_TicketAttributes.NUMBER_OF_POLES = "1";
                m_TicketAttributes.REMARKS         = string.Empty;
                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to populate some ticket attributes.", "Custom Create Ticket Error", MessageBoxButtons.OK);
                return(false);
            }
        }
예제 #10
0
        //public string node1Structure

        public bool ProcessSelectSet()
        {
            bool bReturnValue = false;

            try
            {
                m_aSortedPoints = new CablePullPoint[1];
                m_aSegments     = new CablePullSegment[1];

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                relationshipService.DataContext = m_Application.DataContext;
                int index = 0;
                m_SelectedFID = oGTDCKeys[index].FID;
                m_SelectedFNO = oGTDCKeys[index].FNO;
                relationshipService.ActiveFeature = m_Application.DataContext.OpenFeature(m_SelectedFNO, m_SelectedFID);

                if (relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value != null)
                {
                    m_featureState = relationshipService.ActiveFeature.Components.GetComponent(1).Recordset.Fields["FEATURE_STATE_C"].Value.ToString();
                }

                if (relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.RecordCount > 0)
                {
                    relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.MoveFirst();
                    m_CU = relationshipService.ActiveFeature.Components.GetComponent(21).Recordset.Fields["CU_C"].Value.ToString();
                }

                if (CommonDT.AllowCUEdit(relationshipService.ActiveFeature))
                {
                    m_AllowCUEdit = true;
                }
                else
                {
                    m_AllowCUEdit = false;
                }

                int ductBankFID = 0;

                try
                {
                    IGTKeyObjects relatedDuctKOs = relationshipService.GetRelatedFeatures(6);

                    if (relatedDuctKOs.Count > 0)
                    {
                        relationshipService.ActiveFeature = relatedDuctKOs[0];
                        IGTKeyObjects relatedFormationKOs = relationshipService.GetRelatedFeatures(6);
                        if (relatedFormationKOs.Count > 0)
                        {
                            relationshipService.ActiveFeature = relatedFormationKOs[0];
                            IGTKeyObjects relatedDuctBankKOs = relationshipService.GetRelatedFeatures(3);
                            if (relatedDuctBankKOs.Count > 0)
                            {
                                ductBankFID = relatedDuctBankKOs[0].FID;
                                relationshipService.ActiveFeature = relatedDuctBankKOs[0];
                                IGTKeyObjects structure1 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                                IGTKeyObjects structure2 = relationshipService.GetRelatedFeatures(122, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                                if (structure1.Count > 0)
                                {
                                    IGTKeyObject thing = structure1[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node1Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                                if (structure2.Count > 0)
                                {
                                    IGTKeyObject thing = structure2[0];
                                    thing.Components.GetComponent(1).Recordset.MoveFirst();
                                    if (!thing.Components.GetComponent(1).Recordset.BOF&& !thing.Components.GetComponent(1).Recordset.EOF)
                                    {
                                        m_node2Stucture = thing.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value.ToString();
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_NO_RELATED_DUCTBANK, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return(false);
                    }
                }
                catch
                {
                }


                // Get the primary geographic and primary detail componentviews from metadata
                // Get the selected object matching the primary geographic or primary detail componentviews in that order
                Recordset metadataRS           = m_Application.DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + ConstantsDT.FNO_DUCTBANK);
                short     primaryGeographicCNO = 0;
                short     primaryDetailCNO     = 0;
                if (metadataRS.RecordCount > 0)
                {
                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value))
                    {
                        primaryGeographicCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value);
                    }

                    if (!Convert.IsDBNull(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value))
                    {
                        primaryDetailCNO = Convert.ToInt16(metadataRS.Fields["G3E_PRIMARYDETAILCNO"].Value);
                    }
                }

                IGTDDCKeyObjects oDuctBankGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oDuctBankGTDCKeys = m_Application.DataContext.GetDDCKeyObjects(ConstantsDT.FNO_DUCTBANK, ductBankFID, GTComponentGeometryConstants.gtddcgAllPrimary);

                metadataRS = m_Application.DataContext.MetadataRecordset("G3E_COMPONENTVIEWS_OPTABLE");
                string filter = "(g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryGeographicCNO + ") or (g3e_fno = " + ConstantsDT.FNO_DUCTBANK + " and g3e_cno = " + primaryDetailCNO + ")";
                metadataRS.Filter = filter;
                if (metadataRS.RecordCount > 0)
                {
                    metadataRS.Sort = "g3e_detail";

                    while (!metadataRS.EOF)
                    {
                        if (metadataRS.Fields["G3E_VIEW"].Value.ToString() == oDuctBankGTDCKeys[index].ComponentViewName)
                        {
                            //m_SelectedFID = oGTDCKeys[index].FID;
                            //m_SelectedFNO = oGTDCKeys[index].FNO;
                            break;
                        }
                        metadataRS.MoveNext();
                        index++;
                    }


                    IGTGeometry         oGeometry     = oDuctBankGTDCKeys[index].Geometry;
                    IGTPolylineGeometry oPolyLineGeom = GTClassFactory.Create <IGTPolylineGeometry>();

                    if (oGeometry.Type == GTGeometryTypeConstants.gtgtPolylineGeometry || oGeometry.Type == GTGeometryTypeConstants.gtgtLineGeometry)
                    {
                        // Geometry is okay to use as it is.
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry;
                        bReturnValue  = true;
                    }
                    else if (oGeometry.Type == GTGeometryTypeConstants.gtgtCompositePolylineGeometry)
                    {
                        // Any arcs must be stroked to line segments
                        oPolyLineGeom = (IGTPolylineGeometry)oGeometry.Stroke();
                        bReturnValue  = true;
                    }
                    else
                    {
                        // Invalid geometry type.
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_GEOMETRY, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        bReturnValue = false;
                    }

                    if (bReturnValue)
                    {
                        // Store each point of the line in the feature's geometry
                        StoreLinePoints(oPolyLineGeom, m_SelectedFNO, m_SelectedFID);

                        //Compute the included angles for each set of three points in the sorted array
                        ComputeIncludedAngles();

                        //Build the arrays for the segments and bends that will comprise the pull
                        if (!BuildSegmentsAndBends())
                        {
                            bReturnValue = false;
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_COMPONENT_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    bReturnValue = false;
                }
            }
            catch (Exception e)
            {
                m_aSegments     = new CablePullSegment[1];
                m_aBends        = new double[1];
                m_aSortedPoints = new CablePullPoint[1];
            }

            return(bReturnValue);
        }
예제 #11
0
        /// <summary>
        /// Get Origin point of point feature
        /// </summary>
        /// <param name="m_gtComponents"></param>
        /// <param name="gtRelativeComponent"></param>
        /// <param name="xOffset"></param>
        /// <param name="pointLocation"></param>
        /// <returns></returns>
        private IGTPoint GetOrigin(IGTKeyObject m_KeyObject, IGTComponents m_gtComponents, IGTGraphicComponent m_gtRelativeComponent, double xOffset, string pointLocation)
        {
            try
            {
                IGTPoint    m_gtOriginPoint  = null;
                IGTGeometry m_gtLineGeometry = GTClassFactory.Create <IGTGeometry>();
                m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, currentKeyObject + " Point placement is in Progress......");

                //Get Relative Component
                IGTKeyObject m_gtRelativePoint = m_gtApplication.DataContext.OpenFeature(m_gtRelativeComponent.FNO, m_gtRelativeComponent.FID);

                //get the related Linear features
                IGTKeyObjects m_gtRelativeLines = GetRelatedFeature(m_gtRelativePoint, iRNO, linearFNO);

                //get the related Linear features in case they are not connected to relativepoint
                if (m_gtRelativeLines.Count == 0)
                {
                    IGTKeyObjects m_gtBypasspt = GetRelatedFeature(m_gtRelativePoint, iRNO, m_KeyObject.FNO);
                    if (m_gtBypasspt.Count > 0)
                    {
                        m_gtRelativeLines = GetRelatedFeature(m_gtBypasspt[0], iRNO, linearFNO);
                    }
                }

                //Check if related line geometry is not null
                if (m_gtRelativeLines != null && m_gtRelativeLines.Count > 0)
                {
                    //Get node values
                    m_gtRelativeLines = GetNodeValues(m_gtRelativePoint, m_gtRelativeLines);
                    m_gtLineGeometry  = m_gtRelativeLines[0].Components.GetComponent(primaryCNO).Geometry;

                    //Get Line segment and its angle
                    m_gtLineGeometry = GetSegmentAndAngle(m_gtLineGeometry, m_gtRelativeComponent.Geometry.FirstPoint);

                    if (m_gtLineGeometry != null)
                    {
                        switch (pointLocation)
                        {
                        case "L":
                            //Get Left Origin Point
                            m_gtOriginPoint = GetLeftOriginPoint(m_gtComponents, m_gtRelativePoint, m_gtLineGeometry, m_gtRelativeLines);

                            break;

                        case "R":
                            //Get Right Origin Point
                            m_gtOriginPoint = GetRightOriginPoint(m_gtComponents, m_gtRelativePoint, m_gtLineGeometry);

                            break;

                        case "T":
                            //Get Top Origin Point
                            m_gtOriginPoint = GetTopOriginPoint(m_gtLineGeometry);

                            //establish the connectivity for Relative point with Linear feature
                            EstablishRelationship(m_gtRelativePoint, m_gtRelativeLines);
                            break;

                        default:
                            break;
                        }
                        if (m_gtOriginPoint == null)
                        {
                            m_gtOriginPoint = m_gtRelativeComponent.Geometry.FirstPoint;
                        }
                    }
                    else
                    {
                        if (pointLocation == "R")
                        {
                            MessageBox.Show("Error: Unable to place " + currentKeyObject + " Points as the linear feature is not selected properly", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                return(m_gtOriginPoint);
            }
            catch
            {
                throw;
            }
        }
        private void CopyValuesFromBoundaries(Recordset premiseAttributesRs)
        {
            short  fNo              = 0;
            int    fId              = 0;
            string city             = string.Empty;
            string county           = string.Empty;
            string zipCode          = string.Empty;
            string insideCityLimits = string.Empty;
            string tmpQry           = string.Empty;

            try
            {
                short cityFNO   = Convert.ToInt16(m_Arguments.GetArgument(0));
                int   cityANO   = Convert.ToInt32(m_Arguments.GetArgument(1));
                short countyFNO = Convert.ToInt16(m_Arguments.GetArgument(2));
                int   countyANO = Convert.ToInt32(m_Arguments.GetArgument(3));
                short zipFNO    = Convert.ToInt16(m_Arguments.GetArgument(4));
                int   zipANO    = Convert.ToInt32(m_Arguments.GetArgument(5));

                Recordset commonComponentRs = Components.GetComponent(1).Recordset;
                if (commonComponentRs != null && commonComponentRs.RecordCount > 0)
                {
                    commonComponentRs.MoveFirst();
                    fNo = Convert.ToInt16(commonComponentRs.Fields["G3E_FNO"].Value);
                    fId = Convert.ToInt32(commonComponentRs.Fields["G3E_FID"].Value);
                }

                short primaryGraphicCno = GetPrimaryGraphicCno(fNo);
                if (primaryGraphicCno == 0)
                {
                    return;
                }
                IGTKeyObject             servicePointFeature = m_DataContext.OpenFeature(fNo, fId);
                IGTOrientedPointGeometry geometry            = (IGTOrientedPointGeometry)servicePointFeature.Components.GetComponent(primaryGraphicCno).Geometry;
                if (geometry == null)
                {
                    return;
                }
                IGTPoint point = GTClassFactory.Create <IGTPoint>();
                point.X = geometry.FirstPoint.X;
                point.Y = geometry.FirstPoint.Y;
                // City
                customBoundaryQuery objCustomBoundaryQuery = new customBoundaryQuery(point, cityFNO);
                Recordset           rs = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs != null && rs.RecordCount > 0)
                {
                    IGTKeyObject cityFeature = DataContext.OpenFeature(Convert.ToInt16(rs.Fields["G3E_FNO"].Value), Convert.ToInt32(rs.Fields["G3E_FID"].Value));

                    Recordset tempRs = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + cityANO);
                    if (tempRs != null && tempRs.RecordCount > 0)
                    {
                        tempRs.MoveFirst();
                        string field = Convert.ToString(tempRs.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["CITY_C"].Value))) && cno > 0)
                            {
                                Recordset cityRs = cityFeature.Components.GetComponent(cno).Recordset;
                                if (cityRs != null && cityRs.RecordCount > 0)
                                {
                                    cityRs.MoveFirst();
                                    city = Convert.ToString(cityRs.Fields[field].Value);
                                }
                                if (!string.IsNullOrEmpty(city))
                                {
                                    //premiseAttributesRs.Fields["CITY_C"].Value = city;
                                    m_City = city;
                                    //premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = "Y";
                                    m_CityLimits = "Y";
                                }
                            }
                        }
                    }
                }

                // County
                objCustomBoundaryQuery = new customBoundaryQuery(point, countyFNO);
                Recordset rs1 = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs1 != null && rs1.RecordCount > 0)
                {
                    IGTKeyObject countyFeature = DataContext.OpenFeature(Convert.ToInt16(rs1.Fields["G3E_FNO"].Value), Convert.ToInt32(rs1.Fields["G3E_FID"].Value));
                    Recordset    tempRs1       = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + countyANO);
                    if (tempRs1 != null && tempRs1.RecordCount > 0)
                    {
                        tempRs1.MoveFirst();
                        string field = Convert.ToString(tempRs1.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs1.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs1.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["COUNTY_C"].Value))) && cno > 0)
                            {
                                Recordset countyRs = countyFeature.Components.GetComponent(cno).Recordset;
                                if (countyRs != null && countyRs.RecordCount > 0)
                                {
                                    countyRs.MoveFirst();
                                    county = Convert.ToString(countyRs.Fields[field].Value);
                                }

                                if (!string.IsNullOrEmpty(county))
                                {
                                    //premiseAttributesRs.Fields["COUNTY_C"].Value = county;
                                    m_CountyCode = county;
                                }
                            }
                        }
                    }
                }

                // Zip Code
                objCustomBoundaryQuery = new customBoundaryQuery(point, zipFNO);
                Recordset rs2 = objCustomBoundaryQuery.PerformPointInPolygon();
                if (rs2 != null && rs2.RecordCount > 0)
                {
                    IGTKeyObject zipCodeFeature = DataContext.OpenFeature(Convert.ToInt16(rs2.Fields["G3E_FNO"].Value), Convert.ToInt32(rs2.Fields["G3E_FID"].Value));
                    Recordset    tempRs2        = m_DataContext.MetadataRecordset("G3E_ATTRIBUTEINFO_OPTABLE", "G3E_ANO = " + zipANO);
                    if (tempRs2 != null && tempRs2.RecordCount > 0)
                    {
                        tempRs2.MoveFirst();
                        string field = Convert.ToString(tempRs2.Fields["G3E_FIELD"].Value);
                        short  cno   = 0;
                        if (!string.IsNullOrEmpty(Convert.ToString(tempRs2.Fields["G3E_CNO"].Value)))
                        {
                            cno = Convert.ToInt16(tempRs2.Fields["G3E_CNO"].Value);
                        }
                        if (!string.IsNullOrEmpty(field))
                        {
                            if ((string.IsNullOrEmpty(Convert.ToString(premiseAttributesRs.Fields["ZIP_C"].Value))) && cno > 0)
                            {
                                Recordset zipRs = zipCodeFeature.Components.GetComponent(cno).Recordset;
                                if (zipRs != null && zipRs.RecordCount > 0)
                                {
                                    zipRs.MoveFirst();
                                    zipCode = Convert.ToString(zipRs.Fields[field].Value);
                                }
                                if (!string.IsNullOrEmpty(zipCode))
                                {
                                    //premiseAttributesRs.Fields["ZIP_C"].Value = zipCode;
                                    m_ZipCode = zipCode;
                                }
                            }
                        }
                    }

                    try
                    {
                        premiseAttributesRs.Fields["CITY_C"].Value = m_City;
                        premiseAttributesRs.Fields["INSIDE_CITY_LIMITS_YN"].Value = m_CityLimits;
                        premiseAttributesRs.Fields["COUNTY_C"].Value = m_CountyCode;
                        premiseAttributesRs.Fields["ZIP_C"].Value    = m_ZipCode;
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == "Operation was canceled.")
                        {
                            int tmpRecModified = 0;
                            tmpQry = "begin update premise_n set CITY_C = '" + m_City + "', INSIDE_CITY_LIMITS_YN  = '" + m_CityLimits +
                                     "', COUNTY_C = '" + m_CountyCode + "', ZIP_C = '" + m_ZipCode +
                                     "' where g3e_fid = " + premiseAttributesRs.Fields["G3E_FID"].Value.ToString() +
                                     " and g3e_cid = " + premiseAttributesRs.Fields["G3E_CID"].Value.ToString() + "; end;";

                            m_DataContext.Execute(tmpQry, out tmpRecModified, (int)CommandTypeEnum.adCmdText);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #13
0
        /// <summary>
        /// Method to apply offset to removal feature / old feature
        /// </summary>
        /// <param name="sqlString"></param>
        /// <returns></returns>
        private void ApplyOffSetToGraphicComponents(short featureFNO, int featureFID)
        {
            IGTPoint point = null;

            try
            {
                IGTKeyObject  feature       = m_iGtApplication.DataContext.OpenFeature(featureFNO, featureFID);
                IGTComponents allComponents = feature.Components;
                feature.Components.GetComponent(1).Recordset.MoveFirst();
                string sStructureID = Convert.ToString(feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value);

                foreach (IGTComponent component in allComponents)
                {
                    if (!IsGraphicGeoComp(component.CNO))
                    {
                        continue;
                    }

                    if (component.Geometry == null)
                    {
                        continue;
                    }
                    switch (component.Geometry.Type)
                    {
                    case GTGeometryTypeConstants.gtgtOrientedPointGeometry:
                        IGTOrientedPointGeometry orientedPtGeometry = GTClassFactory.Create <IGTOrientedPointGeometry>();
                        point   = GTClassFactory.Create <IGTPoint>();
                        point.X = component.Geometry.FirstPoint.X + m_offSetX;
                        point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                        orientedPtGeometry.Origin      = point;
                        orientedPtGeometry.Orientation = ((IGTOrientedPointGeometry)component.Geometry).Orientation;
                        component.Geometry             = orientedPtGeometry;
                        break;

                    case GTGeometryTypeConstants.gtgtTextPointGeometry:
                        IGTTextPointGeometry textPtGeometry = GTClassFactory.Create <IGTTextPointGeometry>();
                        point   = GTClassFactory.Create <IGTPoint>();
                        point.X = component.Geometry.FirstPoint.X + m_offSetX;
                        point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                        textPtGeometry.Origin = point;
                        textPtGeometry.Normal = ((IGTOrientedPointGeometry)component.Geometry).Orientation;
                        component.Geometry    = textPtGeometry;
                        break;

                    case GTGeometryTypeConstants.gtgtPolylineGeometry:
                        IGTPolylineGeometry newFtPlineGeo = GTClassFactory.Create <IGTPolylineGeometry>();
                        for (int k = 0; k <= component.Geometry.KeypointCount - 1; k++)
                        {
                            point   = GTClassFactory.Create <IGTPoint>();
                            point.X = component.Geometry.GetKeypointPosition(k).X + m_offSetX;
                            point.Y = component.Geometry.GetKeypointPosition(k).Y + m_offSetY;
                            newFtPlineGeo.Points.Add(point);
                        }
                        component.Geometry = newFtPlineGeo;
                        break;

                    case GTGeometryTypeConstants.gtgtCompositePolylineGeometry:
                        IGTCompositePolylineGeometry newFtCpline          = GTClassFactory.Create <IGTCompositePolylineGeometry>();
                        IGTPolylineGeometry          polylineGeometrytemp = GTClassFactory.Create <IGTPolylineGeometry>();
                        foreach (IGTGeometry subgeom in (IGTCompositePolylineGeometry)component.Geometry)
                        {
                            switch (subgeom.Type)
                            {
                            case GTGeometryTypeConstants.gtgtPointGeometry:
                            case GTGeometryTypeConstants.gtgtOrientedPointGeometry:
                                point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                break;

                            case GTGeometryTypeConstants.gtgtLineGeometry:
                                point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                point.X = component.Geometry.LastPoint.X + m_offSetX;
                                point.Y = component.Geometry.LastPoint.Y + m_offSetY;
                                polylineGeometrytemp.Points.Add(point);
                                break;

                            case GTGeometryTypeConstants.gtgtPolylineGeometry:
                                for (int k = 0; k < subgeom.KeypointCount; k++)
                                {
                                    point.X = component.Geometry.FirstPoint.X + m_offSetX;
                                    point.Y = component.Geometry.FirstPoint.Y + m_offSetY;
                                    polylineGeometrytemp.Points.Add(point);
                                }
                                break;
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }

                feature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value = sStructureID; //Reset the Structure ID to original value. The update is needed as Set Structure Locaiton FI changed the original Structure ID
                UpdateAssociatedWorkPointsStructureId(feature.FNO, feature.FID, sStructureID);            //Update all the WP associated with the feature
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #14
0
        /// <summary>
        /// Method to re-own child features to replaced feature
        /// </summary>
        private void ReOwnToNewFeatureAndSetActivity()
        {
            try
            {
                if (m_childFeatureInfoList != null)
                {
                    string structureId = Convert.ToString(oFeatureCreator.m_newFeature.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value);
                    foreach (ChildFeatureInfo info in m_childFeatureInfoList)
                    {
                        IGTKeyObject childKeyObject = m_dataContext.OpenFeature(info.GtKeyObject.FNO, info.GtKeyObject.FID);

                        Recordset tempRs = childKeyObject.Components.GetComponent(1).Recordset;
                        tempRs.MoveFirst();
                        if (info.Owner1IdExists)
                        {
                            tempRs.Fields["OWNER1_ID"].Value = oFeatureCreator.m_newG3eId;
                        }
                        else if (info.Owner2IdExists)
                        {
                            tempRs.Fields["OWNER2_ID"].Value = oFeatureCreator.m_newG3eId;
                        }

                        // ALM-1993-ONCORDEV-2572  - Update same structure id to each of the non-linear child features
                        if (!IsActiveFeatureIsLinear(info.GtKeyObject.FNO))
                        {
                            tempRs.Fields["STRUCTURE_ID"].Value = structureId;
                        }
                        tempRs.Update(Type.Missing, Type.Missing);
                    }

                    // Set activity
                    foreach (ChildFeatureInfo info in m_childFeatureInfoList)
                    {
                        if (info.GtKeyObject.Components.GetComponent(21) != null)
                        {
                            Recordset rs = info.GtKeyObject.Components.GetComponent(21).Recordset;
                            if (rs != null && rs.RecordCount > 0)
                            {
                                rs.MoveFirst();
                            }
                            if (oHelper.CheckForCorrectionModeProperty() || m_jobType == "WR-MAPCOR")
                            {
                                while (!rs.EOF)
                                {
                                    rs.Fields["ACTIVITY_C"].Value = "TC";
                                    rs.MoveNext();
                                }
                            }
                            else
                            {
                                while (!rs.EOF)
                                {
                                    rs.Fields["ACTIVITY_C"].Value = "T";
                                    rs.MoveNext();
                                }
                            }
                        }
                        if (info.GtKeyObject.Components.GetComponent(22) != null)
                        {
                            Recordset rs1 = info.GtKeyObject.Components.GetComponent(22).Recordset;

                            if (rs1 != null && rs1.RecordCount > 0)
                            {
                                rs1.MoveFirst();
                            }
                            if (oHelper.CheckForCorrectionModeProperty() || m_jobType == "WR-MAPCOR")
                            {
                                while (!rs1.EOF)
                                {
                                    if (Convert.ToString(rs1.Fields["RETIREMENT_C"].Value).Equals("1") || Convert.ToString(rs1.Fields["RETIREMENT_C"].Value).Equals("2"))
                                    {
                                        rs1.Fields["ACTIVITY_C"].Value = "TC";
                                    }
                                    rs1.MoveNext();
                                }
                            }
                            else
                            {
                                while (!rs1.EOF)
                                {
                                    if (Convert.ToString(rs1.Fields["RETIREMENT_C"].Value).Equals("1") || Convert.ToString(rs1.Fields["RETIREMENT_C"].Value).Equals("2"))
                                    {
                                        rs1.Fields["ACTIVITY_C"].Value = "T";
                                    }
                                    rs1.MoveNext();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                m_TransactionManager.Rollback();
                throw;
            }
        }
예제 #15
0
        /// <summary>
        /// Update the Related Work Point attribute of the Second Work Point.
        /// </summary>
        /// <param name="gTOwnerKeyObjects">Owner Key Object of Active Key Object</param>
        private void UpdateRelatedWPAttribute(IGTKeyObjects gTOwnerKeyObjects)
        {
            IGTComponent gtActiveFeatureCommonCom = null;
            int          Owner1Id = 0;
            int          Owner2Id = 0;

            int Owner1Fid = 0;
            int Owner2Fid = 0;

            IGTKeyObject gTOwner1KeyObject = null;
            IGTKeyObject gTOwner2KeyObject = null;

            IGTKeyObjects gTWorkPointOwner1KeyObjects = null;
            IGTKeyObjects gTWorkPointOwner2KeyObjects = null;

            IGTComponent gTOwner1Component = null;
            IGTComponent gTOwner2Component = null;

            Recordset tmpOwnerrs      = null;
            int       WorkPointNumber = 0;

            string sql   = "";
            int    count = 0;

            try
            {
                gtActiveFeatureCommonCom = m_activeKeyObject.Components.GetComponent(1);
                Owner1Id = Convert.ToInt32(gtActiveFeatureCommonCom.Recordset.Fields["OWNER1_ID"].Value);
                Owner2Id = Convert.ToInt32(gtActiveFeatureCommonCom.Recordset.Fields["OWNER2_ID"].Value);


                sql        = "select G3E_FID from COMMON_N where g3e_id = ?";
                tmpOwnerrs = m_dataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, Owner1Id);

                if (tmpOwnerrs != null && tmpOwnerrs.RecordCount > 0)
                {
                    tmpOwnerrs.MoveFirst();
                    if (!(tmpOwnerrs.EOF && tmpOwnerrs.BOF))
                    {
                        Owner1Fid = Convert.ToInt32(tmpOwnerrs.Fields["G3E_FID"].Value);
                    }
                }


                sql        = "select G3E_FID from COMMON_N where g3e_id = ?";
                tmpOwnerrs = m_dataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, Owner2Id);

                if (tmpOwnerrs != null && tmpOwnerrs.RecordCount > 0)
                {
                    tmpOwnerrs.MoveFirst();
                    if (!(tmpOwnerrs.EOF && tmpOwnerrs.BOF))
                    {
                        Owner2Fid = Convert.ToInt32(tmpOwnerrs.Fields["G3E_FID"].Value);
                    }
                }



                foreach (IGTKeyObject keyObj in gTOwnerKeyObjects)
                {
                    if (keyObj.FID == Owner1Fid)
                    {
                        gTOwner1KeyObject = keyObj;
                    }
                    else if (keyObj.FID == Owner2Fid)
                    {
                        gTOwner2KeyObject = keyObj;
                    }
                }

                gTWorkPointOwner1KeyObjects = FindWorkpointsOfFeature(gTOwner1KeyObject.Components.GetComponent(1));
                gTWorkPointOwner2KeyObjects = FindWorkpointsOfFeature(gTOwner2KeyObject.Components.GetComponent(1));

                gTOwner1Component = gTWorkPointOwner1KeyObjects[0].Components["WORKPOINT_CU_N"];
                bool wpRUpdate = false;
                if (gTOwner1Component.Recordset != null && gTOwner1Component.Recordset.RecordCount > 0)
                {
                    gTOwner1Component.Recordset.MoveFirst();
                    gTOwner2Component = gTWorkPointOwner2KeyObjects[0].Components["WORKPOINT_N"];

                    if (gTOwner1Component.Recordset != null && gTOwner1Component.Recordset.RecordCount > 0)
                    {
                        gTOwner2Component.Recordset.MoveFirst();

                        WorkPointNumber = Convert.ToInt32(gTOwner2Component.Recordset.Fields["wp_nbr"].Value);

                        while (!gTOwner1Component.Recordset.EOF)
                        {
                            if (!String.IsNullOrEmpty(Convert.ToString(gTOwner1Component.Recordset.Fields["ASSOC_FID"].Value)) &&
                                Convert.ToInt32(gTOwner1Component.Recordset.Fields["ASSOC_FID"].Value) == m_activeKeyObject.FID)
                            {
                                gTOwner1Component.Recordset.Fields["WP_RELATED"].Value = WorkPointNumber;
                                wpRUpdate = true;
                            }

                            gTOwner1Component.Recordset.MoveNext();
                        }
                    }
                }

                if (!wpRUpdate)
                {
                    gTOwner2Component = gTWorkPointOwner2KeyObjects[0].Components["WORKPOINT_CU_N"];

                    if (gTOwner2Component.Recordset != null && gTOwner2Component.Recordset.RecordCount > 0)
                    {
                        gTOwner2Component.Recordset.MoveFirst();
                        gTOwner1Component = gTWorkPointOwner1KeyObjects[0].Components["WORKPOINT_N"];

                        if (gTOwner2Component.Recordset != null && gTOwner2Component.Recordset.RecordCount > 0)
                        {
                            gTOwner1Component.Recordset.MoveFirst();
                            WorkPointNumber = Convert.ToInt32(gTOwner1Component.Recordset.Fields["wp_nbr"].Value);

                            while (!gTOwner2Component.Recordset.EOF)
                            {
                                if (!String.IsNullOrEmpty(Convert.ToString(gTOwner2Component.Recordset.Fields["ASSOC_FID"].Value)) &&
                                    Convert.ToInt32(gTOwner2Component.Recordset.Fields["ASSOC_FID"].Value) == m_activeKeyObject.FID)
                                {
                                    gTOwner2Component.Recordset.Fields["WP_RELATED"].Value = WorkPointNumber;
                                }

                                gTOwner2Component.Recordset.MoveNext();
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
예제 #16
0
 public FeatureConnectivityAttributes(IGTKeyObject p_keyObject)
 {
     m_FeatureKeyObject = p_keyObject;
     m_oApp             = GTClassFactory.Create <IGTApplication>();
     SetUpstreamNode();
 }
예제 #17
0
 public bool AllowDelete(GTRelationshipGeometryDeleteActionConstants DeleteAction, IGTKeyObject RelatedFeature)
 {
     return(true);
 }
예제 #18
0
        /// <summary>
        /// Method to check whether the active feature has Isolation Point on specific node.
        /// If Isolation Point exists then validate association and update if necessary.
        /// </summary>
        /// <param name="relatedFeatures">Features to check</param>
        /// <param name="isoPtExists">True, if isolation point exists</param>
        /// <param name="isoPtNumber">Isolation point number</param>
        /// <returns>Boolean indicating method execution status</returns>
        private bool ValidateIsolationPoint(IGTKeyObjects relatedFeatures, ref bool isoPtExists, short isoPtNumber)
        {
            bool returnValue = false;

            try
            {
                isoPtExists = false;

                foreach (IGTKeyObject feature in relatedFeatures)
                {
                    // Check if Isolation Point feature exists
                    if ((feature.FNO == 40 || feature.FNO == 80) && m_IsoCommon.CheckAssociatedVirtualPoint(feature, m_IsolationScenarioFeature.GtKeyObject.FID))
                    {
                        isoPtExists = true;

                        if (isoPtNumber == 1)
                        {
                            m_IsolationScenarioFeature.IsolationPoint1 = feature;
                        }
                        else
                        {
                            m_IsolationScenarioFeature.IsolationPoint2 = feature;
                        }

                        // Validate and set, if necessary, specific Isolation Point attributes to associated feature
                        string errMessage;
                        m_IsoCommon.SetVirtualPointAttributes(m_IsolationScenarioFeature, feature, out errMessage);
                        break;
                    }
                }


                if (relatedFeatures.Count == 0)
                {
                    IGTKeyObject gTKeyObject = CheckforVirtualpoint(isoPtNumber);

                    if (gTKeyObject != null)
                    {
                        isoPtExists = true;

                        if (isoPtNumber == 1)
                        {
                            m_IsolationScenarioFeature.IsolationPoint1 = gTKeyObject;
                        }
                        else
                        {
                            m_IsolationScenarioFeature.IsolationPoint2 = gTKeyObject;
                        }

                        // Validate and set, if necessary, specific Isolation Point attributes to associated feature
                        string errMessage;
                        m_IsoCommon.SetVirtualPointAttributes(m_IsolationScenarioFeature, gTKeyObject, out errMessage);
                    }
                }
                returnValue = true;
            }
            catch (Exception ex)
            {
                returnValue = false;
                if (m_IsoCommon.InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:ValidateIsolationPoint - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            return(returnValue);
        }
예제 #19
0
 public void BeforeDelete(GTRelationshipGeometryDeleteActionConstants DeleteAction, IGTKeyObject RelatedFeature)
 {
 }
예제 #20
0
        /// <summary>
        /// Method to create an Isolation Point.
        /// </summary>
        /// <param name="isoPtNumber">Isolation point number</param>
        /// <returns>Boolean indicating method execution status</returns>
        private bool CreateIsolationPoint(short isoPtNumber)
        {
            bool  returnValue = false;
            short primaryCNO  = 0;
            short isoPtCNO    = 0;

            try
            {
                IGTKeyObject isoPtKO = m_dataContext.NewFeature(40);

                string errMessage;
                m_IsoCommon.SetAttributeDefaults(isoPtKO, out errMessage);
                m_IsoCommon.SetVirtualPointAttributes(m_IsolationScenarioFeature, isoPtKO, out errMessage);

                Recordset oRSFeature = m_dataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "g3e_fno = " + m_IsolationScenarioFeature.GtKeyObject.FNO);
                m_IsoCommon.IsDetailMapWindow();
                if (m_IsoCommon.detailID == 0)
                {
                    primaryCNO = Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value);
                    isoPtCNO   = 78;
                }
                else
                {
                    primaryCNO = Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYDETAILCNO"].Value);
                    isoPtCNO   = 79;
                }

                // Check if symbol component has been created. If metadata is defined with alternate required component then symbol record will need to be added.
                if (isoPtKO.Components.GetComponent(isoPtCNO).Recordset.RecordCount == 0)
                {
                    isoPtKO.Components.GetComponent(isoPtCNO).Recordset.AddNew();
                    isoPtKO.Components.GetComponent(isoPtCNO).Recordset.Fields["G3E_FNO"].Value = isoPtKO.FNO;
                    isoPtKO.Components.GetComponent(isoPtCNO).Recordset.Fields["G3E_FID"].Value = isoPtKO.FID;
                    if (m_IsoCommon.detailID != 0)
                    {
                        isoPtKO.Components.GetComponent(isoPtCNO).Recordset.Fields["G3E_DETAILID"].Value = m_IsoCommon.detailID;
                    }
                    isoPtKO.Components.GetComponent(isoPtCNO).Recordset.MoveFirst();
                }

                // Set the geometry
                IGTPoint gtPt = GTClassFactory.Create <IGTPoint>();
                IGTOrientedPointGeometry orientedPtGeom = GTClassFactory.Create <IGTOrientedPointGeometry>();

                orientedPtGeom = (IGTOrientedPointGeometry)m_IsolationScenarioFeature.GtKeyObject.Components.GetComponent(primaryCNO).Geometry;

                double xOffset = 0;
                double yOffset = 0;

                if (m_IsolationScenarioFeature.GtKeyObject.FNO == 36)
                {
                    if (isoPtNumber == 1)
                    {
                        xOffset = IsoCommon.VOLT_REG_ISO_PT1_OFFSET_X;
                        yOffset = IsoCommon.VOLT_REG_ISO_PT1_OFFSET_Y;
                    }
                    else if (isoPtNumber == 2)
                    {
                        xOffset = IsoCommon.VOLT_REG_ISO_PT2_OFFSET_X;
                        yOffset = IsoCommon.VOLT_REG_ISO_PT2_OFFSET_Y;
                    }
                    else
                    {
                        xOffset = IsoCommon.VOLT_REG_ISO_PT3_OFFSET_X;
                        yOffset = IsoCommon.VOLT_REG_ISO_PT3_OFFSET_Y;
                    }
                }
                else
                {
                    if (isoPtNumber == 1)
                    {
                        xOffset = IsoCommon.RECLOSER_ISO_PT1_OFFSET_X;
                        yOffset = IsoCommon.RECLOSER_ISO_PT1_OFFSET_Y;
                    }
                    else if (isoPtNumber == 2)
                    {
                        xOffset = IsoCommon.RECLOSER_ISO_PT2_OFFSET_X;
                        yOffset = IsoCommon.RECLOSER_ISO_PT2_OFFSET_Y;
                    }
                    else
                    {
                        xOffset = IsoCommon.RECLOSER_ISO_PT3_OFFSET_X;
                        yOffset = IsoCommon.RECLOSER_ISO_PT3_OFFSET_Y;
                    }
                }

                gtPt = m_IsoCommon.GetOffsetPoint(orientedPtGeom.Origin, xOffset * .3048, yOffset * .3048, orientedPtGeom.Orientation);

                orientedPtGeom.Origin = gtPt;

                isoPtKO.Components.GetComponent(isoPtCNO).Geometry = orientedPtGeom;

                if (isoPtNumber == 1)
                {
                    //m_IsoCommon.EstablishConnectivity(isoPtKO, m_IsolationScenarioFeature.GtKeyObject, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1);
                    m_IsolationScenarioFeature.RelatedFeaturesNode1.Add(isoPtKO);
                    m_IsolationScenarioFeature.IsolationPoint1 = isoPtKO;
                }
                else if (isoPtNumber == 2)
                {
                    //m_IsoCommon.EstablishConnectivity(isoPtKO, m_IsolationScenarioFeature.GtKeyObject, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal1, GTRelationshipOrdinalConstants.gtrelRelationshipOrdinal2);
                    m_IsolationScenarioFeature.RelatedFeaturesNode2.Add(isoPtKO);
                    m_IsolationScenarioFeature.IsolationPoint2 = isoPtKO;
                }
                else
                {
                    m_IsolationScenarioFeature.IsolationPoint3 = isoPtKO;
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                returnValue = false;
                if (m_IsoCommon.InteractiveMode)
                {
                    MessageBox.Show("Error in Isolation Scenario FI:CreateIsolationPoint - " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            return(returnValue);
        }
예제 #21
0
        /// <summary>
        /// Identifies the Key Object that's the Owner1 and Owner2 of the Child Feature
        /// </summary>
        /// <param name="parentFeatures">IGTKeyObjects</param>
        /// <param name="childFeature">IGTKeyObject</param>
        /// <param name="owner1KeyObject">IGTKeyObject</param>
        /// <param name="owner2KeyObject">IGTKeyObject</param>
        /// <returns></returns>
        public void GetOwner1Owner2(IGTKeyObjects parentFeatures, IGTKeyObject childFeature, ref IGTKeyObject owner1KeyObject, ref IGTKeyObject owner2KeyObject)
        {
            if (DBNull.Value != childFeature.Components["COMMON_N"].Recordset.Fields["OWNER1_ID"].Value)
            {
                int owner1ID = Convert.ToInt32(childFeature.Components["COMMON_N"].Recordset.Fields["OWNER1_ID"].Value);

                foreach (IGTKeyObject ko in parentFeatures)
                {
                    if (null != ko.Components["COMMON_N"].Recordset)
                    {
                        ko.Components["COMMON_N"].Recordset.MoveFirst();

                        if (Convert.ToInt32(ko.Components["COMMON_N"].Recordset.Fields["G3E_ID"].Value) == owner1ID)
                        {
                            owner1KeyObject = ko;
                            break;
                        }
                    }
                }
            }
            if (DBNull.Value != childFeature.Components["COMMON_N"].Recordset.Fields["OWNER2_ID"].Value)
            {
                int owner2ID = Convert.ToInt32(childFeature.Components["COMMON_N"].Recordset.Fields["OWNER2_ID"].Value);

                foreach (IGTKeyObject ko in parentFeatures)
                {
                    if (null != ko.Components["COMMON_N"].Recordset)
                    {
                        ko.Components["COMMON_N"].Recordset.MoveFirst();

                        if (Convert.ToInt32(ko.Components["COMMON_N"].Recordset.Fields["G3E_ID"].Value) == owner2ID)
                        {
                            owner2KeyObject = ko;
                            break;
                        }
                    }
                }
            }
        }
예제 #22
0
        public void DeleteObsoleteCURecords(IGTKeyObject p_keyObject)
        {
            IGTComponent oComponent = p_keyObject.Components.GetComponent(19104);

            ADODB.Recordset rs             = null;
            string          sStrcutureIDWP = string.Empty;

            ADODB.Recordset rsCUComponent = null;

            try
            {
                rsCUComponent  = p_keyObject.Components.GetComponent(19101).Recordset;
                sStrcutureIDWP = Convert.ToString(rsCUComponent.Fields["STRUCTURE_ID"].Value);

                if (oComponent != null)
                {
                    if (oComponent.Recordset != null)
                    {
                        if (oComponent.Recordset.RecordCount > 0)
                        {
                            oComponent.Recordset.MoveFirst();
                            while (oComponent.Recordset.EOF == false)
                            {
                                int    iFID      = Convert.ToInt32(oComponent.Recordset.Fields["ASSOC_FID"].Value);
                                int    iCID      = Convert.ToInt32(oComponent.Recordset.Fields["UNIT_CID"].Value);
                                string sCU       = Convert.ToString(oComponent.Recordset.Fields["CU_C"].Value);
                                string sActivity = Convert.ToString(oComponent.Recordset.Fields["activity_c"].Value);

                                rs = m_dataContext.OpenRecordset("select count(*) from COMMON_N where g3e_fid =?", ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, iFID);

                                if (Convert.ToInt32(rs.Fields[0].Value).Equals(1)) //Feature exists but Strucure ID is different now
                                {
                                    rs = m_dataContext.OpenRecordset("select count(*) from COMMON_N where g3e_fid =? and STRUCTURE_ID<> ?", ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, iFID, sStrcutureIDWP);

                                    if (Convert.ToInt32(rs.Fields[0].Value).Equals(1))
                                    {
                                        oComponent.Recordset.Delete();
                                    }
                                    else  //Check if the relevent record that we are seeing exists on the feature or not. This will take care of discard for a feature on CID level
                                    {
                                        rs = m_dataContext.OpenRecordset("select count(*) from COMP_UNIT_N where g3e_fid =? and g3e_cid = ? and cu_c = ? and activity_c = ?", ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic, (int)ADODB.CommandTypeEnum.adCmdText, iFID, iCID, sCU, sActivity);

                                        if (Convert.ToInt32(rs.Fields[0].Value).Equals(0))
                                        {
                                            oComponent.Recordset.Delete();
                                        }
                                    }
                                }
                                else //Feature does not exist so delete the record corresponding to this associated FID
                                {
                                    oComponent.Recordset.Delete();
                                }

                                if (oComponent.Recordset.EOF == false)
                                {
                                    oComponent.Recordset.MoveNext();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }
        }
예제 #23
0
        /// <summary>
        /// Validates the active feature.
        /// </summary>
        /// <param name="errorPriorityNoWorkpoint"></param>
        /// <param name="errorPriorityNoMatchingWorkPoint"></param>
        /// <param name="p_lstErrorMessage"></param>
        /// <param name="p_lstErrorPriority"></param>
        /// <param name="m_gtcommonFunctions"></param>
        public void ValidateFeature(string errorPriorityNoWorkpoint, string errorPriorityNoMatchingWorkPoint, ref List <string> p_lstErrorMessage, ref List <string> p_lstErrorPriority, CommonFunctions m_gtcommonFunctions)
        {
            IGTKeyObjects gTKeyObjects        = GTClassFactory.Create <IGTKeyObjects>();
            int           relatedWP           = 0;
            string        strArgument1        = "";
            string        strArgument2        = "";
            bool          noWorkPoint         = false;
            bool          noMatchingWorkPoint = false;

            try
            {
                if (m_gtcommonFunctions.IsActiveFeatureIsLinear(m_ActiveKeyObject.FNO))
                {
                    IGTKeyObjects gTOwnerKeyObjects = LocateOwnersOfActiveFeature();
                    if (gTOwnerKeyObjects.Count > 0)
                    {
                        if (gTOwnerKeyObjects.Count == 2)
                        {
                            IGTKeyObject owner1KeyObject = GTClassFactory.Create <IGTKeyObject>();
                            IGTKeyObject owner2KeyObject = GTClassFactory.Create <IGTKeyObject>();

                            GetOwner1Owner2(gTOwnerKeyObjects, m_ActiveKeyObject, ref owner1KeyObject, ref owner2KeyObject);

                            CheckValidationForOwner1Feature(owner1KeyObject, ref relatedWP, ref noWorkPoint, ref noMatchingWorkPoint, ref strArgument1, ref strArgument2);

                            AddValidationsToArray(noWorkPoint, noMatchingWorkPoint, strArgument1, strArgument2, ref p_lstErrorMessage, ref p_lstErrorPriority, errorPriorityNoWorkpoint, errorPriorityNoMatchingWorkPoint);

                            noWorkPoint         = false;
                            noMatchingWorkPoint = true;
                            strArgument1        = "";
                            strArgument2        = "";

                            CheckValidationForOwner2Feature(owner2KeyObject, relatedWP, ref noWorkPoint, ref noMatchingWorkPoint, ref strArgument1, ref strArgument2);

                            AddValidationsToArray(noWorkPoint, noMatchingWorkPoint, strArgument1, strArgument2, ref p_lstErrorMessage, ref p_lstErrorPriority, errorPriorityNoWorkpoint, errorPriorityNoMatchingWorkPoint);
                        }
                        else
                        {
                            CheckValidationForOwner1Feature(gTOwnerKeyObjects[0], ref relatedWP, ref noWorkPoint, ref noMatchingWorkPoint, ref strArgument1, ref strArgument2);

                            AddValidationsToArray(noWorkPoint, noMatchingWorkPoint, strArgument1, strArgument2, ref p_lstErrorMessage, ref p_lstErrorPriority, errorPriorityNoWorkpoint, errorPriorityNoMatchingWorkPoint);
                        }
                    }
                }
                else
                {
                    if (CheckForOwnedByRelation())
                    {
                        IGTKeyObjects gTOwnerKeyObjects = LocateOwnersOfActiveFeature();

                        if (gTOwnerKeyObjects.Count > 0)
                        {
                            CheckValidationForOwner1Feature(gTOwnerKeyObjects[0], ref relatedWP, ref noWorkPoint, ref noMatchingWorkPoint, ref strArgument1, ref strArgument2);

                            AddValidationsToArray(noWorkPoint, noMatchingWorkPoint, strArgument1, strArgument2, ref p_lstErrorMessage, ref p_lstErrorPriority, errorPriorityNoWorkpoint, errorPriorityNoMatchingWorkPoint);
                        }
                    }
                    else
                    {
                        CheckValidationForOwner1Feature(m_ActiveKeyObject, ref relatedWP, ref noWorkPoint, ref noMatchingWorkPoint, ref strArgument1, ref strArgument2);

                        AddValidationsToArray(noWorkPoint, noMatchingWorkPoint, strArgument1, strArgument2, ref p_lstErrorMessage, ref p_lstErrorPriority, errorPriorityNoWorkpoint, errorPriorityNoMatchingWorkPoint);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
예제 #24
0
        private void ProcessModifiedCUComponents()
        {
            try
            {
                foreach (IGTComponent item in m_gtAllCUComponents)
                {
                    m_gTActiveComponent = item;
                    if (CheckForOwnedByRelation())
                    {
                        IGTKeyObjects gTOwnerKeyObjects = LocateOwnersOfActiveFeature(3, m_activeKeyObject);
                        if (gTOwnerKeyObjects.Count > 0)
                        {
                            //if (m_gtcommonFunctions.IsActiveFeatureIsLinear(m_gtActiveFno))
                            if (IsActiveFeatureIsLinear(m_gtActiveFno))
                            {
                                int ownerCount = 0;

                                if (gTOwnerKeyObjects.Count == 2)
                                {
                                    IGTKeyObject owner1KeyObject = GTClassFactory.Create <IGTKeyObject>();
                                    IGTKeyObject owner2KeyObject = GTClassFactory.Create <IGTKeyObject>();
                                    GetOwner1Owner2(gTOwnerKeyObjects, m_activeKeyObject, ref owner1KeyObject, ref owner2KeyObject);
                                    CreateOrUpdateWorkpoint(owner1KeyObject.Components.GetComponent(1), true, ownerCount);
                                    CreateOrUpdateWorkpoint(owner2KeyObject.Components.GetComponent(1), true, -1);
                                }
                                else
                                {
                                    CreateOrUpdateWorkpoint(gTOwnerKeyObjects[0].Components.GetComponent(1), true, ownerCount);
                                }

                                if (gTOwnerKeyObjects.Count == 2)
                                {
                                    UpdateRelatedWPAttribute(gTOwnerKeyObjects);
                                }
                            }
                            else
                            {
                                CreateOrUpdateWorkpoint(gTOwnerKeyObjects[0].Components.GetComponent(1), false, gTOwnerKeyObjects.Count);
                            }
                        }
                    }
                    else
                    {
                        // Accomodate Structures that have no owners

                        // This list of Structure FNOs should be parameterized
                        //106 Manhole
                        //107 Miscellaneous Structure
                        //108 Pad
                        //109 Primary Pull Box
                        //110 Pole
                        //113 Secondary Box
                        //114 Street Light Standard
                        //115 Substation
                        //116 Transmission Tower
                        //117 Vault
                        //120 Secondary Enclosure
                        //2500  Junction Point

                        if (m_activeKeyObject.FNO == 2400)
                        {
                            ProcessingFormation();
                        }
                        else
                        {
                            List <short> structFNO = new List <short> {
                                106, 107, 108, 109, 110, 113, 114, 115, 116, 117, 120, 2500
                            };

                            Recordset rs = m_activeKeyObject.Components.GetComponent(1).Recordset;

                            //string structureID = rs.Fields["STRUCTURE_ID"].Value != DBNull.Value ? Convert.ToString(rs.Fields["STRUCTURE_ID"].Value) : string.Empty;
                            string structureID = (!Convert.IsDBNull(rs.Fields["STRUCTURE_ID"].Value)) ? Convert.ToString(rs.Fields["STRUCTURE_ID"].Value) : string.Empty;

                            if (structFNO.Contains(m_activeKeyObject.FNO) && !string.IsNullOrEmpty(structureID))
                            {
                                CreateOrUpdateWorkpoint(m_activeKeyObject.Components.GetComponent(1), false, 0);
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
예제 #25
0
        /// <summary>
        /// Sets attributes for the virtual point to keep in sync with the associated feature
        /// </summary>
        /// <param name="isoScenarioFeature">The associated feature from which to get attribute values.</param>
        /// <param name="gtKeyObject">Feature key object to validate and set attribute values.</param>
        /// <returns>Boolean indicating status</returns>
        public bool SetVirtualPointAttributes(IsoScenarioFeature isoScenarioFeature, IGTKeyObject gtKeyObject, out string message)
        {
            bool returnValue = false;

            try
            {
                message = "";

                Recordset isoPtRS = gtKeyObject.Components.GetComponent(4).Recordset;
                if (isoPtRS.RecordCount > 0)
                {
                    isoPtRS.MoveFirst();

                    string associatedFID = isoPtRS.Fields["ASSOCIATED_FID"].Value.ToString();
                    if (associatedFID != isoScenarioFeature.GtKeyObject.FID.ToString())
                    {
                        isoPtRS.Fields["ASSOCIATED_FID"].Value = isoScenarioFeature.GtKeyObject.FID;
                    }
                }

                string commFeatureState = string.Empty;

                isoPtRS = gtKeyObject.Components.GetComponent(1).Recordset;
                if (isoPtRS.RecordCount > 0)
                {
                    isoPtRS.MoveFirst();

                    commFeatureState = isoPtRS.Fields["FEATURE_STATE_C"].Value.ToString();
                    if (commFeatureState != isoScenarioFeature.FeatureState)
                    {
                        isoPtRS.Fields["FEATURE_STATE_C"].Value = isoScenarioFeature.FeatureState;
                        commFeatureState = isoScenarioFeature.FeatureState;
                    }
                }

                isoPtRS = gtKeyObject.Components.GetComponent(11).Recordset;
                if (isoPtRS.RecordCount > 0)
                {
                    isoPtRS.MoveFirst();

                    string phase = isoPtRS.Fields["PHASE_ALPHA"].Value.ToString();
                    if (phase != isoScenarioFeature.Phase)
                    {
                        isoPtRS.Fields["PHASE_ALPHA"].Value = isoScenarioFeature.Phase;
                    }

                    string connFeatureState = isoPtRS.Fields["FEATURE_STATE_C"].Value.ToString();
                    if (connFeatureState != commFeatureState)
                    {
                        isoPtRS.Fields["FEATURE_STATE_C"].Value = commFeatureState;
                    }
                }

                returnValue = true;
            }
            catch (Exception ex)
            {
                message     = ex.Message;
                returnValue = false;
            }
            return(returnValue);
        }
예제 #26
0
        private void ProcessingFormation()
        {
            IGTComponent gTContainsComponent = m_activeKeyObject.Components["CONTAIN_N"];


            if (gTContainsComponent != null && gTContainsComponent.Recordset != null &&
                gTContainsComponent.Recordset.RecordCount > 0)
            {
                Recordset rsContains  = gTContainsComponent.Recordset;
                Recordset rsDuctivity = null;

                rsContains.MoveFirst();
                while (!rsContains.EOF)
                {
                    IGTKeyObject formationOwner = m_dataContext.OpenFeature(Convert.ToInt16(rsContains.Fields["G3E_OWNERFNO"].Value), Convert.ToInt32(rsContains.Fields["G3E_OWNERFID"].Value));
                    if (formationOwner.Components.Count > 0 &&
                        formationOwner.Components["DUCTIVITY_N"] != null &&
                        formationOwner.Components["DUCTIVITY_N"].Recordset != null &&
                        formationOwner.Components["DUCTIVITY_N"].Recordset.RecordCount > 0)
                    {
                        rsDuctivity = formationOwner.Components["DUCTIVITY_N"].Recordset;

                        IGTKeyObjects ownerKeyObjects = LocateOwnersOfActiveFeature(122, formationOwner);

                        foreach (IGTKeyObject gtownerKeyObject in ownerKeyObjects)
                        {
                            if (gtownerKeyObject.FID != formationOwner.FID)
                            {
                                List <short> structFNO = new List <short> {
                                    106, 107, 108, 109, 110, 113, 114, 115, 116, 117, 120, 2500
                                };
                                if (structFNO.Contains(Convert.ToInt16(gtownerKeyObject.FNO)))
                                {
                                    IGTKeyObjects ownerWorkpoints = FindWorkpointsOfFeature(gtownerKeyObject.Components.GetComponent(1));

                                    if (ownerWorkpoints != null)
                                    {
                                        if (ownerWorkpoints.Count <= 0)
                                        {
                                            CreateNewWorkpointFeature(
                                                Convert.ToInt16(m_activeKeyObject.Components.GetComponent(1).Recordset.Fields["G3E_FNO"].Value),
                                                Convert.ToInt32(m_activeKeyObject.Components.GetComponent(1).Recordset.Fields["G3E_FID"].Value),
                                                true,
                                                Convert.ToString(gtownerKeyObject.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value),
                                                0, gtownerKeyObject.FNO, gtownerKeyObject.FID);
                                        }
                                        else
                                        {
                                            UpdateWorkpointComponents(Convert.ToInt16(gtownerKeyObject.Components.GetComponent(1).Recordset.Fields["G3E_FNO"].Value),
                                                                      Convert.ToInt32(gtownerKeyObject.Components.GetComponent(1).Recordset.Fields["G3E_FID"].Value),
                                                                      ownerWorkpoints[0], false,
                                                                      Convert.ToString(gtownerKeyObject.Components.GetComponent(1).Recordset.Fields["STRUCTURE_ID"].Value), 0,
                                                                      true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    rsContains.MoveNext();
                }
            }
        }
예제 #27
0
 public void placeServiceLine()
 {
     gtTransactionManager.Begin("Service Line Placement");
     serviceLine = dataContext.NewFeature(g_Service_Line_FNO);
     featurePlacementService.StartFeature(serviceLine);
 }
예제 #28
0
        /// <summary>
        /// Locate the associated Work Point feature (if it exists) for the active WR job.
        /// </summary>
        /// <param name="gTCommonComponent">Common component</param>
        /// <returns></returns>
        private IGTKeyObjects FindWorkpointsOfFeature(IGTComponent gTCommonComponent)
        {
            string        strStructureId      = null;
            string        sql                 = "";
            Recordset     rsWorkpoints        = null;
            int           count               = 0;
            IGTKeyObjects workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>();

            try
            {
                if (gTCommonComponent != null && gTCommonComponent.Recordset.RecordCount > 0)
                {
                    gTCommonComponent.Recordset.MoveFirst();
                    strStructureId = Convert.ToString(gTCommonComponent.Recordset.Fields["STRUCTURE_ID"].Value);
                }

                if (!string.IsNullOrEmpty(strStructureId))
                {
                    sql          = string.Format("select G3E_FID,G3E_FNO from WORKPOINT_N where STRUCTURE_ID = '{0}' and WR_NBR = '{1}'", strStructureId, m_dataContext.ActiveJob);
                    rsWorkpoints = m_dataContext.Execute(sql, out count, (int)ADODB.CommandTypeEnum.adCmdText, null);

                    if (rsWorkpoints != null && rsWorkpoints.RecordCount > 0)
                    {
                        workPointKeyObjects = GTClassFactory.Create <IGTKeyObjects>();
                        rsWorkpoints.MoveFirst();
                        while (!rsWorkpoints.EOF)
                        {
                            IGTKeyObject workPoint = m_dataContext.OpenFeature(Convert.ToInt16(rsWorkpoints.Fields["G3E_FNO"].Value), Convert.ToInt32(rsWorkpoints.Fields["G3E_FID"].Value));
                            workPointKeyObjects.Add(workPoint);
                            rsWorkpoints.MoveNext();
                        }
                    }
                    else if (m_NewWorkpointFidList.Count > 0)
                    {
                        foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList)
                        {
                            if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value))
                            {
                                IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value);
                                workPointKeyObjects.Add(workPoint);
                            }
                        }
                    }
                }
                else if (m_NewWorkpointFidList.Count > 0)
                {
                    foreach (KeyValuePair <int, int> wpListFid in m_NewWorkpointFidList)
                    {
                        if (wpListFid.Key == Convert.ToInt32(gTCommonComponent.Recordset.Fields["G3E_FID"].Value))
                        {
                            IGTKeyObject workPoint = m_dataContext.OpenFeature(191, wpListFid.Value);
                            workPointKeyObjects.Add(workPoint);
                        }
                    }
                }
            }
            catch
            {
                throw;
            }

            return(workPointKeyObjects);
        }
예제 #29
0
        /// <summary>
        /// Method to process the change outs to the target feature
        /// </summary>
        /// <returns>True, if Changeout is successful. Else false</returns>
        private bool ProcessChangeOutsToTargetFeature()
        {
            int       wireCount      = 0;
            Recordset cuAttributesRs = null;

            try
            {
                IGTKeyObject         targetFeature    = m_dataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID);
                IGTComponent         tWireAttributes  = targetFeature.Components.GetComponent(m_wireAttributesCno);
                IGTComponent         tCuAttributes    = targetFeature.Components.GetComponent(21);
                List <CuInformation> TargetCuInfoList = new List <CuInformation>();
                if (tWireAttributes != null)
                {
                    Recordset wireAttributesRs = tWireAttributes.Recordset;
                    wireCount = wireAttributesRs.RecordCount;
                    if (wireAttributesRs != null && wireAttributesRs.RecordCount > 0)
                    {
                        wireAttributesRs.Sort = "G3E_CID";
                        wireAttributesRs.MoveFirst();
                        while (!wireAttributesRs.EOF)
                        {
                            oCuInformation = new CuInformation();
                            if (m_isPrimaryConductor)
                            {
                                oCuInformation.Phase = Convert.ToString(wireAttributesRs.Fields["PHASE_C"].Value);
                            }

                            else
                            {
                                if (String.IsNullOrEmpty(Convert.ToString(wireAttributesRs.Fields["NEUTRAL_YN"].Value)) ||
                                    Convert.ToString(wireAttributesRs.Fields["NEUTRAL_YN"].Value) == "X")
                                {
                                    oCuInformation.isNeutral = false;
                                }
                                else
                                {
                                    oCuInformation.isNeutral = Convert.ToString(wireAttributesRs.Fields["NEUTRAL_YN"].Value) == "Y" ? true : false;
                                }
                            }
                            if (Convert.IsDBNull(wireAttributesRs.Fields["G3E_CID"].Value))
                            {
                                if (m_oGTTransactionManager.TransactionInProgress)
                                {
                                    m_oGTTransactionManager.Rollback();
                                }
                                ExitCommand();
                                return(false);
                            }
                            oCuInformation.TargetCid = Convert.ToInt16(wireAttributesRs.Fields["G3E_CID"].Value);
                            TargetCuInfoList.Add(oCuInformation);
                            wireAttributesRs.MoveNext();
                        }
                        TargetCuInfoList.OrderBy(a => a.TargetCid);
                    }
                }
                if (oCuInformation == null || TargetCuInfoList.Count == 0)
                {
                    if (m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Rollback();
                    }
                    ExitCommand();
                    return(false);
                }
                if (tCuAttributes != null)
                {
                    cuAttributesRs = tCuAttributes.Recordset;
                    int cuCount = cuAttributesRs.RecordCount;
                    if (cuCount != wireCount)
                    {
                        if (m_oGTTransactionManager.TransactionInProgress)
                        {
                            m_oGTTransactionManager.Rollback();
                        }
                        ExitCommand();
                        return(false);
                    }
                    if (cuAttributesRs != null && cuAttributesRs.RecordCount > 0)
                    {
                        cuAttributesRs.Sort = "G3E_CID";
                        cuAttributesRs.MoveFirst();
                        int i = 0;
                        while (!cuAttributesRs.EOF)
                        {
                            TargetCuInfoList[i].CuCode   = Convert.ToString(cuAttributesRs.Fields["CU_C"].Value);
                            TargetCuInfoList[i].Activity = Convert.ToString(cuAttributesRs.Fields["ACTIVITY_C"].Value);
                            //if(!Convert.IsDBNull(cuAttributesRs.Fields["UNIT_CID"].Value))
                            //TargetCuInfoList[i].UnitCID = Convert.ToInt32(cuAttributesRs.Fields["UNIT_CID"].Value);
                            TargetCuInfoList[i].SourceCid = Convert.ToInt16(cuAttributesRs.Fields["G3E_CID"].Value);
                            i = i + 1;
                            cuAttributesRs.MoveNext();
                        }
                    }
                }
                var sourceChangeOutList = m_SourceCuInfoList.Where(a => a.Activity == "R" || a.Activity == "S").ToList();

                List <CuInformation> changeList = new List <CuInformation>();
                List <CuInformation> PhaseAndCUcodeMatchList = new List <CuInformation>();
                List <CuInformation> PhaseMatchList          = new List <CuInformation>();
                List <string>        completedPhasesList     = new List <string>();

                if (m_isPrimaryConductor) // Primary conductor feature
                {
                    bool proceedFurther = false;
                    foreach (CuInformation sourceCU in sourceChangeOutList)
                    {
                        foreach (CuInformation targetCU in TargetCuInfoList)
                        {
                            if (!string.IsNullOrEmpty(sourceCU.Phase) && sourceCU.Phase.Equals(targetCU.Phase))
                            {
                                proceedFurther = true;
                                break;
                            }
                        }
                        if (proceedFurther)
                        {
                            break;
                        }
                    }

                    if (!proceedFurther)
                    {
                        MessageBox.Show("Target conductor span does not include wires that match changes in the source span.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        m_iGtApplication.ActiveMapWindow.HighlightedObjects.Remove(m_selectedObject);
                        return(false);
                    }

                    foreach (CuInformation sourceCU in sourceChangeOutList)
                    {
                        foreach (CuInformation targetCU in TargetCuInfoList)
                        {
                            if (sourceCU.Phase.Equals(targetCU.Phase) && sourceCU.CuCode.Equals(targetCU.CuCode))
                            {
                                CuInformation cu = new CuInformation {
                                    SourceCid = sourceCU.SourceCid, TargetCid = targetCU.SourceCid, UnitCID = sourceCU.UnitCID, Activity = sourceCU.Activity, ReplacedCID = sourceCU.ReplacedCID, Phase = sourceCU.Phase, PhasePosition = sourceCU.PhasePosition
                                };
                                PhaseAndCUcodeMatchList.Add(cu);
                                completedPhasesList.Add(sourceCU.Phase);
                                //break;
                            }
                        }
                    }
                    foreach (CuInformation sourceCU in sourceChangeOutList)
                    {
                        foreach (CuInformation targetCU in TargetCuInfoList)
                        {
                            if (sourceCU.Phase.Equals(targetCU.Phase) && !sourceCU.CuCode.Equals(targetCU.CuCode) && !completedPhasesList.Contains(sourceCU.Phase))
                            {
                                CuInformation cu = new CuInformation {
                                    SourceCid = sourceCU.SourceCid, TargetCid = targetCU.SourceCid, UnitCID = sourceCU.UnitCID, Activity = sourceCU.Activity, ReplacedCID = sourceCU.ReplacedCID, Phase = sourceCU.Phase, PhasePosition = sourceCU.PhasePosition
                                };
                                PhaseMatchList.Add(cu);
                                completedPhasesList.Add(sourceCU.Phase);
                                //break;
                            }
                        }
                    }
                }

                else // Secondary conductor feature
                {
                    bool proceedFurther = false;

                    foreach (CuInformation sourceCU in sourceChangeOutList)
                    {
                        foreach (CuInformation targetCU in TargetCuInfoList)
                        {
                            if (sourceCU.isNeutral.Equals(targetCU.isNeutral) && !sourceCU.isNeutral.Equals(null))
                            {
                                proceedFurther = true;
                                break;
                            }
                        }
                        if (proceedFurther)
                        {
                            break;
                        }
                    }

                    if (!proceedFurther)
                    {
                        MessageBox.Show("Target conductor span does not include wires that match changes in the source span.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        m_iGtApplication.ActiveMapWindow.HighlightedObjects.Remove(m_selectedObject);
                        return(false);
                    }

                    List <CuInformation> tempList  = TargetCuInfoList;
                    List <CuInformation> tempSList = sourceChangeOutList;
                    CuInformation        tempCu    = null;

                    for (int i = 0; i < tempSList.Count; i++)
                    {
                        for (int j = 0; j < tempList.Count; j++)
                        {
                            if (!tempSList[i].Processed && tempSList[i].isNeutral.Equals(tempList[j].isNeutral) && tempSList[i].CuCode.Equals(tempList[j].CuCode) && !tempSList[i].isNeutral.Equals(null))
                            {
                                CuInformation cu = new CuInformation {
                                    SourceCid = tempSList[i].SourceCid, TargetCid = tempList[j].SourceCid, UnitCID = tempSList[i].UnitCID, Activity = tempSList[i].Activity, ReplacedCID = tempSList[i].ReplacedCID, isNeutral = tempSList[i].isNeutral
                                };
                                PhaseAndCUcodeMatchList.Add(cu);
                                completedPhasesList.Add(tempSList[i].isNeutral.ToString());
                                tempCu = cu;
                                tempList.RemoveAt(j);
                                break;
                            }

                            if (!tempSList[i].Processed && tempSList[i].isNeutral.Equals(tempList[j].isNeutral) && !tempSList[i].CuCode.Equals(tempList[j].CuCode) && !tempSList[i].isNeutral.Equals(null))
                            {
                                CuInformation cu = new CuInformation {
                                    SourceCid = tempSList[i].SourceCid, TargetCid = tempList[j].SourceCid, UnitCID = tempSList[i].UnitCID, Activity = tempSList[i].Activity, ReplacedCID = tempSList[i].ReplacedCID, isNeutral = tempSList[i].isNeutral
                                };
                                PhaseMatchList.Add(cu);
                                completedPhasesList.Add(tempSList[i].isNeutral.ToString());
                                tempCu = cu;
                                tempList.RemoveAt(j);
                                break;
                            }
                        }
                        tempSList[i].Processed = true;
                    }
                }

                changeList.AddRange(PhaseMatchList);
                changeList.AddRange(PhaseAndCUcodeMatchList);

                int processedRecordCount = changeList.Count;

                List <CuInformation> installedCUs = new List <CuInformation>();
                foreach (CuInformation changedCU in changeList)
                {
                    foreach (CuInformation SourceCu in m_SourceCuInfoList)
                    {
                        if (SourceCu.ReplacedCID == changedCU.SourceCid)
                        {
                            installedCUs.Add(SourceCu);
                        }
                    }
                }
                changeList.AddRange(installedCUs);

                if (PhaseMatchList.Count > 0)
                {
                    if (MessageBox.Show("Target conductor span has different CUs than the original version of the source feature; perform changeout anyway? [Y/N]", "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //m_overrideCu = true;
                        UpdateTargetFeature(changeList);
                        return(true);
                    }
                }

                else if (PhaseAndCUcodeMatchList.Count > 0 && PhaseMatchList.Count == 0)
                {
                    UpdateTargetFeature(changeList);
                    return(true);
                }

                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #30
0
        /// <summary>
        /// Returns the Primary geometry of the feature
        /// </summary>
        /// <param name="feature"></param>
        /// <returns></returns>
        private void GetPrimaryGeometry(IGTKeyObject feature, ref IGTGeometry primaryGeometry)
        {
            IGTComponent component = null;

            try
            {
                Recordset oRSFeature = DataContext.MetadataRecordset("G3E_FEATURES_OPTABLE", "G3E_FNO=" + feature.FNO);
                // oRSFeature.Filter = "G3E_FNO=" + feature.FNO;

                if (!(oRSFeature.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value is DBNull))
                {
                    component = feature.Components.GetComponent(Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value));

                    if (component != null && component.Recordset != null && component.Recordset.RecordCount == 1)
                    {
                        primaryGeometry = component.Geometry;
                    }

                    else if (component != null && component.Recordset != null && component.Recordset.RecordCount > 1)
                    {
                        throw new DuplicateIdentifierException(string.Format("More than one feature exists with the same feature identifier {0}. Please contact system administrator.", feature.FID));
                    }
                    else
                    {
                        if (!(oRSFeature.Fields["G3E_PRIMARYDETAILCNO"].Value is DBNull))
                        {
                            component = feature.Components.GetComponent(Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYDETAILCNO"].Value));

                            if (component != null && component.Recordset != null && component.Recordset.RecordCount > 0)
                            {
                                primaryGeometry = component.Geometry;
                            }
                        }
                    }
                }

                else if (!(oRSFeature.Fields["G3E_PRIMARYDETAILCNO"].Value is DBNull))
                {
                    component = feature.Components.GetComponent(Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYDETAILCNO"].Value));

                    if (component != null && component.Recordset != null && component.Recordset.RecordCount > 0)
                    {
                        primaryGeometry = component.Geometry;
                    }
                    else
                    {
                        if (!(oRSFeature.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value is DBNull))
                        {
                            component = feature.Components.GetComponent(Convert.ToInt16(oRSFeature.Fields["G3E_PRIMARYGEOGRAPHICCNO"].Value));

                            if (component != null && component.Recordset != null && component.Recordset.RecordCount > 0)
                            {
                                primaryGeometry = component.Geometry;
                            }
                        }
                    }
                }
            }

            catch (DuplicateIdentifierException ex)
            {
                throw ex;
            }
            catch
            {
                throw;
            }
        }