├── .gitattributes
├── .gitignore
├── 1.4
├── Config.daml
├── DataAssistant.csproj
├── Helpers.cs
└── bin
│ └── Release
│ └── DataAssistant.esriAddinX
├── 2.0
├── Config.daml
├── DataAssistant.csproj
├── Helpers.cs
└── bin
│ └── Release
│ └── DataAssistant.esriAddinX
├── 3.0
├── Config.daml
├── DataAssistant.csproj
├── Helpers.cs
└── Properties
│ └── launchSettings.json
├── DataAssistant1.4.sln
├── DataAssistant2.0.sln
├── DataAssistant3.0.sln
├── LICENSE.txt
├── Properties
└── AssemblyInfo.cs
├── README.md
├── Shared
├── DarkImages
│ ├── .DS_Store
│ ├── AppendData16.png
│ ├── AppendData32.png
│ ├── CogWheel16.png
│ ├── CogWheel32.png
│ ├── DataMapper16.png
│ ├── DataMapper32.png
│ ├── NewFile16.png
│ ├── NewFile32.png
│ ├── Preview16.png
│ ├── Preview32.png
│ ├── ReplaceData16.png
│ ├── ReplaceData32.png
│ ├── StageData16.png
│ └── StageData32.png
├── DataClasses.cs
├── Dockpane1.xaml
├── Dockpane1.xaml.cs
├── Dockpane1Apply.cs
├── Dockpane1CheckXmlFile.cs
├── Dockpane1Domains.cs
├── Dockpane1Preview.cs
├── Dockpane1ViewModel.cs
├── Dockpane2Settings.xaml
├── Dockpane2Settings.xaml.cs
├── Dockpane2SettingsViewModel.cs
├── GPTools
│ ├── DataLoadingAssistant.tbx
│ └── arcpy
│ │ ├── FieldMatcher.xsl
│ │ ├── MatchLocal.xml
│ │ ├── dla.py
│ │ ├── dlaAppendData.py
│ │ ├── dlaCreateSourceTarget.py
│ │ ├── dlaExtractLayerToGDB.py
│ │ ├── dlaFieldCalculator.py
│ │ ├── dlaPreview.py
│ │ ├── dlaPublish.py
│ │ ├── dlaReplaceByField.py
│ │ ├── dlaService.py
│ │ ├── dlaStage.py
│ │ └── testHarness.py
├── Images
│ ├── AddInDesktop16.png
│ ├── AppendData16.png
│ ├── AppendData32.png
│ ├── CogWheel16.png
│ ├── CogWheel32.png
│ ├── DataMapper16.png
│ ├── DataMapper32.png
│ ├── NewFile16.png
│ ├── NewFile32.png
│ ├── Preview16.png
│ ├── Preview32.png
│ ├── ReplaceData16.png
│ ├── ReplaceData32.png
│ ├── StageData16.png
│ └── StageData32.png
├── Module1.cs
└── gridTooltipCreator.cs
└── version.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # Byte-compiled / optimized / DLL files
5 | __pycache__/
6 | *.py[cod]
7 | *$py.class
8 |
9 | # User-specific files
10 | *.suo
11 | *.user
12 | *.userosscache
13 | *.sln.docstates
14 |
15 | # User-specific files (MonoDevelop/Xamarin Studio)
16 | *.userprefs
17 |
18 | # Build results
19 | [Dd]ebug/
20 | [Dd]ebugPublic/
21 | [Rr]elease/
22 | [Rr]eleases/
23 | x64/
24 | x86/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | [Ll]og/
29 |
30 | # Include release build of the 1.4,2.0,3.0 add-ins
31 | 3.0/*
32 | !3.0/bin
33 | 3.0/bin/*
34 | !3.0/bin/Release/
35 | 3.0/bin/Release/*
36 | !3.0/bin/Release/*.esriAddInX
37 | 2.0/*
38 | !2.0/bin
39 | 2.0/bin/*
40 | !2.0/bin/Release/
41 | 2.0/bin/Release/*
42 | !2.0/bin/Release/*.esriAddInX
43 | 1.4/*
44 | !1.4/bin
45 | 1.4/bin/*
46 | !1.4/bin/Release/
47 | 1.4/bin/Release/*
48 | !1.4/bin/Release/*.esriAddInX
49 |
50 | # Visual Studio 2015 cache/options directory
51 | .vs/
52 | # Uncomment if you have tasks that create the project's static files in wwwroot
53 | #wwwroot/
54 |
55 | # MSTest test Results
56 | [Tt]est[Rr]esult*/
57 | [Bb]uild[Ll]og.*
58 |
59 | # NUNIT
60 | *.VisualState.xml
61 | TestResult.xml
62 |
63 | # Build Results of an ATL Project
64 | [Dd]ebugPS/
65 | [Rr]eleasePS/
66 | dlldata.c
67 |
68 | # DNX
69 | project.lock.json
70 | artifacts/
71 |
72 | *_i.c
73 | *_p.c
74 | *_i.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.pch
79 | *.pdb
80 | *.pgc
81 | *.pgd
82 | *.rsp
83 | *.sbr
84 | *.tlb
85 | *.tli
86 | *.tlh
87 | *.tmp
88 | *.tmp_proj
89 | *.log
90 | *.vspscc
91 | *.vssscc
92 | .builds
93 | *.pidb
94 | *.svclog
95 | *.scc
96 |
97 | # Chutzpah Test files
98 | _Chutzpah*
99 |
100 | # Visual C++ cache files
101 | ipch/
102 | *.aps
103 | *.ncb
104 | *.opendb
105 | *.opensdf
106 | *.sdf
107 | *.cachefile
108 | *.VC.db
109 | *.VC.VC.opendb
110 |
111 | # Visual Studio profiler
112 | *.psess
113 | *.vsp
114 | *.vspx
115 | *.sap
116 |
117 | # TFS 2012 Local Workspace
118 | $tf/
119 |
120 | # Guidance Automation Toolkit
121 | *.gpState
122 |
123 | # ReSharper is a .NET coding add-in
124 | _ReSharper*/
125 | *.[Rr]e[Ss]harper
126 | *.DotSettings.user
127 |
128 | # JustCode is a .NET coding add-in
129 | .JustCode
130 |
131 | # TeamCity is a build add-in
132 | _TeamCity*
133 |
134 | # DotCover is a Code Coverage Tool
135 | *.dotCover
136 |
137 | # NCrunch
138 | _NCrunch_*
139 | .*crunch*.local.xml
140 | nCrunchTemp_*
141 |
142 | # MightyMoose
143 | *.mm.*
144 | AutoTest.Net/
145 |
146 | # Web workbench (sass)
147 | .sass-cache/
148 |
149 | # Installshield output folder
150 | [Ee]xpress/
151 |
152 | # DocProject is a documentation generator add-in
153 | DocProject/buildhelp/
154 | DocProject/Help/*.HxT
155 | DocProject/Help/*.HxC
156 | DocProject/Help/*.hhc
157 | DocProject/Help/*.hhk
158 | DocProject/Help/*.hhp
159 | DocProject/Help/Html2
160 | DocProject/Help/html
161 |
162 | # Click-Once directory
163 | publish/
164 |
165 | # Publish Web Output
166 | *.[Pp]ublish.xml
167 | *.azurePubxml
168 | # TODO: Comment the next line if you want to checkin your web deploy settings
169 | # but database connection strings (with potential passwords) will be unencrypted
170 | *.pubxml
171 | *.publishproj
172 |
173 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
174 | # checkin your Azure Web App publish settings, but sensitive information contained
175 | # in these scripts will be unencrypted
176 | PublishScripts/
177 |
178 | # NuGet Packages
179 | *.nupkg
180 | # The packages folder can be ignored because of Package Restore
181 | **/packages/*
182 | # except build/, which is used as an MSBuild target.
183 | !**/packages/build/
184 | # Uncomment if necessary however generally it will be regenerated when needed
185 | #!**/packages/repositories.config
186 | # NuGet v3's project.json files produces more ignoreable files
187 | *.nuget.props
188 | *.nuget.targets
189 |
190 | # Microsoft Azure Build Output
191 | csx/
192 | *.build.csdef
193 |
194 | # Microsoft Azure Emulator
195 | ecf/
196 | rcf/
197 |
198 | # Windows Store app package directories and files
199 | AppPackages/
200 | BundleArtifacts/
201 | Package.StoreAssociation.xml
202 | _pkginfo.txt
203 |
204 | # Visual Studio cache files
205 | # files ending in .cache can be ignored
206 | *.[Cc]ache
207 | # but keep track of directories ending in .cache
208 | !*.[Cc]ache/
209 |
210 | # Others
211 | ClientBin/
212 | ~$*
213 | *~
214 | *.dbmdl
215 | *.dbproj.schemaview
216 | *.pfx
217 | *.publishsettings
218 | node_modules/
219 | orleans.codegen.cs
220 |
221 | # Since there are multiple workflows, uncomment next line to ignore bower_components
222 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
223 | #bower_components/
224 |
225 | # RIA/Silverlight projects
226 | Generated_Code/
227 |
228 | # Backup & report files from converting an old project file
229 | # to a newer Visual Studio version. Backup files are not needed,
230 | # because we have git ;-)
231 | _UpgradeReport_Files/
232 | Backup*/
233 | UpgradeLog*.XML
234 | UpgradeLog*.htm
235 |
236 | # SQL Server files
237 | *.mdf
238 | *.ldf
239 |
240 | # Business Intelligence projects
241 | *.rdl.data
242 | *.bim.layout
243 | *.bim_*.settings
244 |
245 | # Microsoft Fakes
246 | FakesAssemblies/
247 |
248 | # GhostDoc plugin setting file
249 | *.GhostDoc.xml
250 |
251 | # Node.js Tools for Visual Studio
252 | .ntvs_analysis.dat
253 |
254 | # Visual Studio 6 build log
255 | *.plg
256 |
257 | # Visual Studio 6 workspace options file
258 | *.opt
259 |
260 | # Visual Studio LightSwitch build output
261 | **/*.HTMLClient/GeneratedArtifacts
262 | **/*.DesktopClient/GeneratedArtifacts
263 | **/*.DesktopClient/ModelManifest.xml
264 | **/*.Server/GeneratedArtifacts
265 | **/*.Server/ModelManifest.xml
266 | _Pvt_Extensions
267 |
268 | # Paket dependency manager
269 | .paket/paket.exe
270 | paket-files/
271 |
272 | # FAKE - F# Make
273 | .fake/
274 |
275 | # JetBrains Rider
276 | .idea/
277 | *.sln.iml
278 |
--------------------------------------------------------------------------------
/1.4/Config.daml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DataAssistant
4 | The Data Assistant can be used to transform your organization’s data and load it into a database or service.
5 | Images\DataMapper32.png
6 | Esri
7 | Vertex3 for Esri
8 | 2017.4.26
9 | Content,Framework,Data Loading Assistant
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
38 |
42 |
46 |
50 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/1.4/DataAssistant.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}
9 | Library
10 | Properties
11 | DataAssistant
12 | DataAssistant
13 | v4.6.1
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | Program
26 | C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe
27 | AnyCPU
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 | Program
37 | C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe
38 | AnyCPU
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll
58 | False
59 |
60 |
61 | C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll
62 | False
63 |
64 |
65 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll
66 | False
67 |
68 |
69 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll
70 | False
71 |
72 |
73 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll
74 | False
75 |
76 |
77 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll
78 | False
79 |
80 |
81 | C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll
82 | False
83 |
84 |
85 |
86 |
87 | Designer
88 |
89 |
90 |
91 |
92 |
93 | Dockpane1.xaml
94 |
95 |
96 |
97 |
98 |
99 | Dockpane2Settings.xaml
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | Properties\AssemblyInfo.cs
108 |
109 |
110 |
111 |
112 |
113 | DarkImages\AppendData16.png
114 |
115 |
116 | DarkImages\AppendData32.png
117 |
118 |
119 | DarkImages\CogWheel16.png
120 |
121 |
122 | DarkImages\CogWheel32.png
123 |
124 |
125 | DarkImages\DataMapper16.png
126 |
127 |
128 | DarkImages\DataMapper32.png
129 |
130 |
131 | DarkImages\NewFile16.png
132 |
133 |
134 | DarkImages\NewFile32.png
135 |
136 |
137 | DarkImages\Preview16.png
138 |
139 |
140 | DarkImages\Preview32.png
141 |
142 |
143 | DarkImages\ReplaceData16.png
144 |
145 |
146 | DarkImages\ReplaceData32.png
147 |
148 |
149 | DarkImages\StageData16.png
150 |
151 |
152 | DarkImages\StageData32.png
153 |
154 |
155 | PreserveNewest
156 | GPTools\arcpy\dla.py
157 |
158 |
159 | PreserveNewest
160 | GPTools\arcpy\dlaExtractLayerToGDB.py
161 |
162 |
163 | PreserveNewest
164 | GPTools\arcpy\dlaService.py
165 |
166 |
167 | PreserveNewest
168 | GPTools\arcpy\dlaAppendData.py
169 |
170 |
171 | PreserveNewest
172 | GPTools\arcpy\dlaCreateSourceTarget.py
173 |
174 |
175 | Images\AppendData16.png
176 |
177 |
178 | Images\AppendData32.png
179 |
180 |
181 | Images\CogWheel16.png
182 |
183 |
184 | Images\CogWheel32.png
185 |
186 |
187 | Images\DataMapper16.png
188 |
189 |
190 | Images\DataMapper32.png
191 |
192 |
193 | Images\NewFile16.png
194 |
195 |
196 | Images\NewFile32.png
197 |
198 |
199 | Images\Preview16.png
200 |
201 |
202 | Images\Preview32.png
203 |
204 |
205 | Images\ReplaceData16.png
206 |
207 |
208 | Images\ReplaceData32.png
209 |
210 |
211 | Images\StageData16.png
212 |
213 |
214 | Images\StageData32.png
215 |
216 |
217 |
218 |
219 | PreserveNewest
220 | GPTools\arcpy\dlaFieldCalculator.py
221 |
222 |
223 | PreserveNewest
224 | GPTools\arcpy\dlaPreview.py
225 |
226 |
227 | PreserveNewest
228 | GPTools\arcpy\dlaPublish.py
229 |
230 |
231 | PreserveNewest
232 | GPTools\arcpy\dlaReplaceByField.py
233 |
234 |
235 | PreserveNewest
236 | GPTools\arcpy\dlaStage.py
237 |
238 |
239 | PreserveNewest
240 | GPTools\arcpy\FieldMatcher.xsl
241 |
242 |
243 | PreserveNewest
244 | GPTools\arcpy\MatchLocal.xml
245 |
246 |
247 | Always
248 | GPTools\DataLoadingAssistant.tbx
249 |
250 |
251 |
252 |
253 | Designer
254 | MSBuild:Compile
255 |
256 |
257 | Designer
258 | MSBuild:Compile
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
274 |
275 |
276 |
277 |
--------------------------------------------------------------------------------
/1.4/Helpers.cs:
--------------------------------------------------------------------------------
1 | using ArcGIS.Desktop.Core;
2 | using ArcGIS.Desktop.Mapping;
3 | using System;
4 | using System.Threading.Tasks;
5 |
6 | namespace DataAssistant
7 | {
8 | internal static class Helpers
9 | {
10 | internal static FeatureLayer CreateFeatureLayer(Uri uri, Map map)
11 | {
12 | return LayerFactory.CreateFeatureLayer(uri, MapView.Active.Map);
13 | }
14 |
15 | internal static Task AddProjectItem(string path)
16 | {
17 | return Project.Current.AddAsync(ItemFactory.Create(path));
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/1.4/bin/Release/DataAssistant.esriAddinX:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/1.4/bin/Release/DataAssistant.esriAddinX
--------------------------------------------------------------------------------
/2.0/Config.daml:
--------------------------------------------------------------------------------
1 |
2 |
3 | DataAssistant
4 | The Data Assistant can be used to transform your organization’s data and load it into a database or service.
5 | Images\DataMapper32.png
6 | Esri
7 | Vertex3 for Esri
8 | 2017.4.26
9 | Content,Framework,Data Loading Assistant
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
38 |
42 |
46 |
50 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/2.0/DataAssistant.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}
9 | Library
10 | Properties
11 | DataAssistant
12 | DataAssistant
13 | v4.6.1
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | Program
26 | C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe
27 | AnyCPU
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 | Program
37 | C:\Program Files\ArcGIS\Pro\bin\ArcGISPro.exe
38 | AnyCPU
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll
58 | False
59 |
60 |
61 | C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll
62 | False
63 |
64 |
65 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll
66 | False
67 |
68 |
69 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll
70 | False
71 |
72 |
73 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll
74 | False
75 |
76 |
77 | C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll
78 | False
79 |
80 |
81 | C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll
82 | False
83 |
84 |
85 |
86 |
87 | Designer
88 |
89 |
90 |
91 |
92 |
93 | Dockpane1.xaml
94 |
95 |
96 |
97 |
98 |
99 | Dockpane2Settings.xaml
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | Properties\AssemblyInfo.cs
108 |
109 |
110 |
111 |
112 |
113 | DarkImages\AppendData16.png
114 |
115 |
116 | DarkImages\AppendData32.png
117 |
118 |
119 | DarkImages\CogWheel16.png
120 |
121 |
122 | DarkImages\CogWheel32.png
123 |
124 |
125 | DarkImages\DataMapper16.png
126 |
127 |
128 | DarkImages\DataMapper32.png
129 |
130 |
131 | DarkImages\NewFile16.png
132 |
133 |
134 | DarkImages\NewFile32.png
135 |
136 |
137 | DarkImages\Preview16.png
138 |
139 |
140 | DarkImages\Preview32.png
141 |
142 |
143 | DarkImages\ReplaceData16.png
144 |
145 |
146 | DarkImages\ReplaceData32.png
147 |
148 |
149 | DarkImages\StageData16.png
150 |
151 |
152 | DarkImages\StageData32.png
153 |
154 |
155 | PreserveNewest
156 | GPTools\arcpy\dla.py
157 |
158 |
159 | PreserveNewest
160 | GPTools\arcpy\dlaExtractLayerToGDB.py
161 |
162 |
163 | PreserveNewest
164 | GPTools\arcpy\dlaService.py
165 |
166 |
167 | PreserveNewest
168 | GPTools\arcpy\dlaAppendData.py
169 |
170 |
171 | PreserveNewest
172 | GPTools\arcpy\dlaCreateSourceTarget.py
173 |
174 |
175 | Images\AddInDesktop16.png
176 |
177 |
178 | Images\AppendData16.png
179 |
180 |
181 | Images\AppendData32.png
182 |
183 |
184 | Images\CogWheel16.png
185 |
186 |
187 | Images\CogWheel32.png
188 |
189 |
190 | Images\DataMapper16.png
191 |
192 |
193 | Images\DataMapper32.png
194 |
195 |
196 | Images\NewFile16.png
197 |
198 |
199 | Images\NewFile32.png
200 |
201 |
202 | Images\Preview16.png
203 |
204 |
205 | Images\Preview32.png
206 |
207 |
208 | Images\ReplaceData16.png
209 |
210 |
211 | Images\ReplaceData32.png
212 |
213 |
214 | Images\StageData16.png
215 |
216 |
217 | Images\StageData32.png
218 |
219 |
220 |
221 |
222 | PreserveNewest
223 | GPTools\arcpy\dlaFieldCalculator.py
224 |
225 |
226 | PreserveNewest
227 | GPTools\arcpy\dlaPreview.py
228 |
229 |
230 | PreserveNewest
231 | GPTools\arcpy\dlaPublish.py
232 |
233 |
234 | PreserveNewest
235 | GPTools\arcpy\dlaReplaceByField.py
236 |
237 |
238 | PreserveNewest
239 | GPTools\arcpy\dlaStage.py
240 |
241 |
242 | PreserveNewest
243 | GPTools\arcpy\FieldMatcher.xsl
244 |
245 |
246 | PreserveNewest
247 | GPTools\arcpy\MatchLocal.xml
248 |
249 |
250 | Always
251 | GPTools\DataLoadingAssistant.tbx
252 |
253 |
254 |
255 |
256 | Designer
257 | MSBuild:Compile
258 |
259 |
260 | Designer
261 | MSBuild:Compile
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
277 |
278 |
279 |
280 |
--------------------------------------------------------------------------------
/2.0/Helpers.cs:
--------------------------------------------------------------------------------
1 | using ArcGIS.Desktop.Core;
2 | using ArcGIS.Desktop.Framework.Threading.Tasks;
3 | using ArcGIS.Desktop.Mapping;
4 | using System;
5 | using System.Threading.Tasks;
6 |
7 | namespace DataAssistant
8 | {
9 | internal static class Helpers
10 | {
11 | internal static FeatureLayer CreateFeatureLayer(Uri uri, Map map)
12 | {
13 | return LayerFactory.Instance.CreateFeatureLayer(uri, MapView.Active.Map);
14 | }
15 |
16 | internal static Task AddProjectItem(string path)
17 | {
18 | var folderToAdd = ItemFactory.Instance.Create(path);
19 | return QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem));
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/2.0/bin/Release/DataAssistant.esriAddinX:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/2.0/bin/Release/DataAssistant.esriAddinX
--------------------------------------------------------------------------------
/3.0/Config.daml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | DataAssistant
5 | The Data Assistant can be used to transform your organization’s data and load it into a database or service.
6 | Images\DataMapper32.png
7 | Esri
8 | Vertex3 for Esri
9 | 2023.6.1
10 | Content,Framework,Data Loading Assistant
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
36 |
39 |
43 |
47 |
51 |
55 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/3.0/DataAssistant.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | win10-x64
6 | false
7 | true
8 | false
9 | CA1416
10 | true
11 | true
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | C:\ArcGIS\bin\ArcGIS.Desktop.Framework.dll
29 | False
30 | False
31 |
32 |
33 | C:\ArcGIS\bin\ArcGIS.Core.dll
34 | False
35 | False
36 |
37 |
38 | C:\ArcGIS\bin\Extensions\Core\ArcGIS.Desktop.Core.dll
39 | False
40 | False
41 |
42 |
43 | C:\ArcGIS\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll
44 | False
45 | False
46 |
47 |
48 | C:\ArcGIS\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll
49 | False
50 | False
51 |
52 |
53 | C:\ArcGIS\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll
54 | False
55 | False
56 |
57 |
58 | C:\ArcGIS\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll
59 | False
60 | False
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | PreserveNewest
98 |
99 |
100 | PreserveNewest
101 |
102 |
103 | PreserveNewest
104 |
105 |
106 | PreserveNewest
107 |
108 |
109 | PreserveNewest
110 |
111 |
112 | PreserveNewest
113 |
114 |
115 | PreserveNewest
116 |
117 |
118 | PreserveNewest
119 |
120 |
121 | PreserveNewest
122 |
123 |
124 | PreserveNewest
125 |
126 |
127 | PreserveNewest
128 |
129 |
130 | PreserveNewest
131 |
132 |
133 | Always
134 |
135 |
136 |
137 |
138 | MSBuild:Compile
139 |
140 |
141 | MSBuild:Compile
142 |
143 |
144 |
145 |
146 |
147 |
148 |
--------------------------------------------------------------------------------
/3.0/Helpers.cs:
--------------------------------------------------------------------------------
1 | using ArcGIS.Desktop.Core;
2 | using ArcGIS.Desktop.Framework.Threading.Tasks;
3 | using ArcGIS.Desktop.Mapping;
4 | using System;
5 | using System.Threading.Tasks;
6 |
7 | namespace DataAssistant
8 | {
9 | internal static class Helpers
10 | {
11 | internal static FeatureLayer CreateFeatureLayer(Uri uri, Map map)
12 | {
13 | QueuedTask.Run(() =>
14 | {
15 | var createParams = new FeatureLayerCreationParams(uri);
16 | return LayerFactory.Instance.CreateLayer(createParams, MapView.Active.Map);
17 | }
18 | );
19 | return null;
20 | }
21 |
22 | internal static Task AddProjectItem(string path)
23 | {
24 | var folderToAdd = ItemFactory.Instance.Create(path);
25 | return QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem));
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/3.0/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "DataAssistant": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\ArcGIS\\bin\\ArcGISPro.exe",
6 | "commandLineArgs": ""
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/DataAssistant1.4.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAssistant", "1.4\DataAssistant.csproj", "{D7BC4883-7429-42D7-9A28-7B4C9030CBC1}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DataAssistant2.0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAssistant", "2.0\DataAssistant.csproj", "{D7BC4883-7429-42D7-9A28-7B4C9030CBC1}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {D7BC4883-7429-42D7-9A28-7B4C9030CBC1}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DataAssistant3.0.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32319.34
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataAssistant", "3.0\DataAssistant.csproj", "{0EFDF797-9DC9-410F-B4AE-1BAED693EEF7}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {0EFDF797-9DC9-410F-B4AE-1BAED693EEF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {0EFDF797-9DC9-410F-B4AE-1BAED693EEF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {0EFDF797-9DC9-410F-B4AE-1BAED693EEF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {0EFDF797-9DC9-410F-B4AE-1BAED693EEF7}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {DFE2BCD1-C027-4941-B819-9E4835B91492}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2016 Esri Inc.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("DataAssistant")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("DataAssistant")]
13 | [assembly: AssemblyCopyright("Copyright © Esri 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("28142961-b645-420f-ba2a-72bcf8212558")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # data-assistant
2 |
3 | The data-assistant repo includes an ArcGIS Pro Add-in that helps communities (states, counties, emergency operations centers, and so on) aggregate information from authoritative sources and use this information to facilitate emergency response, permitting, administrative services and other related workflows.
4 |
5 | ## Features
6 |
7 | * Data Assistant Add-in
8 | * Community Addresses
9 | * Community Parcels
10 |
11 | ## Instructions (2 options)
12 |
13 | ### 1. Install from the compiled add-in
14 |
15 | 1. Download the add-in for version [1.4](1.4/bin/Release/DataAssistant.esriAddinX) or [2.0](2.0/bin/Release/DataAssistant.esriAddinX).
16 | 2. Double-click the .esriaddinX file to install.
17 | 3. Launch ArcGIS Pro and find the capabilities on the Data Assistant tab.
18 |
19 | ### 2. Compile the add-in
20 |
21 | 1. Download or Clone this repo
22 | 2. Open the DataAssistant Visual Studio solution for the appropriate version of Pro and build the solution.
23 | 3. Launch ArcGIS Pro and find the capabilities on the Data Assistant tab.
24 |
25 | ### Esri Solutions
26 |
27 | Esri provides a number of solutions that utilize this Add-in.
28 | * [ArcGIS for Emergency Management's Community Addresses](http://links.esri.com/emergencymanagement/help/AggregateAddresses/)
29 | * [ArcGIS for Emergency Management's Community Parcels](http://links.esri.com/emergencymanagement/help/AggregateParcels/)
30 | * [ArcGIS for Local Government's Community Addresses](http://links.esri.com/localgovernment/help/AggregateAddresses/)
31 | * [ArcGIS for Local Government's Community Parcels](http://links.esri.com/localgovernment/help/AggregateParcels/)
32 | * [ArcGIS for State Government's Community Addresses](http://links.esri.com/stategovernment/help/AggregateAddresses/)
33 | * [ArcGIS for State Government's Community Parcels](http://links.esri.com/stategovernment/help/AggregateParcels/)
34 |
35 | ### Additional Help
36 |
37 | [Detailed help](http://solutions.arcgis.com/emergency-management/help/aggregate-addresses/tools/)
38 | is provided with each solution on the ArcGIS Solution Site.
39 |
40 | ### General Help
41 | [New to Github? Get started here.](http://htmlpreview.github.com/?https://github.com/Esri/esri.github.com/blob/master/help/esri-getting-to-know-github.html)
42 |
43 | ## Requirements
44 |
45 | * ArcGIS Pro 1.4 - 2.0
46 |
47 | ## Resources
48 |
49 | * Learn more about Esri's [ArcGIS for Emergency Management maps and apps](http://solutions.arcgis.com/emergency-management/).
50 | View a list of other [Emergency Management GitHub repositories](http://esri.github.io/#Emergency-Management).
51 |
52 | * Learn more about Esri's [ArcGIS for Local Government maps and apps](http://solutions.arcgis.com/local-government/).
53 | View a list of other [Local Government GitHub repositories](http://esri.github.io/#Local-Government).
54 |
55 | * Learn more about Esri's [ArcGIS for State Government maps and apps](http://solutions.arcgis.com/state-government/).
56 | View a list of other [State Government GitHub repositories](http://esri.github.io/#State-Government).
57 |
58 | ## Issues
59 |
60 | Find a bug or want to request a new feature? Please let us know by submitting an issue.
61 |
62 | ## Contributing
63 |
64 | Esri welcomes contributions from anyone and everyone.
65 | Please see our [guidelines for contributing](https://github.com/esri/contributing).
66 |
67 | ## Licensing
68 |
69 | Copyright 2016 Esri
70 |
71 | Licensed under the Apache License, Version 2.0 (the "License");
72 | you may not use this file except in compliance with the License.
73 | You may obtain a copy of the License at
74 |
75 | http://www.apache.org/licenses/LICENSE-2.0
76 |
77 | Unless required by applicable law or agreed to in writing, software
78 | distributed under the License is distributed on an "AS IS" BASIS,
79 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80 | See the License for the specific language governing permissions and
81 | limitations under the License.
82 |
83 | A copy of the license is available in the repository's
84 | [LICENSE.txt](LICENSE.txt) file.
85 |
--------------------------------------------------------------------------------
/Shared/DarkImages/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/.DS_Store
--------------------------------------------------------------------------------
/Shared/DarkImages/AppendData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/AppendData16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/AppendData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/AppendData32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/CogWheel16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/CogWheel16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/CogWheel32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/CogWheel32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/DataMapper16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/DataMapper16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/DataMapper32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/DataMapper32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/NewFile16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/NewFile16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/NewFile32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/NewFile32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/Preview16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/Preview16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/Preview32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/Preview32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/ReplaceData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/ReplaceData16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/ReplaceData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/ReplaceData32.png
--------------------------------------------------------------------------------
/Shared/DarkImages/StageData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/StageData16.png
--------------------------------------------------------------------------------
/Shared/DarkImages/StageData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/DarkImages/StageData32.png
--------------------------------------------------------------------------------
/Shared/DataClasses.cs:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright 2016 Esri
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ***/
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Threading.Tasks;
22 | using System.Collections.ObjectModel;
23 |
24 | using System.Windows;
25 | using System.Windows.Controls;
26 |
27 |
28 | namespace DataAssistant
29 | {
30 | // Data Classes used for various methods
31 | public class ConcatRow // concatenate method
32 | {
33 | public bool Checked { get; set; }
34 | public string Name { get; set; }
35 | }
36 | public class ValueMapRow // ValueMap method
37 | {
38 | public string Source { get; set; } // source values
39 | public string Target { get; set; } // target values to set
40 | }
41 | public class DomainMapRow // for DomainMap method
42 | {
43 | public List Source { get; set; } // combo items
44 | public int SourceSelectedItem { get; set; } // selected item num
45 | public string SourceTooltip { get; set; } // tooltip on source control - show domain value for code
46 | public List Target { get; set; } // target textbox, will try to match to source domain values, always display all target values
47 | public int TargetSelectedItem { get; set; } // selected item num
48 | public string TargetTooltip { get; set; } // tooltip for target, wil be set to matching domain value if available
49 | }
50 | public class ComboData // combobox data for DomainMap
51 | {
52 | public string Id { get; set; } // domain code
53 | public string Value { get; set; } // domain value
54 | public string Tooltip { get; set; } // set tooltip - just using value seems like the best idea
55 | }
56 | public class PreviewRow // preview rows
57 | {
58 | public string Value { get; set; }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Shared/Dockpane1CheckXmlFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using System.Xml.Linq;
16 | using System.Data;
17 | using System.Collections.ObjectModel;
18 | using System.Globalization;
19 | using System.Windows.Controls.Primitives;
20 |
21 | using ArcGIS.Core.Data;
22 | using ArcGIS.Desktop.Core.Geoprocessing;
23 | using ArcGIS.Desktop.Core;
24 | using ArcGIS.Desktop.Catalog;
25 | using ArcGIS.Desktop.Mapping;
26 | using System.Xml;
27 | using System.Xml.Xsl;
28 | using System.Xml.XPath;
29 |
30 | namespace DataAssistant
31 | {
32 | ///
33 | /// Interaction logic for Dockpane1View.xaml
34 | ///
35 | public partial class Dockpane1View : UserControl
36 | {
37 |
38 | private bool checkXmlFileName(string filepath)
39 | {
40 | bool valid = false;
41 | bool srcValid = false;
42 | bool targValid = false;
43 | bool projValid = false;
44 |
45 | string _project = "//Project";
46 | string _source = "//Source";
47 | string _target = "//Target";
48 |
49 |
50 | if (System.IO.File.Exists(filepath))
51 | {
52 | string folder = getFolder(filepath);
53 | loadXml(filepath); // load the xml file but do not update the UI
54 |
55 | System.Xml.XmlNode project = _xml.SelectSingleNode(_project);
56 | if (project == null)
57 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Warning: Unable to locate Project xml element in folder " + folder);
58 | else
59 | projValid = checkSourceTargetPath(folder, project.InnerText);
60 |
61 | System.Xml.XmlNode source = _xml.SelectSingleNode(_source);
62 | if (source == null)
63 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error: Unable to locate Source xml element in the file");
64 | else
65 | srcValid = checkSourceTargetPath(folder, source.InnerText);
66 |
67 | System.Xml.XmlNode target = _xml.SelectSingleNode(_target);
68 | if (target == null)
69 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error: Unable to locate Target xml element in the file");
70 | else
71 | targValid = checkSourceTargetPath(folder, target.InnerText);
72 |
73 | if (srcValid && targValid) // ignore the Project value in error messages.
74 | valid = true;
75 | else
76 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("All files should be fully qualified paths or be relative to the selected xml file");
77 |
78 | }
79 | else
80 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(filepath + " does not exist");
81 |
82 | return valid;
83 | }
84 | private bool checkSourceTargetPath(string folder, string dataset)
85 | {
86 | bool valid = false;
87 | if (dataset != null)
88 | {
89 | if (!checkDatasetExists(dataset))
90 | {
91 | string ds = System.IO.Path.Combine(folder, dataset);
92 | valid = checkDatasetExists(ds);
93 | }
94 | else
95 | valid = true;
96 | }
97 | if (!valid)
98 | ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Unable to locate dataset '" + dataset + "'");
99 | return valid;
100 | }
101 |
102 | private bool checkDatasetExists(string dataset)
103 | {
104 | string _shp = ".shp";
105 | string _sde = ".sde\\";
106 | string _gdb = ".gdb\\";
107 | string _lyrx = ".lyrx";
108 | string _aprx = ".aprx";
109 | string _http = "http://";
110 | string _https = "https://";
111 | bool exists = false;
112 | if (dataset.ToLower().StartsWith(_http))
113 | {
114 | Uri ds = new Uri(dataset);
115 | try
116 | {
117 | var query = ds.Query; // just a simple url test
118 | exists = true;
119 | }
120 | catch { exists = false; }
121 |
122 | }
123 | if (dataset.ToLower().StartsWith(_https))
124 | {
125 | Uri ds = new Uri(dataset);
126 | try
127 | {
128 | var query = ds.Query; // just a simple url test
129 | exists = true;
130 | }
131 | catch { exists = false; }
132 |
133 | }
134 | if (dataset.ToLower().Contains(_sde))
135 | {
136 | string sde = dataset.Substring(0, dataset.LastIndexOf(_sde) + (_sde.Length-1));
137 | if (System.IO.File.Exists(sde)) // just checking .sde file
138 | exists = true;
139 | }
140 | if (dataset.ToLower().Contains(_gdb))
141 | {
142 | string db = dataset.Substring(0, dataset.LastIndexOf(_gdb) + (_gdb.Length-1));
143 | if (System.IO.Directory.Exists(db)) // just checking .gdb folder exists
144 | exists = true;
145 | }
146 | if (dataset.ToLower().EndsWith(_lyrx))
147 | {
148 | if (System.IO.File.Exists(dataset))
149 | exists = true;
150 | }
151 | if (dataset.ToLower().EndsWith(_aprx))
152 | {
153 | if (System.IO.File.Exists(dataset))
154 | exists = true;
155 | }
156 | if (dataset.ToLower().EndsWith(_shp))
157 | {
158 | if (System.IO.File.Exists(dataset))
159 | exists = true;
160 | }
161 | return exists;
162 | }
163 |
164 |
165 |
166 | }
167 | }
--------------------------------------------------------------------------------
/Shared/Dockpane1ViewModel.cs:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright 2016 Esri
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ***/
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 | using ArcGIS.Desktop.Framework;
22 | using ArcGIS.Desktop.Framework.Contracts;
23 | using ArcGIS.Desktop.Core.Geoprocessing;
24 | using ArcGIS.Desktop.Core;
25 | using ArcGIS.Desktop.Catalog;
26 |
27 | namespace DataAssistant
28 | {
29 | internal class Dockpane1ViewModel : DockPane
30 | {
31 | private const string _dockPaneID = "DataAssistant_Dockpane1";
32 |
33 | protected Dockpane1ViewModel() { }
34 |
35 | ///
36 | /// Show the DockPane.
37 | ///
38 | internal static void Show()
39 | {
40 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
41 |
42 | if (pane == null)
43 | return;
44 | pane.Activate();
45 | }
46 | internal static void doHide()
47 | {
48 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
49 |
50 | if (pane == null)
51 | return;
52 | pane.Hide();
53 | }
54 |
55 | ///
56 | /// Text shown near the top of the DockPane.
57 | ///
58 | private string _heading = "Configure Data Mapping";
59 | public string Heading
60 | {
61 | get { return _heading; }
62 | set
63 | {
64 | SetProperty(ref _heading, value, () => Heading);
65 | }
66 | }
67 | }
68 |
69 | ///
70 | /// Button implementation to show the DockPane.
71 | ///
72 | internal class Dockpane1_CreateFile : Button
73 | {
74 | protected override void OnClick()
75 | {
76 | setupGP.init();
77 | string source = "";
78 | string target = "";
79 | string file = System.IO.Path.Combine(Project.Current.HomeFolderPath,"SourceTarget.xml");
80 |
81 | var param_values = Geoprocessing.MakeValueArray(source,target,file);
82 |
83 | Geoprocessing.OpenToolDialog(setupGP.getToolbox("SourceTargetMapping"), param_values);
84 | }
85 | }
86 |
87 | internal class Dockpane1_ShowButton : Button
88 | {
89 | private const string _dockPaneID = "DataAssistant_Dockpane1";
90 | string fileloc = setupGP.init();
91 | protected override void OnClick()
92 | {
93 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
94 | try
95 | {
96 | //if (pane.IsVisible)
97 | // Dockpane1ViewModel.doHide();
98 | // else
99 | Dockpane1ViewModel.Show();
100 | }
101 | catch { }
102 | }
103 | }
104 | internal class Dockpane1_PreviewButton : Button
105 | {
106 | protected override void OnClick()
107 | {
108 | setupGP.init();
109 | var param_values = Geoprocessing.MakeValueArray(DataAssistant.Dockpane1View.getXmlFileName());
110 |
111 | Geoprocessing.OpenToolDialog(setupGP.getToolbox("Preview"), param_values);
112 | }
113 | }
114 | internal class Dockpane1_AppendDataButton : Button
115 | {
116 | protected override void OnClick()
117 | {
118 | setupGP.init();
119 | var param_values = Geoprocessing.MakeValueArray(DataAssistant.Dockpane1View.getXmlFileName());
120 |
121 | Geoprocessing.OpenToolDialog(setupGP.getToolbox("AppendData"), param_values);
122 | }
123 | }
124 | internal class Dockpane1_StageDataButton : Button
125 | {
126 | protected override void OnClick()
127 | {
128 | setupGP.init();
129 | var param_values = Geoprocessing.MakeValueArray(DataAssistant.Dockpane1View.getXmlFileName());
130 |
131 | Geoprocessing.OpenToolDialog(setupGP.getToolbox("StageData"), param_values);
132 | }
133 | }
134 | internal class Dockpane1_ReplaceDataButton : Button
135 | {
136 | protected override void OnClick()
137 | {
138 | setupGP.init();
139 | var param_values = Geoprocessing.MakeValueArray(DataAssistant.Dockpane1View.getXmlFileName());
140 |
141 | Geoprocessing.OpenToolDialog(setupGP.getToolbox("ReplaceData"), param_values);
142 | }
143 | }
144 | internal class setupGP : Button
145 | {
146 | public static string AddinAssemblyLocation()
147 | {
148 | var asm = System.Reflection.Assembly.GetExecutingAssembly();
149 | return System.IO.Path.GetDirectoryName(
150 | Uri.UnescapeDataString(
151 | new Uri(asm.CodeBase).LocalPath));
152 | }
153 | static string _gpFolder = System.IO.Path.Combine(AddinAssemblyLocation(),"GPTools");
154 | public static string init()
155 | {
156 | var projectFolders = Project.Current.GetItems();
157 | bool found = false;
158 | foreach (var FolderItem in projectFolders)
159 | {
160 | if (FolderItem.Path == _gpFolder)
161 | found = true;
162 | }
163 | if (!found)
164 | Helpers.AddProjectItem(_gpFolder);
165 |
166 | //var pth = Project.Current.DefaultToolboxPath;
167 |
168 | return _gpFolder;
169 | }
170 | public static string getToolbox(string toolname)
171 | {
172 | string gpref = System.IO.Path.Combine(setupGP._gpFolder, "DataLoadingAssistant.tbx", toolname);
173 | return gpref;
174 | }
175 | public static string getConfigFileName()
176 | {
177 | //Dockpane1View.getXmlFileName();
178 | return "";
179 | }
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/Shared/Dockpane2Settings.xaml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
59 |
60 |
61 |
62 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/Shared/Dockpane2Settings.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 | using System.Xml.Linq;
16 | using System.Data;
17 | using System.Collections.ObjectModel;
18 | using System.Globalization;
19 | using System.Windows.Controls.Primitives;
20 | using ArcGIS.Desktop.Core.Geoprocessing;
21 | using ArcGIS.Desktop.Core;
22 | using ArcGIS.Desktop.Catalog;
23 | using System.Xml;
24 | using System.Xml.Xsl;
25 | using System.Xml.XPath;
26 |
27 |
28 | namespace DataAssistant
29 | {
30 | ///
31 | /// Interaction logic for Dockpane2SettingsView.xaml
32 | ///
33 | public partial class Dockpane2SettingsView : UserControl
34 | {
35 | string _matchFile = System.IO.Path.Combine(Dockpane1View.AddinAssemblyLocation(), "GPTools\\arcpy\\MatchLocal.xml");
36 | string _xsltFile = System.IO.Path.Combine(Dockpane1View.AddinAssemblyLocation(), "GPTools\\arcpy\\FieldMatcher.xsl");
37 | public Dockpane2SettingsView()
38 | {
39 | InitializeComponent();
40 | }
41 | public void Enable()
42 | {
43 | this.MatchLibraryGrid.IsEnabled = true;
44 | }
45 | public void Disable()
46 | {
47 | this.MatchLibraryStack.IsEnabled = false;
48 | }
49 | private void UpdateMatchLibraryButton_Click(object sender, RoutedEventArgs e)
50 | {
51 | string xmlFile = Dockpane1View.getXmlFileName();
52 | if (xmlFile != "" && xmlFile != null)
53 | {
54 | if (System.Windows.Forms.MessageBox.Show("Update Match Library Values using the settings in your current configuration file?", "Update Match Library", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
55 | {
56 | XsltArgumentList argList = new XsltArgumentList();
57 | argList.AddParam("configFile", "", xmlFile);
58 | string outfile = _matchFile.Replace(".xml", "1.xml");
59 |
60 | runTransform(_matchFile, _xsltFile, outfile, argList);
61 | copyXml(outfile, _matchFile);
62 | }
63 | }
64 | else
65 | {
66 | System.Windows.Forms.MessageBox.Show("Please open a Configuration File before updating the Match Library", "Update Match Library");
67 | }
68 | }
69 |
70 | private void ResetMatchLibraryButton_Click(object sender, RoutedEventArgs e)
71 | {
72 | string xmlFile = Dockpane1View.getXmlFileName();
73 | if (xmlFile != "" && xmlFile != null)
74 | {
75 | if (System.Windows.Forms.MessageBox.Show("Clear all Match Library Values?", "Clear Match Library", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
76 | {
77 | XsltArgumentList argList = new XsltArgumentList();
78 | argList.AddParam("configFile", "", _matchFile);
79 | string outfile = _matchFile.Replace(".xml", "1.xml");
80 | runTransform(Dockpane1View.getXmlFileName(), _xsltFile, outfile, argList);
81 | copyXml(outfile, _matchFile);
82 | }
83 | }
84 | else
85 | {
86 | System.Windows.Forms.MessageBox.Show("Please open a Configuration File before clearing the Match Library", "Clear Match Library");
87 | }
88 |
89 | }
90 | public static bool runTransform(string xmlPath, string xsltPath, string outputPath, XsltArgumentList argList)
91 | {
92 | XmlTextReader reader = null;
93 | XmlWriter writer = null;
94 | try
95 | {
96 | XsltSettings xslt_set = new XsltSettings();
97 | xslt_set.EnableScript = true;
98 | xslt_set.EnableDocumentFunction = true;
99 |
100 | // Load the XML source file.
101 | reader = new XmlTextReader(xmlPath);
102 |
103 | // Create an XmlWriter.
104 | XmlWriterSettings settings = new XmlWriterSettings();
105 | settings.Indent = true;
106 | settings.Encoding = new UTF8Encoding();
107 | settings.OmitXmlDeclaration = false;
108 |
109 | writer = XmlWriter.Create(outputPath, settings);
110 |
111 | XslCompiledTransform xslt = new XslCompiledTransform();
112 | xslt.Load(xsltPath, xslt_set, new XmlUrlResolver());
113 | if (argList == null)
114 | xslt.Transform(reader, writer);
115 | else
116 | xslt.Transform(reader, argList, writer);
117 | reader.Close();
118 | writer.Close();
119 |
120 | return true;
121 | }
122 | catch (Exception err)
123 | {
124 | try
125 | {
126 | if (reader != null)
127 | reader.Close();
128 | if (writer != null)
129 | writer.Close();
130 | throw (err);
131 | }
132 | catch (Exception err2)
133 | {
134 | MessageBox.Show(err2.ToString());
135 | return false;
136 | }
137 | }
138 | }
139 | private bool copyXml(string fName1, string fName2)
140 | {
141 | System.IO.FileInfo fp1 = new System.IO.FileInfo(fName1);
142 | try
143 | {
144 | fp1.CopyTo(fName2, true);
145 | }
146 | catch (Exception e)
147 | {
148 | string errStr = e.Message;
149 | return false;
150 | }
151 | return true;
152 | }
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/Shared/Dockpane2SettingsViewModel.cs:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright 2016 Esri
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ***/
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 | using ArcGIS.Desktop.Framework;
22 | using ArcGIS.Desktop.Framework.Contracts;
23 |
24 | namespace DataAssistant
25 | {
26 | internal class Dockpane2SettingsViewModel : DockPane
27 | {
28 | private const string _dockPaneID = "DataAssistant_Dockpane2Settings";
29 |
30 | protected Dockpane2SettingsViewModel() { }
31 |
32 | ///
33 | /// Show the DockPane.
34 | ///
35 | internal static void Show()
36 | {
37 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
38 | if (pane == null)
39 | return;
40 |
41 | pane.Activate();
42 | }
43 | internal static void doHide()
44 | {
45 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
46 |
47 | if (pane == null)
48 | return;
49 | pane.Hide();
50 | }
51 | ///
52 | /// Text shown near the top of the DockPane.
53 | ///
54 | private string _heading = "Settings";
55 | public string Heading
56 | {
57 | get { return _heading; }
58 | set
59 | {
60 | SetProperty(ref _heading, value, () => Heading);
61 | }
62 | }
63 | }
64 |
65 | ///
66 | /// Button implementation to show the DockPane.
67 | ///
68 | internal class Dockpane2Settings_ShowButton : Button
69 | {
70 | private const string _dockPaneID = "DataAssistant_Dockpane2Settings";
71 | protected override void OnClick()
72 | {
73 | DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
74 | try
75 | {
76 | //if (pane.IsVisible)
77 | // Dockpane2SettingsViewModel.doHide();
78 | //else
79 | Dockpane2SettingsViewModel.Show();
80 | }
81 | catch { }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Shared/GPTools/DataLoadingAssistant.tbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/GPTools/DataLoadingAssistant.tbx
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/FieldMatcher.xsl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | match file field count =
43 | Looking for fields in new xmlDoc that are not in match list
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Looking for fields in new xmlDoc that are already in the match list
65 |
66 | unique fields
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 | no matching source field in Xml
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | everything does not match
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/MatchLocal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaAppendData.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaAppendData.py - Append Data to a database or service.
19 | # --------------------------------------------------------------------------------------------------------------
20 | '''
21 | Tool to append data to a target dataset. The script calls dlaPublish.publish with one or more
22 | xml file names separated by semi colons - the way that a multiple file parameter is passed from Geoprocessing tools.
23 |
24 | No data will be deleted in the target dataset, and all data from the source will be appended.
25 | '''
26 |
27 | import dlaPublish, arcpy, dla
28 |
29 | dlaPublish._useReplaceSettings = False # setting this to False will Append data
30 |
31 | arcpy.AddMessage("Appending Data")
32 |
33 | xmlFileNames = arcpy.GetParameterAsText(0) # xml file name as a parameter, multiple values separated by ;
34 | dla._errCount = 0
35 |
36 | dlaPublish.publish(xmlFileNames) # perform the processing
37 |
38 | dla.writeFinalMessage("Data Assistant - Append Data")
39 |
40 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaCreateSourceTarget.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaCreateSourceTarget.py - take a list of 2 datasets and export a Configuration file
19 | # December 2015
20 | # Loop through the source and target datasets and write an xml document
21 |
22 | import os, sys, traceback, time, xml.dom.minidom, arcpy, dla, dlaService
23 | from xml.dom.minidom import Document, parse, parseString
24 | import xml.etree.ElementTree as etree
25 | import re
26 |
27 | # Local variables...
28 | debug = False
29 | # Parameters
30 | source = arcpy.GetParameter(0) # source dataset to analyze
31 | sourceStr = arcpy.GetParameterAsText(0) # source dataset to analyze
32 | target = arcpy.GetParameter(1) # target dataset to analyze
33 | targetStr = arcpy.GetParameterAsText(1) # target dataset to analyze
34 |
35 | xmlFileName = arcpy.GetParameterAsText(2) # output file name argument
36 | matchLibrary = 'true' # arcpy.GetParameterAsText(3) always use automatch now. When starting the match library is blank anyway
37 | # so this will have no effect until the user starts working with it.
38 |
39 | if not xmlFileName.lower().endswith(".xml") and str(xmlFileName) != '':
40 | xmlFileName = xmlFileName + ".xml"
41 |
42 | if matchLibrary.lower() == 'true':
43 | matchLibrary = True
44 | else:
45 | matchLibrary = False
46 |
47 | dir = os.path.dirname(os.path.realpath(__file__))
48 |
49 | matchxslt = os.path.join(dir,"FieldMatcher.xsl")
50 | matchfile = os.path.join(dir,"MatchLocal.xml")
51 |
52 | def main(argv = None):
53 | global source,target,xmlFileName
54 |
55 | source = dla.checkIsLayerFile(source,sourceStr)
56 | target = dla.checkIsLayerFile(target,targetStr)
57 |
58 | dla.addMessage("Source: " + str(source))
59 | dla.addMessage("Target: " + str(target))
60 |
61 | dla.addMessage("File: " + xmlFileName)
62 | if not os.path.exists(matchxslt):
63 | msg = matchxslt + " does not exist, exiting"
64 | arcpy.AddError(msg)
65 | print(msg)
66 | return
67 | if not os.path.exists(matchfile):
68 | msg = matchfile + " does not exist, exiting"
69 | arcpy.AddError(msg)
70 | print(msg)
71 | return
72 | createDlaFile(source,target,xmlFileName)
73 |
74 | def createDlaFile(source,target,xmlFileName):
75 | # entry point for calling this tool from another python script
76 | res = False
77 | if str(source) == '' or str(target) == '':
78 | dla.addError("This tool requires both a source and target dataset, exiting.")
79 | elif str(source) == str(target):
80 | dla.addError("2 string layers with the same value is not supported by this tool, please rename one of the layers, exiting.")
81 | else:
82 | prj = dla.getProject()
83 | sourcePath = dla.getLayerPath(source)
84 | targetPath = dla.getLayerPath(target)
85 | if sourcePath == '' or targetPath == '':
86 | if sourcePath == '':
87 | dla.addError("Invalid Path/Type for Source layer , exiting: " + str(source) )
88 | if targetPath == '':
89 | dla.addError("Invalid Path/Type for Target layer, exiting: " + str(target) )
90 | return res
91 | else:
92 | res = writeDocument(sourcePath,targetPath,xmlFileName)
93 | return res
94 |
95 |
96 | def writeDocument(sourcePath,targetPath,xmlFileName):
97 |
98 | if sourcePath == None or targetPath == None:
99 | return False
100 | ## Warn user if capabilities are not correct, exit if not valid layers
101 | errs = False
102 | if dlaService.validateSourceUrl(sourcePath) == False:
103 | dla.addError("Errors in Source Service Capabilities, exiting without writing the output file")
104 | errs = True
105 | if dlaService.validateTargetUrl(targetPath) == False:
106 | dla.addError("Errors in Target Service Capabilities, exiting without writing the output file")
107 | errs = True
108 | try:
109 | desc = arcpy.Describe(sourcePath)
110 | except:
111 | dla.addError("Unable to Describe the source dataset, exiting")
112 | errs = True
113 | try:
114 | descT = arcpy.Describe(targetPath)
115 | except:
116 | dla.addError("Unable to Describe the target dataset, exiting")
117 | errs = True
118 |
119 | if errs:
120 | return False
121 |
122 | xmlDoc = Document()
123 | root = xmlDoc.createElement('SourceTargetMatrix')
124 | xmlDoc.appendChild(root)
125 | root.setAttribute("version",'1.1')
126 | root.setAttribute("xmlns:esri",'http://www.esri.com')
127 |
128 | dataset = xmlDoc.createElement("Datasets")
129 | root.appendChild(dataset)
130 | prj = dla.getProject()
131 | if prj == None:
132 | prj = ''
133 | else:
134 | prj = prj.filePath
135 | setSourceTarget(dataset,xmlDoc,"Project",dla.dropXmlFolder(xmlFileName,prj))
136 | setSourceTarget(dataset,xmlDoc,"Source",dla.dropXmlFolder(xmlFileName,sourcePath))
137 | setSourceTarget(dataset,xmlDoc,"Target",dla.dropXmlFolder(xmlFileName,targetPath))
138 |
139 | setSpatialReference(dataset,xmlDoc,desc,"Source")
140 | setSpatialReference(dataset,xmlDoc,descT,"Target")
141 |
142 | setSourceTarget(dataset,xmlDoc,"ReplaceBy","")
143 |
144 | fieldroot = xmlDoc.createElement("Fields")
145 | root.appendChild(fieldroot)
146 |
147 | fields = getFields(descT)
148 | sourceFields = getFields(desc)
149 | #sourceNames = [field.name[field.name.rfind(".")+1:] for field in sourceFields] ***
150 | sourceNames = [field.name for field in sourceFields]
151 | upperNames = [nm.upper() for nm in sourceNames]
152 |
153 | #try:
154 | for field in fields:
155 |
156 | fNode = xmlDoc.createElement("Field")
157 | fieldroot.appendChild(fNode)
158 | fieldName = field.name #[field.name.rfind(".")+1:] ***
159 | matchSourceFields(xmlDoc,fNode,field,fieldName,sourceNames,upperNames)
160 |
161 | # write the source field values
162 | setSourceFields(root,xmlDoc,sourceFields)
163 | setTargetFields(root,xmlDoc,fields)
164 |
165 | # add data to the document
166 | if len(sourceNames) > 0:
167 | writeDataSample(xmlDoc,root,sourceNames,sourcePath,10)
168 | # write it out
169 | xmlDoc.writexml( open(xmlFileName, 'wt', encoding='utf-8'),indent=" ",addindent=" ",newl='\n')
170 | xmlDoc.unlink()
171 | return True
172 |
173 | def setSpatialReference(dataset,xmlDoc,desc,lyrtype):
174 | if desc.datasetType.lower() == 'table':
175 | return
176 | try:
177 | spref = str(desc.spatialReference.factoryCode)
178 | if spref == None or spref == '' or spref == '0':
179 | setSourceTarget(dataset,xmlDoc,lyrtype + "SpatialReference",desc.spatialReference.exportToString())
180 | else:
181 | setSourceTarget(dataset,xmlDoc,lyrtype + "FactoryCode",spref)
182 | except:
183 | try:
184 | setSourceTarget(dataset,xmlDoc,lyrtype + "SpatialReference",desc.spatialReference.exportToString())
185 | except:
186 | dla.showTraceback()
187 | arcpy.AddError("Could not set Spatial Reference for " + lyrtype + " Layer")
188 |
189 | def matchSourceFields(xmlDoc,fNode,field,fieldName,sourceNames,upperNames):
190 | # match source field names - with and without automap
191 | enode = None
192 | count = 0
193 | nmupper = fieldName.upper()
194 | strippedNames = [name[name.rfind('.')+1:].upper() for name in sourceNames] # look for first match if there are prefixes
195 | if matchLibrary == True: # only do this if matchLibrary parameter is True
196 | doc = etree.parse(matchfile)
197 | nodes = doc.findall(".//Field[TargetName='"+fieldName+"']")
198 | for node in nodes:
199 | try: # get the highest count value for this target name where the source name is valid
200 | nodecount = int(node.get('count'))
201 | if nodecount > count:
202 | sname = node.find("SourceName").text
203 | if sname in sourceNames or sname == '' or sname == None or sname == dla._noneFieldName:
204 | enode = node
205 | count = nodecount
206 | except:
207 | pass
208 |
209 | if count > 0 and enode != None:
210 | addElements(xmlDoc,fNode,enode,fieldName)
211 | elif fieldName in sourceNames and enode == None:
212 | # no previous match but match on field name
213 | addFieldElement(xmlDoc,fNode,"SourceName",fieldName)
214 | addFieldElement(xmlDoc,fNode,"TargetName",fieldName)
215 | addFieldElement(xmlDoc,fNode,"Method",'Copy')
216 | elif nmupper in upperNames and enode == None:
217 | # logic for uppercase field name match, later the field will be renamed to essentially force a copy/rename unless something else set by user
218 | idx = upperNames.index(nmupper)
219 | addFieldElement(xmlDoc,fNode,"SourceName",sourceNames[idx]) # use the original source name
220 | addFieldElement(xmlDoc,fNode,"TargetName",fieldName) # use the original target name
221 | addFieldElement(xmlDoc,fNode,"Method",'Copy')
222 | elif nmupper in upperNames and enode == None:
223 | # logic for uppercase field name match, later the field will be renamed to essentially force a copy/rename unless something else set by user
224 | idx = upperNames.index(nmupper)
225 | addFieldElement(xmlDoc,fNode,"SourceName",sourceNames[idx]) # use the original source name
226 | addFieldElement(xmlDoc,fNode,"TargetName",fieldName) # use the original target name
227 | addFieldElement(xmlDoc,fNode,"Method",'Copy')
228 | elif nmupper in strippedNames and enode == None:
229 | # logic for prefixed field name match
230 | idx = None
231 | for i in range(0,len(strippedNames)):
232 | if strippedNames[i] == nmupper:
233 | idx = i # take the last matching value - if it exists again through a join more likely to want that value...
234 | #idx = strippedNames.index(nmupper)
235 | addFieldElement(xmlDoc,fNode,"SourceName",sourceNames[idx]) # use the original source name
236 | addFieldElement(xmlDoc,fNode,"TargetName",fieldName) # use the original target name
237 | addFieldElement(xmlDoc,fNode,"Method",'Copy')
238 | else:
239 | # otherwise just add None
240 | addFieldElement(xmlDoc,fNode,"SourceName",dla._noneFieldName)
241 | addFieldElement(xmlDoc,fNode,"TargetName",fieldName)
242 | addFieldElement(xmlDoc,fNode,"Method",'None')
243 |
244 | def addElements(xmlDoc,fNode,enode,fieldName):
245 | for item in enode:
246 | strval = etree.tostring(item)
247 | xml = parseString(strval)
248 | removeBlanks(xml)
249 | xml.normalize()
250 | fNode.appendChild(xml.documentElement)
251 |
252 | def removeBlanks(node):
253 | for x in node.childNodes:
254 | if x.nodeType == node.TEXT_NODE:
255 | if x.nodeValue:
256 | x.nodeValue = x.nodeValue.strip()
257 | elif x.nodeType == node.ELEMENT_NODE:
258 | removeBlanks(x)
259 |
260 | def setSourceTarget(root,xmlDoc,name,dataset):
261 | # set source and target elements
262 | sourcetarget = xmlDoc.createElement(name)
263 | nodeText = xmlDoc.createTextNode(dataset)
264 | sourcetarget.appendChild(nodeText)
265 | root.appendChild(sourcetarget)
266 |
267 | def setSourceFields(root,xmlDoc,fields):
268 | # Set SourceFields section of document
269 | sourceFields = xmlDoc.createElement("SourceFields")
270 | fNode = xmlDoc.createElement("SourceField")
271 | sourceFields.appendChild(fNode)
272 | fNode.setAttribute("Name",dla._noneFieldName)
273 |
274 | for field in fields:
275 | fNode = xmlDoc.createElement("SourceField")
276 | sourceFields.appendChild(fNode)
277 | fieldName = field.name # ***[field.name.rfind(".")+1:]
278 | fNode.setAttribute("Name",fieldName)
279 | fNode.setAttribute("AliasName",field.aliasName)
280 | fNode.setAttribute("Type",field.type)
281 | #if field.length != None:
282 | fNode.setAttribute("Length",str(field.length))
283 |
284 | root.appendChild(sourceFields)
285 |
286 | def setTargetFields(root,xmlDoc,fields):
287 | # Set TargetFields section of document
288 | targetFields = xmlDoc.createElement("TargetFields")
289 |
290 | for field in fields:
291 | fNode = xmlDoc.createElement("TargetField")
292 | targetFields.appendChild(fNode)
293 | fieldName = field.name #[field.name.rfind(".")+1:]
294 | fNode.setAttribute("Name",fieldName)
295 | fNode.setAttribute("AliasName",field.aliasName)
296 | fNode.setAttribute("Type",field.type)
297 | #if field.length != None:
298 | fNode.setAttribute("Length",str(field.length))
299 |
300 | root.appendChild(targetFields)
301 |
302 | def addFieldElement(xmlDoc,node,name,value):
303 | xmlName = xmlDoc.createElement(name)
304 | node.appendChild(xmlName)
305 | nodeText = xmlDoc.createTextNode(value)
306 | xmlName.appendChild(nodeText)
307 |
308 | def getFields(desc):
309 | fields = []
310 | ignore = dla.getIgnoreFieldNames(desc)
311 | ignore = [nm.upper() for nm in ignore]
312 |
313 | for field in desc.fields:
314 | if field.name[field.name.rfind('.')+1:].upper() not in ignore:
315 | fields.append(field)
316 |
317 | return fields
318 |
319 | def writeDataSample(xmlDoc,root,sourceFields,sourcePath,rowLimit):
320 | # get a subset of data for preview and other purposes
321 | i = 0
322 | data = xmlDoc.createElement("Data")
323 | root.appendChild(data)
324 |
325 | #if sourcePath.endswith('.lyrx'):
326 | # desc = arcpy.Describe(sourcePath) # dataset path/source as parameter
327 | # fields = desc.fields
328 | # sourceFields = [field.name for field in fields]
329 |
330 | cursor = arcpy.da.SearchCursor(sourcePath,sourceFields)
331 |
332 | i = 0
333 | prefixes = []
334 | for row in cursor:
335 | if i == 10:
336 | return
337 | xrow = xmlDoc.createElement("Row")
338 | for f in range(0,len(sourceFields)):
339 | try:
340 | xrow.setAttribute(sourceFields[f],str(row[f])) # handles numeric values and simple strings
341 | except:
342 | try:
343 | attrval = row[f].encode('utf-8', errors='replace').decode('utf-8',errors='backslashreplace') # handles non-utf-8 codes
344 | xrow.setAttribute(sourceFields[f],attrval)
345 | except:
346 | dla.showTraceback()
347 | pass # backslashreplace should never throw a unicode decode error...
348 |
349 | data.appendChild(xrow)
350 | i += 1
351 |
352 | del cursor
353 |
354 | if __name__ == "__main__":
355 | main()
356 |
357 |
358 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaExtractLayerToGDB.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # ---------------------------------------------------------------------------
19 | # dlaExtractLayerToGDB.py
20 | # Description: Import a .lyr file or feature layer to Geodatabase.
21 | # ---------------------------------------------------------------------------
22 |
23 | import os, sys, traceback, time, arcpy, dla
24 |
25 | xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter
26 | try:
27 | source = arcpy.GetParameterAsText(1) # Source Layer File to load from
28 | except:
29 | source = None
30 | try:
31 | dla.workspace = arcpy.GetParameterAsText(2) # Geodatabase
32 | except:
33 | dla.workspace = arcpy.env.scratchGDB
34 | try:
35 | rowLimit = arcpy.GetParameterAsText(3) # Number of records to extract
36 | except:
37 | rowLimit = None
38 | SUCCESS = 4 # parameter number for output success value
39 |
40 | def main(argv = None):
41 | global source,target
42 |
43 | xmlDoc = dla.getXmlDoc(xmlFileName)
44 | if dla.workspace == "" or dla.workspace == "#" or dla.workspace == None:
45 | dla.workspace = arcpy.env.scratchGDB
46 | if source == "" or source == None:
47 | source = dla.getDatasetPath(xmlDoc,"Source")
48 | if target == "" or target == None:
49 | target = dla.getDatasetPath(xmlDoc,"Target")
50 | if success == False:
51 | dla.addError("Errors occurred during process")
52 | if dla.isTable(source) or dla.isTable(target):
53 | datasetType = 'Table'
54 | else:
55 | datasetType = 'FeatureClass'
56 |
57 | success = extract(xmlFileName,rowLimit,dla.workspace,source,target,datasetType)
58 | arcpy.SetParameter(SUCCESS, success)
59 |
60 | def extract(xmlFileName,rowLimit,workspace,source,target,datasetType):
61 |
62 | xmlDoc = dla.getXmlDoc(xmlFileName)
63 | if workspace == "" or workspace == "#" or workspace == None:
64 | dla.workspace = dla.setWorkspace()
65 | else:
66 | dla.workspace = workspace
67 | fields = dla.getFields(xmlFileName)
68 | success = True
69 | name = ''
70 | try:
71 | if not arcpy.Exists(dla.workspace):
72 | dla.addMessage(dla.workspace + " does not exist, attempting to create")
73 | dla.createGeodatabase()
74 | if len(fields) > 0:
75 | arcpy.SetProgressor("step", "Importing Layer...",0,1,1)
76 |
77 | targetName = dla.getDatasetName(target)
78 | sourceName = dla.getDatasetName(source)
79 | arcpy.SetProgressorLabel("Loading " + sourceName + " to " + targetName +"...")
80 |
81 | if not arcpy.Exists(source):
82 | dla.addError("Layer " + source + " does not exist, exiting")
83 | return
84 |
85 | retVal = exportDataset(xmlDoc,source,dla.workspace,targetName,rowLimit,datasetType)
86 | if retVal == False:
87 | success = False
88 |
89 | arcpy.SetProgressorPosition()
90 | except:
91 | dla.addError("A Fatal Error occurred")
92 | dla.showTraceback()
93 | success = False
94 | finally:
95 | arcpy.ResetProgressor()
96 | #arcpy.RefreshCatalog(dla.workspace)
97 | arcpy.ClearWorkspaceCache_management(dla.workspace)
98 |
99 | return success
100 |
101 | def exportDataset(xmlDoc,source,workspace,targetName,rowLimit,datasetType):
102 | result = True
103 | xmlFields = xmlDoc.getElementsByTagName("Field")
104 | dla.addMessage("Exporting Data from " + source)
105 | whereClause = ""
106 | if rowLimit != None:
107 | whereClause = getObjectIdWhereClause(source,rowLimit)
108 |
109 | if whereClause != '' and whereClause != ' ':
110 | dla.addMessage("Where " + str(whereClause))
111 |
112 | sourceName = dla.getDatasetName(source)
113 | viewName = sourceName + "_View"
114 | dla.addMessage(viewName)
115 |
116 | targetRef = getSpatialReference(xmlDoc,"Target")
117 | sourceRef = getSpatialReference(xmlDoc,"Source")
118 | if datasetType == 'Table':
119 | isTable = True
120 | elif targetRef != '':
121 | isTable = False
122 |
123 | arcpy.env.workspace = workspace
124 | if source.lower().endswith('.lyrx') and not dla.hasJoin(source):
125 | view = dla.getLayerFromString(source)
126 | elif isTable:
127 | view = dla.makeTableView(dla.workspace,source,viewName,whereClause,xmlFields)
128 | elif not isTable:
129 | view = dla.makeFeatureView(dla.workspace,source,viewName,whereClause,xmlFields)
130 |
131 | dla.addMessage("View Created")
132 | srcCount = arcpy.GetCount_management(view).getOutput(0)
133 | dla.addMessage(str(srcCount) + " source rows")
134 | if str(srcCount) == '0':
135 | result = False
136 | dla.addError("Failed to extract " + sourceName + ", Nothing to export")
137 | else:
138 | arcpy.env.overwriteOutput = True
139 | ds = workspace + os.sep + targetName
140 | currentPreserveGlobalIDs = arcpy.env.preserveGlobalIds
141 | if dla.processGlobalIds(xmlDoc): # both datasets have globalids in the correct workspace types
142 | arcpy.env.preserveGlobalIds = True # try to preserve
143 | dla.addMessage("Attempting to preserve GlobalIDs")
144 | else:
145 | arcpy.env.preserveGlobalIds = False # don't try to preserve
146 | dla.addMessage("Unable to preserve GlobalIDs")
147 | if isTable:
148 | arcpy.TableToTable_conversion(in_rows=view,out_path=workspace,out_name=targetName)
149 | else:
150 | spRefMatch = dla.compareSpatialRef(xmlDoc)
151 | currentRef = arcpy.env.outputCoordinateSystem # grab currrent env settings
152 | currentTrans = arcpy.env.geographicTransformations
153 |
154 | if not spRefMatch:
155 | arcpy.env.outputCoordinateSystem = targetRef
156 | transformations = arcpy.ListTransformations(sourceRef, targetRef)
157 | transformations = ";".join(transformations) # concat the values - format change for setting the values.
158 | arcpy.env.geographicTransformations = transformations
159 |
160 | arcpy.FeatureClassToFeatureClass_conversion(in_features=view,out_path=workspace,out_name=targetName)
161 |
162 | if not spRefMatch: # set the spatial reference back
163 | arcpy.env.outputCoordinateSystem = currentRef
164 | arcpy.env.geographicTransformations = currentTrans
165 | arcpy.env.preserveGlobalIds = currentPreserveGlobalIDs
166 |
167 | removeDefaultValues(ds) # don't want to turn nulls into defaultValues in the intermediate data
168 |
169 | # not needed if doing the transformations approach above...
170 | # if isTable:
171 | # if not createDataset('Table',workspace,targetName,None,xmlDoc,source,None):
172 | # arcpy.AddError("Unable to create intermediate table, exiting: " + workspace + os.sep + targetName)
173 | # return False
174 |
175 | # elif not isTable:
176 | # geomType = arcpy.Describe(source).shapeType
177 | # if not createDataset('FeatureClass',workspace,targetName,geomType,xmlDoc,source,targetRef):
178 | # arcpy.AddError("Unable to create intermediate feature class, exiting: " + workspace + os.sep + targetName)
179 | # return False
180 | # fieldMap = getFieldMap(view,ds)
181 | # arcpy.Append_management(view,ds,schema_type="NO_TEST",field_mapping=fieldMap)
182 |
183 | dla.addMessage(arcpy.GetMessages(2)) # only serious errors
184 | count = arcpy.GetCount_management(ds).getOutput(0)
185 | dla.addMessage(str(count) + " source rows exported to " + targetName)
186 | if str(count) == '0':
187 | result = False
188 | dla.addError("Failed to load to " + targetName + ", it is likely that your data falls outside of the target Spatial Reference Extent or there is another basic issue")
189 | dla.addError("To verify please use the Append and/or Copy Features tool to load some data to an intermediate dataset:")
190 | dla.addError(ds)
191 | dla.showTraceback()
192 | return result
193 |
194 | def getFieldMap(view,ds):
195 |
196 | fieldMaps = arcpy.FieldMappings()
197 | fieldMaps.addTable(ds)
198 | inFields = [field.name for field in arcpy.ListFields(view) if field.name.upper() not in dla._ignoreFields] # not field.required removed after .Enabled issue
199 | removenames = []
200 | for i in range(fieldMaps.fieldCount):
201 | field = fieldMaps.fields[i]
202 | fmap = fieldMaps.getFieldMap(i)
203 | fName = field.name
204 | for s in range(0,fmap.inputFieldCount):
205 | try:
206 | fmap.removeInputField(0)
207 | except:
208 | pass
209 | try:
210 | f = -1
211 | try:
212 | f = inFields.index(fName) # simple case where names are equal
213 | except:
214 | f = inFields.index(fName.replace('_','.',1)) # just replace the first char - more complex case like xfmr.phase_designation
215 | if f > -1:
216 | inField = inFields[f]
217 | fmap.addInputField(view,inField)
218 | fieldMaps.replaceFieldMap(i,fmap)
219 | except:
220 | removenames.append(fName)
221 |
222 | for name in removenames:
223 | i = fieldMaps.findFieldMapIndex(name)
224 | fieldMaps.removeFieldMap(i)
225 | dla.addMessage(name + ' removed from fieldMappings')
226 |
227 | return fieldMaps
228 |
229 | #def printFieldMap(fieldMap):
230 |
231 | # for i in range(fieldMap.fieldCount):
232 | # fmap = fieldMap.getFieldMap(i)
233 | # dla.addMesage(str(fmap.getInputFieldName(0)) + ': ' + str(fmap.outputField.name))
234 |
235 | # return
236 |
237 |
238 | def createDataset(dsType,workspace,targetName,geomType,xmlDoc,source,targetRef):
239 |
240 | if source.lower().endswith('.lyrx') and dla.hasJoin(source):
241 | if dsType == 'Table':
242 | arcpy.CreateTable_management(workspace,targetName)
243 | else:
244 | arcpy.CreateFeatureclass_management(workspace,targetName,geometry_type=geomType,spatial_reference=targetRef)
245 |
246 | sourceFields = xmlDoc.getElementsByTagName("SourceField")
247 | for sfield in sourceFields:
248 | #
249 | fname = sfield.getAttributeNode('Name').nodeValue
250 | if fname.count('.') > 0:
251 | fname = fname.replace('.','_')
252 | ftype = sfield.getAttributeNode('Type').nodeValue
253 | flength = sfield.getAttributeNode('Length').nodeValue
254 | dla.addDlaField(os.path.join(workspace,targetName),fname,sfield,[],ftype,flength) # attrs is empty list
255 | else:
256 | if dsType == 'Table':
257 | try:
258 | arcpy.CreateTable_management(workspace,targetName,template=source)
259 | except:
260 | dla.addError("Unable to Create intermediate table")
261 | return False
262 | else:
263 | try:
264 | arcpy.CreateFeatureclass_management(workspace,targetName,template=source,spatial_reference=targetRef)
265 | except:
266 | dla.addError("Unable to Create intermediate feature class")
267 | return False
268 |
269 | return True
270 |
271 | def getSpatialReference(xmlDoc,lyrtype):
272 | spref = None
273 | # try factoryCode first
274 | sprefstr = dla.getNodeValue(xmlDoc,lyrtype + "FactoryCode")
275 | if sprefstr != '' and sprefstr != '0':
276 | #arcpy.AddMessage(lyrtype + ":" + sprefstr)
277 | spref = arcpy.SpatialReference(int(sprefstr))
278 | else:
279 | sprefstr = dla.getNodeValue(xmlDoc,lyrtype + "SpatialReference")
280 | if sprefstr != '':
281 | #arcpy.AddMessage(lyrtype + ":" + sprefstr)
282 | spref = arcpy.SpatialReference()
283 | spref.loadFromString(sprefstr)
284 |
285 | if spref == '' and spref != None:
286 | arcpy.AddError("Unable to retrieve Spatial Reference for " + lyrtype + " layer")
287 |
288 | return spref
289 |
290 | def getObjectIdWhereClause(table,rowLimit):
291 | # build a where clause, assume that oids are sequential or at least in row order...
292 | oidname = arcpy.Describe(table).oidFieldName
293 | #dla.addMessage(table + ' - ' + oidname)
294 | searchCursor = arcpy.da.SearchCursor(table,[oidname])
295 | ids = []
296 | # use the oidname in the where clause
297 | where = oidname + " <= " + str(rowLimit)
298 |
299 | for row in searchCursor:
300 | ids.append(row[0]) # sql server db does not always return OBJECTIDs sorted, no shortcut
301 |
302 | if len(ids) > 0:
303 | ids.sort() # sort the list and take the rowLimit number of rows
304 | minoid = ids[0]
305 | if len(ids) > rowLimit:
306 | maxoid = ids[rowLimit-1]
307 | else:
308 | maxoid = ids[len(ids)-1]
309 |
310 | where = oidname + " >= " + str(minoid) + " AND " + oidname + " <= " + str(maxoid)
311 |
312 | del ids
313 | del searchCursor
314 | return where
315 |
316 | def removeDefaultValues(dataset):
317 | # exported source fields may contain DefaultValues, which can replace None/null values in field calculations
318 | sourceFields = arcpy.ListFields(dataset) # xmlDoc.getElementsByTagName("SourceField")
319 | #stypes = arcpy.da.ListSubtypes(dataset) # my current understanding is that the intermediate/exported dataset will not have subtypes, just default/0 subtype if present in source dataset.
320 |
321 | dla.addMessage("Removing Default Value property from intermediate database fields")
322 | for sfield in sourceFields:
323 | fname = sfield.name
324 | if sfield.defaultValue != None:
325 | try:
326 | arcpy.AssignDefaultToField_management(in_table=dataset,field_name=fname,default_value=None,clear_value=True) # clear the Defaults
327 | except:
328 | dla.addMessage("Unable to set DefaultValue for " + fname) # skip GlobalIDs/other fields that cannot be updated. Should not have a default set in these cases
329 |
330 | if __name__ == "__main__":
331 | main()
332 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaPreview.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaPreview.py - Preview one source to a target with a limited number of rows
19 | # ------------------------------------------------------------------------------------
20 | import arcpy, os, dlaExtractLayerToGDB,dlaFieldCalculator,dla,datetime
21 |
22 | arcpy.AddMessage("Data Assistant - Preview")
23 |
24 | xmlFileName = arcpy.GetParameterAsText(0) # xml file name as a parameter
25 | try:
26 | rowLimit = arcpy.GetParameterAsText(1) # Row limit for preview
27 | rowLimit = int(rowLimit)
28 | if rowLimit == "" or rowLimit == "#":
29 | rowLimit = None
30 | except:
31 | rowLimit = None
32 | _success = 2 # the last param is the derived output layer
33 | source = None
34 | target = None
35 |
36 | def main(argv = None):
37 | preview(xmlFileName)
38 |
39 | def preview(xmlFileName):
40 | global source,target,rowLimit
41 |
42 | dla.setWorkspace()
43 | dla._errCount = 0
44 |
45 | xmlFileName = dla.getXmlDocName(xmlFileName)
46 | xmlDoc = dla.getXmlDoc(xmlFileName)
47 | #arcpy.AddMessage("rowLimit = " + str(rowLimit) )
48 | if rowLimit == "" or rowLimit == None:
49 | rowLimit = 100
50 |
51 | prj = dla.setProject(xmlFileName,dla.getNodeValue(xmlDoc,"Project"))
52 | if prj == None:
53 | dla.addError("Unable to open your project, please ensure it is in the same folder as your current project or your Config file")
54 | return False
55 |
56 | if source == "" or source == None:
57 | source = dla.getDatasetPath(xmlDoc,"Source")
58 | if target == "" or target == None:
59 | target = dla.getDatasetPath(xmlDoc,"Target")
60 |
61 | if dla.isTable(source) or dla.isTable(target):
62 | datasetType = 'Table'
63 | else:
64 | datasetType = 'FeatureClass'
65 | dte = datetime.datetime.now().strftime("%Y%m%d%H%M")
66 | targetName = dla.getDatasetName(target) + dte
67 | targetDS = os.path.join(dla.workspace,targetName)
68 | res = dlaExtractLayerToGDB.extract(xmlFileName,rowLimit,dla.workspace,source,targetDS,datasetType)
69 | if res == True:
70 | res = dlaFieldCalculator.calculate(xmlFileName,dla.workspace,targetName,False)
71 |
72 | if res == True:
73 | arcpy.env.addOutputsToMap = True
74 | layer = targetName
75 | layertmp = targetName + "tmp"
76 | if arcpy.Exists(layertmp):
77 | arcpy.Delete_management(layertmp)
78 | if dla.isTable(targetDS):
79 | arcpy.MakeTableView_management(targetDS,layertmp)
80 | else:
81 | arcpy.MakeFeatureLayer_management(targetDS,layertmp)
82 | fieldInfo = dla.getLayerVisibility(layertmp,xmlFileName)
83 | if dla.isTable(targetDS):
84 | arcpy.MakeTableView_management(targetDS,layer,None,dla.workspace,fieldInfo)
85 | else:
86 | arcpy.MakeFeatureLayer_management(targetDS,layer,None,dla.workspace,fieldInfo)
87 | # should make only the target fields visible
88 | arcpy.SetParameter(_success,layer)
89 | else:
90 | dla.addError("Failed to Extract data")
91 | print("Failed to Extract data")
92 | dla.writeFinalMessage("Data Assistant - Preview")
93 |
94 | if __name__ == "__main__":
95 | main()
96 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaPublish.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaPublish.py - Publish one source to a target
19 | # ----------------------------------------------------------------------------------------------------------------------
20 | '''
21 | This script is called by both Append Data and Replace Data tools. It has several options for running
22 | the tool using as a Geoprocessing script directly or by callng dlaPublish.publish from another script.
23 |
24 | Note in the GP script approach a source and target dataset can be provided as parameters to override the settings
25 | in the Xml Config file. In this case just a single xml file should be passed with the datasets as the 2nd and 3rd
26 | parameters. By default this will use the Append approach, to use replace by settings you can also make the
27 | useReplaceSettings variable to change the behavior (see example at the end of this script).
28 | '''
29 |
30 | import arcpy,dlaExtractLayerToGDB,dlaFieldCalculator,dlaService,dla,dlaService,xml.dom.minidom,os
31 |
32 | arcpy.AddMessage("Data Assistant")
33 |
34 | xmlFileNames = arcpy.GetParameterAsText(0) # xml file name as a parameter, multiple values separated by ;
35 | _outParam = 1
36 | _useReplaceSettings = False # change this from a calling script to make this script replace data.
37 |
38 | _chunkSize = 100
39 |
40 | def main(argv = None):
41 | # this approach makes it easier to call publish from other python scripts with using GP tool method
42 | publish(xmlFileNames)
43 |
44 | def publish(xmlFileNames):
45 | # function called from main or from another script, performs the data update processing
46 | global _useReplaceSettings
47 | dla._errCount = 0
48 |
49 | arcpy.SetProgressor("default","Data Assistant")
50 | arcpy.SetProgressorLabel("Data Assistant")
51 | xmlFiles = xmlFileNames.split(";")
52 | layers = []
53 |
54 | for xmlFile in xmlFiles: # multi value parameter, loop for each file
55 | xmlFile = dla.getXmlDocName(xmlFile)
56 | dla.addMessage("Configuration file: " + xmlFile)
57 | xmlDoc = dla.getXmlDoc(xmlFile) # parse the xml document
58 | if xmlDoc == None:
59 | return
60 | prj = dla.setProject(xmlFile,dla.getNodeValue(xmlDoc,"Project"))
61 | if prj == None:
62 | dla.addError("Unable to open your project, please ensure it is in the same folder as your current project or your Config file")
63 | return False
64 |
65 | source = dla.getDatasetPath(xmlDoc,"Source")
66 | target = dla.getDatasetPath(xmlDoc,"Target")
67 | targetName = dla.getDatasetName(target)
68 | dla.addMessage(source)
69 | dla.addMessage(target)
70 |
71 | if dlaService.checkLayerIsService(source) or dlaService.checkLayerIsService(target):
72 | token = dlaService.getSigninToken() # when signed in get the token and use this. Will be requested many times during the publish
73 | # exit here before doing other things if not signed in
74 | if token == None:
75 | dla.addError("User must be signed in for this tool to work with services")
76 | return False
77 |
78 | expr = getWhereClause(xmlDoc)
79 | if _useReplaceSettings == True and (expr == '' or expr == None):
80 | dla.addError("There must be an expression for replacing by field value, current value = " + str(expr))
81 | return False
82 |
83 | errs = False
84 | if dlaService.validateSourceUrl(source) == False:
85 | dla.addError("Source path does not appear to be a valid feature layer")
86 | errs = True
87 |
88 | if _useReplaceSettings == True:
89 | if dlaService.validateTargetReplace(target) == False:
90 | dla.addError("Target path does not have correct privileges")
91 | errs = True
92 | elif _useReplaceSettings == False:
93 | if dlaService.validateTargetAppend(target) == False:
94 | dla.addError("Target path does not have correct privileges")
95 | errs = True
96 |
97 | if errs:
98 | return False
99 |
100 |
101 | dla.setWorkspace()
102 |
103 | if dla.isTable(source) or dla.isTable(target):
104 | datasetType = 'Table'
105 | else:
106 | datasetType = 'FeatureClass'
107 |
108 | if not dla.isStaged(xmlDoc):
109 | res = dlaExtractLayerToGDB.extract(xmlFile,None,dla.workspace,source,target,datasetType)
110 | if res != True:
111 | table = dla.getTempTable(targetName)
112 | msg = "Unable to export data, there is a lock on existing datasets or another unknown error"
113 | if arcpy.TestSchemaLock(table) != True and arcpy.Exists(table) == True:
114 | msg = "Unable to export data, there is a lock on the intermediate feature class: " + table
115 | dla.addError(msg)
116 | print(msg)
117 | return
118 | else:
119 | res = dlaFieldCalculator.calculate(xmlFile,dla.workspace,targetName,False)
120 | if res == True:
121 | dlaTable = dla.getTempTable(targetName)
122 | res = doPublish(xmlDoc,dlaTable,target,_useReplaceSettings)
123 | else:
124 | dla.addMessage('Data previously staged, will proceed using intermediate dataset')
125 | dlaTable = dla.workspace + os.sep + dla.getStagingName(source,target)
126 | res = doPublish(xmlDoc,dlaTable,target,_useReplaceSettings)
127 | if res == True:
128 | dla.removeStagingElement(xmlDoc)
129 | xmlDoc.writexml(open(xmlFile, 'wt', encoding='utf-8'))
130 | dla.addMessage('Staging element removed from config file')
131 |
132 | arcpy.ResetProgressor()
133 | if res == False:
134 | err = "Data Assistant Update Failed, see messages for details"
135 | dla.addError(err)
136 | print(err)
137 | else:
138 | layers.append(target)
139 |
140 | arcpy.SetParameter(_outParam,';'.join(layers))
141 |
142 | def doPublish(xmlDoc,dlaTable,target,useReplaceSettings):
143 | # either truncate and replace or replace by field value
144 | # run locally or update agol
145 | success = False
146 | expr = ''
147 | dlaTable = handleGeometryChanges(dlaTable,target)
148 |
149 | if useReplaceSettings == True:
150 | expr = getWhereClause(xmlDoc)
151 | if useReplaceSettings == True and (expr == '' or expr == None):
152 | dla.addError("There must be an expression for replacing by field value, current value = '" + str(expr) + "'")
153 | return False
154 | currGlobalIDs = arcpy.env.preserveGlobalIds
155 | if dla.processGlobalIds(xmlDoc) and currGlobalIDs == False: # both datasets have globalids in the correct workspace types
156 | arcpy.env.preserveGlobalIds = True
157 | target = dla.getLayerPath(target)
158 | if target.startswith("http") == True:
159 | success = dlaService.doPublishHttp(dlaTable,target,expr,useReplaceSettings)
160 | else:
161 | # logic change - if not replace field settings then only append
162 | if expr != '' and useReplaceSettings == True:
163 | if dla.deleteRows(target,expr) == True:
164 | success = dla.appendRows(dlaTable,target,expr)
165 | else:
166 | success = False
167 | else:
168 | success = dla.appendRows(dlaTable,target,'')
169 |
170 | if currGlobalIDs != arcpy.env.preserveGlobalIds:
171 | arcpy.env.preserveGlobalIds = currGlobalIDs
172 | return success
173 |
174 | def getWhereClause(xmlDoc):
175 | # get the where clause using the xml document or return ''
176 | repl = xmlDoc.getElementsByTagName("ReplaceBy")[0]
177 | fieldName = dla.getNodeValue(repl,"FieldName")
178 | operator = dla.getNodeValue(repl,"Operator")
179 | value = dla.getNodeValue(repl,"Value")
180 | expr = ''
181 | type = getTargetType(xmlDoc,fieldName)
182 | if fieldName != '' and fieldName != '(None)' and operator != "Where":
183 | if type == 'String':
184 | value = "'" + value + "'"
185 | expr = fieldName + " " + operator + " " + value
186 |
187 | elif operator == 'Where':
188 | expr = value
189 | else:
190 | expr = '' # empty string by default
191 |
192 | return expr
193 |
194 | def getTargetType(xmlDoc,fname):
195 | # get the target field type
196 | for tfield in xmlDoc.getElementsByTagName('TargetField'):
197 | nm = tfield.getAttribute("Name")
198 | if nm == fname:
199 | return tfield.getAttribute("Type")
200 |
201 | def handleGeometryChanges(sourceDataset,target):
202 | # simplfiy polygons
203 | if dla.isTable(sourceDataset):
204 | return sourceDataset
205 | desc = arcpy.Describe(sourceDataset) # assuming local file gdb
206 | dataset = sourceDataset
207 | if desc.ShapeType == "Polygon" and (target.lower().startswith("http://") == True or target.lower().startswith("https://") == True):
208 | dataset = simplifyPolygons(sourceDataset)
209 | else:
210 | dataset = sourceDataset
211 |
212 | return dataset
213 |
214 | def simplifyPolygons(sourceDataset):
215 | # simplify polygons using approach developed by Chris Bus.
216 | dla.addMessage("Simplifying (densifying) Geometry")
217 | arcpy.Densify_edit(sourceDataset)
218 | simplify = sourceDataset + '_simplified'
219 | if arcpy.Exists(simplify):
220 | arcpy.Delete_management(simplify)
221 | if arcpy.Exists(simplify + '_Pnt'):
222 | arcpy.Delete_management(simplify + '_Pnt')
223 |
224 | arcpy.SimplifyPolygon_cartography(sourceDataset, simplify, "POINT_REMOVE", "1 Meters")
225 | return simplify
226 |
227 | if __name__ == "__main__":
228 | main()
229 |
230 |
231 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaReplaceByField.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaReplaceByField.py - use Replace field settings to replace content in a database or service.
19 | # --------------------------------------------------------------------------------------------------------------
20 | '''
21 | Tool to replace data by field value or where clause. The script calls dlaPublish.publish with one or more
22 | xml file names separated by semi colons - the way that a multiple file parameter is passed from Geoprocessing tools.
23 |
24 | Data will be deleted in the target dataset using the Replace By Settings, and all data from the source will be appended.
25 | '''
26 | import dlaPublish, arcpy, dla
27 |
28 | dlaPublish._useReplaceSettings = True # setting this to True will use ReplaceByField logic
29 |
30 | arcpy.AddMessage("Replacing by Field Value")
31 |
32 | xmlFileNames = arcpy.GetParameterAsText(0) # xml file name as a parameter, multiple values separated by ;
33 | dla._errCount = 0
34 |
35 | dlaPublish.publish(xmlFileNames) # perform the processing
36 |
37 | dla.writeFinalMessage("Data Assistant - Replace Data")
38 |
39 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaService.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaService - functions that interact with ArcGIS Online/Portal Services - refactored from dla.py and dlaPublish.py in Dec 2016
19 | # ----------------------------------------------------------------------------------------------------------------------
20 | '''
21 | '''
22 | import arcpy,dla,xml.dom.minidom,os
23 | import json, urllib
24 | import urllib.parse as parse
25 | import urllib.request as request
26 |
27 | _chunkSize = 100
28 |
29 | def getOIDs(targetUrl,expr):
30 | # get the list of oids.
31 | ids = []
32 | arcpy.SetProgressor("default","Querying Existing Rows")
33 | arcpy.SetProgressorLabel("Querying Existing Rows")
34 | url = targetUrl + '/query'
35 | #dla.addMessage("Url:"+url)
36 | token = getSigninToken()
37 | if expr != '':
38 | params = {'f': 'pjson', 'where': expr,'token':token,'returnIdsOnly':'true'}
39 | else:
40 | params = {'f': 'pjson', 'where': '1=1','token':token,'returnIdsOnly':'true'}
41 |
42 | #dla.addMessage("Params:"+json.dumps(params))
43 | result = sendRequest(url,params)
44 | try:
45 | if result['error'] != None:
46 | retval = False
47 | dla.addMessage("Query Rows from Service failed")
48 | dla.addMessage(json.dumps(result))
49 | error = True
50 | except:
51 | ids = result['objectIds']
52 | lenFound = len(ids)
53 | msg = str(lenFound) + " Rows found in existing Service"
54 | print(msg)
55 | dla.addMessage(msg)
56 | retval = True
57 |
58 | return ids
59 |
60 | def deleteRows(source,targetUrl,expr):
61 | # delete Rows using chunks of _chunkSize
62 | retval = False
63 | error = False
64 | # delete section
65 | ids = getOIDs(targetUrl,expr)
66 | try:
67 | lenDeleted = 100
68 | #Chunk deletes using chunk size at a time
69 | rowsProcessed = 0
70 | numFeat = len(ids)
71 | if numFeat == 0:
72 | dla.addMessage("0 Rows to Delete, exiting")
73 | return True # nothing to delete is OK
74 | if numFeat > _chunkSize:
75 | chunk = _chunkSize
76 | else:
77 | chunk = numFeat
78 | arcpy.SetProgressor("default","Deleting Rows")
79 | while rowsProcessed < numFeat and error == False:
80 | #Chunk deletes using chunk size at a time
81 | next = rowsProcessed + chunk
82 | msg = "Deleting rows " + str(rowsProcessed) + ":" + str(next)
83 | dla.addMessage(msg)
84 | arcpy.SetProgressorLabel(msg)
85 | oids = ",".join(str(e) for e in ids[rowsProcessed:next])
86 | url = targetUrl + '/deleteFeatures'
87 | token = getSigninToken()
88 | params = {'f': 'pjson', 'objectIds': oids,'token':token}
89 | result = sendRequest(url,params)
90 | try:
91 | if result['error'] != None:
92 | retval = False
93 | dla.addMessage("Delete rows from Service failed")
94 | dla.addMessage(json.dumps(result))
95 | error = True
96 | except:
97 | try:
98 | lenDeleted = len(result['deleteResults'])
99 | total = rowsProcessed + chunk
100 | if total > numFeat:
101 | total = numFeat
102 | msg = str(lenDeleted) + " rows deleted, " + str(total) + "/" + str(numFeat)
103 | print(msg)
104 | dla.addMessage(msg)
105 | retval = True
106 | except:
107 | retval = False
108 | error = True
109 | dla.showTraceback()
110 | dla.addMessage("Delete rows from Service failed")
111 | dla.addError(json.dumps(result))
112 | rowsProcessed += chunk
113 | except:
114 | retval = False
115 | error = True
116 | dla.showTraceback()
117 | dla.addMessage("Delete rows from Service failed")
118 | pass
119 |
120 | return retval
121 |
122 | def addRows(source,targetUrl,expr):
123 | # add rows using _chunkSize
124 | retval = False
125 | error = False
126 | # add section
127 | try:
128 | arcpy.SetProgressor("default","Adding Rows")
129 | arcpy.SetProgressorLabel("Adding Rows")
130 | rowjs = rowsToJson(source)
131 | url = targetUrl + '/addFeatures'
132 | try:
133 | numFeat = len(rowjs['features'])
134 | except:
135 | numFeat = 0
136 | if numFeat == 0:
137 | dla.addMessage("0 Rows to Add, exiting")
138 | return True # nothing to add is OK
139 | if numFeat > _chunkSize:
140 | chunk = _chunkSize
141 | else:
142 | chunk = numFeat
143 | rowsProcessed = 0
144 | while rowsProcessed < numFeat and error == False:
145 | next = rowsProcessed + chunk
146 | rows = rowjs['features'][rowsProcessed:next]
147 | msg = "Adding rows " + str(rowsProcessed) + ":" + str(next)
148 | dla.addMessage(msg)
149 | arcpy.SetProgressorLabel(msg)
150 | token = getSigninToken()
151 | params = {'rollbackonfailure': 'true','f':'json', 'token':token, 'features': json.dumps(rows)}
152 | result = sendRequest(url,params)
153 | try:
154 | if result['error'] != None:
155 | retval = False
156 | dla.addMessage("Add rows to Service failed")
157 | dla.addMessage(json.dumps(result))
158 | error = True
159 | except:
160 | try:
161 | lenAdded = len(result['addResults'])
162 | total = rowsProcessed + chunk
163 | if total > numFeat:
164 | total = numFeat
165 | msg = str(lenAdded) + " rows added, " + str(total) + "/" + str(numFeat)
166 | print(msg)
167 | dla.addMessage(msg)
168 | retval = True
169 | except:
170 | retval = False
171 | dla.addMessage("Add rows to Service failed. Unfortunately you will need to re-run this tool.")
172 | #dla.showTraceback()
173 | #dla.addError(json.dumps(result))
174 | error = True
175 | rowsProcessed += chunk
176 | except:
177 | retval = False
178 | dla.addMessage("Add rows to Service failed")
179 | dla.showTraceback()
180 | error = True
181 | pass
182 |
183 | return retval
184 |
185 | def doPublishHttp(source,targetUrl,expr,useReplaceSettings):
186 | # logic for publishing to service registered on Portal or ArcGIS Online
187 | retval = True
188 | token = getSigninToken()
189 | if token == None:
190 | dla.addError("Unable to retrieve token, exiting")
191 | return False
192 | dla.setupProxy()
193 | if expr != '' and useReplaceSettings == True:
194 | arcpy.SetProgressor("default","Deleting Existing Rows")
195 | arcpy.SetProgressorLabel("Deleting Existing Rows")
196 | retval = deleteRows(source,targetUrl,expr)
197 | if retval == True:
198 | arcpy.SetProgressor("default","Appending Rows")
199 | arcpy.SetProgressorLabel("Appending Rows")
200 | #retval = dla.appendRows(source,targetUrl,expr) does this work from a local file gdb? I can't make it...
201 | retval = addRows(source,targetUrl,expr)
202 |
203 | return retval
204 |
205 | def rowsToJson(dataset):
206 | # converts a feature class/table to a json dictionary representation
207 | try:
208 | rows = arcpy.FeatureSet(dataset) # Load the feature layer into a feature set
209 | except:
210 | rows = arcpy.RecordSet(dataset) # Load the feature layer into a feature set
211 |
212 | desc = arcpy.Describe(rows) # use the json property of the feature set
213 | return json.loads(desc.json)
214 |
215 | def sendRequest(url, qDict=None, headers=None):
216 | """Robust request maker - from github https://github.com/khibma/ArcGISProPythonAssignedLicensing/blob/master/ProLicense.py"""
217 | #Need to handle chunked response / incomplete reads. 2 solutions here: http://stackoverflow.com/questions/14442222/how-to-handle-incompleteread-in-python
218 | #This function sends a request and handles incomplete reads. However its found to be very slow. It adds 30 seconds to chunked
219 | #responses. Forcing the connection to HTTP 10 (1.0) at the top, for some reason makes it faster.
220 |
221 | qData = parse.urlencode(qDict).encode('UTF-8') if qDict else None
222 | reqObj = request.Request(url)
223 |
224 | if headers != None:
225 | for k, v in headers.items():
226 | reqObj.add_header(k, v)
227 |
228 | try:
229 | if qDict == None: #GET
230 | r = request.urlopen(reqObj)
231 | else: #POST
232 | r = request.urlopen(reqObj, qData)
233 | responseJSON=""
234 | while True:
235 | try:
236 | responseJSONpart = r.read()
237 | except client.IncompleteRead as icread:
238 | responseJSON = responseJSON + icread.partial.decode('utf-8')
239 | continue
240 | else:
241 | responseJSON = responseJSON + responseJSONpart.decode('utf-8')
242 | break
243 |
244 | return (json.loads(responseJSON))
245 |
246 | except Exception as RESTex:
247 | print("Exception occurred making REST call: " + RESTex.__str__())
248 |
249 | def openRequest(url,params):
250 | """
251 | Open an http request, handles the difference between urllib and urllib2 implementations if the includes are
252 | done correctly in the imports section of this file. Currently disabled.
253 | """
254 | response = None
255 | if uselib2 == True:
256 | data = urllib.urlencode(params)
257 | data = data.encode('utf8')
258 | req = urllib2.Request(url,data)
259 | response = urllib2.urlopen(req)
260 | else:
261 | data = parse.urlencode(params)
262 | data = data.encode('utf8')
263 | req = request.Request(url,data)
264 | response = request.urlopen(req)
265 |
266 | return response
267 |
268 | def getSigninToken():
269 | data = arcpy.GetSigninToken()
270 | token = None
271 | if data is not None:
272 | token = data['token']
273 | #expires = data['expires']
274 | #referer = data['referer']
275 | else:
276 | arcpy.AddMessage("Error: No token - Please sign in to ArcGIS Online or your Portal to continue")
277 | return token
278 |
279 | ## Added May 2016
280 | def hasCapabilities(url,token,checkList):
281 | hasit = False
282 | if token != None and isFeatureLayerUrl(url):
283 | params = {'f': 'pjson', 'token':token}
284 | response = sendRequest(url,params)
285 | if response != None:
286 | try:
287 | error = json.dumps(response['error'])
288 | dla.addError('Unable to access service properties ' + error)
289 | return False
290 | except:
291 | hasit = True
292 |
293 | try:
294 | capabilities = json.dumps(response['capabilities'])
295 | dla.addMessage('Service REST capabilities: ' + capabilities)
296 | for item in checkList:
297 | if capabilities.find(item) == -1:
298 | #dla.addMessage('Service does not support: ' + item)
299 | hasit = False
300 | else:
301 | dla.addMessage('Service supports: ' + item)
302 | except:
303 | dla.addError('Unable to access service capabilities')
304 | hasit = False
305 | else:
306 | dla.addError('Unable to access service')
307 | hasit = False
308 |
309 | return hasit
310 |
311 | def getServiceName(url):
312 | parts = url.split('/')
313 | lngth = len(parts)
314 | if len(parts) > 8:
315 | dla.addMessage("Service Name: " + parts[len(parts)-3])
316 | return parts[len(parts)-3]
317 | else:
318 | return None
319 |
320 | def isFeatureLayerUrl(url):
321 | # assume layer string has already had \ and GIS Servers or other characters switched to be a url
322 | parts = url.split('/')
323 | lngth = len(parts)
324 | try:
325 | # check for number at end
326 | # last = int(parts[lngth-1])
327 | if parts[lngth-2] == 'FeatureServer':
328 | return True
329 | except:
330 | dla.addError("2nd last part of url != 'FeatureServer'")
331 | return False
332 |
333 | def checkLayerIsService(layerStr):
334 | ## moved here from dlaPublish
335 | # Check if the layer string is a service
336 | if layerStr.lower().startswith("http") == True or layerStr.lower().startswith("gis servers") == True:
337 | return True
338 | else:
339 | return False
340 |
341 | def checkServiceCapabilities(pth,checklist):
342 | res = False
343 | if pth == None:
344 | dla.addMessage('Error: No path available for layer')
345 | return False
346 | if checkLayerIsService(pth):
347 | url = pth
348 | if isFeatureLayerUrl(url):
349 | data = arcpy.GetSigninToken()
350 | token = data['token']
351 | name = getServiceName(url)
352 | if name != None:
353 | # checklist is a list like: ['Create','Delete']
354 | res = hasCapabilities(url,token,checklist)
355 | if res != True:
356 | dla.addMessage('WARNING: ' + name + ' does not have ' + '+'.join(checklist) + ' privileges')
357 | dla.addMessage('Verify the service properties for: ' + url)
358 | dla.addMessage('This tool will not run until this is addressed')
359 | return res
360 | else:
361 | dla.addMessage("Unable to retrieve Service name from the url")
362 | return res
363 | else:
364 | dla.addMessage(pth + ' Does not appear to be a feature service layer, exiting. Check that you selected a layer not a service')
365 | return False
366 | else:
367 | return None # if it's not a service return None
368 |
369 |
370 | def validateSourceUrl(pth):
371 | valid = checkServiceCapabilities(pth,['Query'])
372 | return valid # can be None, True, False
373 |
374 | def validateTargetUrl(pth):
375 | valid = checkServiceCapabilities(pth,['Create','Delete'])
376 | return valid # can be None, True, False
377 |
378 | def validateTargetAppend(pth):
379 | valid = checkServiceCapabilities(pth,['Create'])
380 | return valid # can be None, True, False
381 |
382 | def validateTargetReplace(pth):
383 | valid = validateTargetUrl(pth)
384 | return valid # can be None, True, False
385 |
386 |
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/dlaStage.py:
--------------------------------------------------------------------------------
1 | """
2 | -------------------------------------------------------------------------------
3 | | Copyright 2016 Esri
4 | |
5 | | Licensed under the Apache License, Version 2.0 (the "License");
6 | | you may not use this file except in compliance with the License.
7 | | You may obtain a copy of the License at
8 | |
9 | | http://www.apache.org/licenses/LICENSE-2.0
10 | |
11 | | Unless required by applicable law or agreed to in writing, software
12 | | distributed under the License is distributed on an "AS IS" BASIS,
13 | | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | | See the License for the specific language governing permissions and
15 | | limitations under the License.
16 | ------------------------------------------------------------------------------
17 | """
18 | # dlaPreview.py - Preview one source to a target with a limited number of rows
19 | # ------------------------------------------------------------------------------------
20 | import arcpy, os, dlaExtractLayerToGDB,dlaFieldCalculator,dla,datetime
21 |
22 | arcpy.AddMessage("Data Assistant - Stage")
23 |
24 | xmlFileNames = arcpy.GetParameterAsText(0) # xml file name as a parameter
25 | _derived = 1 # the last param is the derived output layer
26 | source = None
27 | target = None
28 | rowLimit = None
29 |
30 | def main(argv = None):
31 | stage(xmlFileNames)
32 |
33 | def stage(xmlFileNames):
34 | global source,target,rowLimit
35 |
36 | dla.setWorkspace()
37 | dla._errCount = 0
38 | outlayers = []
39 |
40 | for xmlFileName in xmlFileNames.split(';'):
41 | xmlFileName = dla.getXmlDocName(xmlFileName)
42 | xmlDoc = dla.getXmlDoc(xmlFileName)
43 | prj = dla.setProject(xmlFileName,dla.getNodeValue(xmlDoc,"Project"))
44 | if prj == None:
45 | dla.addError("Unable to open your project, please ensure it is in the same folder as your current project or your Config file")
46 |
47 | if rowLimit == "" or rowLimit == None:
48 | rowLimit = None
49 | if source == "" or source == None:
50 | source = dla.getDatasetPath(xmlDoc,"Source")
51 | if target == "" or target == None:
52 | target = dla.getDatasetPath(xmlDoc,"Target")
53 |
54 | if dla.isTable(source) or dla.isTable(target):
55 | datasetType = 'Table'
56 | else:
57 | datasetType = 'FeatureClass'
58 |
59 | targetName = dla.getStagingName(source,target)
60 | targetDS = os.path.join(dla.workspace,targetName)
61 |
62 | res = dlaExtractLayerToGDB.extract(xmlFileName,rowLimit,dla.workspace,source,targetDS,datasetType)
63 | if res == True:
64 | res = dlaFieldCalculator.calculate(xmlFileName,dla.workspace,targetName,False)
65 |
66 | if res == True:
67 | arcpy.env.addOutputsToMap = True
68 | layer = targetName
69 | layertmp = targetName + "tmp"
70 | if arcpy.Exists(layertmp):
71 | arcpy.Delete_management(layertmp)
72 | if dla.isTable(targetDS):
73 | arcpy.MakeTableView_management(targetDS,layertmp)
74 | else:
75 | arcpy.MakeFeatureLayer_management(targetDS,layertmp)
76 | fieldInfo = dla.getLayerVisibility(layertmp,xmlFileName)
77 | if dla.isTable(targetDS):
78 | arcpy.MakeTableView_management(targetDS,layer,None,dla.workspace,fieldInfo)
79 | else:
80 | arcpy.MakeFeatureLayer_management(targetDS,layer,None,dla.workspace,fieldInfo)
81 | # should make only the target fields visible
82 | outlayers.append(layer)
83 | ### *** need to insert tag in xml file...
84 | dla.insertStagingElement(xmlDoc)
85 | try:
86 | xmlDoc.writexml( open(xmlFileName, 'wt', encoding='utf-8'))
87 | dla.addMessage('Staging element written to config file')
88 | except:
89 | dla.addMessage("Unable to write data to xml file")
90 | xmlDoc.unlink()
91 | else:
92 | dla.addError("Failed to Extract data")
93 | print("Failed to Extract data")
94 | if outlayers != []:
95 | arcpy.SetParameter(_derived,";".join(outlayers))
96 | dla.writeFinalMessage("Data Assistant - Stage")
97 |
98 | if __name__ == "__main__":
99 | main()
--------------------------------------------------------------------------------
/Shared/GPTools/arcpy/testHarness.py:
--------------------------------------------------------------------------------
1 | import os,arcpy, dla, dlaCreateSourceTarget,dlaPreview,dlaPublish,dlaStage
2 |
3 | projFolder = r"C:\Users\Steve\Documents\ArcGIS\Projects\DomainTest"
4 |
5 | def main():
6 | test1()
7 |
8 | def test0():
9 | dlaStage.stage(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\ForSteve\CurbStopValves.xml")
10 |
11 |
12 | def test01():
13 | #dla.setProject(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject1\transformerUnit_to_ElectricDevice2.xml","MyProject1.aprx")
14 | #dlaStage.stage(r"C:\Users\Steve\Documents\ArcGIS\Projects\DomainTest\SourceTarget.xml")
15 | #dlaPublish.useReplaceSettings = True
16 | #dlaPreview.preview(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject1\transformerUnit_to_ElectricDevice2.xml")
17 | #dlaPublish.publish(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\testjoin.xml")
18 | dlaPreview.preview(r"C:\Users\Steve\Documents\ArcGIS\Projects\DomainTest\SourceTarget.xml")
19 |
20 | def testCreate():
21 | projFolder = r"C:\Users\Steve\Documents\ArcGIS\Projects\DomainTest"
22 | dla.setProject(os.path.join(projFolder,"SourceTarget.xml"),(os.path.join(projFolder,"DomainTest.aprx")))
23 | dlaCreateSourceTarget.createDlaFile(os.path.join(projFolder,r'DomainTest.gdb\WaterValve'),
24 | os.path.join(projFolder,r'DomainTest.gdb\WaterDevice'),
25 | os.path.join(projFolder,'SourceTarget.xml'))
26 |
27 |
28 | def test1():
29 | #dla._project = arcpy.mp.ArcGISProject(os.path.join(projFolder,"MyProject.aprx"))
30 | dlaCreateSourceTarget.createDlaFile(r"GIS Servers\https://services2.arcgis.com/EmOtS7q6cfSmspIo/arcgis/rest/services/MCC_Map/FeatureServer/L0Boat",
31 | r"https://services3.arcgis.com/xoil9QbyeUaxAZtF/arcgis/rest/services/Stormwater_OpenDrain_5015368ed0dc4f75a2103bb8dc7b3208/FeatureServer/0",
32 | r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\testjoin.xml")
33 |
34 |
35 | #fcfields = arcpy.ListFields(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\SampleData.gdb\SampleData")
36 | #tfields = arcpy.ListFields(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\SampleData.gdb\SampleTable")
37 |
38 | #vfields = getViewString(tfields,fcfields)
39 | #result = arcpy.MakeFeatureLayer_management(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject\SampleData.gdb\SampleData","Join1")
40 |
41 |
42 | #layer = dla.getMapLayer("JoinTest")
43 | #lname = layer.name
44 | #result = arcpy.MakeFeatureLayer_management(layer,lname)
45 | #layer = result.getOutput(0)
46 | #lyrFile = dla.getLayerPath(layer)
47 |
48 | #layer = dla.getMapLayer("JoinTest")
49 | #arcpy.env.overwriteOutput = True
50 | #lyrFile = os.path.join(projFolder,lname)
51 | #arcpy.SaveToLayerFile_management(layer,lyrFile)
52 | #desc = arcpy.Describe(lyrFile)
53 | #pth = dla.getLayerPath(lyrFile)
54 | #tmp = desc.catalogPath
55 | #fields = arcpy.ListFields(lyrFile)
56 |
57 | #result = arcpy.MakeFeatureLayer_management(lyrFile,lname)
58 | #layer = result.getOutput(0)
59 | #try:
60 | # tmp = layer.connectionProperties
61 | # for item in tmp:
62 | # print(str(item),tmp[item])
63 | # src = tmp['source']
64 | # dest = tmp['destination']
65 | # print(src['dataset'])
66 | # print(src['connection_info']['database'])
67 | # print(dest['dataset'])
68 | # print(dest['connection_info']['database'])
69 | #except:
70 | # pass
71 |
72 | #result = arcpy.MakeFeatureLayer_management(r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject15\MyProject15.gdb\test",
73 | # "testTHIS")
74 | #layer = result.getOutput(0)
75 | #layer = dla.getLayer("Test")
76 | #if isinstance(layer, arcpy._mp.Layer):
77 | # print(layer.dataSource)
78 | #else:
79 | # desc = arcpy.Describe(layer)
80 | # print(desc.catalogPath)
81 |
82 | def getViewString(fields,fields2):
83 | # get the string for creating a view
84 | viewStr = ""
85 | for field in fields: # drop any field prefix from the source layer (happens with map joins)
86 | thisFieldName = field.name[field.name.rfind(".")+1:]
87 | for field2 in fields2:
88 | matchname = field2.name[field2.name.rfind(".")+1:]
89 | if matchname != thisFieldName and matchname.upper() == thisFieldName.upper():
90 | # this is a special case where the source name is different case but the same string as the target
91 | # need to create table so that the name matches the target name so there is no conflict later
92 | thisFieldName = targetname
93 |
94 | thisFieldStr = field.name + " " + thisFieldName + " VISIBLE NONE;"
95 | viewStr += thisFieldStr
96 |
97 | return viewStr
98 |
99 |
100 |
101 | def test2():
102 |
103 | dla._project = arcpy.mp.ArcGISProject(r"C:\Users\Steve\Documents\ArcGIS\Projects\pbmpolygons\pbmpolygons.aprx")
104 | ws = r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject11\shp\Data Assistant 10.4 Testing\pbmnorepair.gdb"
105 | base = "pbmpoly"
106 | res = arcpy.GetCount_management(os.path.join(ws,base))
107 | cnt = int(res.getOutput(0))
108 | chunk = 100000
109 | lngth = int(cnt/chunk)
110 |
111 | for group in range (0,lngth):
112 |
113 | minoid = group * chunk
114 | where = 'OBJECTID > '+ str(minoid) + ' AND OBJECTID <= ' + str(minoid+chunk)
115 | dla.addMessage(where)
116 |
117 | layername = "pbmpolys"
118 | if arcpy.Exists(layername):
119 | arcpy.Delete_management(layername)
120 | result = arcpy.MakeFeatureLayer_management(in_features=os.path.join(ws,base),where_clause=where,workspace=ws,out_layer=layername)
121 |
122 | cnt = result.getOutput(0)
123 | outpath = r"C:\Users\Steve\Documents\ArcGIS\Projects\MyProject11\shp\Data Assistant 10.4 Testing\pbm.gdb"
124 | outname = "pbmpoly"+str(group)
125 | ds = os.path.join(outpath,outname)
126 | if arcpy.Exists(ds):
127 | arcpy.Delete_management(ds)
128 | arcpy.FeatureClassToFeatureClass_conversion(in_features=layername,out_path=outpath,out_name=outname)
129 |
130 | outdoc = r"C:\Users\Steve\Documents\ArcGIS\Projects\pbmpolygons\pbm" + str(group) + ".xml"
131 | svce = r"http://services.arcgis.com/b6gLrKHqgkQb393u/arcgis/rest/services/TaxDistribution/FeatureServer/0"
132 |
133 | dlaCreateSourceTarget.createDlaFile(ds,svce,outdoc)
134 |
135 |
136 | def test3():
137 |
138 | dla._project = arcpy.mp.ArcGISProject(r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\Trails.aprx")
139 |
140 | dlaCreateSourceTarget.createDlaFile(r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\prawn.sde\GDB_D.DBO.GWS_FACILITY",
141 | r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\prawn.sde\GDB_D.DBO.GWS_TANK",
142 | r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\tables.xml")
143 |
144 | def test4():
145 | dlaPreview.preview(r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\tables.xml")
146 |
147 | def test5():
148 | dlaPublish.useReplaceSettings = True
149 | dlaPublish.publish(r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\tables.xml")
150 |
151 | def test6():
152 |
153 | dla._project = arcpy.mp.ArcGISProject(r"C:\Users\Steve\Documents\ArcGIS\Projects\Trails\Trails.aprx")
154 | layer = "Trails"
155 | try:
156 | desc = arcpy.Describe(layer) # never works in scripts
157 | except:
158 | arcpy.AddMessage("Describe error")
159 | dla.showTraceback()
160 |
161 | layer = dla.getLayer("Trails") # loop through maps/layers to find matching name
162 | if layer != None and layer.supports("DataSource"):
163 | try:
164 | arcpy.AddMessage(layer.dataSource)
165 | except:
166 | arcpy.AddMessage("Print error")
167 |
168 | if __name__ == "__main__":
169 | main()
--------------------------------------------------------------------------------
/Shared/Images/AddInDesktop16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/AddInDesktop16.png
--------------------------------------------------------------------------------
/Shared/Images/AppendData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/AppendData16.png
--------------------------------------------------------------------------------
/Shared/Images/AppendData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/AppendData32.png
--------------------------------------------------------------------------------
/Shared/Images/CogWheel16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/CogWheel16.png
--------------------------------------------------------------------------------
/Shared/Images/CogWheel32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/CogWheel32.png
--------------------------------------------------------------------------------
/Shared/Images/DataMapper16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/DataMapper16.png
--------------------------------------------------------------------------------
/Shared/Images/DataMapper32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/DataMapper32.png
--------------------------------------------------------------------------------
/Shared/Images/NewFile16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/NewFile16.png
--------------------------------------------------------------------------------
/Shared/Images/NewFile32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/NewFile32.png
--------------------------------------------------------------------------------
/Shared/Images/Preview16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/Preview16.png
--------------------------------------------------------------------------------
/Shared/Images/Preview32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/Preview32.png
--------------------------------------------------------------------------------
/Shared/Images/ReplaceData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/ReplaceData16.png
--------------------------------------------------------------------------------
/Shared/Images/ReplaceData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/ReplaceData32.png
--------------------------------------------------------------------------------
/Shared/Images/StageData16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/StageData16.png
--------------------------------------------------------------------------------
/Shared/Images/StageData32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Esri/data-assistant/82c83be223ce92367af83822d41a8fb5adcce3e8/Shared/Images/StageData32.png
--------------------------------------------------------------------------------
/Shared/Module1.cs:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright 2016 Esri
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ***/
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Input;
21 | using ArcGIS.Desktop.Framework;
22 | using ArcGIS.Desktop.Framework.Contracts;
23 | using System.Threading.Tasks;
24 |
25 | namespace DataAssistant
26 | {
27 | internal class Module1 : Module
28 | {
29 | private static Module1 _this = null;
30 |
31 | ///
32 | /// Retrieve the singleton instance to this module here
33 | ///
34 | public static Module1 Current
35 | {
36 | get
37 | {
38 | return _this ?? (_this = (Module1)FrameworkApplication.FindModule("DataAssistant_Module"));
39 | }
40 | }
41 |
42 | #region Overrides
43 | ///
44 | /// Called by Framework when ArcGIS Pro is closing
45 | ///
46 | /// False to prevent Pro from closing, otherwise True
47 | protected override bool CanUnload()
48 | {
49 | //TODO - add your business logic
50 | //return false to ~cancel~ Application close
51 | return true;
52 | }
53 |
54 | #endregion Overrides
55 |
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Shared/gridTooltipCreator.cs:
--------------------------------------------------------------------------------
1 | /***
2 | Copyright 2016 Esri
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ***/
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Threading.Tasks;
21 | using System.Windows;
22 | using System.Windows.Controls;
23 | using System.Windows.Data;
24 | using System.Windows.Documents;
25 | using System.Windows.Input;
26 | using System.Windows.Media;
27 | using System.Windows.Media.Imaging;
28 | using System.Windows.Navigation;
29 | using System.Windows.Shapes;
30 | using System.Xml.Linq;
31 | using System.Data;
32 | using System.Collections.ObjectModel;
33 | using System.Globalization;
34 | using System.Windows.Controls.Primitives;
35 | using ArcGIS.Desktop.Core.Geoprocessing;
36 | using ArcGIS.Desktop.Core;
37 | using ArcGIS.Desktop.Catalog;
38 | using System.Xml;
39 | using System.Xml.Xsl;
40 | using System.Xml.XPath;
41 |
42 | namespace DataAssistant
43 | {
44 | class gridTooltipCreator : IValueConverter
45 | {
46 | public object Convert(object value, Type targetType,
47 | object parameter, CultureInfo culture)
48 | {
49 | XmlElement elem = value as XmlElement;
50 | string tip = elem.InnerText.Trim();
51 | if (elem != null)
52 | {
53 | XmlDocument xmlDoc = DataAssistant.Dockpane1View.getXmlDocument();
54 | string xpath = "";
55 | if(elem.Name.ToString().StartsWith("Source"))
56 | xpath = "//SourceField[@Name='" + elem.InnerText + "']";
57 | else
58 | xpath = "//TargetField[@Name='" + elem.InnerText + "']";
59 | XmlNode node = xmlDoc.SelectSingleNode(xpath);
60 | try
61 | {
62 | // construct a label string from the Source or Target Field information in the xml file
63 | string nm = node.Attributes.GetNamedItem("Name").InnerText;
64 | if (elem.InnerText != DataAssistant.Dockpane1View.getNoneFieldName())
65 | {
66 | string alias = getValue(node, "AliasName");
67 | if (alias == "")
68 | alias = getValue(node, "Name");
69 | string typ = getValue(node, "Type");
70 | string len = getValue(node, "Length");
71 | if (len == "0")
72 | len = "";
73 | else if(len != "")
74 | len = "(" + len + ")";
75 | tip = alias + ", " + typ + len;
76 | return tip.Trim();
77 | }
78 | else
79 | return tip;
80 | }
81 | catch
82 | {
83 | return tip;
84 | }
85 | }
86 | else
87 | return tip;
88 | }
89 |
90 | public object ConvertBack(object value, Type targetType,
91 | object parameter, CultureInfo culture)
92 | {
93 | return new NotImplementedException();
94 | }
95 | private string getValue(XmlNode node,string attribute)
96 | {
97 | string val = "";
98 | if (node.Attributes.GetNamedItem(attribute) != null)
99 | {
100 | try { val = node.Attributes.GetNamedItem(attribute).InnerText; }
101 | catch { }
102 | }
103 | return val;
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | ArcGIS Solutions
2 | - June 2017 Release
3 |
--------------------------------------------------------------------------------