FDO-friendly DataRow
Наследование: System.Data.DataRow
Пример #1
0
 /// <summary>
 /// Removes the row (feature) from the table
 /// </summary>
 /// <param name="row"></param>
 public void RemoveRow(FdoFeature row)
 {
     base.Rows.Remove(row);
     if (row.BoundingBox != null)
     {
         _tree.Delete(row.BoundingBox, row);
     }
 }
Пример #2
0
 /// <summary>
 /// Adds a row (feature) to this table
 /// </summary>
 /// <param name="feature"></param>
 public void AddRow(FdoFeature feature)
 {
     base.Rows.Add(feature);
     if (feature.BoundingBox != null)
     {
         _tree.Add(feature.BoundingBox, feature);
     }
 }
 public FdoUpdateScaffoldPresenter(IFdoUpdateView view, FdoFeature feat, FdoConnection conn, string filter)
 {
     _view = view;
     _conn = conn;
     _className = feat.Table.TableName;
     _view.Title = ICSharpCode.Core.ResourceService.GetString("TITLE_UPDATE_FEATURE");
     _view.UpdateFilter = filter;
     _filter = filter;
     _feature = feat;
 }
        private string GenerateFilter(FdoFeature feat)
        {
            FdoFeatureTable table = feat.Table;
            if (table.PrimaryKey.Length > 0)
            {
                List<string> filters = new List<string>();
                foreach (DataColumn col in table.PrimaryKey)
                {
                    DataType dt = ExpressUtility.GetFdoDataTypeFromClrType(col.DataType);
                    string f = string.Empty;
                    if (dt == DataType.DataType_DateTime || dt == DataType.DataType_String)
                        f = col.ColumnName + " = '" + feat[col] + "'";
                    else
                        f = col.ColumnName + " = " + feat[col];

                    filters.Add(f);
                }
                return "(" + string.Join(" AND ", filters.ToArray()) + ")";
            }
            return null;
        }
        private void DeleteFeatures(FdoFeatureTable table, FdoFeature[] features)
        {
            string filter = GenerateFilter(features);
            if (string.IsNullOrEmpty(filter))
            {
                _view.ShowError("Unable to generate a delete filter. Possibly this result set has no unique identifiers or this result set was produced from a SQL query. If this result set is produced from a standard query, make sure that *ALL* identity properties are selected");
                return;
            }

            int expectedCount = features.Length;
            using (FdoFeatureService service = _connection.CreateFeatureService())
            {
                //Deleting is based on a very simple premise, the filter should produce the
                //same number of affected results when selecting and deleting.
                //
                //In our case, the filter should affect exactly the expected number of results when selecting and deleting.
                long count = service.GetFeatureCount(table.TableName, filter, true);
                if (expectedCount == count)
                {
                    int deleted = service.DeleteFeatures(table.TableName, filter, true);
                    if (expectedCount == deleted)
                    {
                        foreach (FdoFeature feat in features)
                        {
                            table.Rows.Remove(feat);
                        }
                        _view.ShowMessage("Delete Feature", "Feature Deleted");
                    }
                }
                else if (count > expectedCount)
                {
                    _view.ShowError("Delete operation would delete more than the expected number of features (" + expectedCount + ")");
                }
                else if (count == 0)
                {
                    _view.ShowError("Delete operation would not delete any features");
                }
            }
        }
 private void DeleteFeatures(FdoFeature feat)
 {
     DeleteFeatures(feat.Table, new FdoFeature[] { feat });
 }
        internal string GenerateFilter(FdoFeature[] features)
        {
            if (features == null || features.Length == 0)
                return null;

            FdoFeatureTable table = features[0].Table;

            //All features in array must originate from the same table
            for (int i = 1; i < features.Length; i++)
            {
                if (features[i].Table != table)
                    return null;
            }

            List<string> filter = new List<string>();

            foreach (FdoFeature feat in features)
            {
                filter.Add(GenerateFilter(feat));
            }

            return string.Join(" OR ", filter.ToArray());
        }
 internal void DoUpdate(FdoFeature feat)
 {
     FeatureQueryOptions query = null;
     switch (_view.SelectedQueryMode)
     {
         case QueryMode.Aggregate:
             {
                 query = (_view.QueryView as IFdoAggregateQueryView).QueryObject;
             }
             break;
         case QueryMode.Standard:
             {
                 query = (_view.QueryView as IFdoStandardQueryView).QueryObject;
             }
             break;
     }
     if (query != null)
     {
         string filter = GenerateFilter(feat);
         if (string.IsNullOrEmpty(filter))
         {
             _view.ShowError("Unable to generate an update filter. Possibly this result set has no unique identifiers or this result set was produced from a SQL query");
             return;
         }
         using (FdoFeatureService service = _connection.CreateFeatureService())
         {
             //Update is based on a very simple premise, the filter should produce the
             //same number of affected results when selecting and updating.
             //
             //In our case, the filter should affect exactly one result when selecting and updating.
             long count = service.GetFeatureCount(feat.Table.TableName, filter, true);
             if (1 == count)
             {
                 Workbench wb = Workbench.Instance;
                 FdoUpdateScaffold ctl = new FdoUpdateScaffold(feat, _connection, filter);
                 wb.ShowContent(ctl, ViewRegion.Dialog);
             }
         }
     }
     else
     {
         _view.ShowError("Could not determine the feature class name from the result set");
     }
 }
 internal void DoDelete(FdoFeature feat)
 {
     this.DeleteFeatures(feat);
 }
        internal void DoDelete(FdoFeature[] features)
        {
            if (features == null || features.Length == 0)
                return;

            this.DeleteFeatures(features[0].Table, features);
        }
Пример #11
0
 /// <summary>
 /// Removes the row (feature) from the table
 /// </summary>
 /// <param name="row"></param>
 public void RemoveRow(FdoFeature row)
 {
     base.Rows.Remove(row);
     if(row.BoundingBox != null)
         _tree.Delete(row.BoundingBox, row);
 }
Пример #12
0
 /// <summary>
 /// Adds a row (feature) to this table
 /// </summary>
 /// <param name="feature"></param>
 public void AddRow(FdoFeature feature)
 {
     base.Rows.Add(feature);
     if(feature.BoundingBox != null)
         _tree.Add(feature.BoundingBox, feature);
 }
Пример #13
0
 public FdoUpdateScaffold(FdoFeature feature, FdoConnection conn, string filter)
     : this()
 {
     _presenter = new FdoUpdateScaffoldPresenter(this, feature, conn, filter);
 }