Exemplo n.º 1
0
 private void keyUp(object sender, GTKeyEventArgs e)
 {
     if (e.KeyCode == (short)ConsoleKey.Escape)
     {
         featurePlacementService.CancelPlacement();
         gtTransactionManager.Rollback();
         customCommandHelper.Complete();
     }
 }
Exemplo n.º 2
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            IGTDDCKeyObjects ddcKeyObjects = GTClassFactory.Create <IGTDDCKeyObjects>();
            List <int>       fidList       = new List <int>();

            try
            {
                m_oGTApp = GTClassFactory.Create <IGTApplication>();
                m_oGTCustomCommandHelper = CustomCommandHelper;

                m_ooddcKeyObjects = GTClassFactory.Create <IGTDDCKeyObjects>();

                ddcKeyObjects = m_oGTApp.Application.SelectedObjects.GetObjects();

                foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects)
                {
                    if (!fidList.Contains(ddcKeyObject.FID))
                    {
                        fidList.Add(ddcKeyObject.FID);
                        m_ooddcKeyObjects.Add(ddcKeyObject);
                    }
                }

                m_oGTApp.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Initializing RemoveFeature...");
                m_oGTApp.Application.BeginWaitCursor();

                SetJobAttributes();

                if (Validate())
                {
                    RemoveFeature();

                    if (!m_ostatusExit)
                    {
                        SynchronizeWP();
                    }

                    if (m_oCorrectionsModeIndex != -1)
                    {
                        m_oGTApp.Application.Properties.Remove("CorrectionsMode");
                        string mapCaption = m_oGTApp.Application.ActiveMapWindow.Caption.Replace("CORRECTIONS MODE - ", "");
                        m_oGTApp.Application.ActiveMapWindow.Caption = mapCaption;
                    }
                }

                if (!m_ostatusExit)
                {
                    ExitCommand();
                }
            }
            catch (Exception ex)
            {
                m_oGTTransactionManager.Rollback();
                MessageBox.Show("Error in Remove Feature command: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ExitCommand();
            }
        }
Exemplo n.º 3
0
 public void Terminate()
 {
     if (gtTransactionManager != null)
     {
         if (gtTransactionManager.TransactionInProgress)
         {
             gtTransactionManager.Rollback();
         }
     }
     gtTransactionManager = null;
 }
Exemplo n.º 4
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_oGTApp = GTClassFactory.Create <IGTApplication>();
                m_oGTCustomCommandHelper = CustomCommandHelper;

                if (Validate())
                {
                    if (m_oGTExplorerService == null)
                    {
                        m_oGTExplorerService = GTClassFactory.Create <IGTFeatureExplorerService>(m_oGTCustomCommandHelper);
                    }

                    m_oGTExplorerService.Slide(true);

                    if (m_oGTPlacementService == null)
                    {
                        m_oGTPlacementService = GTClassFactory.Create <IGTFeaturePlacementService>(m_oGTCustomCommandHelper);
                    }

                    if (!m_oGTTransactionManager.TransactionInProgress)
                    {
                        m_oGTTransactionManager.Begin("Tree Trimming Request Estimate");
                    }

                    m_oStatusBarMessage = "Draw a polygon encompassing all affected Work Points";

                    SubscribeEvents();

                    m_oGTTreeTrimmingfeature = m_oGTApp.DataContext.NewFeature(190);
                    m_oGTPlacementService.StartFeature(m_oGTTreeTrimmingfeature);
                }
                else
                {
                    ExitCommand();
                }
            }
            catch (Exception ex)
            {
                m_oGTExplorerService_CancelClick(null, EventArgs.Empty);
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                }
                MessageBox.Show("Error in TreeTrim Request Estimate command: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ExitCommand();
            }
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ManageNonLocatedSTLT_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.streetLights.Where(a => a.EntityState != EntityMode.Review).Count() > 0)
     {
         if (MessageBox.Show(PendingChangesMsg, ManageNonLocatedTxt, MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             e.Cancel = true;
             return;
         }
         else
         {
             this.streetLightAcct.MiscStructFid = default(int);
             _gtTransactionManager.Rollback();
         }
     }
     CleanUp();
 }
Exemplo n.º 6
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_oGTApp = GTClassFactory.Create <IGTApplication>();
                m_oGTCustomCommandHelper = CustomCommandHelper;
                if (m_oGTApp.DataContext.IsRoleGranted("PRIV_MGMT_STLT"))
                {
                    if (Validate())
                    {
                        string streetlightImportSheet = OpenFileDialog();
                        if (!String.IsNullOrEmpty(streetlightImportSheet))
                        {
                            m_oGTApp.BeginWaitCursor();
                            StreetLightImportWorkSheet importWorkSheet = new StreetLightImportWorkSheet();
                            importWorkSheet.InitializeExcel(streetlightImportSheet);
                            if (importWorkSheet.ExcelTable != null)
                            {
                                ImportSpreadsheetFormatValidation formatValidation = new ImportSpreadsheetFormatValidation(m_oGTApp.DataContext);
                                m_oGTApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Street Light Import Tool : Validating Spreadsheet Format");
                                if (formatValidation.ValidateSpreadsheetFormat(importWorkSheet.ExcelTable))
                                {
                                    ImportSpreadsheetRecordValidation recordValidation = new ImportSpreadsheetRecordValidation(m_oGTApp, m_oGTTransactionManager);
                                    DataTable excelDataTable = recordValidation.ValidateSpreadsheetRecord(importWorkSheet.ExcelTable);
                                    ValidateProcessing(streetlightImportSheet, importWorkSheet, excelDataTable, recordValidation);
                                }
                            }
                            m_oGTApp.EndWaitCursor();
                        }
                    }

                    ExitCommand();
                }
                else
                {
                    MessageBox.Show("User does not have PRIV_MGMT_STLT role.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1);
                    ExitCommand();
                }
            }
            catch (Exception ex)
            {
                m_oGTApp.EndWaitCursor();
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                }
                if (ex.GetType().Name == "DuplicateNameException")
                {
                    MessageBox.Show("WorkSheet contains duplicate column names.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Error in StreetLight Import Tool command: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                ExitCommand();
            }
        }
