Exemplo n.º 1
0
 /// <summary>
 /// Returns statistics for the given index, including a document count and
 /// storage usage.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='indexName'>
 /// The name of the index for which to retrieve statistics.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IndexGetStatisticsResult> GetStatisticsAsync(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetStatisticsWithHttpMessagesAsync(indexName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 2
0
        private void IndexSetCtrl_Load(object sender, EventArgs e)
        {
            int num;

            if ((this.ifeatureClass_0 as IDataset).Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace)
            {
                this.groupBox2.Visible = true;
            }
            else
            {
                this.groupBox2.Visible = false;
            }
            IIndexes indexes = this.ifeatureClass_0.Indexes;

            for (num = 0; num < indexes.IndexCount; num++)
            {
                IIndex index = indexes.get_Index(num);
                if (index.Fields.get_Field(0).Type != esriFieldType.esriFieldTypeGeometry)
                {
                    this.listBoxIndexName.Items.Add(new IndexWrap(index));
                }
            }
            int          num2        = this.ifeatureClass_0.FindField(this.ifeatureClass_0.ShapeFieldName);
            IGeometryDef geometryDef = this.ifeatureClass_0.Fields.get_Field(num2).GeometryDef;

            double[] numArray2 = new double[3];
            for (num = 0; num < geometryDef.GridCount; num++)
            {
                numArray2[num] = geometryDef.get_GridSize(num);
            }
            this.lblGridSize1.Text       = "Grid 1:" + numArray2[0].ToString("0.##");
            this.lblGridSize2.Text       = "Grid 2:" + numArray2[1].ToString("0.##");
            this.lblGridSize3.Text       = "Grid 3:" + numArray2[2].ToString("0.##");
            this.btnAddGridIndex.Enabled = geometryDef.GridCount == 0;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Lists all indexes available for an Azure Search service.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798923.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='select'>
 /// Selects which properties of the index definitions to retrieve. Specified as
 /// a comma-separated list of JSON property names, or '*' for all properties.
 /// The default is all properties.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IndexListResult> ListAsync(this IIndexes operations, string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListWithHttpMessagesAsync(select, searchRequestOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new Azure Search index.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='index'>
 /// The definition of the index to create.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Index> CreateAsync(this IIndexes operations, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(index, searchRequestOptions, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 5
0
        public bool DeleteSpatialIndex(IFeatureClass featureClass)
        {
            bool        result      = true;
            ISchemaLock pSchemaLock = featureClass as ISchemaLock;

            try
            {
                pSchemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                IIndexes   indexes        = featureClass.Indexes;
                String     shapeFieldName = featureClass.ShapeFieldName;
                IEnumIndex enumIndex      = indexes.FindIndexesByFieldName(shapeFieldName);
                enumIndex.Reset();
                IIndex index = enumIndex.Next();
                if (index != null)
                {
                    featureClass.DeleteIndex(index);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
                result       = false;
            }
            finally
            {
                pSchemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
            return(result);
        }
Exemplo n.º 6
0
 /// <summary>
 ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IIndexes" />
 /// </summary>
 /// <param name="source">An <see cref="IIndexes" /> to create an <see cref="IEnumerable{T}" /> from.</param>
 /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns>
 public static IEnumerable <IIndex> AsEnumerable(this IIndexes source)
 {
     if (source != null)
     {
         for (int i = 0; i < source.IndexCount; i++)
         {
             yield return(source.Index[i]);
         }
     }
 }
        public static void dropSpatialIndex(IFeatureClass fc)
        {
            //Delete the spatial index
            IIndexes   indexes        = fc.Indexes;
            String     shapeFieldName = fc.ShapeFieldName;
            IEnumIndex enumIndex      = indexes.FindIndexesByFieldName(shapeFieldName);

            enumIndex.Reset();

            // Get the index based on the shape field (should only be one) and delete it.
            IIndex index = enumIndex.Next();

            if (index != null)
            {
                fc.DeleteIndex(index);
            }
        }
        private void ExpandIndexes(IIndexes indexes, TreeNode node)
        {
            if (HasBlankNode(node))
            {
                foreach (IIndex index in indexes)
                {
                    TreeNode indexNode = new TreeNode(index.Name);
                    indexNode.Tag = new NodeData(NodeType.INDEX, index);
                    indexNode.SelectedImageIndex = indexNode.ImageIndex = 15;
                    node.Nodes.Add(indexNode);

                    if (index.Columns.Count > 0)
                    {
                        TreeNode n = new TreeNode("Columns");
                        n.Tag = new NodeData(NodeType.COLUMNS, index.Columns);
                        n.SelectedImageIndex = n.ImageIndex = 9;
                        indexNode.Nodes.Add(n);
                        n.Nodes.Add(this.BlankNode);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public DataTable getAttributeTable(string shapeFileName, string shapeFilePath)
        {
            DataTable dt = new DataTable();

            IFeatureClass featureClass = GetFeatureClassFromShapefileOnDisk(shapeFilePath, shapeFileName);
            IFields       fields       = featureClass.Fields;
            IField        field        = null;


            for (int i = 0; i < fields.FieldCount; i++)
            {
                field = fields.get_Field(i);
                dt.Columns.Add(field.Name);
            }

            DataRow        r;
            IIndexes       indexes       = featureClass.Indexes;
            IFeatureCursor featureCursor = featureClass.Search(null, false);
            IRow           featureRow;

            featureRow = featureCursor.NextFeature();
            if (featureRow != null)
            {
                while (featureRow != null)
                {
                    r = dt.NewRow();
                    for (int i = 0; i < fields.FieldCount; i++)
                    {
                        r[i] = featureRow.get_Value(i);
                    }
                    dt.Rows.Add(r);
                    featureRow = featureCursor.NextFeature();
                }
            }


            return(dt);
        }
Exemplo n.º 10
0
        public DataTable getCoordinates(string shapeFileName, string shapeFilePath, string type)
        {
            DataTable dt = new DataTable();

            IFeatureClass featureClass = GetFeatureClassFromShapefileOnDisk(shapeFilePath, shapeFileName);
            IFields       fields       = featureClass.Fields;
            //IField field = null;

            DataRow        r;
            IIndexes       indexes       = featureClass.Indexes;
            IFeatureCursor featureCursor = featureClass.Search(null, false);
            IFeature       featureRow;
            IPoint         pfeat;
            IPolyline      pline;

            //IPolygon ppgon;


            featureRow = featureCursor.NextFeature();



            if (type == "point")
            {
                dt.Columns.Add("X");
                dt.Columns.Add("Y");

                if (featureRow != null)
                {
                    while (featureRow != null)
                    {
                        r     = dt.NewRow();
                        pfeat = (IPoint)featureRow.Shape;
                        r[0]  = pfeat.X;
                        r[1]  = pfeat.Y;
                        dt.Rows.Add(r);
                        featureRow = featureCursor.NextFeature();
                    }
                }
            }
            if (type == "polyline")
            {
                dt.Columns.Add("X1");
                dt.Columns.Add("Y1");
                dt.Columns.Add("X2");
                dt.Columns.Add("Y2");

                if (featureRow != null)
                {
                    while (featureRow != null)
                    {
                        r     = dt.NewRow();
                        pline = (IPolyline)featureRow.Shape;
                        r[0]  = pline.FromPoint.X;
                        r[1]  = pline.FromPoint.Y;
                        r[2]  = pline.ToPoint.X;
                        r[3]  = pline.ToPoint.Y;
                        dt.Rows.Add(r);
                        featureRow = featureCursor.NextFeature();
                    }
                }
            }
            if (type == "polygon")
            {
            }
            return(dt);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Lists all indexes available for an Azure Search service.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798923.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='select'>
 /// Selects which properties of the index definitions to retrieve. Specified as
 /// a comma-separated list of JSON property names, or '*' for all properties.
 /// The default is all properties.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static IndexListResult List(this IIndexes operations, string select = default(string), SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
 {
     return(operations.ListAsync(select, searchRequestOptions).GetAwaiter().GetResult());
 }
Exemplo n.º 12
0
 public MongoRepository(IMongoStorage mongoStorage, IIndexes <TEntity> indexes)
 {
     this.Collection = mongoStorage.GetCollection <TEntity>();
     indexes.CreateIndexes(this.Collection);
 }
Exemplo n.º 13
0
 /// <summary>
 /// Returns statistics for the given index, including a document count and
 /// storage usage.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798942.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='indexName'>
 /// The name of the index for which to retrieve statistics.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static IndexGetStatisticsResult GetStatistics(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
 {
     return(operations.GetStatisticsAsync(indexName, searchRequestOptions).GetAwaiter().GetResult());
 }
Exemplo n.º 14
0
 /// <summary>
 /// Deletes an Azure Search index and all the documents it contains.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798926.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='indexName'>
 /// The name of the index to delete.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteAsync(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.DeleteWithHttpMessagesAsync(indexName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Exemplo n.º 15
0
 /// <summary>
 /// Deletes an Azure Search index and all the documents it contains.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798926.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='indexName'>
 /// The name of the index to delete.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static void Delete(this IIndexes operations, string indexName, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
 {
     operations.DeleteAsync(indexName, searchRequestOptions).GetAwaiter().GetResult();
 }
Exemplo n.º 16
0
		private void ExpandIndexes(IIndexes indexes, TreeNode node)
		{
			if(HasBlankNode(node))
			{
				foreach(IIndex index in indexes)
				{
					TreeNode indexNode = new TreeNode(index.Name);
					indexNode.Tag = new NodeData(NodeType.INDEX, index);
					indexNode.SelectedImageIndex = indexNode.ImageIndex = 15;
					node.Nodes.Add(indexNode);

					if(index.Columns.Count > 0)
					{
						TreeNode n = new TreeNode("Columns");
						n.Tag = new NodeData(NodeType.COLUMNS, index.Columns);
						n.SelectedImageIndex = n.ImageIndex = 9;
						indexNode.Nodes.Add(n);
						n.Nodes.Add(this.BlankNode);
					}
				}
			}
		}
Exemplo n.º 17
0
 /// <summary>
 /// Creates a new Azure Search index.
 /// <see href="https://msdn.microsoft.com/library/azure/dn798941.aspx" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='index'>
 /// The definition of the index to create.
 /// </param>
 /// <param name='searchRequestOptions'>
 /// Additional parameters for the operation
 /// </param>
 public static Index Create(this IIndexes operations, Index index, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
 {
     return(operations.CreateAsync(index, searchRequestOptions).GetAwaiter().GetResult());
 }
Exemplo n.º 18
0
 public EntityStorage(IMongoStorage mongoStorage, IIndexes <TEntity> indexes)
 {
     Collection = mongoStorage.GetCollection <TEntity>();
     indexes.CreateIndexes(Collection);
 }
Exemplo n.º 19
0
        /// <summary>
        /// 重建要素类空间索引
        /// </summary>
        /// <param name="pFeatureClass"></param>
        /// <param name="gridOneSize"></param>
        /// <param name="gridTwoSize"></param>
        /// <param name="gridThreeSize"></param>
        /// <returns></returns>
        public bool RebuildSpatialIndex(IFeatureClass pFeatureClass, Double gridOneSize = 0, Double gridTwoSize = 0, Double gridThreeSize = 0)
        {
            ISchemaLock pSchemaLock = pFeatureClass as ISchemaLock;

            try
            {
                pSchemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                // Get an enumerator for indexes based on the shape field.
                IIndexes   indexes        = pFeatureClass.Indexes;
                String     shapeFieldName = pFeatureClass.ShapeFieldName;
                IEnumIndex enumIndex      = indexes.FindIndexesByFieldName(shapeFieldName);
                enumIndex.Reset();

                // Get the index based on the shape field (should only be one) and delete it.
                IIndex index = enumIndex.Next();
                if (index != null)
                {
                    pFeatureClass.DeleteIndex(index);
                }

                // Clone the shape field from the feature class.
                int     shapeFieldIndex  = pFeatureClass.FindField(shapeFieldName);
                IFields fields           = pFeatureClass.Fields;
                IField  sourceField      = fields.get_Field(shapeFieldIndex);
                IClone  sourceFieldClone = (IClone)sourceField;
                IClone  targetFieldClone = sourceFieldClone.Clone();
                IField  targetField      = (IField)targetFieldClone;

                // Open the geometry definition from the cloned field and modify it.
                IGeometryDef     geometryDef     = targetField.GeometryDef;
                IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
                geometryDefEdit.GridCount_2 = 3;
                geometryDefEdit.set_GridSize(0, gridOneSize);
                geometryDefEdit.set_GridSize(1, gridTwoSize);
                geometryDefEdit.set_GridSize(2, gridThreeSize);

                // Create a spatial index and set the required attributes.
                IIndex     newIndex     = new Index();
                IIndexEdit newIndexEdit = (IIndexEdit)newIndex;
                newIndexEdit.Name_2        = String.Concat(shapeFieldName, "_Index");
                newIndexEdit.IsAscending_2 = true;
                newIndexEdit.IsUnique_2    = false;

                // Create a fields collection and assign it to the new index.
                IFields     newIndexFields     = new Fields();
                IFieldsEdit newIndexFieldsEdit = (IFieldsEdit)newIndexFields;
                newIndexFieldsEdit.AddField(targetField);
                newIndexEdit.Fields_2 = newIndexFields;

                // Add the spatial index back into the feature class.
                pFeatureClass.AddIndex(newIndex);
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                pSchemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
        }