Пример #1
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

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

                short fno = 0;
                int   fid = 0;

                m_EmbeddedDT.cmdSaveReport.Enabled = false;

                IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>();
                oGTDCKeys = m_Application.SelectedObjects.GetObjects();
                if (oGTDCKeys.Count > 0)
                {
                    // Check if selected feature is a Conductor.
                    if (oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_COND || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_COND ||
                        oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_SECCOND || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_SECCOND)
                    {
                        fid = oGTDCKeys[0].FID;
                        fno = oGTDCKeys[0].FNO;
                        m_EmbeddedDT.cmdSaveReport.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SAG_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        m_CustomCommandHelper.Complete();
                        return;
                    }
                }

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

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

                m_EmbeddedDT.Application = m_Application;
                m_EmbeddedDT.Text        = ConstantsDT.COMMAND_NAME_SAG_CLEARANCE;
                m_EmbeddedDT.CommandName = ConstantsDT.COMMAND_NAME_SAG_CLEARANCE;
                m_EmbeddedDT.SelectedFID = fid;
                m_EmbeddedDT.SelectedFNO = fno;

                m_EmbeddedDT.InitializeFormSize();

                m_EmbeddedDT.StartPosition = FormStartPosition.CenterScreen;
                m_EmbeddedDT.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }
Пример #2
0
        /// <summary>
        /// The entry point for the custom command.
        /// </summary>
        /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param>
        public void Activate(IGTCustomCommandHelper CustomCommandHelper)
        {
            try
            {
                m_CustomCommandHelper = CustomCommandHelper;

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

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

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

                FIDs.Clear();
                FIDs = null;

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

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

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

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

                    CustomCommandHelper.Complete();
                    return;
                }

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

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

                m_EmbeddedDT.InitializeFormSize();

                m_EmbeddedDT.StartPosition = FormStartPosition.CenterScreen;
                m_EmbeddedDT.Show(m_Application.ApplicationWindow);
            }
            catch (Exception ex)
            {
                MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                CustomCommandHelper.Complete();
            }
        }