Exemplo n.º 7
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.º 8
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                customCommandHelper = CustomCommandHelper;
                if (transactionManager != null)
                {
                    transactionManager.Begin("Blanket Unitization");
                    selectedFeatures = gtApp.SelectedObjects.GetObjects();
                    bool   oneFeatureType = true;
                    short  fnoChecker;
                    string errorMessage = "";
                    if (selectedFeatures.Count > 1)
                    {
                        fnoChecker = selectedFeatures[0].FNO;
                        foreach (IGTDDCKeyObject feature in selectedFeatures)
                        {
                            if (fnoChecker != feature.FNO)
                            {
                                oneFeatureType = false;
                                errorMessage   = "Multiple feature types selected, please retry command after selecting features of the same type.";
                            }
                        }
                    }

                    if (oneFeatureType)
                    {
                        switch (selectedFeatures[0].FNO)
                        {
                        case g_Service_Line_FNO:
                        case g_Secondary_Box_FNO:
                            featureHandler();
                            break;

                        case g_Gaurd_Light_FNO:
                            guardLightHandler();
                            break;

                        default:
                            MessageBox.Show("Invalid feature selected, please select a service line, secondary box, or guard light.");
                            break;
                        }
                        customCommandHelper.Complete();
                    }
                    else
                    {
                        MessageBox.Show(errorMessage, "GTechnology");
                        customCommandHelper.Complete();
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show("Error in ccFieldActivity.Activate " + e.Message + ".");
                transactionManager.Rollback();
                customCommandHelper.Complete();
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Command to add hyperlink entry to feature
        /// </summary>
        /// <param name="p_selectedFNO"></param>
        /// <param name="p_selectedFID"></param>
        /// <param name="p_plotwindowPdfFilename"></param>
        /// <param name="p_description"></param>
        /// <param name="p_type"></param>
        private void AddHyperLinktoSelectedFeature(short p_selectedFNO, int p_selectedFID, string p_hyperLnk, string p_filename, string p_description, string p_type)
        {
            IGTKeyObject ddcSelectedKeyObj;
            Recordset    rsHypLnkComp  = null;
            IGTKeyObject tmpSelFeature = null;

            try
            {
                tmpSelFeature       = m_igtApplication.DataContext.OpenFeature(p_selectedFNO, p_selectedFID);
                rsHypLnkComp        = tmpSelFeature.Components["HYPERLINK_N"].Recordset;
                rsHypLnkComp.Filter = "HYPERLINK_T = '" + p_hyperLnk + "'";

                if (rsHypLnkComp.RecordCount == 0)
                {
                    tmpSelFeature = null;
                    m_igtTransactionManage.Begin("IN PROGRESS");
                    ddcSelectedKeyObj = m_igtApplication.DataContext.OpenFeature(p_selectedFNO, p_selectedFID);
                    ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.AddNew("G3E_FID", p_selectedFID);
                    ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["HYPERLINK_T"].Value   = p_hyperLnk;
                    ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["DESCRIPTION_T"].Value = p_description;
                    if (p_type.Length > ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize)
                    {
                        ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value =
                            p_type.Substring(0, ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize);
                    }
                    else
                    {
                        ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value = p_type;
                    }
                    ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Fields["FILENAME_T"].Value = p_filename;
                    ddcSelectedKeyObj.Components["HYPERLINK_N"].Recordset.Update("G3E_FNO", p_selectedFNO);
                    if (m_igtTransactionManage.TransactionInProgress)
                    {
                        m_igtTransactionManage.Commit();
                    }
                    m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Site drawing has been attached to the selected " + p_selectedFID + " feature.");
                }
                else
                {
                    tmpSelFeature = null;
                }
            }
            catch (Exception)
            {
                if (m_igtTransactionManage.TransactionInProgress)
                {
                    m_igtTransactionManage.Rollback();
                }
                throw;
            }
            finally
            {
                ddcSelectedKeyObj = null;
            }
        }
Exemplo n.º 10
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.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="edits"></param>
 public static void SaveData(System.Data.DataTable edits)
 {
     gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Saving edits…");
     try
     {
         foreach (System.Data.DataRow row in edits.Rows)
         {
             transactionManager.Begin("Edit Feature");
             IGTKeyObject editedFeature     = gtDataContext.OpenFeature(FNO, Convert.ToInt32(row["G3E_FID"]));
             IGTComponent editedComponenent = editedFeature.Components.GetComponent(Convert.ToInt16(row["G3E_CNO"]));
             editedComponenent.Recordset.Filter = "G3E_CID = " + row["G3E_CID"].ToString();
             editedComponenent.Recordset.MoveFirst();
             foreach (Field field in editedComponenent.Recordset.Fields)
             {
                 if (!DBNull.Value.Equals(field.Value) && field.Type == DataTypeEnum.adVarChar)
                 {
                     if (field.Value != row[field.Name].ToString())
                     {
                         field.Value = row[field.Name];
                     }
                 }
                 else if (!DBNull.Value.Equals(field.Value) && field.Type == DataTypeEnum.adNumeric)
                 {
                     if (field.Value != Convert.ToDecimal(row[field.Name]))
                     {
                         field.Value = row[field.Name];
                     }
                 }
                 else if (!DBNull.Value.Equals(field.Value) && field.Type == DataTypeEnum.adDBTimeStamp)
                 {
                     if (field.Value != Convert.ToDateTime(row[field.Name]))
                     {
                         field.Value = row[field.Name];
                     }
                 }
                 else if (DBNull.Value.Equals(field.Value) && !DBNull.Value.Equals(row[field.Name]))
                 {
                     field.Value = row[field.Name];
                 }
             }
             transactionManager.Commit();
             editedFeature = null;
             gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
         }
     }catch (Exception error)
     {
         transactionManager.Rollback();
         MessageBox.Show("Error in SaveData (" + error.Message + ")", "G/Technology");
     }
 }
 /// <summary>
 /// Dispose all method before command exit
 /// </summary>
 private void CleanUp()
 {
     gtCustomCommandHelper.MouseMove -= gtCustomCommandHelper_MouseMove;
     if (detectOverlappingAnalysis != null)
     {
         detectOverlappingAnalysis.Dispose();
     }
     detectOverlappingAnalysis = null;
     if (gtTransactionManager != null)
     {
         if (gtTransactionManager.TransactionInProgress)
         {
             gtTransactionManager.Rollback();
         }
     }
     gtTransactionManager = null;
     if (gtCustomCommandHelper != null)
     {
         gtCustomCommandHelper.Complete();
     }
     gtCustomCommandHelper = null;
 }
Exemplo n.º 13
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_Application.BeginWaitCursor();
                // Get feature number and feature identifier for feature in select set
                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                short fno = oGTDCKeys[0].FNO;
                int   fid = oGTDCKeys[0].FID;

                // Call execute method on UpdateTrace object to run trace and process results
                UpdateTrace updateTrace = new UpdateTrace(CUSTOM_COMMAND_NUMBER, CUSTOM_COMMAND_NAME);

                m_TransactionManager.Begin("Update Trace");

                if (updateTrace.Execute(fno, fid))
                {
                    m_TransactionManager.Commit();
                }
                else
                {
                    m_TransactionManager.Rollback();
                }

                updateTrace = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, "ccUpdateTrace.Activate: Error calling UpdateTrace - " + ex.Message,
                                "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            m_Application.EndWaitCursor();

            CustomCommandHelper.Complete();
        }
Exemplo n.º 14
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

                // Get the job information. Used for validating command enabling.
                if (!CommonDT.GetJobInformation())
                {
                    m_CustomCommandHelper.Complete();
                    return;
                }

                IGTDDCKeyObjects gtDDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                gtDDCKeys = m_Application.SelectedObjects.GetObjects();
                List <int> FIDs = new List <int>();

                if (gtDDCKeys.Count > 0)
                {
                    foreach (IGTDDCKeyObject gtDDCKey in gtDDCKeys)
                    {
                        // Check if selected feature is a Pole.
                        if (gtDDCKey.FNO == ConstantsDT.FNO_POLE)
                        {
                            if (!FIDs.Contains(gtDDCKey.FID))
                            {
                                m_EmbeddedDT.SelectedFID = gtDDCKey.FID;
                                FIDs.Add(gtDDCKey.FID);
                            }
                        }
                        else
                        {
                            MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_GUY_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            CustomCommandHelper.Complete();
                            return;
                        }
                    }
                }

                FIDs.Clear();
                FIDs = null;

                m_EmbeddedDT.Application = m_Application;
                m_EmbeddedDT.Text        = ConstantsDT.COMMAND_NAME_GUYING;
                m_EmbeddedDT.CommandName = ConstantsDT.COMMAND_NAME_GUYING;
                m_EmbeddedDT.SelectedFNO = ConstantsDT.FNO_POLE;

                // Get the Guying Scenario
                string guyingScenarioNumber = string.Empty;
                bool   newGuyingScenario    = false;
                string hyperlinkFilePath    = string.Empty;
                if (!GetGuyingScenario(ref guyingScenarioNumber, ref newGuyingScenario, ref hyperlinkFilePath))
                {
                    CustomCommandHelper.Complete();
                    return;
                }

                if (newGuyingScenario)
                {
                    // Pass notification to Save command to increment G3E_JOB.GUY_SCENARIO_COUNT on successful save.
                    m_EmbeddedDT.NewGuyScenario   = true;
                    m_EmbeddedDT.GuyScenarioCount = Convert.ToInt16(guyingScenarioNumber);
                }
                else
                {
                    // Create Hyperlink component
                    m_EmbeddedDT.WrNumber         = m_Application.DataContext.ActiveJob;
                    m_EmbeddedDT.GuyScenarioCount = Convert.ToInt16(guyingScenarioNumber);

                    m_TransactionManager.Begin("New Hyperlink");
                    if (m_EmbeddedDT.AddHyperlinkComponent(hyperlinkFilePath))
                    {
                        m_TransactionManager.Commit();
                    }
                    else
                    {
                        m_TransactionManager.Rollback();
                    }

                    CustomCommandHelper.Complete();
                    return;
                }

                // Get the report data
                if (!GetReportData(guyingScenarioNumber))
                {
                    CustomCommandHelper.Complete();
                    return;
                }

                // Get the form Close events so we can call the Complete method for the command
                // when the form closes.
                m_EmbeddedDT.cmdClose.Click += cmdClose_Click;
                m_EmbeddedDT.FormClosing    += cmdClose_Click;

                m_EmbeddedDT.InitializeFormSize();

                m_EmbeddedDT.StartPosition = FormStartPosition.CenterScreen;
                m_EmbeddedDT.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }
