IList<IDataListItem> ConvertToIDataListItem(IRecordSet recordSet) { IList<IDataListItem> result = new List<IDataListItem>(); var dataListEntry = recordSet; foreach(var column in dataListEntry.Columns) { var fields = column.Value.Where(c => c.IODirection == enDev2ColumnArgumentDirection.Both || c.IODirection == enDev2ColumnArgumentDirection.Input).ToList(); foreach (var col in fields) { IDataListItem singleRes = new DataListItem(); singleRes.IsRecordset = true; singleRes.Recordset = recordSet.Name; singleRes.Field = col.Name; singleRes.RecordsetIndex = column.Key.ToString(); singleRes.Value = col.Value; singleRes.DisplayValue = string.Concat(recordSet.Name, "(", column.Key, ").", col.Name); singleRes.Description = col.Description; result.Add(singleRes); } } return result; }
private ValueHolder LoadDirectories(AdapterMySql DbAdapter, long FolderId) { Message request = new Message("Command", System.Data.CommandType.StoredProcedure.ToString()); request.AddData(new ValueHolder("Directories", string.Format("uspGetBackupJobDirectories({0})", FolderId))); request.AddSender("LoadDirectories", typeof(Job).ToString()); DbAdapter.Send(request); IRecordSet reply = (IRecordSet)DbAdapter.Receive(); foreach (ValueHolder directory in reply.Data.Annotations) { if (directory != null) { long directoryId = (long)directory.GetAnnotation("Id").Value; ValueHolder files = LoadFiles(DbAdapter, directoryId); if (files != null) { directory.AddAnnotation(files); } } } return(reply.Data); }
//Записывает себя в ReportParams, reportId - id родительской записи public void ToRecordset(IRecordSet rec, int reportId, bool addnew = false) { if (addnew) { rec.AddNew(); } rec.Put("ReportId", reportId); rec.Put("ParamId", ParamId); rec.Put("Project", Project); rec.Put("Code", Code); rec.Put("DataType", DataType.ToRussian()); rec.Put("SuperProcessType", SuperProcess.ToRussian()); rec.Put("CalcParamType", CalcParamType.ToRussian()); rec.Put("IsSingle", Queries.ContainsKey(IntervalType.Single)); rec.Put("IsBase", Queries.ContainsKey(IntervalType.Base)); rec.Put("IsHour", Queries.ContainsKey(IntervalType.Hour)); rec.Put("IsDay", Queries.ContainsKey(IntervalType.Day)); rec.Put("IsCombined", Queries.ContainsKey(IntervalType.Combined)); rec.Put("IsAbsolute", Queries.ContainsKey(IntervalType.Absolute)); rec.Put("IsAbsoluteDay", Queries.ContainsKey(IntervalType.AbsoluteDay)); rec.Put("IsAbsoluteCombined", Queries.ContainsKey(IntervalType.AbsoluteCombined)); rec.Put("IsAbsoluteListBase", Queries.ContainsKey(IntervalType.AbsoluteListBase)); rec.Put("IsAbsoluteListHour", Queries.ContainsKey(IntervalType.AbsoluteListHour)); rec.Put("IsAbsoluteListDay", Queries.ContainsKey(IntervalType.AbsoluteListDay)); rec.Put("IsMoments", Queries.ContainsKey(IntervalType.Moments)); if (addnew) { rec.Update(); } }
private ValueHolder LoadFiles(AdapterMySql DbAdapter, long FolderId) { Message request = new Message("Command", System.Data.CommandType.StoredProcedure.ToString()); request.AddData(new ValueHolder("Files", string.Format("uspGetBackupJobFiles({0})", FolderId))); request.AddSender("LoadFiles", typeof(Job).ToString()); DbAdapter.Send(request); IRecordSet reply = (IRecordSet)DbAdapter.Receive(); return(reply.Data); }
public Job(ValueHolder Definition, IExchangeRequest Logger) { _logger = Logger; _task = new Task(Definition); IRecordSet job = Load(Definition); _task.Parameters.AddAnnotation("Job", job); ((ITask)_task).PreTaskHandler += new TaskEventHandler(StatusHandler); ((ITask)_task).TaskHandler += new TaskEventHandler(ExecuteHandler); ((ITask)_task).PostTaskHandler += new TaskEventHandler(StatusHandler); }
/// <summary> /// Clip features in the recordset to the tile envelope /// </summary> /// <param name="featureCursor"></param> /// <param name="recordset"></param> /// <param name="tileEnvelope"></param> private void ClipFeaturesToTile(ref IFeatureCursor featureCursor, ref IRecordSet recordset, IEnvelope tileEnvelope) { //IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor; featureCursor = recordset.get_Cursor(false) as IFeatureCursor; IFeature feature = featureCursor.NextFeature(); ITopologicalOperator topologicalOperator = null; while (feature != null) { topologicalOperator = feature.Shape as ITopologicalOperator; // modifying shape so don't use ShapeCopy // TODO: verify clip geometry is retained in recordset ******************************** topologicalOperator.Clip(tileEnvelope); feature = featureCursor.NextFeature(); } }
private List <int> GetIdsOfContainedFeatureCentroids(IRecordSet recordset, IPolygon tilePolygon) { List <int> ids = new List <int>(); IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor; IFeature feature = cursor.NextFeature(); if (feature == null) { return(ids); } if (feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryMultipoint && feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPolygon) { throw new ArgumentException("Only multipoint and polygon geometry types are supported by this method."); } this.tracePolygon(tilePolygon); IRelationalOperator2 relationalOperator = tilePolygon as IRelationalOperator2; try { // Envelope must contain centriod IPoint centroid = null; while (feature != null) { centroid = (feature.ShapeCopy as IArea).Centroid; if (relationalOperator.Contains(centroid)) { this.tracePolygonContainsPoint(tilePolygon, centroid, feature.OID); ids.Add(feature.OID); } feature = cursor.NextFeature(); } if (ids.Count > 0) { System.Diagnostics.Debug.WriteLine("OIDs with centroids contained: " + ids.ToDelimitedString <int>(",")); } return(ids); } finally { this.ReleaseComObject(cursor); cursor = null; } }
public string GetAsGeoJSON(IRecordSet recordset) { GeoJSONFeatureCollection jsonFeatures = new GeoJSONFeatureCollection(); ICursor cur = recordset.get_Cursor(false); IFeature f = (IFeature)cur.NextRow(); if (f != null) { while (f != null) { jsonFeatures.Features.Add(GeoJSONFeature.CreateFromIFeature(f)); f = (IFeature)cur.NextRow(); } } return "{}"; }
/// <summary> /// Creates the geojson export. /// </summary> /// <param name="results">The results.</param> /// <param name="exportProperties">The export properties.</param> public void CreateExport(IRecordSet results, string geometryFieldName) { if (results != null) { ICursor cursor; cursor = results.get_Cursor(false); IRow row = cursor.NextRow(); int rowCount = 0; //create an empty list of geojson features var geoJsonFeatures = new List<GeoJSON.Net.Feature.Feature>(); //get the index of the geometry field int fieldIndex = row.Fields.FindField(geometryFieldName); if (fieldIndex == -1) throw new Exception("Could not locate geometry field:shape"); if (row != null) { while (row != null) { //use the factory to convert the esri geometry to the geojson geometry IGeometryObject geoJsonGeom = null; if (row.get_Value(fieldIndex) != null) { GeoJsonGeometryFactory geomFactory = new GeoJsonGeometryFactory(); geoJsonGeom = geomFactory.GetGeometry(row.get_Value(fieldIndex) as IGeometry); } //use the factory to convert esri row to geojson attributes var atts = new GeoJsonAttributeFactory().GetAttributes(row); //create the feature and add it to the collection - use the unique key from the row or create one GeoJSON.Net.Feature.Feature f = null; if (row.Table.HasOID) { f = new GeoJSON.Net.Feature.Feature(geoJsonGeom, atts) { Id = row.get_Value(row.Fields.FindField(row.Table.OIDFieldName)).ToString() }; } else { f = new GeoJSON.Net.Feature.Feature(geoJsonGeom, atts) { Id = Guid.NewGuid().ToString() }; } geoJsonFeatures.Add(f); row = cursor.NextRow(); rowCount++; } } //initialise the geoJsonFeatureCollection var fc = new FeatureCollection(geoJsonFeatures); //to keep the export small, use formatting = none and exclude null values //todo - allow the null value handling and indentation to be exposed _geoJson = JsonConvert.SerializeObject(fc, Formatting.None, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }); } }
private static void DoRecordSetAppending(IRecordSet recordSet, StringBuilder result) { var cnt = recordSet.Columns.Max(pair => pair.Key); for (var i = 1; i <= cnt; i++) { var rowData = recordSet.Columns[i]; if (rowData.All(scalar => string.IsNullOrEmpty(scalar.Value))) { continue; } result.Append("<"); result.Append(recordSet.Name); result.Append(">"); foreach (var col in rowData) { var fName = col.Name; result.Append("<"); result.Append(fName); result.Append(">"); try { result.Append(col.Value); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) { } result.Append("</"); result.Append(fName); result.Append(">"); } result.Append("</"); result.Append(recordSet.Name); result.Append(">"); } }
internal static void DoRecordSetAppending(IRecordSet recordSet, StringBuilder result) { var cnt = recordSet.Columns.Max(pair => pair.Key); for (var i = 1; i <= cnt; i++) { var rowData = recordSet.Columns[i]; result.Append("<"); result.Append(recordSet.Name); result.Append(">"); foreach (var col in rowData) { var fName = col.Name; result.Append("<"); result.Append(fName); result.Append(">"); try { result.Append(col.Value); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) { } result.Append("</"); result.Append(fName); result.Append(">"); } result.Append("</"); result.Append(recordSet.Name); result.Append(">"); } }
private bool RecordsetHasFeatures(IRecordSet recordset) { if (recordset == null) { return false; } ICursor cursor = recordset.get_Cursor(true); try { return (cursor.NextRow() != null); } finally { this.ReleaseComObject(cursor); } }
private int GetRecordsetFeatureCount(IRecordSet recordset) { if (recordset == null) { return 0; } ICursor cursor = recordset.get_Cursor(true); try { int i = 0; while (cursor.NextRow() != null) { i++; } return i; } finally { this.ReleaseComObject(cursor); } }
private List<int> GetIdsOfContainedFeatureCentroids(IRecordSet recordset, IPolygon tilePolygon) { List<int> ids = new List<int>(); IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor; IFeature feature = cursor.NextFeature(); if (feature == null) { return ids; } if (feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryMultipoint && feature.ShapeCopy.GeometryType != esriGeometryType.esriGeometryPolygon) { throw new ArgumentException("Only multipoint and polygon geometry types are supported by this method."); } this.tracePolygon(tilePolygon); IRelationalOperator2 relationalOperator = tilePolygon as IRelationalOperator2; try { // Envelope must contain centriod IPoint centroid = null; while (feature != null) { centroid = (feature.ShapeCopy as IArea).Centroid; if (relationalOperator.Contains(centroid)) { this.tracePolygonContainsPoint(tilePolygon, centroid, feature.OID); ids.Add(feature.OID); } feature = cursor.NextFeature(); } if (ids.Count > 0) { System.Diagnostics.Debug.WriteLine("OIDs with centroids contained: " + ids.ToDelimitedString<int>(",")); } return ids; } finally { this.ReleaseComObject(cursor); cursor = null; } }