示例#1
0
        private void SaveXMLAddHyperlink(string p_WrNbr, int p_DesArFid)
        {
            string LocRedLineFile = string.Empty;
            string tmpWrNum       = string.Empty;

            OncDocManage.OncDocManage tmpDocMg = new OncDocManage.OncDocManage();

            try
            {
                tmpWrNum       = p_WrNbr;
                LocRedLineFile = SaveRedlineXml(tmpWrNum);
                if (LocRedLineFile != string.Empty)
                {
                    if (SaveXmlToSP(tmpWrNum, LocRedLineFile, ref tmpDocMg) == true)
                    {
                        AddHyperlink(p_DesArFid, tmpDocMg);
                    }
                }
                else
                {
                    MessageBox.Show("No Redlines are currently present in the session. \n" +
                                    "Nothing will be saved in SharePoint and the Hyperlink will not be created."
                                    , "SaveXMLAddHyperlink - Error", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "SaveXMLAddHyperlink - Error", MessageBoxButtons.OK);
            }
        }
示例#2
0
        private Boolean SaveXmlToSP(string p_WrNum, string p_SrcPathFile, ref OncDocManage.OncDocManage p_DocMan)
        {
            Boolean        tmpRetVal = false;
            Recordset      tmpRs     = null;
            string         tmpQry    = string.Empty;
            IGTDataContext tmpDC     = gtApp.DataContext;

            OncDocManage.OncDocManage tmpDocMg = p_DocMan;

            try
            {
                tmpQry = "select param_name, param_value from gis_onc.sys_generalparameter " +
                         "where subsystem_name = 'Doc_Management' and subsystem_component = 'GT_SharePoint'";
                tmpRs = tmpDC.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                            LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText);
                if (!(tmpRs.BOF && tmpRs.EOF))
                {
                    tmpRs.MoveFirst();
                    for (int i = 0; i < tmpRs.RecordCount; ++i)
                    {
                        switch (tmpRs.Fields[0].Value.ToString())
                        {
                        case "JOBWO_REL_PATH":
                            tmpDocMg.SPRelPath = tmpRs.Fields[1].Value.ToString();
                            break;

                        case "ROOT_PATH":
                            tmpDocMg.SPRootPath = tmpRs.Fields[1].Value.ToString();
                            break;

                        case "SP_URL":
                            tmpDocMg.SPSiteURL = tmpRs.Fields[1].Value.ToString();
                            break;
                        }
                        tmpRs.MoveNext();
                    }

                    tmpDocMg.SrcFilePath       = p_SrcPathFile;
                    tmpDocMg.WrkOrd_Job        = p_WrNum;
                    tmpDocMg.SPFileType        = "Construction Redlines";
                    tmpDocMg.SPFileDescription = "Saved on " + DateTime.Now.ToString("MM/dd/yyyy a\\t HH:mm");

                    if (!tmpDocMg.AddSPFile(true))
                    {
                        tmpRetVal = false;
                        MessageBox.Show("Error:The Construction Redline file was not saved to SharePoint.", "SaveXmlToSP - Error", MessageBoxButtons.OK);
                    }

                    tmpRetVal = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "SaveXmlToSP - Error", MessageBoxButtons.OK);
            }
            return(tmpRetVal);
        }
