Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method copied CU values from source feature to target feature
        /// </summary>
        /// <param name="source"> Source recordset</param>
        /// <param name="target"> Target recordset</param>
        /// <param name="cu"> part of CU information about source and target</param>
        //private void CopyValuesFromSource(ref Recordset source, ref Recordset target, CuInformation cu)
        private void CopyValuesFromSource(Recordset source, CuInformation cu, bool newInstall, int replaceCid = -1)
        {
            try
            {
                source.MoveFirst();
                Recordset target = m_dataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID).Components.GetComponent(21).Recordset;

                target.Filter = "REPLACED_CID = " + replaceCid;

                if (!target.BOF && !target.EOF && target.RecordCount > 0)
                {
                    cu.TargetCid = Convert.ToInt16(target.Fields["g3e_cid"].Value);
                    newInstall   = false;
                }

                target.Filter = FilterGroupEnum.adFilterNone;

                if (!newInstall)
                {
                    target.Filter = "G3E_CID = " + cu.TargetCid;
                }
                if (target.RecordCount > 0)
                {
                    target.MoveLast();
                }
                if (newInstall)
                {
                    target.AddNew("G3E_FID", m_selectedObject.FID);
                    target.Fields["G3E_FNO"].Value = m_selectedObject.FNO;
                    target.Fields["G3E_CNO"].Value = 21;
                }
                target.Fields["ACTIVITY_C"].Value       = source.Fields["ACTIVITY_C"].Value;
                target.Fields["CIAC_C"].Value           = source.Fields["CIAC_C"].Value;
                target.Fields["CU_C"].Value             = source.Fields["CU_C"].Value;
                target.Fields["CU_DESC"].Value          = source.Fields["CU_DESC"].Value;
                target.Fields["FIELD_DESIGN_XML"].Value = source.Fields["FIELD_DESIGN_XML"].Value;
                target.Fields["LENGTH_FLAG"].Value      = source.Fields["LENGTH_FLAG"].Value;
                target.Fields["MACRO_CU_C"].Value       = source.Fields["MACRO_CU_C"].Value;
                target.Fields["PRIME_ACCT_ID"].Value    = source.Fields["PRIME_ACCT_ID"].Value;
                target.Fields["PROP_UNIT_ID"].Value     = source.Fields["PROP_UNIT_ID"].Value;
                target.Fields["QTY_LENGTH_Q"].Value     = source.Fields["QTY_LENGTH_Q"].Value;
                target.Fields["RETIREMENT_C"].Value     = source.Fields["RETIREMENT_C"].Value;
                target.Fields["WM_SEQ"].Value           = source.Fields["WM_SEQ"].Value;
                target.Fields["WR_EDITED"].Value        = source.Fields["WR_EDITED"].Value;
                if (replaceCid != -1)
                {
                    target.Fields["REPLACED_CID"].Value = replaceCid;
                }
                target.Update(Type.Missing, Type.Missing);
                target.Filter = FilterGroupEnum.adFilterNone;

                // Copy Phase and Phase position - ALM-1836-ONCORDEV-2516
                target = m_dataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID).Components.GetComponent(m_wireAttributesCno).Recordset;
                if (!newInstall)
                {
                    target.Filter = "G3E_CID = " + cu.TargetCid;
                }
                if (target.RecordCount > 0)
                {
                    target.MoveLast();
                }
                if (m_isPrimaryConductor)
                {
                    target.Fields["PHASE_C"].Value = cu.Phase;
                    try
                    {
                        target.Fields["PHASE_POS_C"].Value = cu.PhasePosition;
                    }
                    catch { }
                }
                else
                {
                    if (cu.isNeutral.Equals(false))
                    {
                        target.Fields["NEUTRAL_YN"].Value = "N";
                    }
                    else if (cu.isNeutral.Equals(true))
                    {
                        target.Fields["NEUTRAL_YN"].Value = "Y";
                    }
                }
                target.Update(Type.Missing, Type.Missing);
                target.Filter = FilterGroupEnum.adFilterNone;
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 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;
            }
        }