Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            stltNonLocatedCtx.MiscStructG3eFid = streetLightAcct.MiscStructFid;
            if (this.streetLights.Where <StreetLightNonLocated>(s => s.EntityState != EntityMode.Review).Count() > 0)
            {
                _gtTransactionManager.Begin("Saving Street Light(s)");
                try
                {
                    // ALM 2044 - Set the CU for the current street light.
                    // The same customer-owned CU will apply to all non-located lights for the active account.
                    // If there's not a customer-owned CU for this account, then allow the user to exit the save operation.
                    string CU = CommonUtil.CustomerOwnedSteetLightCU(this.streetLightAcct.LAMP_TYPE, this.streetLightAcct.Wattage, this.streetLightAcct.LUMINARE_STYLE);

                    if (string.IsNullOrEmpty(CU))
                    {
                        string msg = string.Format("A unique customer-owned CU was not found where Lamp Type = {0} and Wattage = {1} and Luminaire Style = {2}.{3}{3}Continue?", this.streetLightAcct.LAMP_TYPE, this.streetLightAcct.Wattage, this.streetLightAcct.LUMINARE_STYLE, Environment.NewLine);

                        if (DialogResult.No == MessageBox.Show(msg, "G/Technology", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            return;
                        }
                    }
                    //Save the Street Light Boundary
                    _gtApp.BeginWaitCursor();
                    foreach (StreetLightNonLocated streetLight in this.streetLights.Where <StreetLightNonLocated>(s => s.EntityState != EntityMode.Review))
                    {
                        if (streetLight.EntityState == EntityMode.Add)
                        {
                            streetLight.LAMP_TYPE      = this.streetLightAcct.LAMP_TYPE;
                            streetLight.LUMINARE_STYLE = this.streetLightAcct.LUMINARE_STYLE;
                            streetLight.Wattage        = this.streetLightAcct.Wattage;
                            streetLight.ESI_LOCATION   = this.streetLightAcct.ESI_LOCATION;
                            streetLight.RATE_CODE      = this.streetLightAcct.RATE_CODE;
                            streetLight.RATE_SCHEDULE  = this.streetLightAcct.RATE_SCHEDULE;
                            streetLight.CU             = this.CU;
                        }
                        stltNonLocatedCtx.SaveStreetLight(streetLight);
                    }
                    _gtTransactionManager.Commit(true);
                    this.streetLights = stltNonLocatedCtx.GetStreetLightByAccountID(this.streetLightAcct.ESI_LOCATION);
                    dtGridViewNonLocated.DataSource = this.streetLights;
                    _gtApp.RefreshWindows();
                    _gtApp.EndWaitCursor();
                    MessageBox.Show("Pending changes committed successfully.", ManageNonLocatedTxt, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    if (_gtTransactionManager.TransactionInProgress)
                    {
                        _gtTransactionManager.Rollback();
                    }
                    _gtApp.EndWaitCursor();
                    MessageBox.Show("Error while Saving Street Light(s): " + ex.Message, ManageNonLocatedTxt, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Mouse double click event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_oGTCustomCommandHelper_DblClick(object sender, GTMouseEventArgs e)
        {
            try
            {
                m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                if (m_selectedObjects.Count == 0)
                {
                    MessageBox.Show("No target features were selected.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ExitCommand();
                    return;
                }
                if (m_ofrmCopyAncillaryCUs != null) // Initial feature has ACUs
                {
                    m_iGtApplication.BeginWaitCursor();
                    if (m_ofrmCopyAncillaryCUs.CanDeleteAllExistigAcus)
                    {
                        DeleteExistingACUs();
                    }
                    if (m_ofrmCopyAncillaryCUs.CuInformationList.Count > 0)
                    {
                        CopySourceACUsToTargetFeature();
                        if (CheckForCorrectionModeProperty())
                        {
                            RemoveCorrectionModeProperty();
                        }
                    }
                }
                else // Initial feature no ACUs and user selected to go ahead and delete ACUs from target
                {
                    DeleteExistingACUs();
                }
                m_oGTTransactionManager.Commit();
                m_oGTTransactionManager.RefreshDatabaseChanges();

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

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

            try
            {
                gtApp.BeginWaitCursor();
                sqlStmt = string.Format(sqlStmt, g3eFno, selfOverlap);
                gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Overlapping Boundarys....");
                gtTransactionManager.Begin("Detect Overlapping Boundarys");
                rs = Execute(sqlStmt);
                gtTransactionManager.Commit();
                MessageBox.Show("Detecting Overlapping Boundarys Analysis is Completed", msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
                gtTransactionManager.RefreshDatabaseChanges();
                gtApp.RefreshWindows();
                gtApp.EndWaitCursor();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Execute Procudure to Detect Polygon Edge Mismatch
        /// </summary>
        private void DetectPolygonEdgeMismatch()
        {
            Recordset rs          = null;
            string    sqlStmt     = "Begin LBM_UTL.DetectPolygonEdgeMismatch; end;";
            string    mergeStatus = string.Empty;

            try
            {
                gtApp.BeginWaitCursor();
                gtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Detecting Polygon Edge Mismatch....");
                gtTransactionManager.Begin("Detect Polygon Edge Mismatch");
                rs = Execute(sqlStmt);
                gtTransactionManager.Commit();
            }
            catch (Exception ex)
            {
                gtTransactionManager.Rollback();
                throw ex;
            }
            finally
            {
                rs = null;
                gtTransactionManager.RefreshDatabaseChanges();
                gtApp.RefreshWindows();
                gtApp.EndWaitCursor();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Ends the process.
 /// </summary>
 public void Terminate()
 {
     dataContext          = null;
     gtTransactionManager = null;
     UnsubscribeEvents();
     customCommandHelper = null;
     if (featurePlacementService != null)
     {
         featurePlacementService.Dispose();
         featurePlacementService = null;
     }
     if (featureExplorerService != null)
     {
         featureExplorerService.Clear();
         featureExplorerService.Dispose();
         featureExplorerService = null;
     }
     m_gtApp.EndWaitCursor();
 }
Esempio n. 8
0
 private void ExitCommand()
 {
     try
     {
         m_gtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
         m_gtApplication.EndWaitCursor();
     }
     catch (Exception)
     {
         throw;
     }
 }
Esempio n. 9
0
 private void GtApp_SelectedObjectsChanged(object sender, EventArgs e)
 {
     try
     {
         if (gtApp.SelectedObjects.FeatureCount > 0)
         {
             g3eFno_src = gtApp.SelectedObjects.GetObjects()[0].FNO;
             g3eFid_src = gtApp.SelectedObjects.GetObjects()[0].FID;
             if (g3eFid_src != g3eFid_trg)
             {
                 gtApp.BeginWaitCursor();
                 if (g3eFno_src == g3eFno_trg)
                 {
                     //check Selected Feature are Valid for merge
                     if (CheckFeaturesAreValidForMerge(g3eFno_trg, g3eFid_trg, g3eFno_src, g3eFid_src))
                     {
                         // Merge Selected Landbase Boundaries
                         MergeLandbaseBoundary(g3eFno_trg, g3eFid_trg, g3eFno_src, g3eFid_src);
                     }
                 }
                 else
                 {
                     MessageBox.Show(ValidationMsg, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 gtApp.EndWaitCursor();
                 CleanUp();
             }
             else
             {
                 gtApp.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, StatusBarMsg);
             }
         }
     }
     catch (Exception ex)
     {
         gtApp.EndWaitCursor();
         MessageBox.Show("Error " + ex.Message, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         CleanUp();
     }
 }
Esempio n. 10
0
 public void Exitcommand()
 {
     if (m_gtApplication != null)
     {
         m_gtApplication.EndWaitCursor();
         m_gtApplication = null;
     }
     if (m_PTHelper != null)
     {
         m_PTHelper.StatusBarPromptsEnabled        = false;
         m_PTHelper.ConstructionAidsEnabled        = GTConstructionAidsEnabledConstants.gtptConstructionAidsNone;
         m_PTHelper.ConstructionAidDynamicsEnabled = false;
         m_PTHelper = null;
     }
 }
Esempio n. 11
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;
            }
        }
Esempio n. 12
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();
        }
Esempio n. 13
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();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Uploads the report file to SharePoint
        /// </summary>
        /// <param name="fileName">The absolute path to the file</param>
        /// <param name="fileType">The file type</param>
        /// <param name="url">URL for the document management file</param>
        /// <param name="docMgmtFileName">Filename for the document management file</param>
        /// <returns>Boolean indicating status</returns>
        public bool UploadReport(string fileName, string fileType, ref string url, ref string docMgmtFileName)
        {
            bool bReturnValue = false;

            try
            {
                m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ConstantsDT.MESSAGE_REPORT_UPLOADING);
                m_Application.BeginWaitCursor();

                string tmpQry = "select param_name, param_value from sys_generalparameter " +
                                "where SUBSYSTEM_NAME = ?";
                Recordset tmpRs = m_Application.DataContext.OpenRecordset(tmpQry, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText, "Doc_Management");
                if (!(tmpRs.BOF && tmpRs.EOF))
                {
                    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 = fileName;
                    rptToSave.WrkOrd_Job  = m_Application.DataContext.ActiveJob;
                    rptToSave.SPFileName  = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                    rptToSave.SPFileType  = fileType;
                    bool bSpFileAdded = rptToSave.AddSPFile(true);

                    if (bSpFileAdded == false)
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_REPORT_SAVING + ": " +
                                        "Error adding " + rptToSave.SPFileName + " to SharePoint.",
                                        ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        bReturnValue = false;
                    }
                    else
                    {
                        bReturnValue = true;
                    }
                    url             = rptToSave.RetFileURL;
                    docMgmtFileName = rptToSave.RetFileName;

                    tmpRs = null;
                }
                else
                {
                    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);
                    bReturnValue = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_REPORT_SAVING + ": " + ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                bReturnValue = false;
            }

            m_Application.EndWaitCursor();
            m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");

            return(bReturnValue);
        }
Esempio n. 15
0
        // Save the report as a pdf
        private bool ExportReport(ref string reportFilename)
        {
            m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ConstantsDT.MESSAGE_REPORT_CREATING);
            m_Application.BeginWaitCursor();

            bool returnValue = true;

            reportFilename = Path.GetTempPath() + m_ReportName;

            // Check if the user has the file open from a previous run of the report.
            if (File.Exists(reportFilename))
            {
                try
                {
                    File.Delete(reportFilename);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ConstantsDT.ERROR_DELETING_FILE + " " + reportFilename + ": " + Environment.NewLine + ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    returnValue = false;
                }

                returnValue = true;
            }

            // Export the workbook to a pdf
            if (returnValue)
            {
                try
                {
                    if (m_CommandName != ConstantsDT.COMMAND_NAME_GUYING)
                    {
                        // Only export first tab
                        m_xlWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, reportFilename);
                    }
                    else
                    {
                        Excel.Application xlApp = new Excel.Application();
                        xlApp.DisplayAlerts = false;

                        m_xlWorkbook.Save();

                        Excel.Workbook tempWorkbook = xlApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);
                        tempWorkbook.SaveAs(Path.GetTempPath() + "Temp_" + m_WorkbookName);
                        tempWorkbook = xlApp.Workbooks.Open(Path.GetTempPath() + "Temp_" + m_WorkbookName);
                        Excel.Workbook masterWorkbook     = xlApp.Workbooks.Open(m_TempName);
                        Excel.Range    range              = masterWorkbook.Sheets["Summary"].Cells[30, 22] as Excel.Range;
                        string         summaryPage        = range.Value2.ToString();
                        string         rowNumberSelect    = "SELECT PARAM_VALUE FROM SYS_GENERALPARAMETER WHERE SUBSYSTEM_NAME = ? AND SUBSYSTEM_COMPONENT = ? AND PARAM_NAME = ?";
                        Recordset      topNumberRecord    = m_Application.DataContext.OpenRecordset(rowNumberSelect, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockBatchOptimistic, -1, "GuyingCC", "Summary Bottom Value", "Page " + (Convert.ToInt16(summaryPage) - 1));
                        Recordset      bottomNumberRecord = m_Application.DataContext.OpenRecordset(rowNumberSelect, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockBatchOptimistic, -1, "GuyingCC", "Summary Bottom Value", "Page " + (Convert.ToInt16(summaryPage)));

                        if (topNumberRecord.RecordCount > 0 || bottomNumberRecord.RecordCount > 0)
                        {
                            masterWorkbook.Sheets["AnchorTable"].Copy(tempWorkbook.Worksheets[1]);
                            masterWorkbook.Sheets["ReportB"].Copy(tempWorkbook.Worksheets[1]);
                            masterWorkbook.Sheets["ReportA"].Copy(tempWorkbook.Worksheets[1]);
                            masterWorkbook.Sheets["Summary"].Copy(tempWorkbook.Worksheets[1]);
                            tempWorkbook.Sheets["Summary"].Range("O1:Z4536").Delete();
                            tempWorkbook.Sheets["Summary"].Visible = Excel.XlSheetVisibility.xlSheetVisible;
                            //top range-- it will always have A and N top will always start at A1 no matter what, unless its the top, so we are looking for the bottom row before our diagram
                            if (summaryPage != "1")
                            {
                                topNumberRecord.MoveFirst();
                                int topNumber = Convert.ToInt32(topNumberRecord.Fields["PARAM_VALUE"].Value);
                                tempWorkbook.Sheets["Summary"].Range("A1:N" + topNumber).Delete();
                            }
                            //bottom range-- it will always end (if it isnt the lowest possible diagram at Z4536
                            if (summaryPage != "72")
                            {
                                bottomNumberRecord.MoveFirst();
                                int bottomNumber = Convert.ToInt32(bottomNumberRecord.Fields["PARAM_VALUE"].Value) + 1;
                                tempWorkbook.Sheets["Summary"].Range("A" + bottomNumber + ":N4539").Delete();
                            }


                            tempWorkbook.Save();

                            tempWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, reportFilename, null, true, false);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Guying Arrangement!", "Unable to Print", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            returnValue = false;
                        }

                        masterWorkbook.Close(false, m_MissingValue, m_MissingValue);
                        tempWorkbook.Close(false, m_MissingValue, m_MissingValue);
                        xlApp.Quit();

                        ReleaseObjects(masterWorkbook);
                        ReleaseObjects(tempWorkbook);
                        ReleaseObjects(xlApp);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ConstantsDT.ERROR_CONVERTING_PDF + " " + reportFilename + ": " + Environment.NewLine + ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    returnValue = false;
                }
            }

            m_Application.EndWaitCursor();
            m_Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");

            return(returnValue);
        }
Esempio n. 16
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;
            }
        }
Esempio n. 17
0
        public void Activate()
        {
            IGTPlotWindow           igtPlotWindow           = null;
            IGTExportService        igtExportService        = null;
            IGTPDFPrinterProperties igtPDFPrinterProperties = null;

            OncDocManage.OncDocManage tmpOncDocMgr = new OncDocManage.OncDocManage();


            try
            {
                m_igtApplication        = GTClassFactory.Create <IGTApplication>();
                igtPlotWindow           = m_igtApplication.ActivePlotWindow;
                igtExportService        = GTClassFactory.Create <IGTExportService>();
                igtPDFPrinterProperties = GTClassFactory.Create <IGTPDFPrinterProperties>();
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing to selected feature started");

                if (Validate())
                {
                    m_plotwindowPdfFilename = m_plotwindowPath + igtPlotWindow.Caption + ".pdf";
                    m_igtApplication.BeginWaitCursor();

                    setPDFPrinterProps(ref igtPDFPrinterProperties);

                    igtExportService.SaveAsPDF(m_plotwindowPdfFilename, igtPDFPrinterProperties, igtPlotWindow, false);
                    igtExportService        = null;
                    igtPDFPrinterProperties = null;
                    igtPlotWindow           = null;
                    //m_igtApplication.EndWaitCursor();
                    if (File.Exists(m_plotwindowPdfFilename))
                    {
                        if (GetGeneralParams(ref tmpOncDocMgr))
                        {
                            m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Adding the Site Drawing PDF file to SharePoint.");
                            tmpOncDocMgr.SrcFilePath = m_plotwindowPdfFilename;
                            tmpOncDocMgr.SPFileName  = m_plotwindowPdfFilename.Substring(m_plotwindowPdfFilename.LastIndexOf("\\") + 1);
                            tmpOncDocMgr.SPFileType  = "Site Drawings";
                            tmpOncDocMgr.WrkOrd_Job  = m_igtApplication.DataContext.ActiveJob;

                            if (tmpOncDocMgr.AddSPFile(true))
                            {
                                //add to hyperlink to selected object
                                //AddHyperLinktoSelectedFeature(m_selectedFNO, m_selectedFID, m_plotwindowPdfFilename, "Plotwindow " + m_igtApplication.ActivePlotWindow.Caption + " pdf", "SITE");
                                AddHyperLinktoSelectedFeature(m_selectedFNO, m_selectedFID,
                                                              tmpOncDocMgr.RetFileURL, tmpOncDocMgr.RetFileName,
                                                              "Plotwindow " + m_igtApplication.ActivePlotWindow.Caption + " pdf", tmpOncDocMgr.SPFileType);
                            }
                            else
                            {
                                MessageBox.Show("Error during while trying to add the file to SharePoint. Error: " + tmpOncDocMgr.RetErrMessage, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(m_igtApplication.ApplicationWindow, "Ad hoc plots may only be attached to a Permit or Easement feature.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing Command has ended.");
                m_igtApplication.EndWaitCursor();
            }
            catch (Exception ex)
            {
                m_igtApplication.EndWaitCursor();
                MessageBox.Show("Error during execution of Attach Site Drawing custom command" + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error);
                m_igtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Attach Site Drawing Command has ended with errors.");
            }
        }
Esempio n. 18
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();
            }
        }
Esempio n. 19
0
        public void Execute()
        {
            GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Creating Duct COnfiguration");
            String         valueEntered = "";
            String         sFNO         = "";
            int            FID          = 0;
            int            iHorz        = 0;
            int            iVert        = 0;
            IGTKeyObject   Feature      = null;
            short          FNO          = 0;
            IGTApplication oApp         = GTClassFactory.Create <IGTApplication>();

            try
            {
                //objGlobal.gServices = GTClassFactory.Create<IGTRelationshipService>();
                //objGlobal.gDataCont = DataContext;

                ADODB.Recordset netElementSet = _components.GetComponent(2401).Recordset;
                netElementSet.MoveFirst();
                valueEntered = netElementSet.Fields["CONFIG_C"].Value.ToString();
                sFNO         = netElementSet.Fields["G3E_FNO"].Value.ToString();
                FID          = Convert.ToInt32(netElementSet.Fields["G3E_FID"].Value.ToString());
                FNO          = Convert.ToInt16(sFNO);
                Feature      = DataContext.OpenFeature(FNO, FID);


                ////Validate if the Duct Configuration is defined already
                //csGlobals.gServices.ActiveFeature = Feature;

                //IGTKeyObjects oCollection = GTClassFactory.Create<IGTKeyObjects>();

                //oCollection = csGlobals.gServices.GetRelatedFeatures(csConstant.iContains);

                //if (oCollection != null)
                //{
                //    GTClassFactory.Create<IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                //    MessageBox.Show( " Duct Configuration is alredy defined", "Create Duct Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    netElementSet.Fields["CU_C"].Value = _original.FieldValue.ToString();
                //    return;
                //}
                csGlobals objGlobal = new csGlobals(DataContext, Feature);

                if (sFNO != "2400")
                {
                    GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                    return;
                }

                if (valueEntered == "")
                {
                    GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
                    return;
                }

                else
                {
                    try
                    {
                        Char     Delimiter = 'X';
                        String[] sValues   = valueEntered.Split(Delimiter);
                        int      iVal      = 1;
                        foreach (var sValue in sValues)
                        {
                            if (iVal == 1)
                            {
                                string sCorrectValue = Regex.Match(sValue, @"\d").Value;
                                iHorz = Convert.ToInt32(sCorrectValue);
                            }
                            else
                            {
                                string sCorrectValue = Regex.Match(sValue, @"\d").Value;
                                iVert = Convert.ToInt32(sCorrectValue);
                            }
                            iVal = iVal + 1;
                        }
                    }
                    catch (Exception exValue)
                    {
                        MessageBox.Show(exValue.Message + " Value is incorrect, should be Horizontal Number X Vertical Number. Example: 2X2", "Create Duct Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    oApp.BeginWaitCursor();
                    objGlobal.DeleteExistingDucts(FNO, FID);
                    objGlobal.CreateDucConfiguration(iHorz, iVert);

                    oApp.EndWaitCursor();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Duct Creation " + ex.Message);
            }
            finally
            {
                oApp.EndWaitCursor();
            }
            GTClassFactory.Create <IGTApplication>().SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "");
        }
Esempio n. 20
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);
        }