示例#3
0
        /// <summary>
        /// Attaches a file to the WR in SharePoint and creates the Hyperlink on the Design Area feature for the WR.
        /// </summary>
        /// <param name="WR">WR to attach file</param>
        /// <param name="fileName">Full pathname of file to attach.</param>
        /// <param name="attachmentType">Classification of file to attach (e.g. "As-Built Redlines", "Construction Redlines", etc.).</param>
        /// <returns></returns>
        public bool AttachDocument(string WR, string fileName, string attachmentType)
        {
            try
            {
                bool retVal = false;

                IGTApplication app = GTClassFactory.Create <IGTApplication>();
                app.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Uploading archived prints to the document repository.");

                // Add the document to Sharepoint via the ONC Document Manager interface
                OncDocManage.OncDocManage oncDocManager = new OncDocManage.OncDocManage();

                // These three are set in a given interface because the OncDocManage class is designed
                // such that it can be used by systems other than G/Tech.
                oncDocManager.SPSiteURL  = SysGeneralParameter(SUBSYSTEMNAME, SUBSYSTEMCOMPONENT, "SP_URL");
                oncDocManager.SPRelPath  = SysGeneralParameter(SUBSYSTEMNAME, SUBSYSTEMCOMPONENT, "JOBWO_REL_PATH");
                oncDocManager.SPRootPath = SysGeneralParameter(SUBSYSTEMNAME, SUBSYSTEMCOMPONENT, "ROOT_PATH");

                oncDocManager.SrcFilePath       = fileName;
                oncDocManager.SPFileName        = fileName.Substring(fileName.LastIndexOf("\\") + 1);
                oncDocManager.SPFileType        = attachmentType;
                oncDocManager.SPFileDescription = string.Format("Archival Print - {0}", attachmentType);
                oncDocManager.WrkOrd_Job        = WR;

                // If the document is successfully uploaded, then create the hyperlink record on the Design Area
                if (oncDocManager.AddSPFile(true))
                {
                    retVal = AddDesignAreaHyperlink(oncDocManager.RetFileURL, attachmentType, oncDocManager.RetFileName, oncDocManager.SPFileDescription);
                }
                else
                {
                    string msg = string.Format("Error attempting to add a file to the document repository:  {0}", oncDocManager.RetErrMessage);
                    throw new Exception(msg);
                }

                return(retVal);
            }
            catch (Exception ex)
            {
                string exMsg = string.Format("Error occurred in {0} of {1}.{2}{3}", System.Reflection.MethodBase.GetCurrentMethod().Name, this.ToString(), Environment.NewLine, ex.Message);
                throw new Exception(exMsg);
            }
        }
示例#4
0
        private Boolean GetGeneralParams(ref OncDocManage.OncDocManage objDocMng)
        {
            Boolean   bRetVal = false;
            Recordset tmpRs;
            string    tmpQry = "select SUBSYSTEM_NAME,SUBSYSTEM_COMPONENT,PARAM_NAME,PARAM_VALUE " +
                               "from GIS_ONC.SYS_GENERALPARAMETER " +
                               "where SUBSYSTEM_NAME = 'Doc_Management'";

            try
            {
                tmpRs = m_igtApplication.DataContext.OpenRecordset(tmpQry, CursorTypeEnum.adOpenStatic,
                                                                   LockTypeEnum.adLockReadOnly,
                                                                   (int)CommandTypeEnum.adCmdText);
                if (!(tmpRs.EOF && tmpRs.EOF))
                {
                    tmpRs.MoveFirst();
                    while (!tmpRs.EOF)
                    {
                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "SP_URL")
                        {
                            objDocMng.SPSiteURL = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                        }
                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "JOBWO_REL_PATH")
                        {
                            objDocMng.SPRelPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                        }
                        if (tmpRs.Fields["PARAM_NAME"].Value.ToString() == "ROOT_PATH")
                        {
                            objDocMng.SPRootPath = tmpRs.Fields["PARAM_VALUE"].Value.ToString();
                        }
                        tmpRs.MoveNext();
                    }
                    bRetVal = true;
                }
            }
            catch (Exception)
            {
                bRetVal = false;
                throw;
            }
            return(bRetVal);
        }
示例#5
0
        private Boolean AddHyperlink(int p_DesignAreaFid, OncDocManage.OncDocManage p_DocMan)
        {
            Boolean      tmpRetVal = false;
            IGTKeyObject tmpKeyObj = null;
            string       SpDocType = "Construction Redlines";

            try
            {
                TransManager.Begin("Add Hyperlink to Design Area");

                tmpKeyObj = gtApp.DataContext.OpenFeature(8100, p_DesignAreaFid);
                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.AddNew("G3E_FID", p_DesignAreaFid);
                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["HYPERLINK_T"].Value   = p_DocMan.RetFileURL;
                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["DESCRIPTION_T"].Value = p_DocMan.SPFileDescription;
                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["FILENAME_T"].Value    = p_DocMan.RetFileName;

                if (SpDocType.Length > tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize)
                {
                    tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value =
                        SpDocType.Substring(0, tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].DefinedSize);
                }
                else
                {
                    tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["TYPE_C"].Value = SpDocType;
                }

                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Fields["G3E_FNO"].Value = 8100;
                tmpKeyObj.Components["JOB_HYPERLINK_N"].Recordset.Update();
                if (TransManager.TransactionInProgress)
                {
                    TransManager.Commit();
                }

                tmpRetVal = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "AddHyperlink - Error", MessageBoxButtons.OK);
                tmpRetVal = false;
            }
            return(tmpRetVal);
        }
示例#6
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.");
            }
        }
示例#7
0
文件: ReportDT.cs 项目: git786hub/DLL
        /// <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);
        }
示例#8
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);
                }
            }
        }
示例#9
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;
            }
        }
示例#10
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);
        }