Exemplo n.º 15
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                #region Perform validations
                m_oGTCustomCommandHelper = CustomCommandHelper;
                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>();
                m_ooddcKeyObjects = m_iGtApplication.SelectedObjects.GetObjects();
                foreach (IGTDDCKeyObject ddcKeyObject in m_ooddcKeyObjects)
                {
                    if (!fidList.Contains(ddcKeyObject.FID))
                    {
                        fidList.Add(ddcKeyObject.FID);
                        selectedObjects.Add(ddcKeyObject);
                    }
                }
                m_originalObject = selectedObjects[0];

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

                m_oGTTransactionManager.Begin("begin Copy Ancillaries...");
                SubscribeEvents();
                DataTable acuDataTable = GetData();
                if (acuDataTable.Rows.Count != 0)
                {
                    m_ofrmCopyAncillaryCUs = new frmCopyAncillaryCUs(m_originalObject, acuDataTable);
                    if (m_ofrmCopyAncillaryCUs.ShowDialog(m_iGtApplication.ApplicationWindow) == DialogResult.Cancel)
                    {
                        ExitCommand();
                        return;
                    }
                }
                else
                {
                    if (MessageBox.Show("Selected feature has no Ancillary CUs. Continue and only delete Ancillary CUs from targeted features?",
                                        "G/Technology", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                    {
                        ExitCommand();
                    }
                }
            }
            catch (Exception ex)
            {
                if (m_oGTTransactionManager.TransactionInProgress)
                {
                    m_oGTTransactionManager.Rollback();
                }
                ExitCommand();
                MessageBox.Show("Error during execution of Copy Ancillaries custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 16
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();
            }
        }
Exemplo n.º 17
0
        private void btnAttach_Click(object sender, EventArgs e)
        {
            OncDocManage.OncDocManage SpDocMan = new OncDocManage.OncDocManage();
            Recordset tmpRs  = null;
            string    tmpQry = string.Empty;

            try
            {
                //File validation
                if (string.IsNullOrEmpty(txtFile.Text) || !File.Exists(txtFile.Text))
                {
                    MessageBox.Show(m_igtApplication.ApplicationWindow, "Valid file is not selected.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    UpdateStatus("Attach Job Document process started.");
                    DialogResult dialogResult = MessageBox.Show(m_igtApplication.ApplicationWindow, m_commonMessages.AttachDialog, "G/Technology", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (dialogResult == DialogResult.OK)
                    {
                        IGTKeyObject m_designAreaObj;
                        #region Adding Hyperlink
                        try
                        {
                            try
                            {
                                UpdateStatus("Adding the file to SharePoint");
                                m_igtApplication.BeginWaitCursor();
                                // add file to sharepoint.
                                // get the WR_NBR
                                tmpQry = "Select j.WR_NBR from DESIGNAREA_P da, g3e_job j " +
                                         "where da.JOB_ID = j.G3E_IDENTIFIER and da.g3e_fid = " + m_designAreaFID.ToString();
                                tmpRs = m_igtApplication.DataContext.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                                                   LockTypeEnum.adLockReadOnly,
                                                                                   (int)CommandTypeEnum.adCmdText);
                                if (!(tmpRs.BOF && tmpRs.EOF))
                                {
                                    tmpRs.MoveFirst();
                                    SpDocMan.WrkOrd_Job = tmpRs.Fields[0].Value.ToString();
                                    tmpRs = null;
                                }
                                else
                                {
                                    MessageBox.Show(m_igtApplication.ApplicationWindow, "The WR number was not found in the Job table.", "Attach Job Document - Error ", MessageBoxButtons.OK);
                                    if (tmpRs != null)
                                    {
                                        tmpRs = null;
                                    }
                                    return;
                                }

                                // Get the Document Management metadata parameters.
                                tmpQry = "select param_name, param_value from SYS_GENERALPARAMETER " +
                                         "where subsystem_name = 'Doc_Management'";
                                tmpRs = m_igtApplication.DataContext.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                                                   LockTypeEnum.adLockReadOnly,
                                                                                   (int)CommandTypeEnum.adCmdText);
                                // Set the OncDocManage class properties
                                if (!(tmpRs.BOF && tmpRs.EOF))
                                {
                                    tmpRs.MoveFirst();
                                    for (int i = 0; i < tmpRs.RecordCount; ++i)
                                    {
                                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "ROOT_PATH")
                                        {
                                            SpDocMan.SPRootPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                                        }
                                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "SP_URL")
                                        {
                                            SpDocMan.SPSiteURL = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                                        }
                                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "JOBWO_REL_PATH")
                                        {
                                            SpDocMan.SPRelPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                                        }
                                        tmpRs.MoveNext();
                                    }
                                }
                                SpDocMan.SPFileDescription = txtDescription.Text;
                                SpDocMan.SrcFilePath       = txtFile.Text;
                                SpDocMan.SPFileType        = cmbType.Text;
                                // Add the file to SharePoint.
                                if (!SpDocMan.AddSPFile(true))
                                {
                                    System.ArgumentException SPExcept = new System.ArgumentException("File was not saved in SharePoint.");
                                }
                            }
                            catch (Exception ex)
                            {
                                m_igtApplication.EndWaitCursor();
                                MessageBox.Show(m_igtApplication.ApplicationWindow, "Unable to copy the file to SharePoint. Error: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            // Add the hyperlink to the Design Area feature.
                            UpdateStatus("Adding the Hyperlink to the Design Area.");
                            // Begin the GTech transaction.
                            m_igtranscation.Begin("IN PROGRESS");
                            // open the Design Area feature.
                            m_designAreaObj = m_igtApplication.DataContext.OpenFeature(8100, m_designAreaFID);
                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.AddNew("G3E_FID", m_designAreaFID);
                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["HYPERLINK_T"].Value   = SpDocMan.RetFileURL;
                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["DESCRIPTION_T"].Value = txtDescription.Text;
                            // Add a new hyperlink component instance
                            if (cmbType.Text.Length > m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize)
                            {
                                m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value =
                                    cmbType.Text.Substring(0, m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize);
                            }
                            else
                            {
                                m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value = cmbType.Text;
                            }

                            // Add the file name to the hyperlink table.
                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["FILENAME_T"].Value = SpDocMan.RetFileName;

                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["G3E_FNO"].Value = 8100;
                            m_designAreaObj.Components["JOB_HYPERLINK_N"].Recordset.Update();
                            // end the GTech transaction.
                            if (m_igtranscation.TransactionInProgress)
                            {
                                m_igtranscation.Commit();
                            }
                            MessageBox.Show(m_igtApplication.ApplicationWindow, "Attach Job Document Completed sucessfully.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            UpdateStatus("Attach Job Document Completed sucessfully.");
                            this.Close();
                        }
                        catch (Exception ex)
                        {
                            // if the GTec transaction fails, rollback the edit and exit the command.
                            tmpQry = ex.Message;
                            if (m_igtranscation.TransactionInProgress)
                            {
                                m_igtranscation.Rollback();
                            }
                            m_igtApplication.EndWaitCursor();
                            throw;
                        }
                        finally
                        {
                            m_designAreaObj = null;
                        }
                        m_igtApplication.EndWaitCursor();
                        #endregion Adding Hyperlink
                    }
                }
            }
            catch (Exception)
            {
                m_igtApplication.EndWaitCursor();
                throw;
            }
        }
Exemplo n.º 18
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.º 19
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.º 20
0
        /// <summary>
        /// Updates a Component for a given feature. The Data from the component is passed into the Function as a DataGridViewRow
        /// </summary>
        /// <param name="row">DataGridViewRow</param>
        /// <param name="feature">IGTKeyObject</param>
        /// <param name="fid">int</param>
        /// <param name="fno">short</param>
        /// <param name="wirelineOrEquipment">string</param>
        /// <returns></returns>
        internal static Boolean updateComponent(DataGridViewRow row,
                                                int fid, short fno, int cid,
                                                string p_CompCd,
                                                string p_Maint1,
                                                string p_Maint2,
                                                string wirelineOrEquipment)
        {
            IGTKeyObject feature   = null;
            Boolean      tmpRetVal = true;

            try
            {
                tmpRetVal = true;
                // Begin the transaction
                gTransMgr.Begin("Update Feature");
                // Open the structure feature.
                feature = gDataCont.OpenFeature(fno, fid);
                // get to the correct attachment component and find the correct attachment record.
                feature.Components[wirelineOrEquipment].Recordset.Filter = "G3E_CID = " + cid;
                feature.Components[wirelineOrEquipment].Recordset.MoveFirst();

                // update the record.
                if (wirelineOrEquipment.Equals("ATTACH_WIRELINE_N"))
                {
                    object[] tmpCols = { "G3E_FID",            "G3E_FNO",             "W_ATTACH_COMPANY",
                                         "W_MAINTAINER_1",     "W_MAINTAINER_2",      "W_PERMIT_NUMBER",
                                         "W_ATTACH_HEIGHT_FT", "W_ATTACHMENT_STATUS",
                                         "W_ATTACH_SOURCE_C",  "W_MESSENGER_C",       "W_ATTACH_TYPE", "W_ATTACH_POSITION" };
                    object[] tmpVals = { fid,                                             fno, p_CompCd, p_Maint1, p_Maint2,
                                         row.Cells["Permit Number"].Value,
                                         row.Cells["Attachment Height"].Value,
                                         row.Cells["Attachment Status"].Value.ToString(),
                                         row.Cells["Attachment Source"].Value.ToString(),
                                         row.Cells["Messenger"].Value.ToString(),
                                         row.Cells["Attachment Type"].Value.ToString(),
                                         row.Cells["Attachment Position"].Value.ToString() };

                    feature.Components[wirelineOrEquipment].Recordset.Update(tmpCols, tmpVals);

                    if (row.Cells["Initial String Tension (lbs)"].Value == null ||
                        row.Cells["Initial String Tension (lbs)"].Value.ToString().Equals("") ||
                        row.Cells["Initial String Tension (lbs)"].Value.ToString().Equals(" "))
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["W_INIT_STR_TENSION"].Value = DBNull.Value;
                    }
                    else
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["W_INIT_STR_TENSION"].Value =
                            Convert.ToInt16(row.Cells["Initial String Tension (lbs)"].Value.ToString());
                    }

                    if (row.Cells["Outside Diameter (inches)"].Value.ToString() == null ||
                        row.Cells["Outside Diameter (inches)"].Value.ToString().Trim() == "")
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["W_OUTSIDE_DIAM"].Value = DBNull.Value;
                    }
                    else
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["W_OUTSIDE_DIAM"].Value =
                            Convert.ToInt16(row.Cells["Outside Diameter (inches)"].Value.ToString());
                    }
                }
                else
                {
                    feature.Components[wirelineOrEquipment].Recordset.MoveFirst();
                    object[] tmpCols = { "G3E_FID", "G3E_FNO", "E_ATTACH_COMPANY", "E_MAINTAINER_1", "E_MAINTAINER_2", "E_PERMIT_NUMBER", "E_ATTACH_HEIGHT_FT", "E_ATTACHMENT_STATUS", "E_ATTACH_SOURCE_C", "E_ATTACH_TYPE_C", "E_ATTACH_POSITION_C", "E_BRACKET_ARM" };
                    object[] tmpVals = { fid,                                               fno, p_CompCd, p_Maint1, p_Maint2, row.Cells["Permit Number"].Value.ToString(),
                                         row.Cells["Attachment Height"].Value.ToString(),
                                         row.Cells["Attachment Status"].Value.ToString(),
                                         row.Cells["Attachment Source"].Value.ToString(),
                                         row.Cells["Attachment Type"].Value.ToString(),
                                         row.Cells["Attachment Position"].Value.ToString(),
                                         row.Cells["Bracket"].Value.ToString() };

                    feature.Components[wirelineOrEquipment].Recordset.Update(tmpCols, tmpVals);
                    if (row.Cells["Weight (lbs/ft)"].Value.ToString().Equals("") || row.Cells["Weight (lbs/ft)"].Value.ToString().Equals(" ") || row.Cells["Weight (lbs/ft)"].Value == null)
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["E_WEIGHT"].Value = DBNull.Value;
                    }
                    else
                    {
                        feature.Components[wirelineOrEquipment].Recordset.Fields["E_WEIGHT"].Value =
                            Convert.ToInt16(row.Cells["Weight (lbs/ft)"].Value.ToString());
                    }
                }
                // commit the transaction.
                gTransMgr.Commit();
                row.Cells["Process Status"].Value = "Existing Attachment - Updated";
            }
            catch (Exception e)
            {
                tmpRetVal = false;
                gTransMgr.Rollback();
                row.Cells["Process Status"].Value = "Error while updating Attachment: " + e;
                // MessageBox.Show(gApp.ApplicationWindow, "updateComponent:" + e.Message, "Import Attachments - Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
            return(tmpRetVal);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Entry point for the Custom Command Modal interface.
        /// </summary>
        public void Activate()
        {
            try
            {
                // Check for out of synch WPs and exit if they are not synchronized
                SharedWriteBackLibrary swbl = new SharedWriteBackLibrary();
                if (!swbl.ValidateWorkPoints())
                {
                    return;
                }

                TransactionManager.Begin("Post Job");

                // PendingEditsExist builds this recordset and we can use it again in
                // ValidateNetworkDrawings to keep from querying for it again there.
                Recordset pendingEdits = null;

                // If there are no pending edits, then nothing else to do here.
                // PendingEditsExist will close/null the recordset object if there are no pending edits.
                if (!PendingEditsExist(ref pendingEdits))
                {
                    MessageBox.Show("There are no pending edits in the active job.  Exiting command.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // Validate pending job edits
                if (!ResolveJobValidationErrors())
                {
                    return;
                }

                // Perform Job Validations.  Return if any fail.
                if (!JobAttributesAreValid)
                {
                    return;
                }

                // Check for existing conflicts
                if (ConflictsExist())
                {
                    return;
                }



                // Allow user to validate the pertinent network drawings attached to the active job.
                // ValidateNetworkDrawings will close/null the recordset object when finished with it.
                if (!ValidateNetworkDrawings(ref pendingEdits))
                {
                    return;
                }

                TransactionManager.Commit(true);

                // Post edits for active job
                if (!PostJobEdits())
                {
                    return;
                }

                // Since nothing else is updated in this command from here to the end,
                // a transaction here should not be necessary; however, leaving it just in case.
                TransactionManager.Begin("Post Job");

                // If indicated, then invoke a Writeback
                // ALM 1566 - Requests removal of the check for the write back flag.
                //            Future design change will check for this in a different way
                //            but leaving the clause in the conditional statement for clarity
                //            until that change is implemented.
                JobManager jobManager = new JobManager();

                if (nonWR != jobManager.JobType /*&& jobManager.WriteBackNeeded*/)
                {
                    DoWriteBack(swbl);
                }

                if (TransactionManager.TransactionInProgress)
                {
                    TransactionManager.Commit(true);
                }
            }
            catch (Exception ex)
            {
                if (TransactionManager.TransactionInProgress)
                {
                    TransactionManager.Rollback();
                }

                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);
            }
        }
Exemplo n.º 22
0
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            m_gTCustomCommandHelper = CustomCommandHelper;
            if (GTDataContext.IsRoleGranted("PRIV_DESIGN_ALL"))
            {
                try
                {
                    presenter = new SupplementalAgreementPresenter(this, CustomCommandHelper, m_oGTTransactionManager);
                    //CustomCommandHelper.MouseMove += CustomCommandHelper_MouseMove;
                    string[] strAlterDesign;

                    if (presenter.IsCCommandValid())
                    {
                        //If command is valid and MSLA date exist CC loads MSLA form.
                        if (presenter.IsMSLAForm)
                        {
                            #region Form With MSLA

                            FormWithMSLA formWithMSLA = new FormWithMSLA();
                            formWithMSLA.StartPosition = FormStartPosition.CenterParent;


                            if (presenter.ActiveWR.Contains("-"))
                            {
                                strAlterDesign     = new string[2];
                                strAlterDesign     = presenter.ActiveWR.Split('-');
                                presenter.ActiveWR = strAlterDesign[0];
                            }
                            presenter.m_UserForm         = formWithMSLA;
                            formWithMSLA.m_formPresenter = presenter;
                            formWithMSLA.ShowDialog(m_iGtApplication.ApplicationWindow);

                            #endregion
                        }
                        else
                        {
                            //If command is valid and MSLA date is null CC loads with out MSLA form.

                            #region Form Without MSLA

                            FormWithoutMSLA formWithoutMSLA = new FormWithoutMSLA();
                            formWithoutMSLA.StartPosition = FormStartPosition.CenterParent;


                            if (presenter.ActiveWR.Contains("-"))
                            {
                                strAlterDesign     = new string[2];
                                strAlterDesign     = presenter.ActiveWR.Split('-');
                                presenter.ActiveWR = strAlterDesign[0];
                            }
                            presenter.m_UserForm            = formWithoutMSLA;
                            formWithoutMSLA.m_formPresenter = presenter;
                            formWithoutMSLA.ShowDialog(m_iGtApplication.ApplicationWindow);

                            #endregion
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(presenter.NotifyPresenterMess))
                        {
                            //GTClassFactory.Create<IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, presenter.NotifyPresenterMess);
                            MessageBox.Show(presenter.NotifyPresenterMess, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                            MessageBoxDefaultButton.Button1);


                            presenter = null;
                            //m_gTCustomCommandHelper.MouseMove -= CustomCommandHelper_MouseMove;
                            ExitCommand(m_gTCustomCommandHelper);
                        }
                        else
                        {
                            presenter = null;
                            // m_gTCustomCommandHelper.MouseMove -= CustomCommandHelper_MouseMove;
                            ExitCommand(m_gTCustomCommandHelper);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1);

                    //CustomCommandHelper.MouseMove -= CustomCommandHelper_MouseMove;

                    if (m_oGTTransactionManager != null)
                    {
                        if (m_oGTTransactionManager.TransactionInProgress)
                        {
                            m_oGTTransactionManager.Rollback();
                        }
                    }
                    m_oGTTransactionManager = null;

                    ExitCommand(CustomCommandHelper);
                }
            }
            else
            {
                MessageBox.Show("User does not have PRIV_DESIGN_ALL role.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1);
                //CustomCommandHelper.MouseMove -= CustomCommandHelper_MouseMove;
                ExitCommand(CustomCommandHelper);
            }
        }
Exemplo n.º 23
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.º 24
0
        // Save the report to a shared location and hyperlink the report to the selected FID
        // Run validation for Guying
        private void cmdSaveReport_Click(object sender, EventArgs e)
        {
            // Perform validation for Guying
            if (m_CommandName == ConstantsDT.COMMAND_NAME_GUYING)
            {
                if (!ValidateGuyingResults())
                {
                    return;
                }
                else
                {
                    foreach (int fid in m_SelectedFIDs)
                    {
                        WriteGuyingResults(fid);
                    }
                }
            }

            string reportFilename = string.Empty;

            if (ExportReport(ref reportFilename))
            {
                try
                {
                    m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ConstantsDT.MESSAGE_REPORT_SAVING);
                    m_Application.BeginWaitCursor();

                    Recordset tmpRs = null;

                    String  tmpQry       = String.Empty;
                    Boolean bSpFileAdded = false;


                    tmpQry = "select param_name, param_value from sys_generalparameter " +
                             "where SUBSYSTEM_NAME = ?";
                    tmpRs = m_Application.DataContext.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                                    LockTypeEnum.adLockReadOnly,
                                                                    (int)CommandTypeEnum.adCmdText,
                                                                    "Doc_Management");
                    if (!(tmpRs.BOF && tmpRs.EOF))
                    {
                        tmpRs.MoveFirst();
                        tmpRs.MoveLast();
                        tmpRs.MoveFirst();
                        OncDocManage.OncDocManage rptToSave = new OncDocManage.OncDocManage();
                        while (!tmpRs.EOF)
                        {
                            if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "JOBWO_REL_PATH")
                            {
                                rptToSave.SPRelPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                            }
                            if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "SP_URL")
                            {
                                rptToSave.SPSiteURL = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                            }
                            if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "ROOT_PATH")
                            {
                                rptToSave.SPRootPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                            }
                            tmpRs.MoveNext();
                        }
                        rptToSave.SrcFilePath = reportFilename;
                        rptToSave.WrkOrd_Job  = m_Application.DataContext.ActiveJob;
                        rptToSave.SPFileName  = reportFilename.Substring(reportFilename.LastIndexOf("\\") + 1);
                        if (m_CommandName == ConstantsDT.COMMAND_NAME_GUYING)
                        {
                            rptToSave.SPFileType = "Guying Program";
                        }
                        else if (m_CommandName == ConstantsDT.COMMAND_NAME_SAG_CLEARANCE)
                        {
                            rptToSave.SPFileType = "Sag Clearance";
                        }
                        else
                        {
                            rptToSave.SPFileType = "";
                        }
                        bSpFileAdded = rptToSave.AddSPFile(true);
                        if (bSpFileAdded == false)
                        {
                            string msg = string.Format("{0}: Error adding {1} to SharePoint.{2}{2}{3}", ConstantsDT.ERROR_REPORT_SAVING, rptToSave.SPFileName, System.Environment.NewLine, rptToSave.RetErrMessage);
                            MessageBox.Show(m_Application.ApplicationWindow, msg, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        tmpRs = null;

                        m_TransactionManager.Begin("New Hyperlink");

                        if (AddHyperlinkComponent(rptToSave.RetFileURL))
                        {
                            if (m_CommandName == ConstantsDT.COMMAND_NAME_GUYING && m_NewGuyScenario)
                            {
                                string sql             = "update g3e_job set guy_scenario_count = ? where g3e_identifier = ?";
                                int    recordsAffected = 0;
                                m_Application.DataContext.Execute(sql, out recordsAffected, (int)CommandTypeEnum.adCmdText, m_GuyScenarioCount, m_Application.DataContext.ActiveJob);
                                m_Application.DataContext.Execute("commit", out recordsAffected, (int)CommandTypeEnum.adCmdText);
                            }

                            m_TransactionManager.Commit();
                        }
                        else
                        {
                            m_TransactionManager.Rollback();
                        }
                    }
                    else
                    {
                        if (m_TransactionManager.TransactionInProgress)
                        {
                            m_TransactionManager.Rollback();
                        }
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_REPORT_SAVING + ": " +
                                        "Error finding General Parameters JOBWO_REL_PATH or 'SP_URL",
                                        ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    m_Application.EndWaitCursor();
                    m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                }
                catch (Exception ex)
                {
                    m_Application.EndWaitCursor();
                    m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                    MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_REPORT_SAVING + ": " + ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemplo n.º 25
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.º 26
0
        /// <summary>
        /// Calls methods to validate and process the transaction.
        /// </summary>
        /// <returns>Boolean indicating status</returns>
        private bool ProcessTransaction()
        {
            bool returnValue = false;

            try
            {
                // Validate the transaction
                ValidateDEIS validateDEIS = new ValidateDEIS(m_Application.DataContext);
                if (!validateDEIS.ValidateTransaction())
                {
                    // Merge status and message, so status can be set to 'COMPLETE'. This is needed for WARNINGs.
                    TransactionDEIS.TransactionMessage = TransactionDEIS.TransactionStatus + " - " + TransactionDEIS.TransactionMessage;
                    TransactionDEIS.TransactionStatus  = TransactionDEIS.TRANS_STATUS_COMPLETE;
                    return(false);
                }

                // If validation passes then call processing method
                m_TransactionManager.Begin("Process DEIS Transaction");
                ProcessDEIS processDEIS = new ProcessDEIS(m_Application.DataContext);

                if (!processDEIS.Process())
                {
                    // Merge status and message, so status can be set to 'COMPLETE'. This is needed for WARNINGs.
                    TransactionDEIS.TransactionMessage = TransactionDEIS.TransactionStatus + " - " + TransactionDEIS.TransactionMessage;
                    TransactionDEIS.TransactionStatus  = TransactionDEIS.TRANS_STATUS_COMPLETE;
                    m_TransactionManager.Rollback();
                    return(false);
                }

                m_TransactionManager.Commit();

                // If success or warning then post job edits.
                string message = string.Empty;
                if (!PostJobEdits(out message))
                {
                    // Merge status and message, so status can be set to 'COMPLETE'. This is needed for WARNINGs.
                    TransactionDEIS.TransactionMessage = TransactionDEIS.TransactionStatus + " - " + TransactionDEIS.TransactionMessage;
                    TransactionDEIS.TransactionStatus  = TransactionDEIS.TRANS_STATUS_COMPLETE;
                    return(false);
                }

                if (TransactionDEIS.TransactionMessage.Length > 0)
                {
                    // Merge status and message, so status can be set to 'COMPLETE'. This is needed for WARNINGs.
                    TransactionDEIS.TransactionMessage = TransactionDEIS.TransactionStatus + " - " + TransactionDEIS.TransactionMessage;
                }
                else
                {
                    TransactionDEIS.TransactionMessage = TransactionDEIS.TRANS_STATUS_SUCCESS;
                }

                TransactionDEIS.TransactionStatus = TransactionDEIS.TRANS_STATUS_COMPLETE;
            }
            catch (Exception ex)
            {
                if (m_TransactionManager.TransactionInProgress)
                {
                    m_TransactionManager.Rollback();
                }
                TransactionDEIS.TransactionStatus  = TransactionDEIS.TRANS_STATUS_FAILED;
                TransactionDEIS.TransactionMessage = "Error processing transaction: " + ex.Message;
                returnValue = false;
            }

            return(returnValue);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Adds the file to Sharepoint and adds the hyperlink to the selected feature.
        /// </summary>
        /// <param name="p_Description"></param>
        /// <param name="p_SrcFile"></param>
        /// <param name="p_SPType"></param>
        /// <returns></returns>
        static internal Boolean gAddSPDocAndHyperLnk(string p_Description, string p_SrcFile, string p_SPType)
        {
            Boolean   tmpRetVal     = false;
            Recordset tmpRs         = null;
            string    tmpQry        = string.Empty;
            string    tmpSPFileName = string.Empty;

            OncDocManage.OncDocManage SpDocMan = new OncDocManage.OncDocManage();

            // add document to SharePoint
            try
            {
                gMessage = "Adding the file to SharePoint.";
                gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);

                gApp.BeginWaitCursor();

                tmpQry = "select param_name, param_value from SYS_GENERALPARAMETER " +
                         "where subsystem_name = 'Doc_Management'";
                tmpRs = gDatacont.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                LockTypeEnum.adLockReadOnly,
                                                (int)CommandTypeEnum.adCmdText);
                if (!(tmpRs.BOF && tmpRs.EOF))
                {
                    tmpRs.MoveFirst();
                    for (int i = 0; i < tmpRs.RecordCount; ++i)
                    {
                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "ROOT_PATH")
                        {
                            SpDocMan.SPRootPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                        }
                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "SP_URL")
                        {
                            SpDocMan.SPSiteURL = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                        }
                        tmpRs.MoveNext();
                    }
                }
                // set the Properties for the OncDocManage class
                SpDocMan.SPRelPath         = gSPDocBaseRelPath;
                SpDocMan.SPFileDescription = p_Description;
                tmpSPFileName        = p_SrcFile.Substring(p_SrcFile.LastIndexOf("\\") + 1);
                tmpSPFileName        = tmpSPFileName.Insert(tmpSPFileName.LastIndexOf("."), csGlobals.gCCFid.ToString());
                SpDocMan.SPFileName  = tmpSPFileName;
                SpDocMan.SrcFilePath = p_SrcFile;
                SpDocMan.SPFileType  = p_SPType;
                SpDocMan.WrkOrd_Job  = gSPDocFeatureDocLoc; // "Feature Documents";
                // Add the file to SharePoint
                if (!SpDocMan.AddSPFile(true))
                {
                    gMessage = "The file was not saved to SharePoint";
                    gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);
                    //System.ArgumentException SPExcept = new System.ArgumentException("File was not saved in SharePoint.");
                    tmpRetVal = false;
                }
            }
            catch (Exception ex)
            {
                gMessage = "Unable to copy the file to SharePoint. Error: " + ex.Message;
                gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);
                MessageBox.Show(gMessage,
                                "Attach Feature Hyperlink Document - csGlobals",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                gApp.EndWaitCursor();
                return(tmpRetVal);
            }

            // Add the Hyperlink component to the feature.
            IGTKeyObject tmpFeature = null;

            try
            {
                gMessage = "Adding the Hyperlink record to the feature";
                gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);
                // begin the transaction
                gManageTransactions.Begin("IN PROGRESS");
                // Open the feature
                tmpFeature = gDatacont.OpenFeature(gCCFno, gCCFid);
                // Add the hyperlink component and set its attributes
                tmpFeature.Components[gCCHyperLnkCno].Recordset.AddNew("G3E_FID", gCCFid);
                tmpFeature.Components[gCCHyperLnkCno].Recordset.Fields["G3E_FNO"].Value       = gCCFno;
                tmpFeature.Components[gCCHyperLnkCno].Recordset.Fields["HYPERLINK_T"].Value   = SpDocMan.RetFileURL.ToString();
                tmpFeature.Components[gCCHyperLnkCno].Recordset.Fields["DESCRIPTION_T"].Value = p_Description.ToString();
                tmpFeature.Components[gCCHyperLnkCno].Recordset.Fields["TYPE_C"].Value        = p_SPType.ToString();
                tmpFeature.Components[gCCHyperLnkCno].Recordset.Fields["FILENAME_T"].Value    = SpDocMan.RetFileName.ToString();
                // Commit the transaction
                if (gManageTransactions.TransactionInProgress)
                {
                    gManageTransactions.Commit();
                }

                gMessage = "Attach Feature Document Completed sucessfully.";

                gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);

                tmpRetVal = true;
            }
            catch (Exception ex)
            {
                if (gManageTransactions.TransactionInProgress)
                {
                    gManageTransactions.Rollback();
                }

                gMessage = "Error in gAddSPDocAndHyperLnk: " + ex.Message;
                gApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, gMessage);
                MessageBox.Show(gMessage,
                                "Attach Feature Hyperlink Document - csGlobals",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                tmpRetVal = false;
            }

            gApp.EndWaitCursor();

            return(tmpRetVal);
        }