├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── buildMainReleaseAction.yml ├── .gitignore ├── AzurePipelineTemplate ├── DW Automation - Export & Apply.json ├── DW Automation Deployment.json └── DW Automation Start, Stop, Pause Maps.json ├── CODE_OF_CONDUCT.md ├── DWHelperUI ├── App.config ├── App.xaml ├── App.xaml.cs ├── AssemblyInfo.cs ├── DWHelperUI.csproj ├── EditConfigForm.xaml ├── EditConfigForm.xaml.cs ├── LogoFinal.ico ├── LogoFinal.png ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── Settings.Designer.cs │ └── Settings.settings └── XamlHelper.cs ├── DWLibary ├── ADOWikiUpload.cs ├── ArgsHandler.cs ├── DWEnums.cs ├── DWEnvCalls.cs ├── DWHttp.cs ├── DWLibary.csproj ├── DWSettings.cs ├── Drivers │ └── edgeversion.txt ├── EdgeUniversal.cs ├── EncryptionHelper.cs ├── EncryptionKeyGenerator.cs ├── Engines │ ├── DWADOWikiEngine.cs │ ├── DWCommonEngine.cs │ ├── DWComparison.cs │ ├── DWMapEngine.cs │ ├── DWSolutionEngine.cs │ └── ResetLinkEngine.cs ├── EnvGatewayCombination.cs ├── GlobalVar.cs ├── HttpClientWithRetry.cs ├── MFAGen.cs ├── Options.cs ├── ServicePrincipalAuth.cs ├── Struct │ ├── DWConnectionSet.cs │ ├── DWEnvironment.cs │ ├── DWFieldMapping.cs │ ├── DWMaps.cs │ ├── DWWikiOverview.cs │ ├── Groups.cs │ ├── InitialSyncDetails.cs │ ├── IntegrationKeys.cs │ ├── LoginData.cs │ ├── MapConfig.cs │ ├── MapDependency.cs │ ├── MapsHelper.cs │ ├── ResetLinkPayload.cs │ ├── SolutionHelpers.cs │ └── SolutionList.cs └── TokenRefresh.cs ├── DualWriteHelper.sln ├── DualWriteHelper ├── App.config ├── AppExecution.cs ├── DWHelperCMD.csproj ├── DWHostedService.cs ├── ExampleRun-AllParameters.bat ├── ExampleRun-ExportMaps - Copy.bat ├── ExampleRun-adoWikiUpload.bat ├── ExampleRun-customConfig.bat ├── ExampleRun-deployment.bat ├── ExampleRun-initalSync.bat ├── ExampleRunCMD.bat └── Main.cs ├── LICENSE ├── README.md ├── SECURITY.md └── SUPPORT.md /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CS8600: Converting null literal or possible null value to non-nullable type. 4 | dotnet_diagnostic.CS8600.severity = none 5 | csharp_indent_labels = one_less_than_current 6 | csharp_using_directive_placement = outside_namespace:silent 7 | csharp_prefer_simple_using_statement = true:suggestion 8 | csharp_prefer_braces = true:silent 9 | csharp_style_namespace_declarations = block_scoped:silent 10 | csharp_style_prefer_method_group_conversion = true:silent 11 | csharp_style_prefer_top_level_statements = true:silent 12 | csharp_style_expression_bodied_methods = false:silent 13 | csharp_style_expression_bodied_constructors = false:silent 14 | csharp_style_expression_bodied_operators = false:silent 15 | csharp_style_expression_bodied_properties = true:silent 16 | csharp_style_expression_bodied_indexers = true:silent 17 | csharp_style_expression_bodied_accessors = true:silent 18 | csharp_style_expression_bodied_lambdas = true:silent 19 | csharp_style_expression_bodied_local_functions = false:silent 20 | 21 | [*.{cs,vb}] 22 | dotnet_style_operator_placement_when_wrapping = beginning_of_line 23 | tab_width = 4 24 | indent_size = 4 25 | end_of_line = crlf 26 | dotnet_style_coalesce_expression = true:suggestion 27 | dotnet_style_null_propagation = true:suggestion 28 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion 29 | dotnet_style_prefer_auto_properties = true:silent 30 | dotnet_style_object_initializer = true:suggestion 31 | dotnet_style_collection_initializer = true:suggestion 32 | dotnet_style_prefer_simplified_boolean_expressions = true:suggestion 33 | dotnet_style_prefer_conditional_expression_over_assignment = true:silent 34 | dotnet_style_prefer_conditional_expression_over_return = true:silent 35 | dotnet_style_explicit_tuple_names = true:suggestion 36 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 37 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 38 | dotnet_style_prefer_compound_assignment = true:suggestion 39 | dotnet_style_prefer_simplified_interpolation = true:suggestion 40 | [*.{cs,vb}] 41 | #### Naming styles #### 42 | 43 | # Naming rules 44 | 45 | dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion 46 | dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface 47 | dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i 48 | 49 | dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion 50 | dotnet_naming_rule.types_should_be_pascal_case.symbols = types 51 | dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case 52 | 53 | dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion 54 | dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members 55 | dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case 56 | 57 | # Symbol specifications 58 | 59 | dotnet_naming_symbols.interface.applicable_kinds = interface 60 | dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 61 | dotnet_naming_symbols.interface.required_modifiers = 62 | 63 | dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum 64 | dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 65 | dotnet_naming_symbols.types.required_modifiers = 66 | 67 | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method 68 | dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 69 | dotnet_naming_symbols.non_field_members.required_modifiers = 70 | 71 | # Naming styles 72 | 73 | dotnet_naming_style.begins_with_i.required_prefix = I 74 | dotnet_naming_style.begins_with_i.required_suffix = 75 | dotnet_naming_style.begins_with_i.word_separator = 76 | dotnet_naming_style.begins_with_i.capitalization = pascal_case 77 | 78 | dotnet_naming_style.pascal_case.required_prefix = 79 | dotnet_naming_style.pascal_case.required_suffix = 80 | dotnet_naming_style.pascal_case.word_separator = 81 | dotnet_naming_style.pascal_case.capitalization = pascal_case 82 | 83 | dotnet_naming_style.pascal_case.required_prefix = 84 | dotnet_naming_style.pascal_case.required_suffix = 85 | dotnet_naming_style.pascal_case.word_separator = 86 | dotnet_naming_style.pascal_case.capitalization = pascal_case 87 | dotnet_style_namespace_match_folder = true:suggestion 88 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/buildMainReleaseAction.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a .NET project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net 3 | 4 | name: .NET 5 | 6 | on: 7 | push: 8 | branches: [ "main" ] 9 | pull_request: 10 | branches: [ "main" ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: windows-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Setup .NET 20 | uses: actions/setup-dotnet@v3 21 | with: 22 | dotnet-version: 6.0.x 23 | - name: Restore dependencies 24 | run: dotnet restore 25 | - name: Build 26 | run: dotnet build --no-restore --configuration "Release" 27 | - name: Test 28 | run: dotnet test --no-build --verbosity normal 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd 364 | /DualWriteHelper01/CCBA.config 365 | /DualWriteHelper01/tokens.txt 366 | /DualWriteHelper/DEBUGArgs.txt 367 | /DualWriteHelper/DEMO.config 368 | /DualWriteHelper/TEST.config 369 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Microsoft Open Source Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 4 | 5 | Resources: 6 | 7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) 8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) 9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns 10 | -------------------------------------------------------------------------------- /DWHelperUI/App.config: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | True 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | False 27 | 28 | 29 | False 30 | 31 | 32 | 33 | 34 | 35 | All 36 | 37 | 38 | DWHelperCMD.dll.config 39 | 40 | 41 | Information 42 | 43 | 44 | Default 45 | 46 | 47 | 48 | 49 | 50 | False 51 | 52 | 53 | False 54 | 55 | 56 | Default 57 | 58 | 59 | False 60 | 61 | 62 | True 63 | 64 | 65 | True 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /DWHelperUI/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /DWHelperUI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Data; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | using System.Windows; 11 | 12 | namespace DWHelperUI 13 | { 14 | /// 15 | /// Interaction logic for App.xaml 16 | /// 17 | public partial class App : Application 18 | { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DWHelperUI/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /DWHelperUI/DWHelperUI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 1.0.11 5 | WinExe 6 | net9.0-windows7.0 7 | enable 8 | true 9 | LogoFinal.ico 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | PreserveNewest 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | True 39 | True 40 | Settings.settings 41 | 42 | 43 | 44 | 45 | 46 | SettingsSingleFileGenerator 47 | Settings.Designer.cs 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /DWHelperUI/EditConfigForm.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using CommandLine; 5 | using DWLibary; 6 | using Microsoft.Identity.Client; 7 | using Microsoft.VisualStudio.Services.CircuitBreaker; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Collections.ObjectModel; 11 | using System.Collections.Specialized; 12 | using System.Configuration; 13 | using System.Globalization; 14 | using System.Linq; 15 | using System.Text; 16 | using System.Threading.Tasks; 17 | using System.Windows; 18 | using System.Windows.Controls; 19 | using System.Windows.Data; 20 | using System.Windows.Documents; 21 | using System.Windows.Input; 22 | using System.Windows.Media; 23 | using System.Windows.Media.Imaging; 24 | using System.Windows.Shapes; 25 | using System.Xml.Linq; 26 | 27 | namespace DWHelperUI 28 | { 29 | /// 30 | /// Interaction logic for EditConfigForm.xaml 31 | /// 32 | public partial class EditConfigForm 33 | { 34 | public string configName { get; set; } 35 | ObservableCollection mapConfigsContent; 36 | 37 | public EditConfigForm(string configName) 38 | { 39 | InitializeComponent(); 40 | this.configName = configName; 41 | 42 | initConfig(); 43 | getAppSettingsGridData(); 44 | getSolutionsGridData(); 45 | getGroupsGridData(); 46 | getADOGridData(); 47 | getMapsGridData(); 48 | } 49 | 50 | private void initConfig() 51 | { 52 | GlobalVar.configFileName = configName; 53 | GlobalVar.initConfig(); 54 | } 55 | 56 | private void getADOGridData() 57 | { 58 | List gridContent = GlobalVar.dwSettings.ADOWikiParameters.Cast().ToList(); 59 | 60 | setVisibility(adoSettings); 61 | 62 | adoSettings.ItemsSource = gridContent; 63 | 64 | } 65 | 66 | private void getAppSettingsGridData() 67 | { 68 | List gridContent = GlobalVar.config.AppSettings.Settings.Cast().ToList(); 69 | 70 | setVisibility(appSettings); 71 | 72 | 73 | 74 | 75 | appSettings.ItemsSource = gridContent; 76 | 77 | } 78 | 79 | 80 | private void getSolutionsGridData() 81 | { 82 | List gridContent = GlobalVar.dwSettings.Solutions.Cast().ToList(); 83 | 84 | setVisibility(solutions); 85 | 86 | solutions.ItemsSource = gridContent; 87 | 88 | } 89 | 90 | private void getGroupsGridData() 91 | { 92 | List gridContent = GlobalVar.dwSettings.Groups.Cast().ToList(); 93 | 94 | setVisibility(groups); 95 | 96 | groups.ItemsSource = gridContent; 97 | 98 | } 99 | 100 | private void setVisibility(DataGrid _grid) 101 | { 102 | _grid.AutoGenerateColumns = false; 103 | var properties = typeof(T).GetProperties(); 104 | 105 | foreach (var prop in properties) 106 | { 107 | dynamic column = new DataGridTextColumn(); 108 | 109 | 110 | 111 | if (prop.Name == "executionMode") 112 | { 113 | column = new DataGridTextColumn(); 114 | } 115 | 116 | 117 | 118 | column.Binding = new Binding(prop.Name); 119 | column.Header = prop.Name; 120 | 121 | if (typeof(T).IsAssignableFrom(prop.DeclaringType) && prop.IsDefined(typeof(ConfigurationPropertyAttribute), false)) 122 | { 123 | column.Visibility = Visibility.Visible; 124 | } 125 | else 126 | { 127 | column.Visibility = Visibility.Hidden; 128 | } 129 | _grid.Columns.Add(column); 130 | } 131 | } 132 | 133 | private void getMapsGridData() 134 | { 135 | 136 | mapConfigsContent = new ObservableCollection(GlobalVar.dwSettings.MapConfigs.Cast().ToList()); 137 | setVisibility(mapConfig); 138 | mapConfig.ItemsSource = mapConfigsContent; 139 | 140 | } 141 | 142 | private void saveSettings() 143 | { 144 | clearFilter(); 145 | 146 | GlobalVar.dwSettings.ADOWikiParameters.Clear(); 147 | 148 | foreach (var item in adoSettings.Items) 149 | { 150 | if (item is ADOWikiParameter) 151 | GlobalVar.dwSettings.ADOWikiParameters.Add((ADOWikiParameter)item); 152 | } 153 | 154 | 155 | GlobalVar.dwSettings.MapConfigs.Clear(); 156 | foreach (var item in mapConfig.Items) 157 | { 158 | if (item is MapConfig) 159 | GlobalVar.dwSettings.MapConfigs.Add((MapConfig)item); 160 | } 161 | 162 | GlobalVar.dwSettings.Groups.Clear(); 163 | foreach (var item in groups.Items) 164 | { 165 | if (item is Group) 166 | GlobalVar.dwSettings.Groups.Add((Group)item); 167 | } 168 | 169 | 170 | GlobalVar.dwSettings.Solutions.Clear(); 171 | foreach (var item in solutions.Items) 172 | { 173 | if (item is Solution) 174 | GlobalVar.dwSettings.Solutions.Add((Solution)item); 175 | } 176 | 177 | 178 | GlobalVar.config.AppSettings.Settings.Clear(); 179 | foreach (var item in appSettings.Items) 180 | { 181 | if (item is KeyValueConfigurationElement) 182 | GlobalVar.config.AppSettings.Settings.Add((KeyValueConfigurationElement)item); 183 | } 184 | 185 | GlobalVar.config.Save(ConfigurationSaveMode.Modified); 186 | } 187 | 188 | private void SaveSettings_Click(object sender, RoutedEventArgs e) 189 | { 190 | saveSettings(); 191 | 192 | } 193 | 194 | private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) 195 | { 196 | MessageBoxResult result = MessageBox.Show("Do you want to save your settings before closing?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question); 197 | switch (result) 198 | { 199 | case MessageBoxResult.Yes: 200 | // Save settings and continue closing the window 201 | saveSettings(); 202 | break; 203 | case MessageBoxResult.No: 204 | // Do not save settings and continue closing the window 205 | break; 206 | } 207 | } 208 | 209 | private void filterGrid() 210 | { 211 | var view = CollectionViewSource.GetDefaultView(mapConfig.ItemsSource); 212 | view.Filter = o => 213 | { 214 | var item = o as MapConfig; 215 | var properties = item.GetType().GetProperties(); 216 | foreach (var property in properties) 217 | { 218 | var value = property.GetValue(item, null); 219 | if (value != null && value.ToString().ToLower().Contains(SearchString.Text.ToLower())) 220 | { 221 | return true; 222 | } 223 | } 224 | return false; 225 | }; 226 | } 227 | private void Close_Click(object sender, RoutedEventArgs e) 228 | { 229 | this.Close(); 230 | } 231 | 232 | private void Grid_MouseDown(object sender, MouseButtonEventArgs e) 233 | { 234 | if (e.ChangedButton == MouseButton.Left) 235 | { 236 | this.DragMove(); 237 | } 238 | } 239 | 240 | private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 241 | { 242 | if (e.ClickCount == 2) 243 | { 244 | this.WindowState = WindowState.Normal; 245 | } 246 | } 247 | 248 | private void Filter_Click(object sender, RoutedEventArgs e) 249 | { 250 | filterGrid(); 251 | } 252 | 253 | private void ClearFilter_Click(object sender, RoutedEventArgs e) 254 | { 255 | clearFilter(); 256 | } 257 | 258 | private void clearFilter() 259 | { 260 | SearchString.Clear(); 261 | filterGrid(); 262 | } 263 | 264 | private void moveUp_Click(object sender, RoutedEventArgs e) 265 | { 266 | 267 | int selectedIndex = mapConfig.SelectedIndex; 268 | if (selectedIndex > 0) 269 | { 270 | int newIndex = selectedIndex - 1; 271 | 272 | MapConfig selectedItem = mapConfig.SelectedItem as MapConfig; 273 | if (selectedItem != null) 274 | { 275 | mapConfigsContent.RemoveAt(selectedIndex); 276 | mapConfigsContent.Insert(newIndex, selectedItem); 277 | mapConfig.SelectedItem = mapConfig.Items[newIndex]; 278 | mapConfig.Focus(); 279 | } 280 | } 281 | 282 | } 283 | 284 | private void moveDown_Click(object sender, RoutedEventArgs e) 285 | { 286 | int selectedIndex = mapConfig.SelectedIndex; 287 | if (selectedIndex > 0) 288 | { 289 | 290 | int newIndex = selectedIndex + 1; 291 | MapConfig selectedItem = mapConfig.SelectedItem as MapConfig; 292 | 293 | if (newIndex < mapConfig.Items.Count && selectedItem != null) 294 | { 295 | mapConfigsContent.RemoveAt(selectedIndex); 296 | mapConfigsContent.Insert(newIndex, selectedItem); 297 | mapConfig.SelectedItem = mapConfig.Items[newIndex]; 298 | mapConfig.Focus(); 299 | } 300 | } 301 | } 302 | } 303 | 304 | 305 | 306 | } 307 | -------------------------------------------------------------------------------- /DWHelperUI/LogoFinal.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Dual-write-automations/04b956efc7b6e4162ad90ff0f2dc4872355c311e/DWHelperUI/LogoFinal.ico -------------------------------------------------------------------------------- /DWHelperUI/LogoFinal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Dual-write-automations/04b956efc7b6e4162ad90ff0f2dc4872355c311e/DWHelperUI/LogoFinal.png -------------------------------------------------------------------------------- /DWHelperUI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DWHelperUI.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 29 | public bool applySolutionCheckbox { 30 | get { 31 | return ((bool)(this["applySolutionCheckbox"])); 32 | } 33 | set { 34 | this["applySolutionCheckbox"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | public global::System.Collections.Specialized.StringCollection envList { 41 | get { 42 | return ((global::System.Collections.Specialized.StringCollection)(this["envList"])); 43 | } 44 | set { 45 | this["envList"] = value; 46 | } 47 | } 48 | 49 | [global::System.Configuration.UserScopedSettingAttribute()] 50 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 51 | [global::System.Configuration.DefaultSettingValueAttribute("")] 52 | public string envURL { 53 | get { 54 | return ((string)(this["envURL"])); 55 | } 56 | set { 57 | this["envURL"] = value; 58 | } 59 | } 60 | 61 | [global::System.Configuration.UserScopedSettingAttribute()] 62 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 63 | [global::System.Configuration.DefaultSettingValueAttribute("")] 64 | public string password { 65 | get { 66 | return ((string)(this["password"])); 67 | } 68 | set { 69 | this["password"] = value; 70 | } 71 | } 72 | 73 | [global::System.Configuration.UserScopedSettingAttribute()] 74 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 75 | [global::System.Configuration.DefaultSettingValueAttribute("")] 76 | public string username { 77 | get { 78 | return ((string)(this["username"])); 79 | } 80 | set { 81 | this["username"] = value; 82 | } 83 | } 84 | 85 | [global::System.Configuration.UserScopedSettingAttribute()] 86 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 87 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 88 | public bool adowikiupload { 89 | get { 90 | return ((bool)(this["adowikiupload"])); 91 | } 92 | set { 93 | this["adowikiupload"] = value; 94 | } 95 | } 96 | 97 | [global::System.Configuration.UserScopedSettingAttribute()] 98 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 99 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 100 | public bool exportConfig { 101 | get { 102 | return ((bool)(this["exportConfig"])); 103 | } 104 | set { 105 | this["exportConfig"] = value; 106 | } 107 | } 108 | 109 | [global::System.Configuration.UserScopedSettingAttribute()] 110 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 111 | [global::System.Configuration.DefaultSettingValueAttribute("")] 112 | public string runmode { 113 | get { 114 | return ((string)(this["runmode"])); 115 | } 116 | set { 117 | this["runmode"] = value; 118 | } 119 | } 120 | 121 | [global::System.Configuration.UserScopedSettingAttribute()] 122 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 123 | [global::System.Configuration.DefaultSettingValueAttribute("All")] 124 | public string exportStatus { 125 | get { 126 | return ((string)(this["exportStatus"])); 127 | } 128 | set { 129 | this["exportStatus"] = value; 130 | } 131 | } 132 | 133 | [global::System.Configuration.UserScopedSettingAttribute()] 134 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 135 | [global::System.Configuration.DefaultSettingValueAttribute("DWHelperCMD.dll.config")] 136 | public string configName { 137 | get { 138 | return ((string)(this["configName"])); 139 | } 140 | set { 141 | this["configName"] = value; 142 | } 143 | } 144 | 145 | [global::System.Configuration.UserScopedSettingAttribute()] 146 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 147 | [global::System.Configuration.DefaultSettingValueAttribute("Information")] 148 | public string logLevel { 149 | get { 150 | return ((string)(this["logLevel"])); 151 | } 152 | set { 153 | this["logLevel"] = value; 154 | } 155 | } 156 | 157 | [global::System.Configuration.UserScopedSettingAttribute()] 158 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 159 | [global::System.Configuration.DefaultSettingValueAttribute("Default")] 160 | public string exportOption { 161 | get { 162 | return ((string)(this["exportOption"])); 163 | } 164 | set { 165 | this["exportOption"] = value; 166 | } 167 | } 168 | 169 | [global::System.Configuration.UserScopedSettingAttribute()] 170 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 171 | [global::System.Configuration.DefaultSettingValueAttribute("")] 172 | public string targetFO { 173 | get { 174 | return ((string)(this["targetFO"])); 175 | } 176 | set { 177 | this["targetFO"] = value; 178 | } 179 | } 180 | 181 | [global::System.Configuration.UserScopedSettingAttribute()] 182 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 183 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 184 | public bool forceReset { 185 | get { 186 | return ((bool)(this["forceReset"])); 187 | } 188 | set { 189 | this["forceReset"] = value; 190 | } 191 | } 192 | 193 | [global::System.Configuration.UserScopedSettingAttribute()] 194 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 195 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 196 | public bool disablePrivateBrowser { 197 | get { 198 | return ((bool)(this["disablePrivateBrowser"])); 199 | } 200 | set { 201 | this["disablePrivateBrowser"] = value; 202 | } 203 | } 204 | 205 | [global::System.Configuration.UserScopedSettingAttribute()] 206 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 207 | [global::System.Configuration.DefaultSettingValueAttribute("Default")] 208 | public string catchUpSetting { 209 | get { 210 | return ((string)(this["catchUpSetting"])); 211 | } 212 | set { 213 | this["catchUpSetting"] = value; 214 | } 215 | } 216 | 217 | [global::System.Configuration.UserScopedSettingAttribute()] 218 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 219 | [global::System.Configuration.DefaultSettingValueAttribute("False")] 220 | public bool lightMode { 221 | get { 222 | return ((bool)(this["lightMode"])); 223 | } 224 | set { 225 | this["lightMode"] = value; 226 | } 227 | } 228 | 229 | [global::System.Configuration.UserScopedSettingAttribute()] 230 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 231 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 232 | public bool darkMode { 233 | get { 234 | return ((bool)(this["darkMode"])); 235 | } 236 | set { 237 | this["darkMode"] = value; 238 | } 239 | } 240 | 241 | [global::System.Configuration.UserScopedSettingAttribute()] 242 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 243 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 244 | public bool upgradeRequired { 245 | get { 246 | return ((bool)(this["upgradeRequired"])); 247 | } 248 | set { 249 | this["upgradeRequired"] = value; 250 | } 251 | } 252 | 253 | [global::System.Configuration.UserScopedSettingAttribute()] 254 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 255 | [global::System.Configuration.DefaultSettingValueAttribute("")] 256 | public string EncryptionKey { 257 | get { 258 | return ((string)(this["EncryptionKey"])); 259 | } 260 | set { 261 | this["EncryptionKey"] = value; 262 | } 263 | } 264 | 265 | [global::System.Configuration.UserScopedSettingAttribute()] 266 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 267 | [global::System.Configuration.DefaultSettingValueAttribute("")] 268 | public string EncryptionIv { 269 | get { 270 | return ((string)(this["EncryptionIv"])); 271 | } 272 | set { 273 | this["EncryptionIv"] = value; 274 | } 275 | } 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /DWHelperUI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | True 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | False 22 | 23 | 24 | False 25 | 26 | 27 | 28 | 29 | 30 | All 31 | 32 | 33 | DWHelperCMD.dll.config 34 | 35 | 36 | Information 37 | 38 | 39 | Default 40 | 41 | 42 | 43 | 44 | 45 | False 46 | 47 | 48 | False 49 | 50 | 51 | Default 52 | 53 | 54 | False 55 | 56 | 57 | True 58 | 59 | 60 | True 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /DWHelperUI/XamlHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Controls; 10 | using System.Windows.Data; 11 | using System.Windows; 12 | 13 | namespace DWHelperUI 14 | { 15 | public static class Secure 16 | { 17 | private static readonly DependencyProperty PasswordInitializedProperty = 18 | DependencyProperty.RegisterAttached("PasswordInitialized", typeof(bool), typeof(Secure), new PropertyMetadata(false)); 19 | 20 | private static readonly DependencyProperty SettingPasswordProperty = 21 | DependencyProperty.RegisterAttached("SettingPassword", typeof(bool), typeof(Secure), new PropertyMetadata(false)); 22 | 23 | public static string GetPassword(DependencyObject obj) 24 | { 25 | return (string)obj.GetValue(PasswordProperty); 26 | } 27 | public static void SetPassword(DependencyObject obj, string value) 28 | { 29 | obj.SetValue(PasswordProperty, value); 30 | } 31 | // We play a trick here. If we set the initial value to something, it'll be set to something else when the binding kicks in, 32 | // and HandleBoundPasswordChanged will be called, which allows us to set up our event subscription. 33 | // If the binding sets us to a value which we already are, then this doesn't happen. Therefore start with a value that's 34 | // definitely unique. 35 | public static readonly DependencyProperty PasswordProperty = 36 | DependencyProperty.RegisterAttached("Password", typeof(string), typeof(Secure), 37 | new FrameworkPropertyMetadata(Guid.NewGuid().ToString(), HandleBoundPasswordChanged) 38 | { 39 | BindsTwoWayByDefault = true, 40 | DefaultUpdateSourceTrigger = UpdateSourceTrigger.LostFocus // Match the default on Binding 41 | }); 42 | 43 | private static void HandleBoundPasswordChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e) 44 | { 45 | var passwordBox = dp as PasswordBox; 46 | if (passwordBox == null) 47 | return; 48 | 49 | // If we're being called because we set the value of the property we're bound to (from inside 50 | // HandlePasswordChanged, then do nothing - we already have the latest value). 51 | if ((bool)passwordBox.GetValue(SettingPasswordProperty)) 52 | return; 53 | 54 | // If this is the initial set (see the comment on PasswordProperty), set ourselves up 55 | if (!(bool)passwordBox.GetValue(PasswordInitializedProperty)) 56 | { 57 | passwordBox.SetValue(PasswordInitializedProperty, true); 58 | passwordBox.PasswordChanged += HandlePasswordChanged; 59 | } 60 | 61 | passwordBox.Password = e.NewValue as string; 62 | } 63 | 64 | private static void HandlePasswordChanged(object sender, RoutedEventArgs e) 65 | { 66 | var passwordBox = (PasswordBox)sender; 67 | passwordBox.SetValue(SettingPasswordProperty, true); 68 | SetPassword(passwordBox, passwordBox.Password); 69 | passwordBox.SetValue(SettingPasswordProperty, false); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /DWLibary/ADOWikiUpload.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using Microsoft.TeamFoundation.SourceControl.WebApi; 5 | using Microsoft.VisualStudio.Services.Common; 6 | using Microsoft.VisualStudio.Services.WebApi; 7 | using Microsoft.TeamFoundation.Wiki.WebApi; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using Microsoft.VisualBasic; 14 | using System.Diagnostics.Metrics; 15 | using System.Configuration; 16 | using System.IO; 17 | using Microsoft.Extensions.Logging; 18 | using Azure; 19 | 20 | namespace DWLibary 21 | { 22 | 23 | 24 | 25 | public class ADOWikiUpload 26 | { 27 | 28 | string projectName = ""; 29 | 30 | string pat = ""; 31 | public string wikiPath = ""; 32 | string wikiName = ""; 33 | string orgURL = ""; 34 | public bool useUpload = false; 35 | 36 | private WikiHttpClient wikiClient; 37 | 38 | private WikiV2 wiki; 39 | 40 | ILogger logger; 41 | 42 | public ADOWikiUpload(ILogger _logger) 43 | { 44 | logger = _logger; 45 | loadParamaters(); 46 | 47 | } 48 | 49 | 50 | private void loadParamaters() 51 | { 52 | foreach (ADOWikiParameter param in GlobalVar.dwSettings.ADOWikiParameters) 53 | { 54 | switch (param.Key.ToUpper()) 55 | { 56 | case "USEADOWIKIUPLOAD": 57 | if (GlobalVar.useadowikiupload) 58 | useUpload = GlobalVar.useadowikiupload; 59 | else 60 | useUpload = Convert.ToBoolean(param.Value); 61 | 62 | break; 63 | 64 | case "ACCESSTOKEN": 65 | if (GlobalVar.adotoken != String.Empty) 66 | pat = GlobalVar.adotoken; 67 | else 68 | pat = param.Value; 69 | break; 70 | 71 | case "PROJECTNAME": 72 | projectName = param.Value; 73 | break; 74 | 75 | case "ORGANIZATIONURL": 76 | orgURL = param.Value; 77 | break; 78 | 79 | case "WIKINAME": 80 | wikiName = param.Value; 81 | break; 82 | 83 | case "WIKIPATH": 84 | wikiPath = param.Value; 85 | break; 86 | 87 | } 88 | } 89 | } 90 | 91 | public async Task init() 92 | { 93 | 94 | if (!useUpload) 95 | return useUpload; 96 | 97 | var creds = new VssBasicCredential(string.Empty, pat); 98 | 99 | Uri baseUrl = new Uri(orgURL); 100 | 101 | wikiClient = new WikiHttpClient(baseUrl, creds); 102 | 103 | try 104 | { 105 | wiki = await wikiClient.GetWikiAsync(projectName, wikiName); 106 | } 107 | catch (Exception ex) 108 | { 109 | logger.LogError("Could not authenticate to the wiki, please check the configuration"); 110 | useUpload= false; 111 | } 112 | 113 | if(wiki == null) 114 | { 115 | logger.LogError($"Could not authenticate to the wiki or wiki was not found under project {projectName}, Wiki: {wikiName} , please check the configuration and make sure your access token has Read / Write for Wiki"); 116 | useUpload = false; 117 | } 118 | 119 | 120 | return useUpload; 121 | 122 | 123 | } 124 | 125 | public string CombineForward(string path1, string path2) 126 | { 127 | 128 | string ret = string.Empty; 129 | 130 | 131 | if(path1.Length > 0) 132 | { 133 | if (path1.Substring(0, 1) != "/") 134 | path1 = "/" + path1; 135 | } 136 | 137 | if(path2.Length > 0) 138 | { 139 | if(path2.Substring(path2.Length-1, 1) == "/") 140 | path2 = path2.Substring(0, path2.Length-1); 141 | 142 | } 143 | 144 | if(path1.Length > 0 && path2.Length > 0) 145 | { 146 | 147 | string endPath1 = path1.Substring(path1.Length - 1, 1); 148 | string beginPath2 = path2.Substring(0, 1); 149 | 150 | if (endPath1 != "/" && beginPath2 == "/") 151 | ret = path1 + path2; 152 | 153 | if (endPath1 == "/" && beginPath2 != "/") 154 | ret = path1 + path2; 155 | 156 | if (endPath1 != "/" && beginPath2 != "/") 157 | ret = path1 + "/" + path2; 158 | 159 | if (endPath1 == "/" && beginPath2 == "/") 160 | ret = path1 + path2.Substring(1, path2.Length - 1); 161 | 162 | } 163 | 164 | 165 | return ret; 166 | 167 | } 168 | 169 | public async Task createUpdatePage(string content, string path, bool updatePage = true) 170 | { 171 | 172 | try 173 | { 174 | if (!useUpload) 175 | return; 176 | 177 | 178 | string finalPath = CombineForward(wikiPath, path); 179 | 180 | content = $"_This Page is automatically generated, if you do makes changes it may be overwritten_{Environment.NewLine}" + content; 181 | 182 | WikiPageCreateOrUpdateParameters parameters = new WikiPageCreateOrUpdateParameters(); 183 | parameters.Content = content; 184 | 185 | GitVersionDescriptor gitVersion = null; 186 | if(wiki.Versions.Any()) 187 | { 188 | gitVersion = wiki.Versions.FirstOrDefault(); 189 | } 190 | 191 | 192 | WikiPageResponse wikiPage = null; 193 | //parameters. 194 | try 195 | { 196 | wikiPage = await wikiClient.GetPageAsync(wiki.ProjectId, wiki.Id, finalPath); 197 | } 198 | catch { } 199 | 200 | if (wikiPage != null) 201 | { 202 | if (updatePage) 203 | await wikiClient.CreateOrUpdatePageAsync(parameters, wiki.ProjectId, wiki.Id, finalPath, wikiPage.ETag.FirstOrDefault(), null,gitVersion); 204 | } 205 | else 206 | 207 | { 208 | await wikiClient.CreateOrUpdatePageAsync(parameters, wiki.ProjectId, wiki.Id, finalPath,"",null, gitVersion); 209 | } 210 | 211 | } 212 | catch(Exception ex) 213 | { 214 | logger.LogError(ex.ToString()); 215 | } 216 | 217 | } 218 | 219 | public async Task runTest() 220 | { 221 | 222 | await init(); 223 | 224 | if (!useUpload) 225 | return; 226 | 227 | string finalPath = "/DualWrite Automation/something"; 228 | //var wikis = await wiki.GetAllWikisAsync(); //Gets all Wikis 229 | 230 | 231 | // Get data about a specific repository 232 | // var repo = gitClient.GetRepositoryAsync(projectName, repoName).Result; 233 | 234 | WikiPageCreateOrUpdateParameters parameters = new WikiPageCreateOrUpdateParameters(); 235 | parameters.Content = "Some content3"; 236 | 237 | 238 | //parameters. 239 | 240 | WikiPageResponse wikiPage = null; 241 | //parameters. 242 | try 243 | { 244 | wikiPage = await wikiClient.GetPageAsync(wiki.ProjectId, wiki.Id, finalPath); 245 | } 246 | catch { } 247 | 248 | 249 | 250 | await wikiClient.CreateOrUpdatePageAsync(parameters, wiki.ProjectId, wiki.Id, finalPath, wikiPage == null ? "" : wikiPage.ETag.FirstOrDefault()); 251 | 252 | 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /DWLibary/ArgsHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using CommandLine; 7 | 8 | namespace DWLibary 9 | { 10 | public class ArgsHandler 11 | { 12 | public Options parsedOptions; 13 | 14 | public void parseCommands(string[] args) 15 | { 16 | 17 | var parser = new CommandLine.Parser(s => 18 | { 19 | s.CaseSensitive = false; 20 | s.CaseInsensitiveEnumValues = true; 21 | }); 22 | parser.ParseArguments(args) 23 | .WithParsed(o => { 24 | // parsing successful; go ahead and run the app 25 | GlobalVar.username = o.username; 26 | GlobalVar.password = o.password; 27 | 28 | GlobalVar.foEnv = parseUriHostname(o.environment); 29 | 30 | 31 | GlobalVar.configFileName = o.configFileName; 32 | GlobalVar.mfasecret = o.mfasecret; 33 | GlobalVar.useadowikiupload = o.useadowikiupload; 34 | GlobalVar.adotoken = o.adotoken; 35 | 36 | GlobalVar.runMode = o.runmode; 37 | GlobalVar.exportState = o.status; 38 | GlobalVar.exportOption = o.exportOption; 39 | 40 | GlobalVar.noSolutions = o.noSolutions; 41 | 42 | GlobalVar.newConfigFileName = o.newConfigFileName; 43 | 44 | parsedOptions = o; 45 | 46 | 47 | 48 | o.targetenvironment = parseUriHostname(o.targetenvironment); 49 | GlobalVar.parsedOptions = o; 50 | 51 | 52 | Console.WriteLine("Commandline arguments parsed and set"); 53 | 54 | }) 55 | .WithNotParsed(e => { 56 | 57 | foreach (var error in e) 58 | { 59 | if (error is NamedError namedError) 60 | { 61 | Console.WriteLine($"Failed to parse parameter: {namedError.NameInfo.NameText}"); 62 | } 63 | else 64 | { 65 | Console.WriteLine(error.ToString()); 66 | } 67 | } 68 | // parsing unsuccessful; deal with parsing errors 69 | throw new Exception("Commandline parameters wrong"); 70 | 71 | 72 | }); 73 | } 74 | 75 | 76 | private string parseUriHostname(string url) 77 | { 78 | 79 | string ret = String.Empty; 80 | 81 | if(url == null || url.Length == 0) 82 | { 83 | return ret; 84 | } 85 | 86 | url = url.Trim(); 87 | 88 | UriBuilder builder = new UriBuilder(url); 89 | if (builder.Uri != null) 90 | { 91 | ret = builder.Uri.Host; 92 | } 93 | 94 | 95 | return ret; 96 | 97 | 98 | } 99 | 100 | 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /DWLibary/DWEnums.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace DWLibary 13 | { 14 | public class DWEnums 15 | { 16 | public enum ExecutionMode 17 | { 18 | parallel, 19 | sequential 20 | }; 21 | 22 | 23 | public enum StartStop 24 | { 25 | none, 26 | start, 27 | stop, 28 | pause, 29 | resume, 30 | init = 8 31 | }; 32 | 33 | public enum CatchUpSyncOption 34 | { 35 | [Description("Catch up synchronization of queued records")] 36 | Default, 37 | [Description("Skip to live synchronization preserving queued records to catch-up errors for retry")] 38 | BackendQueueProcessing, 39 | [Description("Skip to live synchronization and discard queued records")] 40 | DeleteQueueProcessing 41 | } 42 | 43 | public enum MapStatus 44 | { 45 | None = 0, 46 | Stopped = 1, 47 | InitialSync = 2, 48 | CatchUp = 3, 49 | Running = 4, 50 | Paused = 5, 51 | //Paused = 4, 52 | NotRunning = 6, 53 | 54 | Keep = 99, 55 | All = 100 56 | }; 57 | 58 | public enum RequestStatus 59 | { 60 | Waiting = 1, 61 | Completed = 2, 62 | Error = 3 63 | }; 64 | 65 | public enum ExceptionHandling 66 | { 67 | ignore, 68 | skip, 69 | stop 70 | 71 | }; 72 | 73 | public enum ExportOptions 74 | { 75 | [Description("Default export, any Author, latest version")] 76 | Default = 0, 77 | [Description("Exact version & author")] 78 | precise = 1, 79 | } 80 | 81 | public enum DWSyncDirection 82 | { 83 | [Description("FO <-> CE")] 84 | Both = 3, 85 | [Description("FO -> CE")] 86 | FOOnly = 1, 87 | [Description("FO <- CE")] 88 | CEOnly = 2 89 | } 90 | 91 | public enum DataMaster 92 | { 93 | [Description("CRM")] 94 | CE = 0, 95 | [Description("AX")] 96 | FO = 1 97 | 98 | }; 99 | 100 | public enum RunMode 101 | { 102 | [Description("Default from configuration")] 103 | none, 104 | [Description("Deploy maps")] 105 | deployment, 106 | [Description("Deploy and Initial sync where set in config")] 107 | deployInitialSync, 108 | [Description("Start maps")] 109 | start, 110 | [Description("Stop maps")] 111 | stop, 112 | [Description("Pause maps")] 113 | pause, 114 | [Description("Export configuration")] 115 | export, 116 | [Description("Wiki upload")] 117 | wikiUpload, 118 | [Description("Compare environment")] 119 | compare, 120 | [Description("Reset link")] 121 | resetLink 122 | }; 123 | 124 | 125 | public static T GetValueFromDescription(string description) where T : Enum 126 | { 127 | foreach (var field in typeof(T).GetFields()) 128 | { 129 | if (Attribute.GetCustomAttribute(field, 130 | typeof(DescriptionAttribute)) is DescriptionAttribute attribute) 131 | { 132 | if (attribute.Description == description) 133 | return (T)field.GetValue(null); 134 | } 135 | else 136 | { 137 | if (field.Name == description) 138 | return (T)field.GetValue(null); 139 | } 140 | } 141 | 142 | //throw new ArgumentException("Not found.", nameof(description)); 143 | return default(T); 144 | } 145 | public static string DescriptionAttr(T source) 146 | { 147 | FieldInfo fi = source.GetType().GetField(source.ToString()); 148 | 149 | DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes( 150 | typeof(DescriptionAttribute), false); 151 | 152 | if (attributes != null && attributes.Length > 0) return attributes[0].Description; 153 | else return source.ToString(); 154 | } 155 | 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /DWLibary/DWEnvCalls.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary.Struct; 5 | using Newtonsoft.Json; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace DWLibary 13 | { 14 | public class DWEnvCalls 15 | { 16 | DWEnvironment env; 17 | 18 | 19 | public async Task getEnvironment() 20 | { 21 | DWEnvironment environment = new DWEnvironment(); 22 | try 23 | { 24 | HttpClient client = new HttpClientWithRetry(); 25 | DWHttp dW = new DWHttp(); 26 | HttpRequestMessage req = dW.buildDefaultHttpRequestGet(); 27 | 28 | UriBuilder uriBuilder = new UriBuilder(req.RequestUri); 29 | uriBuilder.Path += $"Environments"; 30 | uriBuilder.Query = $"targetType=AX&identifier={GlobalVar.foEnv}"; 31 | 32 | req.RequestUri = uriBuilder.Uri; 33 | 34 | var response = await client.SendAsync(req); 35 | 36 | string content = await response.Content.ReadAsStringAsync(); 37 | environment = JsonConvert.DeserializeObject>(content)[0]; 38 | environment.foEnvironment = GlobalVar.foEnv; 39 | 40 | 41 | 42 | } 43 | catch (Exception ex) 44 | { 45 | 46 | } 47 | 48 | return environment; 49 | 50 | } 51 | 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /DWLibary/DWHttp.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary.Struct; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace DWLibary 12 | { 13 | public class DWHttp 14 | { 15 | 16 | HttpRequestMessage _httpRequest; 17 | DWEnvironment env; 18 | 19 | private const string CustomUserAgent = "DualWriteHelper/1.0 (Windows NT 10.0; Win64; x64)"; 20 | 21 | public DWHttp(DWEnvironment _env = default) 22 | { 23 | env = _env; 24 | } 25 | 26 | 27 | public HttpRequestMessage buildDefaultHttpRequestPost() 28 | { 29 | _httpRequest = new HttpRequestMessage(); 30 | 31 | 32 | _httpRequest.Method = HttpMethod.Post; 33 | _httpRequest.Headers.Add("Accept", "application/json"); 34 | _httpRequest.Headers.Add("Origin", GlobalVar.dataintegratorURL.AbsoluteUri); 35 | _httpRequest.Headers.Add("User-Agent", CustomUserAgent); 36 | 37 | _httpRequest.RequestUri = buildReqUri(); 38 | buildAuth(); 39 | 40 | 41 | return _httpRequest; 42 | } 43 | 44 | private Uri buildReqUri() 45 | { 46 | Uri ret = null; 47 | 48 | if (GlobalVar.baseUrl != null && GlobalVar.baseUrl.Length > 0) 49 | { 50 | UriBuilder uriBuilder = new UriBuilder(GlobalVar.baseUrl); 51 | uriBuilder.Path = "/api/DualWriteManagement/1.0/"; 52 | 53 | ret = uriBuilder.Uri; 54 | } 55 | 56 | return ret; 57 | } 58 | 59 | public HttpRequestMessage buildDefaultHttpRequestGet() 60 | { 61 | try 62 | { 63 | _httpRequest = new HttpRequestMessage(); 64 | 65 | _httpRequest.Method = HttpMethod.Get; 66 | 67 | _httpRequest.RequestUri = buildReqUri(); 68 | 69 | buildAuth(); 70 | } 71 | catch (Exception ex) 72 | { 73 | 74 | } 75 | 76 | 77 | return _httpRequest; 78 | } 79 | 80 | private void buildAuth() 81 | { 82 | 83 | LoginData localLogin = null; 84 | 85 | if(env.foEnvironment != null) 86 | { 87 | localLogin = GlobalVar.savedTokens.Where(x => x.environment.ToUpper().Equals(env.foEnvironment.ToUpper())).FirstOrDefault(); 88 | } 89 | 90 | _httpRequest.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", localLogin != null ? localLogin.access_token : GlobalVar.loginData.access_token); 91 | } 92 | 93 | 94 | 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /DWLibary/DWLibary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0 5 | enable 6 | enable 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | PreserveNewest 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /DWLibary/DWSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Xml; 11 | using System.Xml.Serialization; 12 | 13 | namespace DWLibary 14 | { 15 | 16 | public class ADOWikiParameter : ConfigurationSection 17 | { 18 | 19 | public ADOWikiParameter() { } 20 | 21 | public ADOWikiParameter(string key) 22 | { 23 | Key = key; 24 | //ReportType = reportType; 25 | } 26 | 27 | [ConfigurationProperty("key", DefaultValue = "", IsRequired = true, IsKey = true)] 28 | public string Key 29 | { 30 | get { return (string)this["key"]; } 31 | set { this["key"] = value; } 32 | } 33 | 34 | [ConfigurationProperty("value", DefaultValue = "", IsRequired = true, IsKey = true)] 35 | public string Value 36 | { 37 | get { return (string)this["value"]; } 38 | set { this["value"] = value; } 39 | } 40 | } 41 | 42 | 43 | public class DWSettings : ConfigurationSection 44 | { 45 | 46 | [ConfigurationProperty("ADOWikiParameters", IsDefaultCollection = false)] 47 | [ConfigurationCollection(typeof(ADOWikiParameters), 48 | AddItemName = "add", 49 | ClearItemsName = "clear", 50 | RemoveItemName = "remove")] 51 | public ADOWikiParameters ADOWikiParameters 52 | { 53 | get 54 | { 55 | return (ADOWikiParameters)base["ADOWikiParameters"]; 56 | } 57 | } 58 | 59 | 60 | [ConfigurationProperty("Solutions", IsDefaultCollection = false)] 61 | [ConfigurationCollection(typeof(Solutions), 62 | AddItemName = "Solution", 63 | ClearItemsName = "clear", 64 | RemoveItemName = "remove")] 65 | public Solutions Solutions 66 | { 67 | get 68 | { 69 | return (Solutions)base["Solutions"]; 70 | } 71 | } 72 | 73 | [ConfigurationProperty("Groups", IsDefaultCollection = false)] 74 | [ConfigurationCollection(typeof(Groups), 75 | AddItemName = "Group", 76 | ClearItemsName = "clear", 77 | RemoveItemName = "remove")] 78 | public Groups Groups 79 | { 80 | get 81 | { 82 | return (Groups)base["Groups"]; 83 | } 84 | } 85 | 86 | [ConfigurationProperty("MapConfigs", IsDefaultCollection = false)] 87 | [ConfigurationCollection(typeof(MapConfigs), 88 | AddItemName = "Map", 89 | ClearItemsName = "clear", 90 | RemoveItemName = "remove")] 91 | public MapConfigs MapConfigs 92 | { 93 | get 94 | { 95 | return (MapConfigs)base["MapConfigs"]; 96 | } 97 | } 98 | } 99 | 100 | public class ADOWikiParameters : ConfigurationElementCollection 101 | { 102 | public ADOWikiParameters() 103 | { 104 | // Console.WriteLine("ServiceCollection Constructor"); 105 | } 106 | 107 | public ADOWikiParameter this[int index] 108 | { 109 | get { return (ADOWikiParameter)BaseGet(index); } 110 | set 111 | { 112 | if (BaseGet(index) != null) 113 | { 114 | BaseRemoveAt(index); 115 | } 116 | BaseAdd(index, value); 117 | } 118 | } 119 | 120 | public void Add(ADOWikiParameter serviceConfig) 121 | { 122 | BaseAdd(serviceConfig); 123 | } 124 | 125 | public void Clear() 126 | { 127 | BaseClear(); 128 | } 129 | 130 | protected override ConfigurationElement CreateNewElement() 131 | { 132 | return new ADOWikiParameter(); 133 | } 134 | 135 | protected override object GetElementKey(ConfigurationElement element) 136 | { 137 | return ((ADOWikiParameter)element).Key; 138 | } 139 | 140 | public void Remove(ADOWikiParameter serviceConfig) 141 | { 142 | BaseRemove(serviceConfig.Key); 143 | } 144 | 145 | public void RemoveAt(int index) 146 | { 147 | BaseRemoveAt(index); 148 | } 149 | 150 | public void Remove(string name) 151 | { 152 | BaseRemove(name); 153 | } 154 | } 155 | 156 | public class Solutions : ConfigurationElementCollection 157 | { 158 | public Solutions() 159 | { 160 | // Console.WriteLine("ServiceCollection Constructor"); 161 | } 162 | 163 | public Solution this[int index] 164 | { 165 | get { return (Solution)BaseGet(index); } 166 | set 167 | { 168 | if (BaseGet(index) != null) 169 | { 170 | BaseRemoveAt(index); 171 | } 172 | BaseAdd(index, value); 173 | } 174 | } 175 | 176 | public void Add(Solution serviceConfig) 177 | { 178 | BaseAdd(serviceConfig); 179 | } 180 | 181 | public void Clear() 182 | { 183 | BaseClear(); 184 | } 185 | 186 | protected override ConfigurationElement CreateNewElement() 187 | { 188 | return new Solution(); 189 | } 190 | 191 | protected override object GetElementKey(ConfigurationElement element) 192 | { 193 | return ((Solution)element).Name; 194 | } 195 | 196 | public void Remove(Solution serviceConfig) 197 | { 198 | BaseRemove(serviceConfig.Name); 199 | } 200 | 201 | public void RemoveAt(int index) 202 | { 203 | BaseRemoveAt(index); 204 | } 205 | 206 | public void Remove(string name) 207 | { 208 | BaseRemove(name); 209 | } 210 | } 211 | 212 | public class Groups : ConfigurationElementCollection 213 | { 214 | public Groups() 215 | { 216 | //Console.WriteLine("ServiceCollection Constructor"); 217 | } 218 | 219 | public Group this[int index] 220 | { 221 | get { return (Group)BaseGet(index); } 222 | set 223 | { 224 | if (BaseGet(index) != null) 225 | { 226 | BaseRemoveAt(index); 227 | } 228 | BaseAdd(index, value); 229 | } 230 | } 231 | 232 | public void Add(Group serviceConfig) 233 | { 234 | BaseAdd(serviceConfig); 235 | } 236 | 237 | public void Clear() 238 | { 239 | BaseClear(); 240 | } 241 | 242 | protected override ConfigurationElement CreateNewElement() 243 | { 244 | return new Group(); 245 | } 246 | 247 | protected override object GetElementKey(ConfigurationElement element) 248 | { 249 | return ((Group)element).name; 250 | } 251 | 252 | public void Remove(Group serviceConfig) 253 | { 254 | BaseRemove(serviceConfig.name); 255 | } 256 | 257 | public void RemoveAt(int index) 258 | { 259 | BaseRemoveAt(index); 260 | } 261 | 262 | public void Remove(string name) 263 | { 264 | BaseRemove(name); 265 | } 266 | } 267 | 268 | 269 | public class MapConfigs : ConfigurationElementCollection 270 | { 271 | public MapConfigs() 272 | { 273 | 274 | } 275 | 276 | public MapConfig this[int index] 277 | { 278 | get { return (MapConfig)BaseGet(index); } 279 | set 280 | { 281 | if (BaseGet(index) != null) 282 | { 283 | BaseRemoveAt(index); 284 | } 285 | BaseAdd(index, value); 286 | } 287 | } 288 | 289 | public void Add(MapConfig serviceConfig) 290 | { 291 | BaseAdd(serviceConfig); 292 | } 293 | 294 | public void Clear() 295 | { 296 | BaseClear(); 297 | } 298 | 299 | protected override ConfigurationElement CreateNewElement() 300 | { 301 | return new MapConfig(); 302 | } 303 | 304 | protected override object GetElementKey(ConfigurationElement element) 305 | { 306 | return ((MapConfig)element).mapName; 307 | } 308 | 309 | public void Remove(MapConfig serviceConfig) 310 | { 311 | BaseRemove(serviceConfig.mapName); 312 | } 313 | 314 | public void RemoveAt(int index) 315 | { 316 | BaseRemoveAt(index); 317 | } 318 | 319 | public void Remove(string name) 320 | { 321 | BaseRemove(name); 322 | } 323 | 324 | public static implicit operator List(MapConfigs v) 325 | { 326 | throw new NotImplementedException(); 327 | } 328 | } 329 | 330 | public class Solution : ConfigurationElement 331 | { 332 | public Solution() { } 333 | 334 | public Solution(string name) 335 | { 336 | Name = name; 337 | //ReportType = reportType; 338 | } 339 | 340 | [ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)] 341 | public string Name 342 | { 343 | get { return (string)this["name"]; } 344 | set { this["name"] = value; } 345 | } 346 | 347 | 348 | 349 | } 350 | 351 | 352 | 353 | } 354 | -------------------------------------------------------------------------------- /DWLibary/Drivers/edgeversion.txt: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /DWLibary/EncryptionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Security.Cryptography; 4 | using System.Text; 5 | 6 | 7 | namespace DWLibary 8 | { 9 | 10 | public class EncryptionHelper 11 | { 12 | private readonly byte[] Key; 13 | private readonly byte[] IV; 14 | 15 | public EncryptionHelper(string _key, string _iv) 16 | { 17 | Key = ProtectedData.Unprotect(Convert.FromBase64String(_key), null, DataProtectionScope.CurrentUser); 18 | IV = ProtectedData.Unprotect(Convert.FromBase64String(_iv), null, DataProtectionScope.CurrentUser); 19 | } 20 | 21 | public string Encrypt(string plainText) 22 | { 23 | using (Aes aesAlg = Aes.Create()) 24 | { 25 | aesAlg.Key = Key; 26 | aesAlg.IV = IV; 27 | 28 | ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV); 29 | 30 | using (MemoryStream msEncrypt = new MemoryStream()) 31 | { 32 | using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)) 33 | { 34 | using (StreamWriter swEncrypt = new StreamWriter(csEncrypt)) 35 | { 36 | swEncrypt.Write(plainText); 37 | } 38 | return Convert.ToBase64String(msEncrypt.ToArray()); 39 | } 40 | } 41 | } 42 | } 43 | 44 | public string Decrypt(string cipherText) 45 | { 46 | using (Aes aesAlg = Aes.Create()) 47 | { 48 | aesAlg.Key = Key; 49 | aesAlg.IV = IV; 50 | 51 | ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV); 52 | 53 | using (MemoryStream msDecrypt = new MemoryStream(Convert.FromBase64String(cipherText))) 54 | { 55 | using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) 56 | { 57 | using (StreamReader srDecrypt = new StreamReader(csDecrypt)) 58 | { 59 | return srDecrypt.ReadToEnd(); 60 | } 61 | } 62 | } 63 | } 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /DWLibary/EncryptionKeyGenerator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Security.Cryptography; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace DWLibary 9 | { 10 | public class EncryptionKeyGenerator 11 | { 12 | 13 | 14 | public static List GenerateAndStoreKeys() 15 | { 16 | List keyiv = new List(); 17 | 18 | using (Aes aes = Aes.Create()) 19 | { 20 | aes.KeySize = 256; // 256 bits for AES-256 21 | aes.GenerateKey(); 22 | aes.GenerateIV(); 23 | 24 | byte[] protectedKey = ProtectedData.Protect(aes.Key, null, DataProtectionScope.CurrentUser); 25 | byte[] protectedIV = ProtectedData.Protect(aes.IV, null, DataProtectionScope.CurrentUser); 26 | 27 | keyiv.Add(Convert.ToBase64String(protectedKey)); 28 | keyiv.Add(Convert.ToBase64String(protectedIV)); 29 | 30 | 31 | } 32 | 33 | return keyiv; 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DWLibary/Engines/DWComparison.cs: -------------------------------------------------------------------------------- 1 | using DWLibary.Engines; 2 | using DWLibary.Struct; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.Drawing.Text; 8 | using System.Linq; 9 | using System.Net; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using static Azure.Core.HttpHeader; 13 | 14 | namespace DWLibary 15 | { 16 | public class DWComparison 17 | { 18 | public DWCommonEngine common01, common02; 19 | public DWEnvironment env01, env02; 20 | 21 | 22 | public string foUrl01, foUrl02; 23 | 24 | MapConfigs mapConfigs; 25 | MapConfig curMapConfig; 26 | 27 | List dwMaps01, dwMaps02; 28 | DWMap currentMap01, currentMap02; 29 | 30 | ILogger logger; 31 | 32 | public DWComparison(string _foUrl01, string _foUrl02, ILogger _logger) 33 | { 34 | this.foUrl01 = _foUrl01; 35 | this.foUrl02 = _foUrl02; 36 | this.logger = _logger; 37 | } 38 | 39 | private async Task init() 40 | { 41 | DWEnvCalls dWEnvCalls = new DWEnvCalls(); 42 | 43 | GlobalVar.foEnv = foUrl01; 44 | EdgeUniversal uni = new EdgeUniversal(logger); 45 | uni.getToken(); 46 | 47 | env01 = await dWEnvCalls.getEnvironment(); 48 | 49 | 50 | GlobalVar.foEnv = foUrl02; 51 | GlobalVar.loginData = new LoginData(); 52 | uni = new EdgeUniversal(logger); 53 | uni.getToken(); 54 | 55 | env02 = await dWEnvCalls.getEnvironment(); 56 | 57 | 58 | if (env01.cid == null || env01.cid.Length == 0) 59 | { 60 | logger.LogInformation("Source environment is not linked, exiting"); 61 | return; 62 | } 63 | 64 | if (env02.cid == null || env02.cid.Length == 0) 65 | { 66 | logger.LogInformation("Target environment is not linked, exiting"); 67 | return; 68 | } 69 | 70 | common01 = new DWCommonEngine(env01, logger); 71 | common02 = new DWCommonEngine(env02, logger); 72 | 73 | } 74 | 75 | public async Task runComparison() 76 | { 77 | 78 | await init(); 79 | 80 | dwMaps01 = await common01.getDWMaps(); 81 | dwMaps02 = await common02.getDWMaps(); 82 | 83 | mapConfigs = GlobalVar.dwSettings.MapConfigs; 84 | 85 | string prefix = ""; 86 | 87 | foreach (MapConfig config in mapConfigs) 88 | { 89 | curMapConfig = config; 90 | 91 | currentMap01 = dwMaps01.Where(x => x.detail.tName.Equals(config.mapName)).FirstOrDefault(); 92 | currentMap02 = dwMaps02.Where(x => x.detail.tName.Equals(config.mapName)).FirstOrDefault(); 93 | 94 | if (!mapCompareExists()) 95 | continue; 96 | 97 | prefix = config.mapName; 98 | //getField mappings 99 | await common01.getFieldMappingForMaps(currentMap01, config.mapName); 100 | await common02.getFieldMappingForMaps(currentMap02, config.mapName); 101 | 102 | 103 | //Compare filters: 104 | if (common01.getSourceFilter() != common02.getSourceFilter()) 105 | { 106 | logger.LogWarning($"Map {prefix}: FO Filters are different, Source: {common01.getSourceFilter()}, Target: {common02.getSourceFilter()}"); 107 | } 108 | 109 | if (common01.getDestinationFilter() != common02.getDestinationFilter()) 110 | { 111 | logger.LogWarning($"Map {prefix}: CE Filters are different, Source: {common01.getDestinationFilter()}, Target: {common02.getDestinationFilter()}"); 112 | } 113 | 114 | 115 | //compare integration keys 116 | await compareIntegrationKeys(prefix); 117 | 118 | 119 | 120 | List mapping01, mapping02; 121 | 122 | DWConnSetEnvironment con01 = await common01.getConnectionSetEnvironment(DWEnums.DataMaster.FO); 123 | DWConnSetEnvironment con02 = await common02.getConnectionSetEnvironment(DWEnums.DataMaster.FO); 124 | 125 | mapping01 = common01.curFieldMapping.entityMappingTasks[0].legs[0].fieldMappings; 126 | mapping02 = common02.curFieldMapping.entityMappingTasks[0].legs[0].fieldMappings; 127 | 128 | 129 | logger.LogWarning($"Comparing Source as {con01.name} with target {con02.name}"); 130 | compareFieldMapping(mapping01, mapping02, true); 131 | 132 | 133 | logger.LogWarning($"Comparing Source as {con02.name} with target {con01.name}"); 134 | compareFieldMapping(mapping02, mapping01); 135 | 136 | 137 | } 138 | 139 | 140 | 141 | 142 | 143 | } 144 | 145 | private async Task compareIntegrationKeys(string _prefix) 146 | { 147 | 148 | var soureKeys = (await common01.getCurrentKeyList(currentMap01)).OrderBy(x => x).ToList(); 149 | var targetKeys = (await common02.getCurrentKeyList(currentMap02)).OrderBy(x => x).ToList(); 150 | 151 | 152 | var difference = soureKeys.Except(targetKeys).ToList(); 153 | 154 | 155 | 156 | foreach (var key in difference) 157 | { 158 | logger.LogWarning($"{_prefix} Integration key is different in key {key}"); 159 | } 160 | 161 | 162 | } 163 | 164 | 165 | private void compareFieldMapping(List source, List target, bool compareDetails = false) 166 | { 167 | 168 | foreach (FieldMapping map01 in source) 169 | { 170 | string prefix = $"Map {curMapConfig.mapName}, Mapping {map01.sourceField} - {map01.destinationField}:"; 171 | 172 | FieldMapping map02 = target.Where(x => x.sourceField.Equals(map01.sourceField)).Where(y => y.destinationField.Equals(map01.destinationField)).FirstOrDefault(); 173 | 174 | 175 | if (map02.sourceField == null) 176 | { 177 | logger.LogWarning($"{prefix} Exists in source but not in target"); 178 | 179 | } 180 | else 181 | { 182 | if(map01.syncDirection != map02.syncDirection) 183 | { 184 | logger.LogWarning($"{prefix} Sync direction is different"); 185 | } 186 | 187 | //No value transform 188 | if ((map01.valueTransforms == null || !map01.valueTransforms.Any()) && (map02.valueTransforms == null || !map02.valueTransforms.Any())) 189 | continue; 190 | 191 | if((map01.valueTransforms == null || !map01.valueTransforms.Any()) && (map02.valueTransforms != null && map02.valueTransforms.Any())) 192 | { 193 | logger.LogWarning($"{prefix} Value map exixts in Target but not in Source"); 194 | continue; 195 | } 196 | 197 | if ((map01.valueTransforms != null && map01.valueTransforms.Any()) && (map02.valueTransforms == null || !map02.valueTransforms.Any())) 198 | { 199 | logger.LogWarning($"{prefix} Value map exixts in Target but not in Source"); 200 | continue; 201 | } 202 | 203 | //Check default value 204 | var transfromObj01 = map01.valueTransforms.FirstOrDefault(); 205 | var transfromObj02 = map02.valueTransforms.FirstOrDefault(); 206 | 207 | //Default 208 | if (transfromObj01.transformType.ToUpper() == transfromObj02.transformType.ToUpper()) 209 | { 210 | //Default value 211 | if (transfromObj01.transformType.ToUpper() == "DEFAULT") 212 | { 213 | if(map01.valueTransforms.FirstOrDefault().defaultValue != map02.valueTransforms.FirstOrDefault().defaultValue) 214 | { 215 | logger.LogWarning($"{prefix} Default value is different, Source: {map01.valueTransforms.FirstOrDefault().defaultValue}, Target: {map02.valueTransforms.FirstOrDefault().defaultValue}"); 216 | } 217 | } 218 | //valuemap 219 | else 220 | { 221 | if(transfromObj01.valueMap == null && transfromObj02.valueMap != null) 222 | { 223 | logger.LogWarning($"{prefix} Value map exixts in Target but not in Source"); 224 | } 225 | else if (transfromObj01.valueMap != null && transfromObj02.valueMap == null) 226 | { 227 | logger.LogWarning($"{prefix} Value map exixts in Source but not in Target"); 228 | } 229 | //Value map in both 230 | else 231 | { 232 | compareValueMap(transfromObj01.valueMap, transfromObj02.valueMap, prefix); 233 | } 234 | } 235 | 236 | 237 | } 238 | else 239 | { 240 | logger.LogWarning($"{prefix} Transformation type is different, Source: {transfromObj01.transformType}, Target: {transfromObj02.transformType}"); 241 | } 242 | 243 | } 244 | 245 | 246 | } 247 | } 248 | 249 | private void compareValueMap(Dictionary _map01, Dictionary _map02, string _prefix) 250 | { 251 | 252 | var map01 = _map01.OrderBy(x => x.Key).ToList(); 253 | var map02 = _map02.OrderBy(x => x.Key).ToList(); 254 | 255 | var difference = map01.Except(map02).ToList(); 256 | 257 | 258 | 259 | foreach (var key in difference) 260 | { 261 | logger.LogWarning($"{_prefix} Value map is different in key {key}"); 262 | } 263 | 264 | 265 | } 266 | 267 | private bool mapCompareExists() 268 | { 269 | bool ret = true; 270 | 271 | if (currentMap01.detail.pid == null || currentMap02.detail.pid == null) 272 | { 273 | logger.LogInformation($"Map not found {curMapConfig.mapName}"); 274 | ret = false; 275 | } 276 | 277 | if (currentMap01.detail.pid == null && currentMap02.detail.pid != null) 278 | { 279 | logger.LogInformation($"Map found in Env02 but not Env01 {curMapConfig.mapName}"); 280 | ret = false; 281 | } 282 | 283 | if (currentMap01.detail.pid != null && currentMap02.detail.pid == null) 284 | { 285 | logger.LogInformation($"Map found in Env01 but not Env02 {curMapConfig.mapName}"); 286 | ret = false; 287 | } 288 | return ret; 289 | } 290 | 291 | //private void compareFielMapping(List ) 292 | 293 | } 294 | } 295 | -------------------------------------------------------------------------------- /DWLibary/Engines/DWSolutionEngine.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary.Struct; 5 | using Microsoft.Extensions.Logging; 6 | using Newtonsoft.Json; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Configuration; 10 | using System.Linq; 11 | using System.Net.WebSockets; 12 | using System.Text; 13 | using System.Threading.Tasks; 14 | using System.Xml; 15 | using System.Xml.Linq; 16 | 17 | namespace DWLibary.Engines 18 | { 19 | public class DWSolutionEngine 20 | { 21 | DWEnvironment env; 22 | Solutions solutions; 23 | List solutionRequests; 24 | SolutionRequestResponse response; 25 | ILogger logger; 26 | 27 | public DWSolutionEngine(DWEnvironment _env, ILogger _logger) 28 | { 29 | env = _env; 30 | logger = _logger; 31 | 32 | } 33 | 34 | public async Task applySolutions() 35 | { 36 | solutions = GlobalVar.dwSettings.Solutions; 37 | 38 | 39 | buildSolutionRequest(); 40 | 41 | await postSolutionApply(); 42 | 43 | 44 | 45 | } 46 | 47 | private async Task checkSolutionApplied() 48 | { 49 | bool ret = false; 50 | 51 | try 52 | { 53 | HttpClient client = new HttpClientWithRetry(); 54 | DWHttp dW = new DWHttp(); 55 | 56 | HttpRequestMessage req = dW.buildDefaultHttpRequestGet(); 57 | 58 | UriBuilder uriBuilder = new UriBuilder(req.RequestUri); 59 | uriBuilder.Path += $"SolutionAware/{env.cid}/Status/{response.requestId}"; 60 | req.RequestUri = uriBuilder.Uri; 61 | 62 | //Debug Logging >> 63 | logger.LogDebug($"Request URI: {req.RequestUri}"); 64 | //Debug Logging << 65 | 66 | var responseStr = await client.SendAsync(req); 67 | 68 | string content = await responseStr.Content.ReadAsStringAsync(); 69 | 70 | //Debug Logging >> 71 | logger.LogDebug($"Response: {responseStr} {content}"); 72 | //Debug Logging << 73 | 74 | 75 | SolutionResult result = JsonConvert.DeserializeObject(content); 76 | 77 | 78 | if (result.state == "2") 79 | { 80 | ret = true; 81 | logger.LogInformation($"Successfully applied solutions"); 82 | } 83 | 84 | if(result.state == "3") 85 | { 86 | //error state 87 | logger.LogError("Solution applying errored"); 88 | ret = true; 89 | } 90 | 91 | 92 | } 93 | catch (Exception ex) 94 | { 95 | 96 | } 97 | 98 | return ret; 99 | } 100 | 101 | 102 | private async Task postSolutionApply() 103 | { 104 | 105 | //each solution should be applied seperatly otherwise duplicates will appear 106 | 107 | foreach (SolutionApplyObj solutionReq in solutionRequests) 108 | { 109 | logger.LogInformation($"Applying solution {solutionReq.solutions[0].criteria.uniquename}"); 110 | 111 | 112 | HttpClient client = new HttpClientWithRetry(); 113 | DWHttp dW = new DWHttp(); 114 | 115 | HttpRequestMessage req = dW.buildDefaultHttpRequestPost(); 116 | 117 | UriBuilder uriBuilder = new UriBuilder(req.RequestUri); 118 | uriBuilder.Path += $"SolutionAware/{env.cid}/RestoreTemplates"; 119 | req.RequestUri = uriBuilder.Uri; 120 | req.Content = new StringContent(JsonConvert.SerializeObject(solutionReq), Encoding.UTF8, "application/json"); 121 | 122 | //Debug Logging >> 123 | logger.LogDebug($"Request URI: {req.RequestUri}"); 124 | //Debug Logging << 125 | 126 | var responseStr = await client.SendAsync(req); 127 | 128 | string content = await responseStr.Content.ReadAsStringAsync(); 129 | 130 | //Debug Logging >> 131 | logger.LogDebug($"Response: {responseStr} {content}"); 132 | //Debug Logging << 133 | 134 | response = JsonConvert.DeserializeObject(content); 135 | 136 | 137 | while (!await checkSolutionApplied()) 138 | { 139 | //wait until successful 140 | logger.LogInformation($"Waiting for solutions to be applied."); 141 | Thread.Sleep(1000); 142 | } 143 | 144 | 145 | } 146 | 147 | 148 | } 149 | 150 | 151 | private void buildSolutionRequest() 152 | { 153 | 154 | solutionRequests = new List(); 155 | foreach (Solution solution in solutions) 156 | { 157 | SolutionApplyObj solutionRequest = new SolutionApplyObj(); 158 | solutionRequest.action = "2"; //Apply 159 | solutionRequest.solutions = new List(); 160 | 161 | SolutionCriteria criteria = new SolutionCriteria(); 162 | SolutionCriteriaValue solutionCriteriaValue = new SolutionCriteriaValue(); 163 | //todo 164 | solutionCriteriaValue.uniquename = solution.Name; 165 | 166 | criteria.criteria = solutionCriteriaValue; 167 | solutionRequest.solutions.Add(criteria); 168 | 169 | solutionRequests.Add(solutionRequest); 170 | } 171 | 172 | logger.LogInformation($"Solution request build: {JsonConvert.SerializeObject(solutionRequests)}"); 173 | } 174 | 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /DWLibary/Engines/ResetLinkEngine.cs: -------------------------------------------------------------------------------- 1 | using DWLibary.Struct; 2 | using Microsoft.Extensions.Logging; 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Engines 11 | { 12 | public class ResetLinkEngine 13 | { 14 | DWCommonEngine common; 15 | DWEnvironment env; 16 | ILogger logger; 17 | ResetLinkPayload payload; 18 | bool forceReset; 19 | 20 | public ResetLinkEngine(ILogger _logger, DWEnvironment _env) 21 | { 22 | this.logger = _logger; 23 | this.env = _env; 24 | payload = new ResetLinkPayload(); 25 | common = new DWCommonEngine(env, logger); 26 | } 27 | 28 | 29 | public async Task resetLink(bool force = false) 30 | 31 | { 32 | 33 | forceReset = force; 34 | await common.getConnectionSet(); 35 | 36 | await buildEnvironments(); 37 | 38 | getAddCurrentLegalEntities(); 39 | 40 | await sendResetLinkPayload(); 41 | 42 | } 43 | 44 | public async Task sendResetLinkPayload() 45 | { 46 | //connectionSet is only needed once 47 | 48 | logger.LogInformation($"Reset Link"); 49 | try 50 | { 51 | HttpClient client = new HttpClientWithRetry(); 52 | client.Timeout = new TimeSpan(0,0,300); 53 | DWHttp dW = new DWHttp(env); 54 | 55 | HttpRequestMessage req = dW.buildDefaultHttpRequestPost(); 56 | 57 | UriBuilder uriBuilder = new UriBuilder(req.RequestUri.Scheme + "://" + req.RequestUri.Host); 58 | uriBuilder.Path += $"api/ConnectionSet/{env.cid}/Reset"; 59 | uriBuilder.Query = $"targetType=AX&forceReset={forceReset}"; 60 | 61 | req.RequestUri = uriBuilder.Uri; 62 | 63 | 64 | string payloadStr = JsonConvert.SerializeObject(payload, Newtonsoft.Json.Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); 65 | logger.LogDebug($"ResetLinkPayload: {payloadStr}"); 66 | 67 | req.Content = new StringContent(payloadStr, Encoding.UTF8, "application/json"); 68 | 69 | //Debug Logging >> 70 | logger.LogDebug($"Request URI: {req.RequestUri}"); 71 | //Debug Logging << 72 | logger.LogInformation("Sending ResetLink request, this can take longer..."); 73 | var responseStr = await client.SendAsync(req); 74 | 75 | string content = await responseStr.Content.ReadAsStringAsync(); 76 | 77 | //Debug Logging >> 78 | logger.LogDebug($"Response: {responseStr} {content}"); 79 | //Debug Logging << 80 | 81 | if(responseStr.IsSuccessStatusCode) 82 | { 83 | logger.LogInformation("Successful reset"); 84 | } 85 | else 86 | { 87 | logger.LogError("Reset link failed"); 88 | } 89 | 90 | 91 | 92 | } 93 | catch (Exception ex) 94 | { 95 | logger.LogError(ex.ToString()); 96 | } 97 | } 98 | 99 | 100 | private void getAddCurrentLegalEntities() 101 | { 102 | List ret = new List(); 103 | 104 | foreach(var le in common.connectionSet.dualWriteDetail.legalEntityMappings.mappings) 105 | { 106 | if(!ret.Contains(le.left.name)) 107 | { 108 | ret.Add(le.left.name); 109 | } 110 | } 111 | 112 | payload.legalEntities = ret; 113 | 114 | //return ret; 115 | 116 | } 117 | 118 | private async Task buildEnvironments() 119 | { 120 | payload.environments = new List(); 121 | 122 | 123 | DWConnSetEnvironment ceEnv = await common.getConnectionSetEnvironment(DWEnums.DataMaster.CE); 124 | DWConnSetEnvironment foEnv = await common.getConnectionSetEnvironment(DWEnums.DataMaster.FO); 125 | 126 | payload.environments.Add(mapEnvToResetLinkEnv(ceEnv)); 127 | payload.environments.Add(mapEnvToResetLinkEnv(foEnv)); 128 | 129 | //adding power apps env: 130 | 131 | payload.powerAppsEnvironmentName = ceEnv.powerAppsEnvironment; 132 | 133 | } 134 | 135 | private ResetLinkEnvironment mapEnvToResetLinkEnv(DWConnSetEnvironment _env) 136 | { 137 | ResetLinkEnvironment ret = new ResetLinkEnvironment(); 138 | 139 | ret.name = _env.name; 140 | ret.displayName = _env.environmentDisplayName; 141 | ret.id = _env.powerAppsEnvironment; 142 | ret.isDevInstance = _env.isDevInstance; 143 | ret.targetType = _env.targetType; 144 | ret.directUrl = _env.directUrl; 145 | return ret; 146 | 147 | } 148 | 149 | 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /DWLibary/EnvGatewayCombination.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary 11 | { 12 | public class EnvGatewayCombination 13 | { 14 | public string environment { get; set; } 15 | public string gateway { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DWLibary/GlobalVar.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary.Struct; 5 | using Microsoft.Extensions.Logging; 6 | using Newtonsoft.Json; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Configuration; 10 | using System.Diagnostics; 11 | using System.Linq; 12 | using System.Security.Policy; 13 | using System.Text; 14 | using System.Threading.Tasks; 15 | 16 | namespace DWLibary 17 | { 18 | public static class GlobalVar 19 | { 20 | private static LoginData _loginData; 21 | 22 | public static int maxThreads { get; set; } 23 | 24 | //public static bool exportConfig { get; set; } 25 | public static DWEnums.MapStatus exportState { get; set; } 26 | public static DWEnums.ExportOptions exportOption { get; set; } 27 | 28 | public static DWEnums.RunMode runMode { get; set; } 29 | public static DWEnums.ExecutionMode executionMode { get; set; } 30 | 31 | public static DWSettings dwSettings { get; private set; } 32 | 33 | public static Configuration config { get; private set; } 34 | 35 | public static string configFileName { get; set; } 36 | 37 | public static string newConfigFileName { get; set; } 38 | 39 | public static string tenant { get; set; } 40 | 41 | public static bool noSolutions { get; set; } 42 | public static string mfasecret { get; set; } 43 | public static bool useadowikiupload { get; set; } 44 | public static string adotoken { get; set; } 45 | 46 | public static Uri dataintegratorURL { get; set; } 47 | 48 | public static List errors { get; set; } 49 | 50 | public static Options parsedOptions { get; set; } 51 | 52 | public static LoginData loginData 53 | { 54 | get 55 | { 56 | return _loginData; 57 | } 58 | set 59 | { 60 | _loginData = value; 61 | 62 | saveLoginData(); 63 | } 64 | 65 | } 66 | 67 | public static string username { get; set; } 68 | public static string password { get; set; } 69 | 70 | private static string gatewayUrl { get; set; } 71 | public static string baseUrl 72 | { 73 | get 74 | { 75 | return gatewayUrl; 76 | } 77 | set 78 | { 79 | gatewayUrl = value; 80 | saveGateway(); 81 | } 82 | } 83 | 84 | public static string foEnv { get; set; } 85 | 86 | 87 | public static List savedTokens { get; set; } 88 | 89 | public static List envGateways { get; set; } 90 | 91 | public static void initTestValues() 92 | { 93 | baseUrl = "https://projectmanagementservice.weu-il107.gateway.prod.island.powerapps.com";///api/DualWriteManagement/1.0/"; 94 | } 95 | 96 | public static void initConfig() 97 | { 98 | var map = new ExeConfigurationFileMap(); 99 | 100 | configFileName = Path.Combine(curExecutingDirectory(), configFileName); 101 | if(logger != null) 102 | logger.LogInformation($"Config path: {configFileName}"); 103 | if (configFileName != String.Empty && File.Exists(configFileName)) 104 | { 105 | map.ExeConfigFilename = configFileName; 106 | config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); 107 | if (logger != null) 108 | logger.LogInformation("Custom configuration loaded"); 109 | } 110 | else 111 | { 112 | config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 113 | if (logger != null) 114 | logger.LogInformation("Default configuration loaded"); 115 | } 116 | 117 | dwSettings = config.GetSection("DWSettings") as DWSettings; 118 | 119 | foreach(MapConfig mc in dwSettings.MapConfigs) 120 | { 121 | mc.initSettings(); 122 | 123 | } 124 | 125 | } 126 | 127 | private static ILogger logger; 128 | //used to display all errors at the end 129 | 130 | public static void addError(string _errorMessage, string prefix = "") 131 | { 132 | 133 | ErrorMessage message = new ErrorMessage(); 134 | message.error = _errorMessage; 135 | message.prefix = prefix; 136 | 137 | 138 | errors.Add(message); 139 | 140 | if(prefix != "") 141 | logger.LogError($"{prefix}: {_errorMessage}"); 142 | else 143 | logger.LogError(_errorMessage); 144 | } 145 | 146 | public static void outputErrors() 147 | { 148 | 149 | errors = errors.OrderBy(x => x.prefix).ToList(); 150 | 151 | logger.LogInformation("Output all errors.."); 152 | foreach(ErrorMessage e in errors) 153 | { 154 | logger.LogError($"{e.prefix}: {e.error}"); 155 | } 156 | 157 | } 158 | 159 | public static string curExecutingDirectory() 160 | { 161 | string ret = String.Empty; 162 | 163 | try 164 | { 165 | var dir = new DirectoryInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); 166 | ret = dir.Parent.FullName; 167 | 168 | } 169 | catch(Exception ex) { } 170 | 171 | 172 | return ret; 173 | } 174 | 175 | public static void setdataintegratorURL() 176 | { 177 | 178 | //UriBuilder builder = new UriBuilder(); 179 | 180 | string configURL = "https://dataintegrator.trafficmanager.net"; 181 | 182 | try 183 | { 184 | configURL = config.AppSettings.Settings["dataintegratorURL"].Value; 185 | } 186 | catch 187 | { 188 | 189 | } 190 | dataintegratorURL = new UriBuilder(configURL).Uri; 191 | } 192 | 193 | public static void init(ILogger _logger) 194 | { 195 | 196 | logger = _logger; 197 | initConfig(); 198 | 199 | setdataintegratorURL(); 200 | 201 | errors = new List(); 202 | 203 | loginData = new LoginData(); 204 | #pragma warning disable CS8601 // Possible null reference assignment. 205 | //not needed anymore, parsing automatically - needed if using client id/ secret 206 | 207 | if (baseUrl == null) 208 | baseUrl = String.Empty; 209 | 210 | //if coming from commandline args dont use the config file 211 | if (foEnv == null ||foEnv == String.Empty) 212 | foEnv = config.AppSettings.Settings["FOEnvironment"].Value; 213 | #pragma warning restore CS8601 // Possible null reference assignment. 214 | 215 | maxThreads = Convert.ToInt16(config.AppSettings.Settings["maxThreads"].Value); 216 | executionMode = DWEnums.GetValueFromDescription(config.AppSettings.Settings["executionMode"].Value); 217 | 218 | if(runMode == DWEnums.RunMode.none) 219 | runMode = DWEnums.GetValueFromDescription(config.AppSettings.Settings["runMode"].Value); 220 | 221 | if (maxThreads == 1) 222 | executionMode = DWEnums.ExecutionMode.sequential; 223 | 224 | //readLoginTokens(); //Do not make this anymore, can keep it in memory but not on disk 225 | 226 | if (savedTokens == null) 227 | savedTokens = new List(); 228 | else 229 | { 230 | //check if tokes exist 231 | if (GlobalVar.username != null && GlobalVar.username != String.Empty) 232 | { 233 | GlobalVar.loginData = savedTokens.Where(x => x.username.ToUpper().Equals(GlobalVar.username.ToUpper())).FirstOrDefault(); 234 | 235 | if (GlobalVar.loginData != null) 236 | { 237 | TokenRefresh tr = new TokenRefresh(_logger); 238 | tr.tryGetRefreshToken(true); 239 | } 240 | else 241 | loginData = new LoginData(); 242 | 243 | } 244 | } 245 | 246 | // readGateways(); //Do not make this anymore, can keep it in memory but not on disk 247 | if (envGateways != null) 248 | { 249 | EnvGatewayCombination lookup = envGateways.Where(x => x.environment.Equals(foEnv)).FirstOrDefault(); 250 | 251 | if (lookup != null) 252 | baseUrl = lookup.gateway; 253 | 254 | } 255 | else 256 | { 257 | envGateways = new List(); 258 | } 259 | 260 | // envGateways 261 | 262 | } 263 | 264 | 265 | 266 | private static void saveGateway() 267 | { 268 | if (baseUrl == null || baseUrl == String.Empty || envGateways == null) 269 | return; 270 | 271 | EnvGatewayCombination comb = new EnvGatewayCombination(); 272 | comb.environment = foEnv; 273 | comb.gateway = baseUrl; 274 | 275 | EnvGatewayCombination lookup = envGateways.Where(x => x.environment.Equals(comb.environment)).FirstOrDefault(); 276 | 277 | if (lookup != null) 278 | { 279 | envGateways.Remove(lookup); 280 | } 281 | 282 | envGateways.Add(comb); 283 | //writeGateways(); //Do not make this anymore, can keep it in memory but not on disk 284 | 285 | 286 | } 287 | 288 | private static void saveLoginData() 289 | { 290 | 291 | //dont want to have orphant records 292 | if (loginData == null || loginData.access_token == null || loginData.access_token == String.Empty) 293 | return; 294 | 295 | 296 | LoginData lookup = savedTokens.Where(x => x.username.ToUpper().Equals(GlobalVar.loginData.username.ToUpper())).FirstOrDefault(); 297 | 298 | if(lookup != null) 299 | { 300 | savedTokens.Remove(lookup); 301 | } 302 | 303 | loginData.environment = foEnv; 304 | 305 | savedTokens.Add(GlobalVar.loginData); 306 | //writeLoginTokens(); //Do not make this anymore, can keep it in memory but not on disk 307 | 308 | 309 | } 310 | 311 | //Do not make this anymore, can keep it in memory but not on disk 312 | public static void writeGateways() 313 | { 314 | try 315 | { 316 | 317 | var base64 = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(envGateways)); 318 | 319 | using (StreamWriter sw = new StreamWriter(@"envgateways.txt")) 320 | { 321 | sw.WriteLine(Convert.ToBase64String(base64)); 322 | } 323 | } 324 | catch (Exception ex) 325 | { 326 | 327 | } 328 | } 329 | //Do not make this anymore, can keep it in memory but not on disk 330 | public static void readGateways() 331 | { 332 | try 333 | { 334 | 335 | 336 | 337 | using (StreamReader sr = new StreamReader(@"envgateways.txt")) 338 | { 339 | var bytes = Convert.FromBase64String(sr.ReadToEnd()); 340 | 341 | var decodedString = Encoding.UTF8.GetString(bytes); 342 | 343 | envGateways = JsonConvert.DeserializeObject>(decodedString); 344 | } 345 | } 346 | catch (Exception ex) 347 | { 348 | 349 | } 350 | } 351 | //Do not make this anymore, can keep it in memory but not on disk 352 | public static void writeLoginTokens() 353 | { 354 | try 355 | { 356 | 357 | var base64 = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(savedTokens)); 358 | 359 | using (StreamWriter sw = new StreamWriter(@"tokens.txt")) 360 | { 361 | sw.WriteLine(Convert.ToBase64String(base64)); 362 | } 363 | } 364 | catch(Exception ex) 365 | { 366 | 367 | } 368 | } 369 | //Do not make this anymore, can keep it in memory but not on disk 370 | public static void readLoginTokens() 371 | { 372 | try 373 | { 374 | 375 | 376 | 377 | using (StreamReader sr = new StreamReader(@"tokens.txt")) 378 | { 379 | var bytes = Convert.FromBase64String(sr.ReadToEnd()); 380 | 381 | var decodedString = Encoding.UTF8.GetString(bytes); 382 | 383 | savedTokens = JsonConvert.DeserializeObject>(decodedString); 384 | } 385 | } 386 | catch (Exception ex) 387 | { 388 | 389 | } 390 | } 391 | 392 | } 393 | 394 | public class ErrorMessage 395 | { 396 | public string prefix { get; set; } 397 | public string error { get; set; } 398 | } 399 | } 400 | -------------------------------------------------------------------------------- /DWLibary/HttpClientWithRetry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net.Http; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Polly; 6 | using Polly.Retry; 7 | 8 | namespace DWLibary 9 | { 10 | public class HttpClientWithRetry : HttpClient 11 | { 12 | private readonly AsyncRetryPolicy _retryPolicy; 13 | 14 | public HttpClientWithRetry() 15 | { 16 | _retryPolicy = Policy 17 | .HandleResult(r => r.StatusCode == System.Net.HttpStatusCode.TooManyRequests) 18 | .WaitAndRetryAsync(5, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); 19 | } 20 | 21 | public override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 22 | { 23 | return await _retryPolicy.ExecuteAsync(() => base.SendAsync(request, cancellationToken)); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DWLibary/MFAGen.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using OtpNet; 10 | 11 | namespace DWLibary 12 | { 13 | public class MFAGen 14 | { 15 | public static string getMFAKey() 16 | { 17 | string secret = string.Empty; 18 | 19 | if (GlobalVar.mfasecret != String.Empty) 20 | secret = GlobalVar.mfasecret; 21 | else 22 | secret = GlobalVar.config.AppSettings.Settings["MFASecretKey"].Value; 23 | 24 | var otpKeyBytes = Base32Encoding.ToBytes(secret); 25 | var totp = new Totp(otpKeyBytes); 26 | var twoFactorCode = totp.ComputeTotp(); // <- got 2FA coed at this time! 27 | 28 | return twoFactorCode; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /DWLibary/Options.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace DWLibary 9 | { 10 | 11 | public class Options 12 | { 13 | [Option('u', "username", HelpText = "Username to use")] 14 | public string username { get; set; } 15 | 16 | [Option('p', "password", HelpText = "Password to use")] 17 | public string password { get; set; } 18 | 19 | [Option('e', "environment", HelpText = "Environment without https://www.")] 20 | public string environment { get; set; } 21 | 22 | [Option('c', "config", HelpText = "define what config to use for execution", Default = "")] 23 | public string configFileName { get; set; } 24 | 25 | [Option('n', "new config", HelpText = "Define the name of the new configuration file during export", Default = "")] 26 | public string newConfigFileName { get; set; } 27 | 28 | [Option('s', Default = DWEnums.MapStatus.None, HelpText = "Status for export, values Running, All, Stopped")] 29 | public DWEnums.MapStatus status { get; set; } 30 | 31 | [Option('l', Default = "", HelpText = "Log level, values Debug, Information, Error")] 32 | public string logLevel { get; set; } 33 | 34 | [Option('t', "target environment", HelpText = "Target environment for comparison without https://www.")] 35 | public string targetenvironment { get; set; } 36 | 37 | [Option("nosolutions", Default = false, HelpText = "Prevents solutions from beeing applied")] 38 | public bool noSolutions { get; set; } 39 | 40 | [Option("forceReset", Default = false, HelpText = "Forces reset when using ResetLink")] 41 | public bool forceReset { get; set; } 42 | 43 | [Option("runmode", Default = DWEnums.RunMode.none, HelpText = "Overwrites the runmode in the config file, possible: deployment, deployInitialSync, start, stop, pause, export")] 44 | public DWEnums.RunMode runmode { get; set; } 45 | 46 | [Option("catchupsetting", Default = DWEnums.CatchUpSyncOption.Default, HelpText = "Defines how CatchUps are handles after pausing!")] 47 | public DWEnums.CatchUpSyncOption catchupsetting { get; set; } 48 | 49 | [Option("mfasecret", Default = "", HelpText = "Overwrites the mfasecret in the config file, usable in deployment pipelines when the secret is storerd in a key vault")] 50 | public string mfasecret { get; set; } 51 | 52 | [Option("useadowikiupload", Default = false, HelpText = "Overwrites the UseADOWikiUpload parameter in the config, usable in pipelines")] 53 | public bool useadowikiupload { get; set; } 54 | 55 | [Option("adotoken", Default = "", HelpText = "Overwrites the AccessToken in the config file for ADO Wiki uploads, usable in deployment pipelines when the secret is storerd in a key vault")] 56 | public string adotoken { get; set; } 57 | 58 | [Option('o', Default = DWEnums.ExportOptions.Default, HelpText = "Additional options for export")] 59 | public DWEnums.ExportOptions exportOption { get; set; } 60 | 61 | [Option("clientid", Default = "", HelpText = "Client ID, App registration")] 62 | public string clientId { get; set; } 63 | 64 | [Option("tenant", Default = "", HelpText = "Azure tenant ID")] 65 | public string tenant { get; set; } 66 | 67 | [Option("notinprivate", Default = false, HelpText = "Disable opening private browsing")] 68 | public bool notinprivate { get; set; } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DWLibary/ServicePrincipalAuth.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using Azure.Core; 5 | using Azure.Identity; 6 | using Microsoft.Extensions.Logging; 7 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 8 | using Microsoft.IdentityModel.Tokens; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | using System.Net.Http.Headers; 13 | using System.Text; 14 | using System.Threading.Tasks; 15 | 16 | namespace DWLibary 17 | { 18 | 19 | //for future releases 20 | public class ServicePrincipalAuth 21 | { 22 | ILogger logger; 23 | 24 | public ServicePrincipalAuth(ILogger _logger) 25 | { 26 | logger = _logger; 27 | } 28 | public async Task authenticate() 29 | { 30 | bool ret = false; 31 | try 32 | { 33 | var clientCredential = new ClientCredential(GlobalVar.username, GlobalVar.password); 34 | 35 | var credential = new UsernamePasswordCredential(GlobalVar.username, GlobalVar.password, GlobalVar.parsedOptions.tenant, GlobalVar.parsedOptions.clientId); 36 | var token = await credential.GetTokenAsync(new TokenRequestContext(new[] { "https://IntegratorApp.com/.default" })); 37 | 38 | GlobalVar.loginData.accessToken = token; 39 | 40 | } 41 | catch(Exception ex) 42 | { 43 | logger.LogError(ex.ToString()); 44 | } 45 | 46 | return ret; 47 | 48 | } 49 | 50 | 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DWLibary/Struct/DWConnectionSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 13 | 14 | 15 | public struct DWConnSetEnvironment 16 | { 17 | public string name { get; set; } 18 | public string connectionSetName { get; set; } 19 | public string targetType { get; set; } 20 | public List sharedEnums { get; set; } 21 | public List schemas { get; set; } 22 | public string connectionDisplayName { get; set; } 23 | public string environmentDisplayName { get; set; } 24 | public string metadataUrl { get; set; } 25 | public string environmentInfo { get; set; } 26 | public string powerAppsEnvironment { get; set; } 27 | public string directUrl { get; set; } 28 | public bool isDevInstance { get; set; } 29 | public bool bypassApiHubConnector { get; set; } 30 | public bool needsIntegrationKey { get; set; } 31 | public bool excludeHardCodedIntegrationKeys { get; set; } 32 | } 33 | 34 | 35 | 36 | public struct DataPartitionMapping 37 | { 38 | public string firstPartitionEnvName { get; set; } 39 | public string firstPartition { get; set; } 40 | public string secondPartitionEnvName { get; set; } 41 | public string secondPartition { get; set; } 42 | } 43 | 44 | public struct Left 45 | { 46 | public string name { get; set; } 47 | public string id { get; set; } 48 | } 49 | 50 | public struct Right 51 | { 52 | public string name { get; set; } 53 | public string id { get; set; } 54 | } 55 | 56 | public struct Mapping 57 | { 58 | public Left left { get; set; } 59 | public Right right { get; set; } 60 | } 61 | 62 | public struct LegalEntityMappings 63 | { 64 | public string leftEnvironment { get; set; } 65 | public string rightEnvironment { get; set; } 66 | public List mappings { get; set; } 67 | } 68 | 69 | public struct ConflictResolution 70 | { 71 | public string option { get; set; } 72 | public string master { get; set; } 73 | } 74 | 75 | public struct Threshold 76 | { 77 | public int count { get; set; } 78 | public int interval { get; set; } 79 | public string unitOfTime { get; set; } 80 | } 81 | 82 | public struct AlertSetting 83 | { 84 | public string name { get; set; } 85 | public string state { get; set; } 86 | public List errorTypes { get; set; } 87 | public Threshold threshold { get; set; } 88 | public string action { get; set; } 89 | } 90 | 91 | public struct Result 92 | { 93 | public string message { get; set; } 94 | public string status { get; set; } 95 | } 96 | 97 | public struct SolutionAwareRequest 98 | { 99 | public string requestId { get; set; } 100 | public string action { get; set; } 101 | public DateTime createdOn { get; set; } 102 | public DateTime modifiedOn { get; set; } 103 | public string state { get; set; } 104 | public Result result { get; set; } 105 | public string rootActivityId { get; set; } 106 | } 107 | 108 | public struct ScheduledRequest 109 | { 110 | public string activityType { get; set; } 111 | public DateTime lastExecutionTime { get; set; } 112 | public string frequency { get; set; } 113 | public int interval { get; set; } 114 | } 115 | 116 | public struct DualWriteDetail 117 | { 118 | public DateTime trialExpiresOn { get; set; } 119 | public LegalEntityMappings legalEntityMappings { get; set; } 120 | public ConflictResolution conflictResolution { get; set; } 121 | public List alertSettings { get; set; } 122 | public List autoPauseThresholdSettings { get; set; } 123 | public bool isOnFirstPartyAuth { get; set; } 124 | public bool isSolutionAware { get; set; } 125 | public List solutionAwareRequests { get; set; } 126 | public List actionDetails { get; set; } 127 | public List errorTableNames { get; set; } 128 | public string dualWriteScheduleLogicAppRunId { get; set; } 129 | public List scheduledRequests { get; set; } 130 | public bool isTrialEnvironment { get; set; } 131 | public bool errorTableUpdateInProgress { get; set; } 132 | public string catchupCleanupTriggerName { get; set; } 133 | } 134 | 135 | public struct DWConnectionSet 136 | { 137 | public string name { get; set; } 138 | public string displayName { get; set; } 139 | public Dictionary environments { get; set; } 140 | public List targetTypeList { get; set; } 141 | public List dataPartitionMappings { get; set; } 142 | public string tenant { get; set; } 143 | public bool forDualWrite { get; set; } 144 | public DualWriteDetail dualWriteDetail { get; set; } 145 | public bool bypassApiHubConnector { get; set; } 146 | public string id { get; set; } 147 | public string owner { get; set; } 148 | public DateTime createdDateTime { get; set; } 149 | public List tags { get; set; } 150 | } 151 | 152 | 153 | } 154 | -------------------------------------------------------------------------------- /DWLibary/Struct/DWEnvironment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | 13 | public struct DWEnvironmentDetail 14 | { 15 | public bool isSolutionAware { get; set; } 16 | } 17 | 18 | public struct DWEnvironment 19 | { 20 | public string cid { get; set; } 21 | public string cname { get; set; } 22 | public string targetType { get; set; } 23 | public string displayName { get; set; } 24 | public DWEnvironmentDetail detail { get; set; } 25 | public string powerAppsEnvironment { get; set; } 26 | public string foEnvironment { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DWLibary/Struct/DWFieldMapping.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using Newtonsoft.Json; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace DWLibary.Struct 12 | { 13 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 14 | public struct TypeDetails 15 | { 16 | [JsonProperty("$type")] 17 | public string Type { get; set; } 18 | public string type { get; set; } 19 | public int length { get; set; } 20 | public bool isMultiLine { get; set; } 21 | public int? precision { get; set; } 22 | public double? minimumValue { get; set; } 23 | public double? maximumValue { get; set; } 24 | public bool? isDateOnly { get; set; } 25 | public string relatedEntity { get; set; } 26 | public string navigationPropertyName { get; set; } 27 | } 28 | 29 | public struct Field 30 | { 31 | [JsonProperty("$id")] 32 | public string Id { get; set; } 33 | public string name { get; set; } 34 | public string displayName { get; set; } 35 | public bool isRequired { get; set; } 36 | public bool isRetrievable { get; set; } 37 | public bool isReadonly { get; set; } 38 | public TypeDetails typeDetails { get; set; } 39 | public string parentRelationDataSetName { get; set; } 40 | public string parentRelationEntitySchemaName { get; set; } 41 | public string nestedParentRelationEntitySchemaName { get; set; } 42 | } 43 | 44 | public struct Key 45 | { 46 | public string name { get; set; } 47 | public string displayName { get; set; } 48 | public List fields { get; set; } 49 | public bool isIntegrationKey { get; set; } 50 | public bool isPrimaryKey { get; set; } 51 | public bool isCustomized { get; set; } 52 | public bool isHardcoded { get; set; } 53 | public string message { get; set; } 54 | } 55 | 56 | public struct AuthorizedUser 57 | { 58 | public string user { get; set; } 59 | public List permissions { get; set; } 60 | } 61 | 62 | public struct Schema 63 | { 64 | [JsonProperty("$id")] 65 | public string Id { get; set; } 66 | public string targetType { get; set; } 67 | public string refreshState { get; set; } 68 | public string name { get; set; } 69 | public string displayName { get; set; } 70 | public List fields { get; set; } 71 | public List keys { get; set; } 72 | public string tenant { get; set; } 73 | public string primaryCompanyContextField { get; set; } 74 | public List authorizedUsers { get; set; } 75 | public string id { get; set; } 76 | public string owner { get; set; } 77 | public List tags { get; set; } 78 | public string singletonName { get; set; } 79 | public List companyContextFields { get; set; } 80 | } 81 | 82 | public struct FMEnvironment 83 | { 84 | public string name { get; set; } 85 | public string connectionSetName { get; set; } 86 | public string targetType { get; set; } 87 | public List sharedEnums { get; set; } 88 | public List schemas { get; set; } 89 | public string connectionDisplayName { get; set; } 90 | public string environmentDisplayName { get; set; } 91 | public string metadataUrl { get; set; } 92 | public string environmentInfo { get; set; } 93 | public string powerAppsEnvironment { get; set; } 94 | public bool isDevInstance { get; set; } 95 | public bool bypassApiHubConnector { get; set; } 96 | public bool needsIntegrationKey { get; set; } 97 | public bool excludeHardCodedIntegrationKeys { get; set; } 98 | public string directUrl { get; set; } 99 | } 100 | 101 | public struct ValueMap 102 | { 103 | 104 | } 105 | 106 | public struct ValueTransform 107 | { 108 | [JsonProperty("$type")] 109 | public string Type { get; set; } 110 | public string transformType { get; set; } 111 | //public ValueMap valueMap { get; set; } 112 | public Dictionary valueMap { get; set; } 113 | public string defaultValue { get; set; } 114 | public bool createValuesOnDestination { get; set; } 115 | } 116 | 117 | public struct FieldMapping 118 | { 119 | public DWEnums.DWSyncDirection syncDirection { get; set; } 120 | public string sourceField { get; set; } 121 | public string destinationField { get; set; } 122 | public List valueTransforms { get; set; } 123 | public bool isSystemGenerated { get; set; } 124 | public string destinationLookupFieldRelatedEntity { get; set; } 125 | } 126 | 127 | public struct Leg 128 | { 129 | public string id { get; set; } 130 | public string sourceEnvironment { get; set; } 131 | public string sourceSchema { get; set; } 132 | public string sourceEnvironmentType { get; set; } 133 | public string sourceFilter { get; set; } 134 | public bool isSourceFilterEditable { get; set; } 135 | public string destinationEnvironment { get; set; } 136 | public string destinationSchema { get; set; } 137 | public string destinationEnvironmentType { get; set; } 138 | public string reversedSourceFilter { get; set; } 139 | public List fieldMappings { get; set; } 140 | public string entityFileFormat { get; set; } 141 | public bool deleteNonMatchingData { get; set; } 142 | } 143 | 144 | public struct EntityMappingTask 145 | { 146 | public string name { get; set; } 147 | public int order { get; set; } 148 | public string connectionSetName { get; set; } 149 | public string leftEnvironmentType { get; set; } 150 | public string centerEnvironmentType { get; set; } 151 | public string rightEnvironmentType { get; set; } 152 | public string leftEnvironment { get; set; } 153 | public string centerEnvironment { get; set; } 154 | public string leftPartitionName { get; set; } 155 | public string centerPartitionName { get; set; } 156 | public List legs { get; set; } 157 | } 158 | 159 | public struct Version 160 | { 161 | public int major { get; set; } 162 | public int minor { get; set; } 163 | public int build { get; set; } 164 | public int revision { get; set; } 165 | public int majorRevision { get; set; } 166 | public int minorRevision { get; set; } 167 | } 168 | 169 | public struct TemplateIdentifier 170 | { 171 | public string name { get; set; } 172 | public Version version { get; set; } 173 | public string id { get; set; } 174 | public string displayName { get; set; } 175 | } 176 | 177 | public struct DWFieldMapping 178 | { 179 | public string name { get; set; } 180 | public string displayName { get; set; } 181 | public List environments { get; set; } 182 | public List targetTypeList { get; set; } 183 | public List entityMappingTasks { get; set; } 184 | public List validationIssues { get; set; } 185 | public string projectState { get; set; } 186 | public bool isPQOnlineFlow { get; set; } 187 | public int maxCrmIo { get; set; } 188 | public bool useCrmOdataExport { get; set; } 189 | public bool createImportErrorFile { get; set; } 190 | public bool autoRetryFailedImportRecords { get; set; } 191 | public TemplateIdentifier templateIdentifier { get; set; } 192 | public bool isDataManagementProject { get; set; } 193 | public string dataManagementOperation { get; set; } 194 | public string tenant { get; set; } 195 | public bool isDualWriteProject { get; set; } 196 | public bool isDualWriteEnabled { get; set; } 197 | public bool skipInitialSync { get; set; } 198 | public bool areKeysMismatched { get; set; } 199 | public List authorizedUsers { get; set; } 200 | public string id { get; set; } 201 | public string owner { get; set; } 202 | public DateTime createdDateTime { get; set; } 203 | public List tags { get; set; } 204 | } 205 | 206 | 207 | } 208 | -------------------------------------------------------------------------------- /DWLibary/Struct/DWMaps.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 13 | public struct DWMapLeftEntity 14 | { 15 | public string targetType { get; set; } 16 | public string name { get; set; } 17 | public string displayName { get; set; } 18 | } 19 | 20 | public struct DWMapRightEntity 21 | { 22 | public string targetType { get; set; } 23 | public string name { get; set; } 24 | public string displayName { get; set; } 25 | } 26 | 27 | public struct DWMapVersion 28 | { 29 | public int major { get; set; } 30 | public int minor { get; set; } 31 | public int build { get; set; } 32 | public int revision { get; set; } 33 | public int majorRevision { get; set; } 34 | public int minorRevision { get; set; } 35 | } 36 | 37 | public struct DWMapTemplate 38 | { 39 | public string id { get; set; } 40 | public string name { get; set; } 41 | public bool readOnly { get; set; } 42 | public string displayName { get; set; } 43 | public string author { get; set; } 44 | public DWMapVersion version { get; set; } 45 | public List tags { get; set; } 46 | public string description { get; set; } 47 | public DateTime createdDateTime { get; set; } 48 | } 49 | 50 | 51 | public struct DWMapLastRequest 52 | { 53 | public string requestId { get; set; } 54 | public string action { get; set; } 55 | public DateTime createdOn { get; set; } 56 | public DateTime modifiedOn { get; set; } 57 | public string state { get; set; } 58 | public string errorMessage { get; set; } 59 | public string errorUri { get; set; } 60 | public string rootActivityId { get; set; } 61 | } 62 | 63 | 64 | public struct DWMapDetail 65 | { 66 | public string tid { get; set; } 67 | public string tName { get; set; } 68 | public List tags { get; set; } 69 | public List templates { get; set; } 70 | public DWMapTemplate template { get; set; } 71 | public string pid { get; set; } 72 | public DWMapLastRequest lastRequest { get; set; } 73 | private string _state { get; set; } 74 | public string state 75 | { 76 | get 77 | { 78 | return _state; 79 | } 80 | set 81 | { 82 | _state = value; 83 | mapStatus = (DWEnums.MapStatus)Convert.ToInt16(value); 84 | } 85 | } 86 | 87 | public DWEnums.MapStatus mapStatus { get; set; } 88 | public List actions { get; set; } 89 | public List lastRequests { get; set; } 90 | public bool isProjectDeleted { get; set; } 91 | 92 | public Group group { get; set; } 93 | } 94 | 95 | public struct DWMap 96 | { 97 | public DWMapLeftEntity leftEntity { get; set; } 98 | public DWMapRightEntity rightEntity { get; set; } 99 | public DWMapDetail detail { get; set; } 100 | 101 | public List dependency { get; set; } 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /DWLibary/Struct/DWWikiOverview.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | public struct DWWikiOverview 13 | { 14 | public string FOEntity { get; set; } 15 | public string CEEntity { get; set; } 16 | public string subPageLink { get; set; } 17 | public string subPageName { get; set; } 18 | public DWEnums.DWSyncDirection syncDirection { get; set; } 19 | public string Version { get; set; } 20 | public string Publisher { get; set; } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DWLibary/Struct/Groups.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Xml; 11 | 12 | namespace DWLibary 13 | { 14 | public class Group : ConfigurationElement 15 | { 16 | [ConfigurationProperty("name", DefaultValue = "", IsRequired = true, IsKey = true)] 17 | public string name 18 | { 19 | get { return (string)this["name"]; } 20 | set { this["name"] = value; } 21 | } 22 | 23 | [ConfigurationProperty("initialSync", DefaultValue = false, IsRequired = true, IsKey = false)] 24 | public bool initialSync 25 | { 26 | get { return (bool)this["initialSync"]; } 27 | set { this["initialSync"] = value; } 28 | } 29 | 30 | [ConfigurationProperty("retry", DefaultValue = false, IsRequired = true, IsKey = false)] 31 | public bool retry 32 | { 33 | get { return (bool) this["retry"]; } 34 | set { this["retry"] = value; } 35 | } 36 | 37 | [ConfigurationProperty("targetState", DefaultValue = DWEnums.MapStatus.Keep, IsRequired = true, IsKey = false)] 38 | public DWEnums.MapStatus targetStatus 39 | { 40 | get { return (DWEnums.MapStatus)this["targetState"]; } 41 | set { this["targetState"] = value; } 42 | } 43 | 44 | [ConfigurationProperty("exceptionHandling", DefaultValue = DWEnums.ExceptionHandling.ignore, IsRequired = true, IsKey = false)] 45 | public DWEnums.ExceptionHandling exceptionHandling 46 | { 47 | get { return (DWEnums.ExceptionHandling)this["exceptionHandling"]; } 48 | set { this["exceptionHandling"] = value; } 49 | } 50 | 51 | [ConfigurationProperty("wikiUpload", DefaultValue = true, IsRequired = false, IsKey = false)] 52 | public bool wikiUpload 53 | { 54 | get { return (bool)this["wikiUpload"]; } 55 | set { this["wikiUpload"] = value; } 56 | } 57 | 58 | public Group() 59 | { 60 | name = String.Empty; 61 | initialSync = false; 62 | retry = false; 63 | targetStatus = DWEnums.MapStatus.Running; 64 | exceptionHandling = DWEnums.ExceptionHandling.ignore; 65 | wikiUpload = true; 66 | } 67 | 68 | } 69 | 70 | 71 | 72 | 73 | //public class Groups : IConfigurationSectionHandler 74 | //{ 75 | // public object Create(object parent, object configContext, XmlNode section) 76 | // { 77 | // List obj = new List(); 78 | 79 | // foreach (XmlNode childNode in section.ChildNodes) 80 | // { 81 | 82 | // Group grp = new Group(); 83 | 84 | // if (childNode.NodeType == XmlNodeType.Comment) 85 | // continue; 86 | 87 | // foreach (XmlAttribute attrib in childNode.Attributes) 88 | // { 89 | 90 | // if (attrib.Name.ToUpper() == "NAME") 91 | // grp.name = attrib.Value; 92 | 93 | // if (attrib.Name.ToUpper() == "INITIALSYNC") 94 | // grp.initialSync = Convert.ToBoolean(attrib.Value); 95 | 96 | // if (attrib.Name.ToUpper() == "RETRY") 97 | // grp.retry = Convert.ToBoolean(attrib.Value); 98 | 99 | // if (attrib.Name.ToUpper() == "TARGETSTATE") 100 | // grp.targetStatus = DWEnums.GetValueFromDescription(attrib.Value); 101 | 102 | // if (attrib.Name.ToUpper() == "EXCEPTIONHANDLING") 103 | // grp.exceptionHandling = DWEnums.GetValueFromDescription(attrib.Value); 104 | 105 | 106 | 107 | // } 108 | // obj.Add(grp); 109 | // } 110 | // return obj; 111 | // } 112 | //} 113 | } 114 | -------------------------------------------------------------------------------- /DWLibary/Struct/InitialSyncDetails.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 13 | public struct ExportRangeInfo 14 | { 15 | public string start { get; set; } 16 | public string end { get; set; } 17 | } 18 | 19 | public struct Error 20 | { 21 | public string recordId { get; set; } 22 | public string sourceField { get; set; } 23 | public string errorMessage { get; set; } 24 | } 25 | 26 | 27 | 28 | public struct TaskExecutionStatus 29 | { 30 | public string name { get; set; } 31 | public string status { get; set; } 32 | public bool isRunning { get; set; } 33 | public List legs { get; set; } 34 | } 35 | 36 | public struct ProjectExecutionRespons 37 | { 38 | public string responseId { get; set; } 39 | public string displayName { get; set; } 40 | public string projectName { get; set; } 41 | public string legalEntityName { get; set; } 42 | public string legalEntityId { get; set; } 43 | public string schedule { get; set; } 44 | public DateTime submittedOn { get; set; } 45 | public string executionStatus { get; set; } 46 | public DateTime lastExecutionStatusChangeOn { get; set; } 47 | public List taskExecutionStatuses { get; set; } 48 | public string runtimeMappingExecutionRequestName { get; set; } 49 | public bool isDataManagementProject { get; set; } 50 | public string dataManagementOperation { get; set; } 51 | public string tenant { get; set; } 52 | public string initialSyncRequestId { get; set; } 53 | public string id { get; set; } 54 | public int upsertCount { get; set; } 55 | public int errorCount { get; set; } 56 | public string owner { get; set; } 57 | public DateTime createdDateTime { get; set; } 58 | public List tags { get; set; } 59 | } 60 | 61 | public class SyncLeg 62 | { 63 | public string displayName { get; set; } 64 | public string status { get; set; } 65 | public string details { get; set; } 66 | public string exportStatus { get; set; } 67 | public string exportDetails { get; set; } 68 | public string exportJob { get; set; } 69 | public DateTime exportStarted { get; set; } 70 | public DateTime exportFinished { get; set; } 71 | public int exportRecordCount { get; set; } 72 | public int exportRecordErrorCount { get; set; } 73 | public string exportNewVersionToken { get; set; } 74 | public ExportRangeInfo exportRangeInfo { get; set; } 75 | public string importStatus { get; set; } 76 | public string importDetails { get; set; } 77 | public string importJob { get; set; } 78 | public DateTime importStarted { get; set; } 79 | public DateTime importFinished { get; set; } 80 | public int importRecordsInsertedCount { get; set; } 81 | public int importRecordsUpdatedCount { get; set; } 82 | public int importRecordsErrorCount { get; set; } 83 | public List exportErrors { get; set; } 84 | public string exportUri { get; set; } 85 | public List importErrors { get; set; } 86 | public string importErrorUri { get; set; } 87 | } 88 | public struct InitialSyncDetails 89 | { 90 | public string projectName { get; set; } 91 | public List projectExecutionResponses { get; set; } 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /DWLibary/Struct/IntegrationKeys.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 13 | public struct DWIntegrationKeyUpdate 14 | { 15 | public Dictionary> integrationKeys { get; set; } 16 | public string datasetName { get; set; } 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DWLibary/Struct/LoginData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using Azure.Core; 5 | using Microsoft.IdentityModel.Clients.ActiveDirectory; 6 | using Newtonsoft.Json; 7 | using Newtonsoft.Json.Linq; 8 | using System; 9 | using System.Collections.Generic; 10 | using System.IdentityModel.Tokens.Jwt; 11 | using System.Linq; 12 | using System.Text; 13 | using System.Threading.Tasks; 14 | 15 | namespace DWLibary.Struct 16 | { 17 | public class LoginData 18 | { 19 | public string token_type { get; set; } 20 | public string scope { get; set; } 21 | public int expires_in { get; set; } 22 | public int ext_expires_in { get; set; } 23 | 24 | private string _access_token; 25 | public string access_token { 26 | get { 27 | return _access_token; 28 | } 29 | set { 30 | _access_token = value; 31 | getUsername(); 32 | } 33 | } 34 | public string refresh_token { get; set; } 35 | public string id_token { get; set; } 36 | public string client_info { get; set; } 37 | public DateTime tokenRefreshDate { get; set; } 38 | 39 | private AccessToken _accessToken; 40 | public AccessToken accessToken { get 41 | { 42 | return _accessToken; 43 | 44 | } set 45 | { 46 | _accessToken = value; 47 | 48 | if(value.Token != null) 49 | _access_token = value.Token; 50 | //tokenRefreshDate = value. 51 | 52 | } 53 | } 54 | 55 | public string username { get; set; } 56 | 57 | public string environment { get; set; } 58 | 59 | public LoginData() 60 | { 61 | tokenRefreshDate = DateTime.Now; 62 | environment = String.Empty; 63 | } 64 | 65 | public string getUsername() 66 | { 67 | string ret = string.Empty; 68 | 69 | try 70 | 71 | { 72 | 73 | var handler = new JwtSecurityTokenHandler(); 74 | var jsonToken = handler.ReadToken(access_token); 75 | var tokenS = jsonToken as JwtSecurityToken; 76 | 77 | ret = tokenS.Claims.First(claim => claim.Type == "upn").Value; 78 | 79 | username = ret; 80 | } 81 | catch { } 82 | 83 | return ret; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /DWLibary/Struct/MapConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Configuration; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Xml; 11 | 12 | namespace DWLibary 13 | { 14 | public class MapConfig : ConfigurationElement 15 | { 16 | [ConfigurationProperty("mapName", DefaultValue = "", IsRequired = true, IsKey = true)] 17 | public string mapName 18 | { 19 | get { return (string)this["mapName"]; } 20 | set { this["mapName"] = value; } 21 | } 22 | 23 | [ConfigurationProperty("version", DefaultValue = "", IsRequired = true, IsKey = false)] 24 | public string version 25 | { 26 | get { return (string)this["version"]; } 27 | set { this["version"] = value; } 28 | } 29 | 30 | //private string _group { get; set; } 31 | [ConfigurationProperty("group", DefaultValue = "", IsRequired = true, IsKey = false)] 32 | public string group 33 | { 34 | get { return (string)this["group"]; } 35 | set { this["group"] = value; } 36 | } 37 | 38 | public void initSettings() 39 | { 40 | if (group != null && group != String.Empty) 41 | { 42 | // List groups = ConfigurationManager.GetSection("Groups") as List; 43 | foreach(Group g in GlobalVar.dwSettings.Groups) 44 | { 45 | if (group.ToUpper() == g.name.ToUpper()) 46 | { 47 | groupSetting = g; 48 | break; 49 | } 50 | } 51 | 52 | //groupSetting = GlobalVar.dwSettings.Groups.Where(x => x.name.ToUpper().Equals(group.ToUpper())).FirstOrDefault(); 53 | 54 | if (groupSetting == null) 55 | groupSetting = new Group(); 56 | } 57 | else if(group == String.Empty) 58 | { 59 | groupSetting = new Group(); 60 | } 61 | 62 | if (authorsStr != null && authorsStr != String.Empty) 63 | { 64 | authors = authorsStr.Split(',').ToList(); 65 | List cleanList = new List(); 66 | foreach (string author in authors) 67 | { 68 | string localAuth = author.Trim(); 69 | 70 | if(localAuth.Length > 0) 71 | cleanList.Add(localAuth); 72 | } 73 | 74 | authors = cleanList; 75 | } 76 | 77 | if (keysStr != null && keysStr != String.Empty) 78 | { 79 | keys = keysStr.Split(',').ToList(); 80 | List cleanList = new List(); 81 | foreach (string key in keys) 82 | { 83 | string localKey = key.Trim(); 84 | localKey = localKey.Replace(" ", String.Empty); 85 | if (localKey.Length > 0) 86 | cleanList.Add(localKey); 87 | } 88 | 89 | keys = cleanList; 90 | } 91 | 92 | } 93 | 94 | 95 | [ConfigurationProperty("authors", DefaultValue = "", IsRequired = true, IsKey = false)] 96 | public string authorsStr 97 | { 98 | get { return (string)this["authors"]; } 99 | set { 100 | this["authors"] = value; 101 | 102 | 103 | } 104 | } 105 | 106 | public List authors { get; set; } 107 | 108 | [ConfigurationProperty("keys", DefaultValue = "", IsRequired = true, IsKey = false)] 109 | public string keysStr 110 | { 111 | get { return (string)this["keys"]; } 112 | set { 113 | this["keys"] = value; 114 | 115 | 116 | } 117 | } 118 | 119 | public List keys { get; set; } 120 | 121 | [ConfigurationProperty("master", DefaultValue = DWEnums.DataMaster.CE, IsRequired = true, IsKey = false)] 122 | public DWEnums.DataMaster master 123 | { 124 | get { return (DWEnums.DataMaster)this["master"]; } 125 | set { this["master"] = value; } 126 | } 127 | 128 | public Group groupSetting { get; set; } 129 | 130 | public MapConfig() 131 | { 132 | authors = new List(); 133 | keys = new List(); 134 | 135 | master = DWEnums.DataMaster.CE; 136 | 137 | 138 | } 139 | 140 | } 141 | 142 | 143 | //public class MapConfigs : IConfigurationSectionHandler 144 | //{ 145 | // public object Create(object parent, object configContext, XmlNode section) 146 | // { 147 | // List obj = new List(); 148 | 149 | // foreach (XmlNode childNode in section.ChildNodes) 150 | // { 151 | // if (childNode.NodeType == XmlNodeType.Comment) 152 | // continue; 153 | // MapConfig map = new MapConfig(); 154 | // foreach (XmlAttribute attrib in childNode.Attributes) 155 | // { 156 | 157 | // if (attrib.Name.ToUpper() == "MAPNAME") 158 | // map.mapName = attrib.Value; 159 | 160 | // if (attrib.Name.ToUpper() == "VERSION") 161 | // map.version = attrib.Value; 162 | 163 | // if (attrib.Name.ToUpper() == "GROUP") 164 | // map.group = attrib.Value; 165 | 166 | // if (attrib.Name.ToUpper() == "MASTER") 167 | // map.master = DWEnums.GetValueFromDescription(attrib.Value); 168 | 169 | // if (attrib.Name.ToUpper() == "AUTHORS") 170 | // { 171 | // if (attrib.Value != String.Empty) 172 | // { 173 | // map.authors = attrib.Value.Split(',').ToList(); 174 | // List cleanList = new List(); 175 | // foreach (string author in map.authors) 176 | // { 177 | // cleanList.Add(author.Trim()); 178 | // } 179 | 180 | // map.authors = cleanList; 181 | // } 182 | // } 183 | 184 | 185 | // if (attrib.Name.ToUpper() == "KEYS") 186 | // { 187 | // if (attrib.Value != String.Empty) 188 | // { 189 | // map.keys = attrib.Value.Split(',').ToList(); 190 | // List cleanList = new List(); 191 | // foreach(string key in map.keys) 192 | // { 193 | // cleanList.Add(key.Replace(" ", String.Empty)); 194 | // } 195 | 196 | // map.keys = cleanList; 197 | // } 198 | 199 | // } 200 | 201 | // } 202 | // obj.Add(map); 203 | // } 204 | // return obj; 205 | // } 206 | //} 207 | 208 | 209 | } 210 | -------------------------------------------------------------------------------- /DWLibary/Struct/MapDependency.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | public class MapDependency 13 | { 14 | public List> mapPidList { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DWLibary/Struct/MapsHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 13 | public struct MapStartStopActionConflictResolution 14 | { 15 | public string option { get; set; } 16 | public string master { get; set; } 17 | } 18 | 19 | public class MapStartStopActionParameters 20 | { 21 | 22 | public bool skipInitialSync { get; set; } 23 | public MapStartStopActionConflictResolution conflictResolution { get; set; } 24 | } 25 | 26 | public class MapCatchUpParameter 27 | { 28 | public Dualwriteskipcatchupsyncparameters dualWriteSkipCatchUpSyncParameters { get; set; } 29 | } 30 | 31 | public struct MapStartStopActionDetail 32 | { 33 | public string tid { get; set; } 34 | public string pid { get; set; } 35 | public string cid { get; set; } 36 | public dynamic parameters { get; set; } 37 | } 38 | 39 | public struct MapStartStopAction 40 | { 41 | public string action { get; set; } 42 | public List details { get; set; } 43 | } 44 | 45 | public struct MapsRequestResponse 46 | { 47 | public string requestId { get; set; } 48 | } 49 | 50 | public class Parameters 51 | { 52 | public Dualwriteskipcatchupsyncparameters dualWriteSkipCatchUpSyncParameters { get; set; } 53 | } 54 | 55 | public struct Dualwriteskipcatchupsyncparameters 56 | { 57 | public bool skipCatchUpSyncPreserveData { get; set; } 58 | } 59 | 60 | 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /DWLibary/Struct/ResetLinkPayload.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DWLibary 8 | { 9 | public struct ResetLinkPayload 10 | { 11 | public string powerAppsEnvironmentName { get; set; } 12 | public List environments { get; set; } 13 | public List legalEntities { get; set; } 14 | } 15 | 16 | public struct ResetLinkEnvironment 17 | { 18 | public string targetType { get; set; } 19 | public string name { get; set; } 20 | public string displayName { get; set; } 21 | public string id { get; set; } 22 | public bool isDevInstance { get; set; } 23 | public string directUrl { get; set; } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /DWLibary/Struct/SolutionHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | public struct SolutionCriteriaValue 13 | { 14 | public string uniquename { get; set; } 15 | } 16 | 17 | public struct SolutionCriteria 18 | { 19 | public SolutionCriteriaValue criteria { get; set; } 20 | } 21 | 22 | public struct SolutionApplyObj 23 | { 24 | public string action { get; set; } 25 | public List solutions { get; set; } 26 | } 27 | 28 | public struct SolutionRequestResponse 29 | { 30 | public string requestId { get; set; } 31 | } 32 | 33 | 34 | // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); 35 | public struct SolutionResultMessage 36 | { 37 | public string message { get; set; } 38 | public string status { get; set; } 39 | } 40 | 41 | public struct SolutionResult 42 | { 43 | public string requestId { get; set; } 44 | public string action { get; set; } 45 | public DateTime createdOn { get; set; } 46 | public DateTime modifiedOn { get; set; } 47 | public string state { get; set; } 48 | public SolutionResultMessage result { get; set; } 49 | public string rootActivityId { get; set; } 50 | } 51 | 52 | 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /DWLibary/Struct/SolutionList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace DWLibary.Struct 11 | { 12 | 13 | public class DWSolution 14 | { 15 | public string description { get; set; } 16 | public string friendlyname { get; set; } 17 | public bool ismanaged { get; set; } 18 | public string solutionid { get; set; } 19 | public string id { get; set; } 20 | public string uniquename { get; set; } 21 | public string version { get; set; } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /DWLibary/TokenRefresh.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary.Struct; 5 | using Microsoft.Extensions.Logging; 6 | using Newtonsoft.Json; 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Linq; 10 | using System.Net.Http.Headers; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | 14 | namespace DWLibary 15 | { 16 | public class TokenRefresh 17 | { 18 | ILogger logger; 19 | 20 | public TokenRefresh(ILogger _logger) 21 | { 22 | logger = _logger; 23 | } 24 | 25 | public void run() 26 | { 27 | 28 | Thread thread = new Thread(new ThreadStart(runThread)); 29 | thread.Start(); 30 | 31 | } 32 | 33 | 34 | public bool tryGetRefreshToken(bool runRefreshThread = false) 35 | { 36 | bool ret = false; 37 | 38 | TimeSpan ts = GlobalVar.loginData.tokenRefreshDate.AddSeconds(GlobalVar.loginData.expires_in) - DateTime.Now; 39 | 40 | //token is expired 41 | if (ts.TotalMilliseconds < 0) 42 | { 43 | 44 | if (getRefreshToken().Result) 45 | { 46 | ret = true; 47 | 48 | if (runRefreshThread) 49 | run(); 50 | } 51 | else 52 | { 53 | //reset the variable 54 | GlobalVar.loginData = new LoginData(); 55 | } 56 | 57 | } 58 | //still valid 59 | else 60 | { 61 | if (runRefreshThread) 62 | run(); 63 | } 64 | 65 | return ret; 66 | 67 | } 68 | 69 | private async void runThread() 70 | { 71 | 72 | while(true) 73 | { 74 | 75 | if(GlobalVar.loginData.accessToken.Token != null) 76 | { 77 | 78 | TimeSpan timeToExpire = GlobalVar.loginData.accessToken.ExpiresOn.UtcDateTime - DateTime.UtcNow; 79 | 80 | int ms = (int)timeToExpire.TotalMilliseconds - (60 * 1000 * 5); 81 | 82 | if (ms > 0) 83 | Thread.Sleep(ms); // 5 mins deduction 84 | 85 | ServicePrincipalAuth servicePrincipalAuth = new ServicePrincipalAuth(logger); 86 | await servicePrincipalAuth.authenticate(); 87 | } 88 | else 89 | { 90 | TimeSpan ts = GlobalVar.loginData.tokenRefreshDate.AddSeconds(GlobalVar.loginData.expires_in) - DateTime.Now; 91 | 92 | int ms = (int)ts.TotalMilliseconds - (60 * 1000 * 5); 93 | 94 | if (ms > 0) 95 | Thread.Sleep(ms); // 5 mins deduction 96 | 97 | await getRefreshToken(); 98 | 99 | } 100 | 101 | 102 | 103 | 104 | } 105 | 106 | } 107 | 108 | 109 | public async Task getRefreshToken() 110 | { 111 | bool ret = false; 112 | 113 | LoginData refresh = await getLoginDataRefreshed(); 114 | 115 | if(refresh != null) 116 | { 117 | ret = true; 118 | GlobalVar.loginData = refresh; 119 | } 120 | 121 | 122 | 123 | return ret; 124 | } 125 | 126 | public async Task getLoginDataRefreshed(LoginData _loginData = null, ILogger _log = null) 127 | { 128 | 129 | LoginData ret = null; 130 | 131 | HttpClient client = new HttpClientWithRetry(); 132 | HttpRequestMessage req = new HttpRequestMessage(); 133 | 134 | req.Method = HttpMethod.Post; 135 | req.Headers.Add("Accept", "application/json"); 136 | req.Headers.Add("origin", GlobalVar.dataintegratorURL.AbsoluteUri); 137 | 138 | UriBuilder builder = new UriBuilder(GlobalVar.dataintegratorURL); 139 | builder.Path = "dualWrite"; 140 | 141 | var formData = new[] 142 | { 143 | new KeyValuePair("client_id", "2e49aa60-1bd3-43b6-8ab6-03ada3d9f08b"), 144 | new KeyValuePair("scope", "https://IntegratorApp.com/.default openid profile offline_access"), 145 | new KeyValuePair("redirect_uri", builder.Uri.AbsoluteUri), 146 | new KeyValuePair("grant_type", "refresh_token"), 147 | new KeyValuePair("refresh_token", _loginData == null ? GlobalVar.loginData.refresh_token : _loginData.refresh_token), 148 | }; 149 | 150 | req.Content = new FormUrlEncodedContent(formData); 151 | 152 | req.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); 153 | req.Content.Headers.ContentType.CharSet = "UTF-8"; 154 | 155 | req.RequestUri = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/token"); 156 | 157 | var response = await client.SendAsync(req); 158 | 159 | if(response.IsSuccessStatusCode) 160 | { 161 | if (_log != null) 162 | _log.LogInformation("Token retrieved successful"); 163 | 164 | ret = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()); 165 | 166 | } 167 | else 168 | { 169 | string error = await response.Content.ReadAsStringAsync(); 170 | 171 | if (_log != null) 172 | _log.LogError(error); 173 | } 174 | 175 | return ret; 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /DualWriteHelper.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.1.32228.430 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DWHelperCMD", "DualWriteHelper\DWHelperCMD.csproj", "{3405999E-7C4C-42AE-BE7C-EFB348B1CA42}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DWLibary", "DWLibary\DWLibary.csproj", "{28424FDF-9FB8-4552-9CCF-40BF0D2733A4}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{62A09BAE-D901-4900-A7FE-AD5E4B96D4C7}" 11 | ProjectSection(SolutionItems) = preProject 12 | .editorconfig = .editorconfig 13 | EndProjectSection 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DWHelperUI", "DWHelperUI\DWHelperUI.csproj", "{28412193-5333-4B68-B220-3D847436533D}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {3405999E-7C4C-42AE-BE7C-EFB348B1CA42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {3405999E-7C4C-42AE-BE7C-EFB348B1CA42}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {3405999E-7C4C-42AE-BE7C-EFB348B1CA42}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {3405999E-7C4C-42AE-BE7C-EFB348B1CA42}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {28424FDF-9FB8-4552-9CCF-40BF0D2733A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {28424FDF-9FB8-4552-9CCF-40BF0D2733A4}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {28424FDF-9FB8-4552-9CCF-40BF0D2733A4}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {28424FDF-9FB8-4552-9CCF-40BF0D2733A4}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {28412193-5333-4B68-B220-3D847436533D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {28412193-5333-4B68-B220-3D847436533D}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {28412193-5333-4B68-B220-3D847436533D}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {28412193-5333-4B68-B220-3D847436533D}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {5203CFB0-73AB-4F97-A692-04FF9BDA1120} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /DualWriteHelper/AppExecution.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Newtonsoft.Json; 11 | using System.Text.Json.Nodes; 12 | using DWLibary.Struct; 13 | using DWLibary; 14 | using static System.Net.Mime.MediaTypeNames; 15 | using DWLibary.Engines; 16 | using Newtonsoft.Json.Linq; 17 | using Microsoft.Extensions.Logging; 18 | using DWHelper; 19 | using OpenQA.Selenium; 20 | using OpenQA.Selenium.Edge; 21 | using System.Diagnostics; 22 | using Microsoft.Extensions.Hosting.Internal; 23 | using Microsoft.Extensions.Hosting; 24 | using System.Security.Cryptography; 25 | 26 | namespace DWHelper 27 | { 28 | public class AppExecution 29 | { 30 | 31 | ILogger logger; 32 | IHostApplicationLifetime lifeTime; 33 | 34 | public AppExecution(ILogger _logger, IHostApplicationLifetime _lifetime) 35 | { 36 | logger = _logger; 37 | //exportConfig = false; 38 | lifeTime = _lifetime; 39 | } 40 | 41 | public void run() 42 | { 43 | try 44 | { 45 | 46 | GlobalVar.init(logger); 47 | 48 | //string test = MFAGen.getMFAKey(); 49 | 50 | //check if the given username is a user or a client id: 51 | //ClientId won't work 52 | 53 | 54 | 55 | 56 | if (GlobalVar.runMode == DWEnums.RunMode.compare) 57 | { 58 | //do something 59 | if(GlobalVar.parsedOptions.targetenvironment == null || GlobalVar.parsedOptions.targetenvironment == String.Empty) 60 | { 61 | logger.LogError("Target environment is empty, for comparison specify a target with -t"); 62 | lifeTime.StopApplication(); 63 | return; 64 | } 65 | 66 | DWComparison dWComparison = new DWComparison(GlobalVar.foEnv, GlobalVar.parsedOptions.targetenvironment, logger); 67 | dWComparison.runComparison().Wait(); 68 | logger.LogInformation("Comparison complete"); 69 | lifeTime.StopApplication(); 70 | return; 71 | } 72 | 73 | if (!GlobalVar.username.Contains("@")) 74 | { 75 | //Client / Secret auth 76 | 77 | ServicePrincipalAuth servicePrincipalAuth = new ServicePrincipalAuth(logger); 78 | if(!servicePrincipalAuth.authenticate().Result) 79 | return; 80 | 81 | } 82 | else 83 | { 84 | 85 | //user based authentication 86 | 87 | logger.LogInformation("Get access token, opening Edge"); 88 | 89 | checkEdgeVersionAndRetrieveToken(); 90 | 91 | } 92 | 93 | TokenRefresh tokenRefresh = new TokenRefresh(logger); 94 | tokenRefresh.run(); 95 | 96 | logger.LogInformation("Get Environment"); 97 | 98 | DWEnvCalls dWEnvCalls = new DWEnvCalls(); 99 | DWEnvironment dwEnv = dWEnvCalls.getEnvironment().Result; 100 | 101 | if (dwEnv.cid == null || dwEnv.cid.Length == 0) 102 | { 103 | logger.LogInformation("Environment is not linked, exiting"); 104 | lifeTime.StopApplication(); 105 | return; 106 | } 107 | 108 | 109 | //now do the Wiki Upload 110 | //DWADOWikiEngine adoWiki = new DWADOWikiEngine(dwEnv, logger); 111 | //adoWiki.runWikiUpload().Wait(); 112 | 113 | logger.LogInformation($"Runmode: {GlobalVar.runMode}"); 114 | 115 | DWMapEngine mapEngine = new DWMapEngine(dwEnv, logger); 116 | 117 | switch(GlobalVar.runMode) 118 | { 119 | case DWEnums.RunMode.export: 120 | logger.LogInformation("Exporting config parameter is true"); 121 | mapEngine.generateMapConfig().Wait(); 122 | break; 123 | 124 | case DWEnums.RunMode.wikiUpload: 125 | DWADOWikiEngine adoWiki = new DWADOWikiEngine(dwEnv, logger); 126 | adoWiki.runWikiUpload(true).Wait(); 127 | break; 128 | 129 | case DWEnums.RunMode.resetLink: 130 | ResetLinkEngine resetLink = new ResetLinkEngine(logger, dwEnv); 131 | resetLink.resetLink(GlobalVar.parsedOptions.forceReset).Wait(); 132 | 133 | break; 134 | 135 | default: 136 | if (!GlobalVar.noSolutions) 137 | { 138 | DWSolutionEngine dWSolution = new DWSolutionEngine(dwEnv, logger); 139 | dWSolution.applySolutions().Wait(); 140 | } 141 | 142 | 143 | mapEngine.applyMaps().Wait(); 144 | 145 | 146 | // now do the Wiki Upload 147 | DWADOWikiEngine adoWikiDeploy = new DWADOWikiEngine(dwEnv, logger); 148 | adoWikiDeploy.runWikiUpload().Wait(); 149 | break; 150 | } 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | } 159 | catch (Exception ex) 160 | { 161 | GlobalVar.addError(ex.ToString()); 162 | } 163 | 164 | lifeTime.StopApplication(); 165 | } 166 | 167 | 168 | 169 | public void reAuthenticate() 170 | { 171 | 172 | checkEdgeVersionAndRetrieveToken(); 173 | 174 | } 175 | 176 | private void checkEdgeVersionAndRetrieveToken() 177 | { 178 | EdgeUniversal uni = new EdgeUniversal(logger); 179 | uni.getToken(); 180 | 181 | } 182 | 183 | 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /DualWriteHelper/DWHelperCMD.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net9.0 6 | enable 7 | enable 8 | Always 9 | 10 | 13 | 14 | 15 | 16 | 17 | 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 | Never 43 | 44 | 45 | Never 46 | 47 | 48 | 49 | PreserveNewest 50 | 51 | 52 | PreserveNewest 53 | 54 | 55 | PreserveNewest 56 | 57 | 58 | PreserveNewest 59 | 60 | 61 | Always 62 | 63 | 64 | PreserveNewest 65 | 66 | 67 | PreserveNewest 68 | 69 | 70 | PreserveNewest 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /DualWriteHelper/DWHostedService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | using DWLibary; 5 | using Microsoft.AspNetCore.Builder; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | using Microsoft.Extensions.Options; 10 | using System.Configuration; 11 | 12 | namespace DWHelper; 13 | 14 | public class DWHostedService : IHostedService 15 | { 16 | private readonly ILogger _logger; 17 | 18 | private readonly IHostApplicationLifetime _appLifetime; 19 | 20 | public bool isRunning { get; set; } 21 | public DWHostedService( 22 | ILogger logger, 23 | IHostApplicationLifetime appLifetime) 24 | { 25 | _logger = logger; 26 | _appLifetime = appLifetime; 27 | appLifetime.ApplicationStarted.Register(OnStarted); 28 | appLifetime.ApplicationStopping.Register(OnStopping); 29 | appLifetime.ApplicationStopped.Register(OnStopped); 30 | } 31 | 32 | private void DoWorkAsync() 33 | { 34 | _logger.LogInformation($"Background Service is working. {DateTime.Now}"); 35 | try 36 | { 37 | isRunning = true; 38 | AppExecution ae = new AppExecution(_logger, _appLifetime); 39 | 40 | ae.run(); 41 | // dosometing you want 42 | } 43 | catch (Exception ex) 44 | { 45 | isRunning = false; 46 | _logger.LogInformation("Error {0}", ex.Message); 47 | 48 | throw ex; 49 | 50 | } 51 | // return Task.CompletedTask; 52 | } 53 | public Task StartAsync(CancellationToken cancellationToken) 54 | { 55 | _logger.LogInformation("Starting..."); 56 | 57 | 58 | //start new thread 59 | Thread t = new Thread(new ThreadStart(DoWorkAsync)); 60 | t.Start(); 61 | //DoWorkAsync(null); 62 | 63 | 64 | 65 | //StopAsync(cancellationToken); 66 | 67 | 68 | return Task.CompletedTask; 69 | } 70 | 71 | 72 | 73 | 74 | 75 | public Task StopAsync(CancellationToken cancellationToken) 76 | { 77 | // _logger.LogInformation("4. StopAsync has been called."); 78 | 79 | return Task.CompletedTask; 80 | } 81 | 82 | 83 | private void OnStarted() 84 | { 85 | 86 | //_logger.LogInformation("2. OnStarted has been called."); 87 | } 88 | 89 | private void OnStopping() 90 | { 91 | // _logger.LogInformation("3. OnStopping has been called."); 92 | 93 | } 94 | 95 | private void OnStopped() 96 | { 97 | 98 | int errorCode = 0; 99 | 100 | if (GlobalVar.errors.Count > 0) 101 | errorCode = 400; 102 | 103 | if(errorCode == 0) 104 | _logger.LogInformation($"Application stopped successful without errors!"); 105 | else 106 | _logger.LogInformation($"Application stopped with errors, check the log files!"); 107 | 108 | Environment.Exit(errorCode); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-AllParameters.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" --mfasecret "mfa secret" -c "your config.config", --runmode "deployment" --nosolutions --useadowikiupload --adotoken "your personal access token" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-ExportMaps - Copy.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" --export "Running" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-adoWikiUpload.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" --useadowikiupload --adotoken "your personal access token" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-customConfig.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" -c "yourCustomConfigFile.config" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-deployment.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" --runmode "deployment" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRun-initalSync.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username@somewhere.com" -p "password" -e "yourenvironment.cloudax.dynamics.com" --runmode "onlySync" 4 | 5 | 6 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 7 | ::-c "configFile.config" - optional runs the programm from a different config file 8 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 9 | ::--nosolutions Skips applying the solution at the start 10 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 11 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 12 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 13 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 14 | pause -------------------------------------------------------------------------------- /DualWriteHelper/ExampleRunCMD.bat: -------------------------------------------------------------------------------- 1 | :: Copyright (c) Microsoft Corporation. 2 | :: Licensed under the MIT License. 3 | DWHelperCMD.exe -u "username" -p "password" -e "environment" 4 | 5 | ::--runmode "deployment" --runmode "deployment" --runmode "deployInitialSync", Values: deployment, deployInitialSync, start, stop, pause export //overwrites the runmode in the config 6 | ::-c "configFile.config" - optional runs the programm from a different config file 7 | ::-s in combination with runMode export "All" exports the current configuration of the environment, possible states: Running, Stopped, All 8 | ::--nosolutions Skips applying the solution at the start 9 | ::--mfasecret "secret" //overwrites / set the mfasecret in the config - usable in pipelines where the values comes from a key vault 10 | ::--useadowikiupload //overwrites / set the useadowikiupload in the config and sets it to true - usable in pipelines where the values comes from a key vault, only works with mode deployment 11 | ::--adotoken "" //overwrites / set the wiki upload token - usable in pipelines where the values comes from a key vault 12 | ::-l "Information" //Loglevel, Values: Information, Debug, Error 13 | pause -------------------------------------------------------------------------------- /DualWriteHelper/Main.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. 2 | // Licensed under the MIT license. 3 | 4 | // See https://aka.ms/new-console-template for more information 5 | using CommandLine; 6 | using DWLibary; 7 | using Microsoft.Extensions.DependencyInjection; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.Extensions.Logging; 10 | using Microsoft.Extensions.Configuration; 11 | using DWHelper; 12 | using System.Text.RegularExpressions; 13 | using Microsoft.VisualStudio.Services.Common.CommandLine; 14 | using Serilog; 15 | using Microsoft.Extensions.Logging.ApplicationInsights; 16 | #if DEBUG 17 | 18 | //args = new string[] {"-u", "username/clientId", "-p" , "password/secret", 19 | //"-e", "environment URL", 20 | //"-c", "configFile.config", 21 | //"-t", "tenant", //not used yet 22 | //"-g", "gateway", //not used yet 23 | //"--export", "Running", 24 | //"--nosolutions" 25 | //}; 26 | 27 | 28 | if (File.Exists(@"DEBUGArgs.txt")) 29 | { 30 | using (StreamReader sr = new StreamReader(@"DEBUGArgs.txt")) 31 | { 32 | 33 | var data = sr.ReadToEnd(); 34 | 35 | data = data.Replace("\r", ""); 36 | data = data.Replace("\n", ""); 37 | 38 | string exp = @"((?:|^\b|\s+)--(?.+?)(?:\s|=|$)(?!-)(?[\""\'].+?[\""\']|.+?(?:\s|$))?|(?:|^\b)-(?.)(?:\s|=|$)(?!-)(?[\""\'].+?[\""\']|.+?(?:\s|$))?|(?[\""\'].+?[\""\']|.+?(?:\s|$)))"; 39 | 40 | MatchCollection collection = Regex.Matches(data, exp); 41 | List argsList = new List(); 42 | 43 | foreach (Match match in collection) 44 | 45 | { 46 | string value = match.Value.Trim(); 47 | value = value.Replace("\"", ""); 48 | argsList.Add(value); 49 | 50 | if (value == "--runmode") 51 | argsList.Add(DWEnums.RunMode.start.ToString()); 52 | 53 | 54 | 55 | } 56 | if (argsList.Count > 0) 57 | { 58 | argsList.Add("--catchupsetting"); 59 | argsList.Add("BackendQueueProcessing"); 60 | 61 | args = new string[argsList.Count]; 62 | 63 | argsList.CopyTo(args, 0); 64 | } 65 | 66 | 67 | } 68 | } 69 | 70 | 71 | 72 | #endif 73 | 74 | 75 | 76 | 77 | 78 | ArgsHandler argsHandler = new ArgsHandler(); 79 | argsHandler.parseCommands(args); 80 | 81 | 82 | LogLevel level = LogLevel.Information; 83 | 84 | if(argsHandler.parsedOptions.logLevel != null && argsHandler.parsedOptions.logLevel != "") 85 | Enum.TryParse(argsHandler.parsedOptions.logLevel, out level); 86 | 87 | 88 | 89 | Console.WriteLine($"LogLevel {level}"); 90 | GlobalVar.initConfig(); 91 | 92 | //CreateHostBuilderv2(args, level).Build().Run(); 93 | 94 | var host = CreateHostBuilderv2(args, level).Build(); 95 | 96 | 97 | using(host) 98 | { 99 | await host.RunAsync(); 100 | } 101 | 102 | Environment.Exit(0); 103 | //using var host = CreateHostBuilderv2(args, level).Build(); 104 | //host.Run(); 105 | 106 | 107 | 108 | static IHostBuilder CreateHostBuilderv2(string[] args, LogLevel _logLevel) => 109 | Host.CreateDefaultBuilder(args).ConfigureLogging((hostingContext, builder) => { 110 | builder.ClearProviders(); 111 | string subFolder = "Logs"; 112 | string fileName = $"-{DateTime.Now.ToString("yyyy-MM-dd")}_{GlobalVar.foEnv}-{new Random().Next(1, 99999999)}.txt"; 113 | 114 | if (_logLevel <= LogLevel.Debug) 115 | builder.AddFile(Path.Combine(subFolder, "DEBUG" + fileName), _logLevel); 116 | 117 | builder.AddFile(Path.Combine(subFolder, "ERROR" + fileName), LogLevel.Error); 118 | builder.AddFile(Path.Combine(subFolder, "WARN" + fileName), LogLevel.Warning); 119 | 120 | builder.AddFile(Path.Combine(subFolder, "LOG-" + fileName), LogLevel.Information).SetMinimumLevel(LogLevel.Information); 121 | 122 | string appInsightConStr = String.Empty; 123 | try 124 | { 125 | appInsightConStr = GlobalVar.config.AppSettings.Settings["appInsightConnectionString"].Value; 126 | } 127 | catch 128 | { 129 | Console.WriteLine("No app Insights connection string found!"); 130 | } 131 | 132 | if (appInsightConStr != null && appInsightConStr != "") 133 | { 134 | builder.AddApplicationInsights(configureTelemetryConfiguration: (config) => 135 | config.ConnectionString = GlobalVar.config.AppSettings.Settings["appInsightConnectionString"].Value, 136 | 137 | 138 | configureApplicationInsightsLoggerOptions: (options) => { } 139 | ); 140 | } 141 | builder.AddConsole(); // Add console logging 142 | }) 143 | .ConfigureServices((_, services) => 144 | services.AddHostedService()); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dual-Write automation for deployment and initial setup 2 | 3 | ## Disclaimer / Support 4 | Please note that this is not supported by Microsoft in anyway. 5 | It is provided AS IS and it can break anytime because changes made in the API beeing used. 6 | 7 | If you need support or assistance, please use the "Discussions" section in this repo. 8 | https://github.com/microsoft/Dual-write-automations/discussions 9 | 10 | ## Feedback 11 | 12 | Feedback is essential - good or bad, please do not hesitate to provide Feedback in the Discussions section: 13 | https://github.com/microsoft/Dual-write-automations/discussions 14 | 15 | ## What can this tool do? 16 | 17 | Mainly this tool is intended as a utility to help save time during Dual-write setup and mainance tasks. 18 | It doesen't look the prettiest but it does the job. 19 | 20 | This is what it can do: 21 | 22 | - Apply the latest map version based on authors or any author 23 | - Apply integration keys 24 | - Refresh tables 25 | - Stop/Start the maps before and after 26 | - Run's on multi-threading, means multiple maps are applied at the same time. 27 | - Uploads maps to ADO Wiki 28 | - Start / Stop / Pause maps 29 | - Export configurations in the correct order 30 | - Run initial sync 31 | - Parallel deployment to multiple target environments only using command line or multiple instances of the UI 32 | - Compare two environments and show differences 33 | - Reset link (Using currently configured legal entities and relinks with them) 34 | 35 | Generally the tool has a UI and a Console application execution. Ultimately the UI will call the console application with arguments. 36 | This makes it possible to also run any of what you are running in the UI also in an Azure pipeline. 37 | Be aware every function runs based on the configuration file, e.g. stopping maps will only stop the maps which are specified in the config. 38 | 39 | ## How to get started? 40 | 41 | Download the pre-compiled application here: https://github.com/microsoft/Dual-write-automations/releases/ 42 | or clone the repo and compile it on your machine. 43 | 44 | 1. Setup an environment with Dual-Write and the maps how you need/ want it 45 | 2. Export the configuration with the tool 46 | 3. Apply on other environments based on the config with the tool. 47 | 48 | Please refer to the Wiki page where the steps are described in details. 49 | --> https://github.com/microsoft/Dual-write-automations/wiki 50 | 51 | ## Contributing 52 | 53 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 54 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 55 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. 56 | 57 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide 58 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions 59 | provided by the bot. You will only need to do this once across all repos using our CLA. 60 | 61 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 62 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 63 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 64 | 65 | ## Trademarks 66 | 67 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft 68 | trademarks or logos is subject to and must follow 69 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). 70 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. 71 | Any use of third-party trademarks or logos are subject to those third-party's policies. 72 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Support 2 | 3 | ## How to file issues and get help 4 | 5 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing 6 | issues before filing new issues to avoid duplicates. For new issues, file your bug or 7 | feature request as a new Issue. 8 | 9 | For help and questions about using this project, please move to the discussions section. 10 | 11 | ## Microsoft Support Policy 12 | 13 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above. 14 | --------------------------------------------------------------------------------