Exemplo n.º 1
0
        /// <summary>
        /// Mouse double click event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_oGTCustomCommandHelper_DblClick(object sender, GTMouseEventArgs e)
        {
            try
            {
                m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                if (m_selectedObjects.Count == 0)
                {
                    MessageBox.Show("No target features were selected.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ExitCommand();
                    return;
                }
                if (m_ofrmCopyAncillaryCUs != null) // Initial feature has ACUs
                {
                    m_iGtApplication.BeginWaitCursor();
                    if (m_ofrmCopyAncillaryCUs.CanDeleteAllExistigAcus)
                    {
                        DeleteExistingACUs();
                    }
                    if (m_ofrmCopyAncillaryCUs.CuInformationList.Count > 0)
                    {
                        CopySourceACUsToTargetFeature();
                        if (CheckForCorrectionModeProperty())
                        {
                            RemoveCorrectionModeProperty();
                        }
                    }
                }
                else // Initial feature no ACUs and user selected to go ahead and delete ACUs from target
                {
                    DeleteExistingACUs();
                }
                m_oGTTransactionManager.Commit();
                m_oGTTransactionManager.RefreshDatabaseChanges();

                SynchronizeWP();
            }
            catch (Exception ex)
            {
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                }
                MessageBox.Show("Error during execution of Copy Ancillaries custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
            finally
            {
                m_iGtApplication.EndWaitCursor();
                ExitCommand();
            }
        }
        /// <summary>
        /// Execute Procudure to Purge Expired Archived Landbase
        /// </summary>
        private void PurgeLandbase()
        {
            ADODB.Recordset rs          = null;
            string          sqlStmt     = "Begin LBM_UTL.PurgeExpiredArchivedLandbase; end;";
            string          mergeStatus = string.Empty;

            try
            {
                gtTransactionManager.Begin("Purge Expired Landbase");
                gtApp.BeginWaitCursor();
                rs = Execute(sqlStmt);
                gtTransactionManager.Commit();
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
                gtTransactionManager.RefreshDatabaseChanges();
                gtApp.RefreshWindows();
                gtApp.EndWaitCursor();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute Procudure to Detect Polygon Edge Mismatch
        /// </summary>
        private void DetectPolygonEdgeMismatch()
        {
            Recordset rs          = null;
            string    sqlStmt     = "Begin LBM_UTL.DetectPolygonEdgeMismatch; end;";
            string    mergeStatus = string.Empty;

            try
            {
                gtApp.BeginWaitCursor();
                gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Polygon Edge Mismatch....");
                gtTransactionManager.Begin("Detect Polygon Edge Mismatch");
                rs = Execute(sqlStmt);
                gtTransactionManager.Commit();
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
                gtTransactionManager.RefreshDatabaseChanges();
                gtApp.RefreshWindows();
                gtApp.EndWaitCursor();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Execute Procudure to Purge Expired Archived Landbase
        /// </summary>
        private void DetectOverlapping(int g3eFno, bool selfOverlap)
        {
            ADODB.Recordset rs      = null;
            string          sqlStmt = "Begin LBM_UTL.DetectOverlappingPolygons({0},{1}); end;";

            try
            {
                gtApp.BeginWaitCursor();
                sqlStmt = string.Format(sqlStmt, g3eFno, selfOverlap);
                gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Overlapping Boundarys....");
                gtTransactionManager.Begin("Detect Overlapping Boundarys");
                rs = Execute(sqlStmt);
                gtTransactionManager.Commit();
                MessageBox.Show("Detecting Overlapping Boundarys Analysis is Completed", msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
                gtTransactionManager.RefreshDatabaseChanges();
                gtApp.RefreshWindows();
                gtApp.EndWaitCursor();
            }
        }
Exemplo n.º 5
0
        public void Activate()
        {
            string           featureState    = string.Empty;
            List <int>       fidList         = new List <int>();
            IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>();

            try
            {
                IGTDDCKeyObjects ddcKeyObjects = m_iGtApp.SelectedObjects.GetObjects();
                foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects)
                {
                    if (!fidList.Contains(ddcKeyObject.FID))
                    {
                        fidList.Add(ddcKeyObject.FID);
                        selectedObjects.Add(ddcKeyObject);
                    }
                }

                foreach (IGTDDCKeyObject selectedObject in selectedObjects)
                {
                    featureState = GetFeatureState(selectedObject);

                    if (string.IsNullOrEmpty(featureState) || !m_featureStatesList.Contains(featureState))
                    {
                        MessageBox.Show("One or more features are in an invalid feature state for this operation.", "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (!m_TransactionManager.TransactionInProgress)
                {
                    m_TransactionManager.Begin("updating feature state...");
                }
                int current    = 1;
                int totalCount = selectedObjects.Count;

                foreach (IGTDDCKeyObject selectedObject in selectedObjects)
                {
                    m_iGtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Transitioning " + current + " out of " + totalCount + " features.");
                    SetFeatureState(selectedObject);
                    current++;
                }

                m_TransactionManager.Commit();
                m_TransactionManager.RefreshDatabaseChanges();

                m_iGtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Selected features were transitioned successfully.");
            }
            catch (Exception ex)
            {
                m_TransactionManager.Rollback();
                MessageBox.Show("Error during execution of Complete Feature custom command." + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_TransactionManager = null;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to delete StreetLight.
        /// </summary>
        /// <param name="streetLightAttributeRS">Recordset of StreetLight Attribute</param>
        /// <param name="locatable">Bool value whether StreetLight is Located to delete</param>
        /// <returns></returns>
        private void DeleteStreetLight(Recordset streetLightAttributeRS, bool locatable)
        {
            IGTKeyObjects relatedFeatures = GTClassFactory.Create <IGTKeyObjects>();
            IGTKeyObjects deleteFeatures  = GTClassFactory.Create <IGTKeyObjects>();
            IGTKeyObject  feature         = GTClassFactory.Create <IGTKeyObject>();

            try
            {
                StreetLightImportUtility importUtility = new StreetLightImportUtility(m_oGTDataContext);

                if (!m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Begin("Importing Street Light(s) using Import Tool");
                }

                if (locatable)
                {
                    streetLightAttributeRS.MoveFirst();

                    feature = m_oGTDataContext.OpenFeature(Convert.ToInt16(streetLightAttributeRS.Fields["G3E_FNO"].Value), Convert.ToInt32(streetLightAttributeRS.Fields["G3E_FID"].Value));
                    deleteFeatures.Add(feature);

                    relatedFeatures = importUtility.GetRelatedFeatures(feature, 3);
                    if (relatedFeatures.Count > 0)
                    {
                        feature = CheckForMiscellaneousStructure(relatedFeatures, feature.FID);

                        if (feature != null)
                        {
                            deleteFeatures.Add(feature);
                        }
                    }
                }
                else
                {
                    streetLightAttributeRS.MoveFirst();
                    while (!streetLightAttributeRS.EOF)
                    {
                        feature = m_oGTDataContext.OpenFeature(Convert.ToInt16(streetLightAttributeRS.Fields["G3E_FNO"].Value), Convert.ToInt32(streetLightAttributeRS.Fields["G3E_FID"].Value));
                        deleteFeatures.Add(feature);

                        streetLightAttributeRS.MoveNext();
                    }
                }
                importUtility.DeleteFeatures(deleteFeatures);

                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Commit(true);
                    m_oGTTransactionManager.RefreshDatabaseChanges();
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Method to exceute the TreeTrimRequestEstimate command.
        /// </summary>
        private void TreeTrimRequestEstimate()
        {
            Recordset               wpRecordset = null;
            ccTreeTrimRequestForm   ccTreeTrimRequestForm;
            VoucherEstimatesUtility estimatesUtility = null;

            try
            {
                estimatesUtility = new VoucherEstimatesUtility(m_oGTApp);

                wpRecordset = estimatesUtility.GetWorkpointRsContainedByTreeTrimming(m_oGTTreeTrimmingfeature);

                if (wpRecordset != null && wpRecordset.RecordCount > 0)
                {
                    ccTreeTrimRequestForm = new ccTreeTrimRequestForm(estimatesUtility.GetWorkPtAccountRecordset(wpRecordset), m_oGTApp, m_oGTTreeTrimmingfeature);
                    ccTreeTrimRequestForm.ShowDialog(m_oGTApp.ApplicationWindow);
                    if (ccTreeTrimRequestForm.ProcessDone && ccTreeTrimRequestForm.CommandExit)
                    {
                        ProcessVoucherEstimates oProcessEstimate = new ProcessVoucherEstimates();
                        oProcessEstimate.UpdateVoucherAttributes(m_oGTTreeTrimmingfeature, ccTreeTrimRequestForm.VoucherAccountVal);

                        m_oGTTransactionManager.Commit();
                        m_oGTTransactionManager.RefreshDatabaseChanges();

                        oProcessEstimate.ProcessEmail(ccTreeTrimRequestForm.RecipientName, ccTreeTrimRequestForm.RecipientEmail, ccTreeTrimRequestForm.VegMngSheetTemplate, ccTreeTrimRequestForm.PlotPDFName, m_oGTApp.DataContext.ActiveJob);

                        ExitCommand();
                    }
                    else
                    {
                        m_oGTExplorerService_CancelClick(null, EventArgs.Empty);
                        ExitCommand();
                    }
                }
                else
                {
                    m_oStatusBarMessage = "No Work Points were found within the polygon; draw a new polygon";
                    m_oGTExplorerService_CancelClick(null, EventArgs.Empty);
                    m_oGTTransactionManager.Begin("TreeTrimRequestEstimate");
                    m_oGTTreeTrimmingfeature = m_oGTApp.DataContext.NewFeature(190);
                    m_oGTPlacementService.StartFeature(m_oGTTreeTrimmingfeature);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (wpRecordset != null)
                {
                    wpRecordset = null;
                }
            }
        }
Exemplo n.º 8
0
        public void Terminate()
        {
            try
            {
                UnsubscribeEvents();

                if (m_oEditService != null)
                {
                    if (m_oEditService.GeometryCount > 0)
                    {
                        m_oEditService.RemoveAllGeometries();
                    }
                }

                m_oGTApplication.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                if (m_oGTTransactionManager != null && m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                    m_oGTTransactionManager.RefreshDatabaseChanges();
                }
                m_oGTApplication.EndWaitCursor();
                m_oGTApplication.SelectedObjects.Clear();
                m_oGTApplication.RefreshWindows();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex.Message, m_sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_oGTApplication         = null;
                m_oGTCustomCommandHelper = null;
                m_osrcGeometry           = null;
                m_otrgFeature            = null;
                m_trgComponent           = null;
                m_oEditService           = null;
                m_oGTTransactionManager  = null;
                m_EditObjects            = null;
                m_locatedObjects         = null;
                m_snapPoint = null;
            }
        }
Exemplo n.º 9
0
        void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e)
        {
            try
            {
                if (e.Button == 1)
                {
                    foreach (Recordset rs in m_oRSList)
                    {
                        UpdateActivity(rs, "R", false);
                    }
                }
                else if (e.Button == 2)
                {
                    foreach (Recordset rs in m_oRSList)
                    {
                        UpdateActivity(rs, "S", false);
                    }
                }

                // Commit the transaction to reflect the WR_EDITED when set by the trigger
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Commit();
                    m_oGTTransactionManager.RefreshDatabaseChanges();
                }

                //  Begin a new transaction to process WP synchronization
                m_oGTTransactionManager.Begin(" WP synchronization...");

                SynchronizeWP();

                ExitCommand();
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Merge Selected landbase Boundaries
        /// </summary>
        /// <param name="g3eFno_trg"></param>
        /// <param name="g3eFid_trg"></param>
        /// <param name="g3eFno_src"></param>
        /// <param name="g3eFid_src"></param>
        private void MergeLandbaseBoundary(int g3eFno_trg, int g3eFid_trg, int g3eFno_src, int g3eFid_src)
        {
            ADODB.Recordset rs          = null;
            string          sqlStmt     = "Begin LBM_UTL.MergeLandbaseBoundaries({0},{1},{2},{3}); end;";
            string          mergeStatus = string.Empty;

            try
            {
                gtTransactionManager.Begin("Merging Landbase Boundries");
                rs = Execute(string.Format(sqlStmt, g3eFno_trg, g3eFid_trg, g3eFno_src, g3eFid_src));
                gtTransactionManager.Commit();
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
            }
            gtTransactionManager.RefreshDatabaseChanges();
        }
Exemplo n.º 11
0
        public void Activate()
        {
            string featureState = string.Empty;
            string jobStatus    = string.Empty;

            try
            {
                IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>();
                List <int>       fidList         = new List <int>();
                IGTDDCKeyObjects ddcKeyObjects   = m_iGtApplication.SelectedObjects.GetObjects();
                foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects)
                {
                    if (!fidList.Contains(ddcKeyObject.FID))
                    {
                        fidList.Add(ddcKeyObject.FID);
                        selectedObjects.Add(ddcKeyObject);
                    }
                }
                foreach (IGTDDCKeyObject selectedObject in selectedObjects)
                {
                    if (!ValidateFeatureState(selectedObject))
                    {
                        if (!m_AssetHistoryCheckpassed)
                        {
                            MessageBox.Show("This command cannot be used on unposted features.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            return;
                        }

                        MessageBox.Show("One or more features are in an invalid feature state for this operation.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (!CheckIfCuAttributesExists(selectedObject))
                    {
                        MessageBox.Show("This command applies only to features with CUs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (!CheckIfInstallAndActiveWrAreDifferent(selectedObject))
                    {
                        MessageBox.Show("The same feature may not be installed and abandoned in the same WR.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (CheckIfNonWrJob(out jobStatus))
                {
                    MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }



                // Validations have been completed. Update feature state.
                if (!m_TransactionManager.TransactionInProgress)
                {
                    m_TransactionManager.Begin("updating feature state...");
                }

                int current    = 1;
                int totalCount = selectedObjects.Count;
                foreach (IGTDDCKeyObject selectedObject in selectedObjects)
                {
                    m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Transtioning " + current + " out of " + totalCount + " features.");
                    SetFeatureStateBasedOnJobStatus(selectedObject, jobStatus);
                    SetActivity(selectedObject);
                    current++;
                }
                m_TransactionManager.Commit();

                // Sync work point in a new transaction

                m_TransactionManager.Begin("WP Synchronization...");

                foreach (IGTDDCKeyObject selectedObject in selectedObjects)
                {
                    ProcessWPSync(selectedObject);
                }
                m_TransactionManager.Commit();
                m_TransactionManager.RefreshDatabaseChanges();

                m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Selected features were transitioned successfully.");
            }
            catch (Exception ex)
            {
                m_TransactionManager.Rollback();
                MessageBox.Show("Error during execution of Abandon Feature custom command." + Environment.NewLine + "Transition failed for selected features." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_TransactionManager = null;
            }
        }
Exemplo n.º 12
0
        void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e)
        {
            IGTLocateService selectedFeaturesService;
            IGTDDCKeyObjects selectedFeatures;

            try
            {
                m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                m_iGtApplication.BeginWaitCursor();
                m_invalidFeatureMessage = false;
                if (e.Button == 1)
                {
                    selectedFeaturesService = m_iGtApplication.ActiveMapWindow.LocateService;
                    selectedFeatures        = selectedFeaturesService.Locate(e.WorldPoint, -1, 0, GTSelectionTypeConstants.gtmwstSelectAll);
                    IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>();
                    List <int>       fidList         = new List <int>();
                    foreach (IGTDDCKeyObject ddcKeyObject in selectedFeatures)
                    {
                        if (!fidList.Contains(ddcKeyObject.FID))
                        {
                            fidList.Add(ddcKeyObject.FID);
                            selectedObjects.Add(ddcKeyObject);
                        }
                    }
                    if (selectedObjects == null || selectedObjects.Count == 0)
                    {
                        return;
                    }
                    m_selectedObject = selectedObjects[0];

                    if (m_selectedObject.FNO != m_originalObject.FNO || m_selectedObject.FID == m_originalObject.FID)  // Restrict selection to features of the same class as the original feature
                    {
                        m_invalidFeatureMessage = true;
                        m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Invalid feature selected.Selected feature(s) are not of same class as source feature or selected feature itself is source feature.");
                        return;
                    }

                    m_iGtApplication.ActiveMapWindow.HighlightedObjects.AddSingle(m_selectedObject);

                    if (m_oGTTransactionManager != null && !m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Begin(" begin Repeat reconductoring...");
                    }
                    if (ProcessChangeOutsToTargetFeature())
                    {
                        m_oGTTransactionManager.Commit();
                        m_oGTTransactionManager.RefreshDatabaseChanges();

                        // Synchronize Work points - ALM-1838-JIRA-2514
                        SynchronizeWP(m_dataContext.OpenFeature(m_originalObject.FNO, m_originalObject.FID));
                        SynchronizeWP(m_dataContext.OpenFeature(m_selectedObject.FNO, m_selectedObject.FID));

                        m_iGtApplication.EndWaitCursor();
                        m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Identify next span to changeout wires; double-click to exit.");
                    }
                }
            }
            catch (Exception ex)
            {
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                }
                ExitCommand();
                MessageBox.Show("Error during execution of Repeat Reconductoring custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_iGtApplication.EndWaitCursor();
            }
        }
Exemplo n.º 13
0
        public void Activate()
        {
            string jobStatus         = string.Empty;
            bool   dummyCuCodeExists = false;

            oHelper = new Helper();
            oHelper.m_dataContext = m_dataContext;
            oIsolationScenario    = new IsolationScenario(m_dataContext);

            try
            {
                #region Perform validations
                if (CheckIfNonWrJob())
                {
                    MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>();
                List <int>       fidList         = new List <int>();
                IGTDDCKeyObjects ddcKeyObjects   = m_iGtApplication.SelectedObjects.GetObjects();
                foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects)
                {
                    if (!fidList.Contains(ddcKeyObject.FID))
                    {
                        fidList.Add(ddcKeyObject.FID);
                        selectedObjects.Add(ddcKeyObject);
                    }
                }
                m_selectedObject = selectedObjects[0];
                oHelper.m_fid    = m_selectedObject.FID;
                oHelper.m_fno    = m_selectedObject.FNO;
                if (!CheckIfFeatureIsReplaceable())
                {
                    MessageBox.Show("Replace Feature is not configured to operate on the selected feature class.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!CheckIfValidCuAttributesExists(out dummyCuCodeExists))
                {
                    MessageBox.Show("This command applies only to features with CUs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (dummyCuCodeExists)
                {
                    MessageBox.Show("This command cannot operate on dummy CUs (i.e.- CU codes beginning with ZZ).", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!ValidateFeatureState())
                {
                    MessageBox.Show("One or more features are in an invalid feature state for this operation.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!GetOffsetValuesFromGeneralParameters())
                {
                    MessageBox.Show("General parameters JobMgmt_ReplaceOffsetX or JobMgmt_ReplaceOffsetY  is not configured correctly.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!CheckIfPointFeature())
                {
                    MessageBox.Show("Command is restricted to only work for point features.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!CheckIfInstallAndActiveWrAreDifferent())
                {
                    MessageBox.Show("The same feature may not be installed and replaced in the same WR.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                #endregion

                frmSelectReplacementStatus oReplacementStatusForm = new frmSelectReplacementStatus();
                if (oReplacementStatusForm.ShowDialog(m_iGtApplication.ApplicationWindow) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    this.m_replaceAction = oReplacementStatusForm.ReplacementStatus;
                    m_iGtApplication.BeginWaitCursor();
                    m_oIsolationScenario = oIsolationScenario.CheckIsoScenarioFeature(m_selectedObject.FNO, m_selectedObject.FID);
                    ProcessReplacement();
                    m_TransactionManager.RefreshDatabaseChanges();
                }
            }
            catch (Exception ex)
            {
                m_iGtApplication.EndWaitCursor();
                m_TransactionManager.Rollback();

                MessageBox.Show("Error during execution of Replace Feature custom command." + Environment.NewLine + "Replace failed for selected feature." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_TransactionManager = null;
                m_iGtApplication.EndWaitCursor();
            }
        }
Exemplo n.º 14
0
        public void Activate()
        {
            string                  sql            = "SELECT G3E_FID FROM WORKPOINT_N WHERE WR_NBR=:1 AND G3E_FNO=191";
            Recordset               rsValidate     = null;
            int                     jFid           = 0;
            short                   jFno           = 0;
            IGTKeyObject            jKeyObject     = null;
            IGTJobManagementService oJobManagement = GTClassFactory.Create <IGTJobManagementService>();

            oJobManagement.DataContext = m_ogtApplication.DataContext;

            try
            {
                if (ValidateCommand())
                {
                    ADODB.Recordset rsPendingEdits = oJobManagement.FindPendingEdits();
                    if (rsPendingEdits != null && rsPendingEdits.RecordCount > 0)
                    {
                        oJobManagement.DiscardJob(); //ALM 1321 - Automatically discard job at the start and assume that there are no unposted data
                        m_oGTTransactionManager.RefreshDatabaseChanges();
                        m_ogtApplication.RefreshWindows();
                    }

                    rsValidate = m_ogtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly,
                                                                            (int)ADODB.CommandTypeEnum.adCmdText, new object[] { m_ogtApplication.DataContext.ActiveJob });

                    if (rsValidate == null || rsValidate.RecordCount == 0)
                    {
                        return;
                    }

                    m_oGTTransactionManager.Begin("Revert Job");

                    commonRevertAPI rFeature = new commonRevertAPI(m_ogtApplication);
                    rsValidate.MoveFirst();
                    while (!rsValidate.EOF)
                    {
                        jFno = 191;
                        jFid = Convert.ToInt32(rsValidate.Fields["G3E_FID"].Value);

                        jKeyObject = m_ogtApplication.DataContext.OpenFeature(jFno, jFid);

                        rFeature.m_FromJob = "JOB";
                        rFeature.RevertWPFeature(jKeyObject);


                        rsValidate.MoveNext();
                    }

                    if (rFeature.m_uProcessedCUs)
                    {
                        MessageBox.Show("Check remaining Work Points to make manual corrections.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);
                    }

                    if (m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Commit();
                        m_oGTTransactionManager.RefreshDatabaseChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);

                m_oGTTransactionManager.Rollback();
            }
            finally
            {
                if (rsValidate != null)
                {
                    if (rsValidate.State == 1)
                    {
                        rsValidate.Close();
                        rsValidate.ActiveConnection = null;
                    }
                    rsValidate = null;
                }
            }
        }
Exemplo n.º 15
0
        public void Activate()
        {
            IGTComponent cuComponent            = null;
            short        aFno                   = 0;
            int          aFid                   = 0;
            int          wpNotAssoFeaturesCount = 0;

            try
            {
                IGTDDCKeyObjects gtDDCKeyObjects = m_ogtApplication.Application.SelectedObjects.GetObjects();
                activeFeatureDDCKey = gtDDCKeyObjects[0];

                IGTJobHelper gTJobHelper = null;
                gTJobHelper = GTClassFactory.Create <IGTJobHelper>();
                ADODB.Recordset myfeatures = gTJobHelper.FindPendingEdits();
                if (myfeatures != null && myfeatures.RecordCount > 0)
                {
                    myfeatures.MoveFirst();
                    myfeatures.Find("g3e_fid=" + activeFeatureDDCKey.FID + "");
                    if (!(myfeatures.BOF || myfeatures.EOF))
                    {
                        MessageBox.Show("This command cannot be used on unposted features.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                        return;
                    }
                }
                gTJobHelper = null;
                myfeatures  = null;

                commonRevertAPI rFeature = new commonRevertAPI(m_ogtApplication);
                if (ValidateCommand())
                {
                    if (!rFeature.ValidateActiveFetature(m_oActiveKeyObject))
                    {
                        //m_ogtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Feature has been edited by WR " + rFeature.m_WRID + "; cannot revert.");

                        MessageBox.Show("Feature has been edited by WR " + rFeature.m_WRID + "; cannot revert.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);
                    }
                    else
                    {
                        if (m_oActiveKeyObject.FNO == 191)
                        {
                            m_oGTTransactionManager.Begin("Revert Feature Fno=" + m_oActiveKeyObject.FNO + " FID=" + m_oActiveKeyObject.FID);

                            cuComponent = m_oActiveKeyObject.Components.GetComponent(19104);
                            if (cuComponent != null && cuComponent.Recordset != null && cuComponent.Recordset.RecordCount > 0)
                            {
                                cuComponent.Recordset.MoveFirst();
                                while (!cuComponent.Recordset.EOF)
                                {
                                    aFno = Convert.ToInt16(cuComponent.Recordset.Fields["ASSOC_FNO"].Value);
                                    aFid = Convert.ToInt32(cuComponent.Recordset.Fields["ASSOC_FID"].Value);

                                    if (!rFeature.ValidateActiveFetature(m_ogtApplication.DataContext.OpenFeature(aFno, aFid)))
                                    {
                                        wpNotAssoFeaturesCount = wpNotAssoFeaturesCount + 1;
                                    }

                                    cuComponent.Recordset.MoveNext();
                                }
                            }

                            if (wpNotAssoFeaturesCount == 0)
                            {
                                rFeature.RevertWPFeature(m_oActiveKeyObject);

                                if (m_oGTTransactionManager.TransactionInProgress)
                                {
                                    m_oGTTransactionManager.Commit();
                                    m_oGTTransactionManager.RefreshDatabaseChanges();
                                }
                            }
                            else if (wpNotAssoFeaturesCount == cuComponent.Recordset.RecordCount)
                            {
                                MessageBox.Show("All features associated with this Work Point have been edited by other WRs and cannot be reverted.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                MessageBoxDefaultButton.Button1);
                            }
                            else if (wpNotAssoFeaturesCount < cuComponent.Recordset.RecordCount)
                            {
                                DialogResult dResult = MessageBox.Show("One or more features associated with this Work Point have been edited by other WRs and cannot be reverted.  Continue reverting other associated features?", "G/Technology", MessageBoxButtons.OKCancel,
                                                                       MessageBoxIcon.Question);

                                if (dResult == DialogResult.OK)
                                {
                                    rFeature.RevertWPFeature(m_oActiveKeyObject);

                                    if (m_oGTTransactionManager.TransactionInProgress)
                                    {
                                        m_oGTTransactionManager.Commit();
                                        m_oGTTransactionManager.RefreshDatabaseChanges();
                                    }
                                }
                                else
                                {
                                    m_oGTTransactionManager.Rollback();
                                }
                            }
                        }
                        else
                        {
                            if (m_oActiveKeyObject.Components["COMMON_N"].Recordset != null && m_oActiveKeyObject.Components["COMMON_N"].Recordset.RecordCount > 0)
                            {
                                m_oGTTransactionManager.Begin("Revert Feature Fno=" + m_oActiveKeyObject.FNO + " FID=" + m_oActiveKeyObject.FID);

                                rFeature.RevertFeture(m_oActiveKeyObject.FNO, m_oActiveKeyObject.FID, m_ostrActFeatureState, 0, 0, 0);

                                if (m_oGTTransactionManager.TransactionInProgress)
                                {
                                    m_oGTTransactionManager.Commit();
                                    m_oGTTransactionManager.RefreshDatabaseChanges();
                                }
                            }
                        }

                        if (rFeature.m_uProcessedCUs)
                        {
                            MessageBox.Show("Command was unable to revert all activity.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                            MessageBoxDefaultButton.Button1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);

                m_oGTTransactionManager.Rollback();
            }
        }