Пример #1
0
        internal AutoDataReader doQuery(string sql)
        {
            log.enterFunc("doQuery");

            IDbConnection con;
            IDbCommand    cmd;

            createCommand(sql, out con, out cmd);
            AutoDataReader retVal = null;

            using (cmd)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("Executing reader ...");
                    log.Debug(cmd.CommandText);
                }
                IDataReader dr = cmd.ExecuteReader();
                retVal = new AutoDataReader(con, dr);
                if (log.IsDebugEnabled)
                {
                    log.Debug("Reader executed.");
                }
            }

            log.leaveFunc();

            return(retVal);
        }
Пример #2
0
        public DataTable getDataFields(bool reloadFromDatabase)
        {
            log.enterFunc("getDataFields");

            // reloadFromDatabase - true to refresh the cache from the database.
            if (m_fields == null || reloadFromDatabase)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("1");
                }
                // Query the view for its fields and store them in the array.
                // Paolo: gid is not always in the PostGIS layer: let's use limit 1 instead than gid=-1
                string sql = DbHelper.createSelectSql(schemaAndView, "*", null, null, "limit 1");
                if (log.IsDebugEnabled)
                {
                    log.Debug(sql);
                }
                using (AutoDataReader dr = connection.doQuery(sql))
                {
                    log.Debug(dr == null ? "null" : "not null");
                    log.Debug("2");
                    m_fields = dr.GetSchemaTable();
                }
            }

            log.leaveFunc();

            return(m_fields);
        }
Пример #3
0
        public int FindField(string Name)
        {
            log.enterFunc("FindField");

            if (log.IsDebugEnabled)
            {
                log.Debug(Name);
            }

            int i = Fields.FindField(Name);

            log.leaveFunc();

            return(i);
        }
Пример #4
0
        public int Next()
        {
            //log.enterFunc("Next");

            int retVal = -1;

            try
            {
                if (enumerator.MoveNext())
                {
                    retVal = (int)enumerator.Current;
                }
                else
                {
                    log.Debug("End of enum.");
                    Helper.signalEndOfEnum();
                }
            }
            finally
            {
                //if (log.IsDebugEnabled) log.Debug(retVal);
                //log.leaveFunc();
            }
            return(retVal);
        }
Пример #5
0
        internal PostGisFields(Layer postGisLayer)
        {
            log.enterFunc("ctor");

            try
            {
                bool hasGIDField = false;
                if (log.IsDebugEnabled)
                {
                    log.Debug("1");
                }
                DataTable dataFields = postGisLayer.getDataFields(false);
                if (log.IsDebugEnabled)
                {
                    log.Debug("2");
                }
                m_flds = new PostGisField[dataFields.Rows.Count];
                m_ids  = new Hashtable(fields.Length);
                PostGisField pgisFld;
                int          i = 0;
                foreach (DataRow r in dataFields.Rows)
                {
                    pgisFld   = new PostGisField(postGisLayer, r, i);
                    m_flds[i] = pgisFld;
                    m_ids.Add(pgisFld.Name, i);
                    if (pgisFld.Name.ToLower() == "gid")
                    {
                        hasGIDField = true;
                    }
                    ++i;
                }
                //gid (int4 or int8) is mandatory as GDB unique OID
                if (hasGIDField == false)
                {
                    System.Windows.Forms.MessageBox.Show("This PostGis layer will be added in ArcMap but will not correctly work for some funcitonality (selections, rendering, ...): it misses a mandatory gid (int) field as unique OID for each feature. This gid field is necessary for the Esri Geodatabase model.");
                }
            }
            catch (Exception e)
            {
                log.Error("", e);
                throw;
            }
            finally
            {
                log.leaveFunc();
            }
        }