Beispiel #1
0
        /// <summary>
        /// Executes the operation
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public override IEnumerable <FdoRow> Execute(IEnumerable <FdoRow> rows)
        {
            //We fetch the class def here instead of the ctor as the class in question
            //may have to be created by a pre-copy operation
            _clsDef = _service.GetClassByName(this.ClassName);

            IInsert insert = null;

            using (FdoFeatureService service = _conn.CreateFeatureService())
            {
                insert = service.CreateCommand <IInsert>(CommandType.CommandType_Insert);
            }
            this.Info("Set feature class to: {0}", this.ClassName);
            insert.SetFeatureClassName(this.ClassName);
            PropertyValueCollection propVals = insert.PropertyValues;

            Prepare(propVals);
            foreach (FdoRow row in rows)
            {
                Bind(row);
                insert.Prepare();
                try
                {
                    using (IFeatureReader reader = insert.Execute())
                    {
                        reader.Close();
                    }
                }
                catch (OSGeo.FDO.Common.Exception ex)
                {
                    ex.Data["Class/Table"] = this.ClassName;
                    RaiseFailedFeatureProcessed(row, ex);
                    RePrepare(propVals);
                }
                yield return(row);
            }
            insert.Dispose();
            //yield break;
        }