private FeatureRow SaveFeature(IDbContext dbContext, FeatureContextRow context, string featureName) { var contextId = context.Id; List <FeatureRow> features; if (this.Features.TryGetValue(contextId, out features)) { foreach (var f in features) { if (f.Name.Equals(featureName, StringComparison.OrdinalIgnoreCase)) { return(f); } } } else { // Create feature collection for this context features = new List <FeatureRow>(); this.Features.Add(contextId, features); } // Insert into database var newFeatureId = FeatureAdapter.InsertFeature(dbContext, featureName, contextId); var feature = new FeatureRow(newFeatureId, featureName, contextId); //Insert the new feature into the cache features.Add(feature); return(feature); }
private FeatureData RecordSetToFeatureData(RecordSet recordSet, FieldSelection fieldSelection) { int fieldCount = fieldSelection.Fields.Count; int[] fieldIndex = new int[fieldCount]; var select = recordSet.Fields.FieldArray.Select((field, index) => new { field, index }); for (int i = 0; i < fieldCount; ++i) { var result = select.Where(x => String.Compare(x.field.Name, fieldSelection.Fields[i].Name, true) == 0).FirstOrDefault(); fieldIndex[i] = result == null ? -1 : result.index; } FeatureData featureData = fieldSelection.CreateFeatureData(); featureData.LayerName = Name; featureData.Rows = new FeatureRow[recordSet.Records.Length]; for (int r = 0; r < recordSet.Records.Length; ++r) { FeatureRow featureRow = new FeatureRow(); featureRow.Values = new object[fieldCount]; for (int c = 0; c < fieldSelection.Fields.Count; ++c) { if (fieldIndex[c] >= 0) { object value = recordSet.Records[r].Values[fieldIndex[c]]; if (value != null) { if (fieldSelection.Fields[c].Type == CommonFieldType.Geometry) { featureRow.Values[c] = ((AppGeo.Clients.Ags.Proxy.Geometry)value).ToCommon(); } else { featureRow.Values[c] = value; } } } } featureData.Rows[r] = featureRow; } return(featureData); }
public void RemoveFeatureRow(FeatureRow row) { Rows.Remove(row); }
public void AddFeatureRow(FeatureRow row) { Rows.Add(row); }
public Corporation_LinkRow AddCorporation_LinkRow(FeatureRow parentFeatureRowByFeature_Corp_Link, long CorpID) { Corporation_LinkRow rowCorporation_LinkRow = ((Corporation_LinkRow) (NewRow())); rowCorporation_LinkRow.ItemArray = new object[] { parentFeatureRowByFeature_Corp_Link[0], CorpID }; Rows.Add(rowCorporation_LinkRow); return rowCorporation_LinkRow; }
public Sheet_LinkRow AddSheet_LinkRow(FeatureRow parentFeatureRowByFeature_Sheet_Link, long SheetID, long X, long Y) { Sheet_LinkRow rowSheet_LinkRow = ((Sheet_LinkRow) (NewRow())); rowSheet_LinkRow.ItemArray = new object[] { parentFeatureRowByFeature_Sheet_Link[0], SheetID, X, Y }; Rows.Add(rowSheet_LinkRow); return rowSheet_LinkRow; }
public Person_LinkRow AddPerson_LinkRow(FeatureRow parentFeatureRowByFeature_Person_Link, long PersonID, string Type) { Person_LinkRow rowPerson_LinkRow = ((Person_LinkRow) (NewRow())); rowPerson_LinkRow.ItemArray = new object[] { parentFeatureRowByFeature_Person_Link[0], PersonID, Type }; Rows.Add(rowPerson_LinkRow); return rowPerson_LinkRow; }
public FeatureRowChangeEvent(FeatureRow row, DataRowAction action) { eventRow = row; eventAction = action; }
private void LoadFeatureData(Features features, FeatureData featureData, FieldSelection fieldSelection) { if (features.Count == 0) { return; } int[] fieldIndex = new int[fieldSelection.Fields.Count]; var select = features[0].Fields.Select((field, index) => new { field, index }); for (int i = 0; i < fieldSelection.Fields.Count; ++i) { var result = select.Where(x => String.Compare(x.field.Name, fieldSelection.Fields[i].Name, true) == 0).FirstOrDefault(); fieldIndex[i] = result == null ? -1 : result.index; } int offset = 0; if (featureData.Rows == null) { featureData.Rows = new FeatureRow[features.Count]; } else { offset = featureData.Rows.Length; Array.Resize(ref featureData.Rows, offset + features.Count); } for (int r = 0; r < features.Count; ++r) { FeatureRow featureRow = new FeatureRow(); featureRow.Values = new object[fieldSelection.Fields.Count]; for (int c = 0; c < fieldSelection.Fields.Count; ++c) { if (fieldIndex[c] >= 0) { string value = features[r].Fields[fieldIndex[c]].Value; if (!String.IsNullOrEmpty(value) || features[r].Shape != null) { switch (fieldSelection.Fields[c].Type) { case CommonFieldType.Geometry: if (features[r].Shape.OgcGeometryType == OgcGeometryType.MultiPoint && fieldSelection.Fields[c].GeometryType == OgcGeometryType.Point) { featureRow.Values[c] = ((IMultiPoint)features[r].Shape)[0]; } else { featureRow.Values[c] = features[r].Shape; } break; case CommonFieldType.Date: featureRow.Values[c] = new DateTime((Convert.ToInt64(value) * 10000) + 621355968000000000); break; default: featureRow.Values[c] = Convert.ChangeType(value, fieldSelection.Fields[c].DataType); break; } } } } featureData.Rows[r + offset] = featureRow; } }