예제 #1
0
        /// <summary>
        /// This method runs a query for all Work Point features in the active WR and attach the results to the display control
        /// </summary>
        private void WorkPointDisplayQuery()
        {
            Recordset  workPointRS = null;
            List <int> iListFids   = new List <int>();

            try
            {
                workPointRS = m_gtApplication.DataContext.OpenRecordset("Select * from WORKPOINT_N where WR_NBR=:1"
                                                                        , CursorTypeEnum.adOpenStatic,
                                                                        LockTypeEnum.adLockReadOnly, (int)CommandTypeEnum.adCmdText, m_gtApplication.DataContext.ActiveJob);

                if (workPointRS != null && workPointRS.RecordCount > 0)
                {
                    workPointRS.MoveFirst();
                    while (!workPointRS.EOF)
                    {
                        if (workPointRS.Fields["G3E_FID"] != null && workPointRS.Fields["G3E_FID"].Value != null &&
                            !String.IsNullOrEmpty(workPointRS.Fields["G3E_FID"].Value.ToString()))
                        {
                            iListFids.Add(Convert.ToInt32(workPointRS.Fields["G3E_FID"].Value));
                        }
                        workPointRS.MoveNext();
                    }
                }

                if (rsOldQueryRecord != null && rsOldQueryRecord.RecordCount > 0 && m_bDeleteAction == false)
                {
                    rsOldQueryRecord.MoveFirst();
                    while (!rsOldQueryRecord.EOF)
                    {
                        if (rsOldQueryRecord.Fields["G3E_FID"] != null &&
                            !iListFids.Contains(Convert.ToInt32(rsOldQueryRecord.Fields["G3E_FID"].Value)))
                        {
                            workPointRS.AddNew();
                            for (int i = 0; i < rsOldQueryRecord.Fields.Count; i++)
                            {
                                workPointRS.Fields[rsOldQueryRecord.Fields[i].Name].Value = rsOldQueryRecord.Fields[i].Value;
                            }
                            workPointRS.Update();
                        }
                        rsOldQueryRecord.MoveNext();
                    }
                }



                if (m_bDeleteAction == true)
                {
                    if (workPointRS != null && workPointRS.RecordCount > 0)
                    {
                        for (workPointRS.MoveFirst(); !workPointRS.EOF; workPointRS.MoveNext())
                        {
                            if (workPointRS.Fields["g3e_fid"].Value.Equals(m_gtRecordset.Fields["g3e_fid"].Value))
                            {
                                workPointRS.Delete();
                                break;
                            }
                        }
                    }
                }
                else if (m_bDeleteAction == false)
                {
                    if (CheckActiveRecord(workPointRS) && Convert.ToString(m_gtRecordset.Fields["WR_NBR"].Value) == m_gtApplication.DataContext.ActiveJob)
                    {
                        workPointRS.AddNew();
                        for (int i = 0; i < m_gtRecordset.Fields.Count; i++)
                        {
                            workPointRS.Fields[m_gtRecordset.Fields[i].Name].Value = m_gtRecordset.Fields[i].Value;
                        }
                        workPointRS.Update();
                    }
                }
                if (workPointRS != null && workPointRS.RecordCount > 0)
                {
                    workPointRS.MoveFirst();
                    m_gtDisplayService.AppendQuery(m_gtWORKPOINT_QUERY, m_gtWorkPtQueryDisplayName, workPointRS, null, false);
                    m_gtApplication.RefreshWindows();
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                workPointRS = null;
            }
        }
예제 #2
0
        /// <summary>
        /// Adds the results of the trace to the legend.
        /// </summary>
        /// <param name="displayRS">The trace recordset to display</param>
        /// <param name="displayPathName">Node on the legend that contains the trace entry</param>
        /// <param name="displayName">Name of the trace entry on the legend</param>
        /// <param name="symbology">Symbology overrides for the trace</param>
        /// <param name="overrideStyle">True if style should be overridden</param>
        /// <param name="primaryGraphicsOnly">True if only the primary graphic should be displayed</param>
        /// <param name="activeWindowOnly">True if the results should only be displayed in the active window</param>
        /// <param name="removeItem">True if the existing item should be removed from the legend</param>
        /// <returns>Boolean indicating status</returns>
        public bool DisplayResults(Recordset displayRS, string displayPathName, string displayName, IGTSymbology symbology,
                                   bool overrideStyle, bool primaryGraphicsOnly, bool activeWindowOnly, bool removeItem)
        {
            IGTMapWindow      gtMapWindow      = default(IGTMapWindow);
            IGTMapWindows     gtMapWindows     = default(IGTMapWindows);
            IGTDisplayService gtDisplayService = default(IGTDisplayService);

            bool returnValue = false;

            try
            {
                if (removeItem)
                {
                    // Remove existing item from the Display Control window
                    try
                    {
                        if (activeWindowOnly)
                        {
                            gtMapWindow = m_Application.ActiveMapWindow;
                            gtMapWindow.DisplayService.Remove(displayPathName, displayName);
                        }
                        else
                        {
                            gtMapWindows = m_Application.GetMapWindows(GTMapWindowTypeConstants.gtapmtGeographic);

                            foreach (IGTMapWindow mapWindow in gtMapWindows)
                            {
                                mapWindow.DisplayService.Remove(displayPathName, displayName);
                            }
                        }
                    }
                    catch
                    {
                        // Ignore error if item is not on the legend
                    }
                }

                if (displayRS.RecordCount > 0)
                {
                    if (activeWindowOnly)
                    {
                        gtMapWindow      = m_Application.ActiveMapWindow;
                        gtDisplayService = gtMapWindow.DisplayService;

                        if (overrideStyle)
                        {
                            gtDisplayService.AppendQuery(displayPathName, displayName, displayRS, symbology, primaryGraphicsOnly);
                        }
                        else
                        {
                            gtDisplayService.AppendQuery(displayPathName, displayName, displayRS);
                        }
                    }
                    else
                    {
                        gtMapWindows = m_Application.GetMapWindows(GTMapWindowTypeConstants.gtapmtAll);
                        foreach (IGTMapWindow mapWindow in gtMapWindows)
                        {
                            gtDisplayService = mapWindow.DisplayService;

                            if (overrideStyle)
                            {
                                gtDisplayService.AppendQuery(displayPathName, displayName, displayRS, symbology, primaryGraphicsOnly);
                            }
                            else
                            {
                                gtDisplayService.AppendQuery(displayPathName, displayName, displayRS);
                            }
                        }
                    }
                }

                m_Application.RefreshWindows();

                returnValue = true;
            }
            catch
            {
                returnValue = false;
            }
            finally
            {
                gtMapWindow      = null;
                gtMapWindows     = null;
                gtDisplayService = null;
            }

            return(returnValue);
        }