From cb0737e7b11c7b648470dfcd701c158514060165 Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Fri, 12 Apr 2019 08:32:41 +1200 Subject: [PATCH 1/7] change domain to return object #52 --- src/Anywhere.ArcGIS/Operation/Query.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Anywhere.ArcGIS/Operation/Query.cs b/src/Anywhere.ArcGIS/Operation/Query.cs index 8019e37..c2b9fef 100644 --- a/src/Anywhere.ArcGIS/Operation/Query.cs +++ b/src/Anywhere.ArcGIS/Operation/Query.cs @@ -309,7 +309,7 @@ public class Field public string SqlType { get; set; } [DataMember(Name = "domain")] - public string Domain { get; set; } + public Domain Domain { get; set; } [DataMember(Name = "defaultValue")] public string DefaultValue { get; set; } From 7c651b490d066b602880477211fa9f6fb9c80c67 Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Mon, 15 Apr 2019 07:19:42 +1200 Subject: [PATCH 2/7] bump v1.9.2 --- build.cake | 2 +- src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 8508c63..745f091 100644 --- a/build.cake +++ b/build.cake @@ -9,7 +9,7 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); var solution = "./Anywhere.ArcGIS.sln"; -var version = "1.9.1"; +var version = "1.9.2"; var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX"); ////////////////////////////////////////////////////////////////////// diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index b0247e4..5112433 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -15,7 +15,7 @@ https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth - 1.9.1 + 1.9.2 From 38d604113da8b488df376e610e8a20d650235fbd Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Wed, 29 May 2019 08:56:35 +1200 Subject: [PATCH 3/7] add fields #53 --- src/Anywhere.ArcGIS/Operation/Query.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Anywhere.ArcGIS/Operation/Query.cs b/src/Anywhere.ArcGIS/Operation/Query.cs index c2b9fef..635e527 100644 --- a/src/Anywhere.ArcGIS/Operation/Query.cs +++ b/src/Anywhere.ArcGIS/Operation/Query.cs @@ -313,6 +313,12 @@ public class Field [DataMember(Name = "defaultValue")] public string DefaultValue { get; set; } + + [DataMember(Name = "nullable")] + public bool Nullable { get; set; } + + [DataMember(Name = "editable")] + public bool Editable { get; set; } } /// From ea87e775b1ac9624cde15e94b7d0d52114b36d0c Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Fri, 19 Jul 2019 08:51:03 +1200 Subject: [PATCH 4/7] null check --- src/Anywhere.ArcGIS/Operation/Token.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Anywhere.ArcGIS/Operation/Token.cs b/src/Anywhere.ArcGIS/Operation/Token.cs index 9d73b67..60bf993 100644 --- a/src/Anywhere.ArcGIS/Operation/Token.cs +++ b/src/Anywhere.ArcGIS/Operation/Token.cs @@ -181,7 +181,7 @@ public GenerateFederatedToken(string serverUrl, ITokenProvider tokenProvider) public string Request { get { return "getToken"; } } [DataMember(Name = "token")] - public string TokenValue { get { return FederatedToken.Value; } } + public string TokenValue { get { return FederatedToken?.Value; } } [DataMember(Name = "referer")] public string Referer { get; set; } From 846de362d2c757e0e92171e148868b91b3396da3 Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Fri, 19 Jul 2019 09:04:27 +1200 Subject: [PATCH 5/7] add DeleteGlobalIds --- src/Anywhere.ArcGIS/Operation/ApplyEdits.cs | 38 +++++++++- .../ArcGISGatewayTests.cs | 76 +++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) diff --git a/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs b/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs index 1ecb623..df03adc 100644 --- a/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs +++ b/src/Anywhere.ArcGIS/Operation/ApplyEdits.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; +using System.Text; namespace Anywhere.ArcGIS.Operation { @@ -24,6 +25,7 @@ public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Ac Adds = new List>(); Updates = new List>(); Deletes = new List(); + DeleteGlobalIds = new List(); RollbackOnFailure = true; } @@ -45,8 +47,42 @@ public ApplyEdits(ArcGISServerEndpoint endpoint, Action beforeRequest = null, Ac [IgnoreDataMember] public List Deletes { get; set; } + /// + /// The Global IDs of this layer / table to be deleted. Use if useGlobalIds is true + /// + [IgnoreDataMember] + public List DeleteGlobalIds { get; set; } + [DataMember(Name = "deletes")] - public string DeleteIds { get { return Deletes == null ? string.Empty : string.Join(",", Deletes); } } + public string DeleteIds + { + get + { + /* Return in form array of quoted, braced GUIDS - examples: + [] + ['{509caea1-7a3f-444d-a0ef-81c942474624}'] + ['{509caea1-7a3f-444d-a0ef-81c942474624}','{701a68ab-86df-4244-a9cb-dda10028f528}'] + */ + if (UseGlobalIds) + { + var deleteIds = new StringBuilder("["); + if (DeleteGlobalIds != null && DeleteGlobalIds.Any()) + { + foreach (var deleteGlobalId in DeleteGlobalIds) + { + deleteIds.AppendFormat("'{0:B}',", deleteGlobalId); + } + deleteIds.Remove(deleteIds.Length - 1, 1); + } + deleteIds.Append("]"); + return deleteIds.ToString(); + } + else + { + return Deletes == null ? string.Empty : string.Join(",", Deletes); + } + } + } /// /// Geodatabase version to apply the edits. This parameter applies only if the isDataVersioned property of the layer is true. diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs index 97a3af3..60ef6bd 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs @@ -671,6 +671,82 @@ public async Task CanAddUpdateAndDelete() Assert.Equal(resultDelete.Deletes.First().ObjectId, id); } + [Fact] + public async Task CanAddUpdateAndDeleteUsingGlobalIds() + { + var gateway = new PortalGateway("https://sampleserver6.arcgisonline.com/arcgis"); + + var feature = new Feature(); + feature.Attributes.Add("type", 0); + feature.Geometry = new Point { SpatialReference = new SpatialReference { Wkid = SpatialReference.WebMercator.Wkid }, X = -13073617.8735768, Y = 4071422.42978062 }; + Guid newGlobalId = System.Guid.NewGuid(); + feature.Attributes.Add("GlobalID", newGlobalId); + feature.Attributes.Add("creator", "Anywhere.ArcGIS"); + + var adds = new ApplyEdits(@"Sync/SaveTheBaySync/FeatureServer/0".AsEndpoint()) + { + Adds = new List> { feature }, + UseGlobalIds = true + }; + var resultAdd = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + { + return gateway.ApplyEdits(adds); + }); + + Assert.True(resultAdd.Adds.Any()); + Assert.True(resultAdd.Adds.First().Success); + Assert.Equal(resultAdd.ExpectedAdds, resultAdd.ActualAdds); + Assert.Equal(resultAdd.ActualAdds, resultAdd.ActualAddsThatSucceeded); + + var id = resultAdd.Adds.First().GlobalId; + Assert.Equal(newGlobalId.ToString("B"), id); + + feature.Attributes.Add("comments", "something"); // problem with serialization means we need single quotes around string values + feature.Attributes.Add("editor", "Anywhere.ArcGIS"); + + var updates = new ApplyEdits(@"Sync/SaveTheBaySync/FeatureServer/0") + { + Updates = new List> { feature }, + UseGlobalIds = true + }; + var resultUpdate = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + { + return gateway.ApplyEdits(updates); + }); + + Assert.True(resultUpdate.Updates.Any()); + // Note - Success returns false, even though it's worked. + // Assert.True(resultUpdate.Updates.First().Success); + Assert.Equal(1, resultUpdate.ExpectedUpdates); + Assert.Equal(1, resultUpdate.ActualUpdates); + Assert.Equal(resultUpdate.ExpectedUpdates, resultUpdate.ActualUpdates); + // Note - resultUpdate.ActualUpdatesThatSucceeded returns 0, even though it's worked. + // Assert.Equal(resultUpdate.ActualUpdates, resultUpdate.ActualUpdatesThatSucceeded); + + // Not sure why, but GlobalId in Updates is in D format, not B format. + Assert.Equal(newGlobalId.ToString("D"), resultUpdate.Updates.First().GlobalId); + + var deletes = new ApplyEdits(@"Sync/SaveTheBaySync/FeatureServer/0".AsEndpoint()) + { + DeleteGlobalIds = new List { newGlobalId }, + UseGlobalIds = true + }; + + var resultDelete = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + { + return gateway.ApplyEdits(deletes); + }); + + Assert.True(resultDelete.Deletes.Any()); + Assert.True(resultDelete.Deletes.First().Success); + // resultDelete.ExpectedDeletes returns 0 - not expected value (1). + // Assert.Equal(resultDelete.ExpectedDeletes, resultDelete.ActualDeletes); + Assert.Equal(1, resultDelete.ActualDeletes); + Assert.Equal(1, resultDelete.ActualDeletesThatSucceeded); + Assert.Equal(resultDelete.ActualDeletes, resultDelete.ActualDeletesThatSucceeded); + Assert.Equal(resultDelete.Deletes.First().GlobalId, id); + } + [Fact] public async Task FindCanReturnResultsAndGeometry() { From cd1034b908de443a553a0310cf3e32259a1b0daa Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Fri, 19 Jul 2019 09:06:04 +1200 Subject: [PATCH 6/7] v 1.10.0 --- build.cake | 2 +- src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 745f091..eb1fd85 100644 --- a/build.cake +++ b/build.cake @@ -9,7 +9,7 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); var solution = "./Anywhere.ArcGIS.sln"; -var version = "1.9.2"; +var version = "1.10.0"; var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX"); ////////////////////////////////////////////////////////////////////// diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index 5112433..f3e2147 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -15,7 +15,7 @@ https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth - 1.9.2 + 1.10.0 From 782df0a59ff707feb2c8b54214424b81bff5220a Mon Sep 17 00:00:00 2001 From: Dave Timmins Date: Fri, 19 Jul 2019 09:10:35 +1200 Subject: [PATCH 7/7] use license file in package --- src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index f3e2147..64aacb2 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -9,13 +9,14 @@ Operations and data types used with the ArcGIS REST API. Operations and data types used with the ArcGIS REST API. Copyright Dave Timmins (c) 2018. All rights reserved. - https://raw.githubusercontent.com/davetimmins/Anywhere.ArcGIS/master/LICENSE + https://github.com/davetimmins/Anywhere.ArcGIS https://raw.githubusercontent.com/davetimmins/Anywhere.ArcGIS/master/logo.png https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth 1.10.0 + LICENSE @@ -36,4 +37,11 @@ + + + + True + + +