├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── EpicorRESTGenerator.WPFGUI
├── App.config
├── App.xaml
├── App.xaml.cs
├── EpicorRESTGenerator.WPFGUI.csproj
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── generator.xaml
├── generator.xaml.cs
└── packages.config
├── EpicorRESTGenerator.sln
├── EpicorSwaggerRESTGenerator
├── ClientBase.cs
├── EpicorSwaggerRESTGenerator.csproj
├── Models
│ ├── Client.cs
│ ├── EpicorDetails.cs
│ ├── Service.cs
│ ├── serviceWorkspace.cs
│ ├── serviceWorkspaceCollection.cs
│ └── title.cs
├── Properties
│ └── AssemblyInfo.cs
├── app.config
└── packages.config
├── LICENSE
└── README.md
/.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 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # Benchmark Results
46 | BenchmarkDotNet.Artifacts/
47 |
48 | # .NET Core
49 | project.lock.json
50 | project.fragment.lock.json
51 | artifacts/
52 | **/Properties/launchSettings.json
53 |
54 | *_i.c
55 | *_p.c
56 | *_i.h
57 | *.ilk
58 | *.meta
59 | *.obj
60 | *.pch
61 | *.pdb
62 | *.pgc
63 | *.pgd
64 | *.rsp
65 | *.sbr
66 | *.tlb
67 | *.tli
68 | *.tlh
69 | *.tmp
70 | *.tmp_proj
71 | *.log
72 | *.vspscc
73 | *.vssscc
74 | .builds
75 | *.pidb
76 | *.svclog
77 | *.scc
78 |
79 | # Chutzpah Test files
80 | _Chutzpah*
81 |
82 | # Visual C++ cache files
83 | ipch/
84 | *.aps
85 | *.ncb
86 | *.opendb
87 | *.opensdf
88 | *.sdf
89 | *.cachefile
90 | *.VC.db
91 | *.VC.VC.opendb
92 |
93 | # Visual Studio profiler
94 | *.psess
95 | *.vsp
96 | *.vspx
97 | *.sap
98 |
99 | # TFS 2012 Local Workspace
100 | $tf/
101 |
102 | # Guidance Automation Toolkit
103 | *.gpState
104 |
105 | # ReSharper is a .NET coding add-in
106 | _ReSharper*/
107 | *.[Rr]e[Ss]harper
108 | *.DotSettings.user
109 |
110 | # JustCode is a .NET coding add-in
111 | .JustCode
112 |
113 | # TeamCity is a build add-in
114 | _TeamCity*
115 |
116 | # DotCover is a Code Coverage Tool
117 | *.dotCover
118 |
119 | # Visual Studio code coverage results
120 | *.coverage
121 | *.coveragexml
122 |
123 | # NCrunch
124 | _NCrunch_*
125 | .*crunch*.local.xml
126 | nCrunchTemp_*
127 |
128 | # MightyMoose
129 | *.mm.*
130 | AutoTest.Net/
131 |
132 | # Web workbench (sass)
133 | .sass-cache/
134 |
135 | # Installshield output folder
136 | [Ee]xpress/
137 |
138 | # DocProject is a documentation generator add-in
139 | DocProject/buildhelp/
140 | DocProject/Help/*.HxT
141 | DocProject/Help/*.HxC
142 | DocProject/Help/*.hhc
143 | DocProject/Help/*.hhk
144 | DocProject/Help/*.hhp
145 | DocProject/Help/Html2
146 | DocProject/Help/html
147 |
148 | # Click-Once directory
149 | publish/
150 |
151 | # Publish Web Output
152 | *.[Pp]ublish.xml
153 | *.azurePubxml
154 | # TODO: Comment the next line if you want to checkin your web deploy settings
155 | # but database connection strings (with potential passwords) will be unencrypted
156 | *.pubxml
157 | *.publishproj
158 |
159 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
160 | # checkin your Azure Web App publish settings, but sensitive information contained
161 | # in these scripts will be unencrypted
162 | PublishScripts/
163 |
164 | # NuGet Packages
165 | *.nupkg
166 | # The packages folder can be ignored because of Package Restore
167 | **/packages/*
168 | # except build/, which is used as an MSBuild target.
169 | !**/packages/build/
170 | # Uncomment if necessary however generally it will be regenerated when needed
171 | #!**/packages/repositories.config
172 | # NuGet v3's project.json files produces more ignorable files
173 | *.nuget.props
174 | *.nuget.targets
175 |
176 | # Microsoft Azure Build Output
177 | csx/
178 | *.build.csdef
179 |
180 | # Microsoft Azure Emulator
181 | ecf/
182 | rcf/
183 |
184 | # Windows Store app package directories and files
185 | AppPackages/
186 | BundleArtifacts/
187 | Package.StoreAssociation.xml
188 | _pkginfo.txt
189 | *.appx
190 |
191 | # Visual Studio cache files
192 | # files ending in .cache can be ignored
193 | *.[Cc]ache
194 | # but keep track of directories ending in .cache
195 | !*.[Cc]ache/
196 |
197 | # Others
198 | ClientBin/
199 | ~$*
200 | *~
201 | *.dbmdl
202 | *.dbproj.schemaview
203 | *.jfm
204 | *.pfx
205 | *.publishsettings
206 | orleans.codegen.cs
207 |
208 | # Since there are multiple workflows, uncomment next line to ignore bower_components
209 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
210 | #bower_components/
211 |
212 | # RIA/Silverlight projects
213 | Generated_Code/
214 |
215 | # Backup & report files from converting an old project file
216 | # to a newer Visual Studio version. Backup files are not needed,
217 | # because we have git ;-)
218 | _UpgradeReport_Files/
219 | Backup*/
220 | UpgradeLog*.XML
221 | UpgradeLog*.htm
222 |
223 | # SQL Server files
224 | *.mdf
225 | *.ldf
226 | *.ndf
227 |
228 | # Business Intelligence projects
229 | *.rdl.data
230 | *.bim.layout
231 | *.bim_*.settings
232 |
233 | # Microsoft Fakes
234 | FakesAssemblies/
235 |
236 | # GhostDoc plugin setting file
237 | *.GhostDoc.xml
238 |
239 | # Node.js Tools for Visual Studio
240 | .ntvs_analysis.dat
241 | node_modules/
242 |
243 | # Typescript v1 declaration files
244 | typings/
245 |
246 | # Visual Studio 6 build log
247 | *.plg
248 |
249 | # Visual Studio 6 workspace options file
250 | *.opt
251 |
252 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
253 | *.vbw
254 |
255 | # Visual Studio LightSwitch build output
256 | **/*.HTMLClient/GeneratedArtifacts
257 | **/*.DesktopClient/GeneratedArtifacts
258 | **/*.DesktopClient/ModelManifest.xml
259 | **/*.Server/GeneratedArtifacts
260 | **/*.Server/ModelManifest.xml
261 | _Pvt_Extensions
262 |
263 | # Paket dependency manager
264 | .paket/paket.exe
265 | paket-files/
266 |
267 | # FAKE - F# Make
268 | .fake/
269 |
270 | # JetBrains Rider
271 | .idea/
272 | *.sln.iml
273 |
274 | # CodeRush
275 | .cr/
276 |
277 | # Python Tools for Visual Studio (PTVS)
278 | __pycache__/
279 | *.pyc
280 |
281 | # Cake - Uncomment if you are using it
282 | # tools/**
283 | # !tools/packages.config
284 |
285 | # Tabs Studio
286 | *.tss
287 |
288 | # Telerik's JustMock configuration file
289 | *.jmconfig
290 |
291 | # BizTalk build output
292 | *.btp.cs
293 | *.btm.cs
294 | *.odx.cs
295 | *.xsd.cs
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at welshfamily12345@hotmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | File an issue
2 | Solve issue
3 | Commit changes
4 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace EpicorSwaggerRESTGenerator
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/EpicorRESTGenerator.WPFGUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}
8 | WinExe
9 | Properties
10 | EpicorRESTGenerator.WPFGUI
11 | EpicorRESTGenerator.WPFGUI
12 | v4.5.2
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
40 | True
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | 4.0
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | MSBuild:Compile
60 | Designer
61 |
62 |
63 | Designer
64 | MSBuild:Compile
65 |
66 |
67 | App.xaml
68 | Code
69 |
70 |
71 | generator.xaml
72 |
73 |
74 |
75 |
76 | Code
77 |
78 |
79 | True
80 | True
81 | Resources.resx
82 |
83 |
84 | True
85 | Settings.settings
86 | True
87 |
88 |
89 | ResXFileCodeGenerator
90 | Resources.Designer.cs
91 |
92 |
93 |
94 | SettingsSingleFileGenerator
95 | Settings.Designer.cs
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}
105 | EpicorSwaggerRESTGenerator
106 |
107 |
108 |
109 |
116 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("EpicorSwaggerRESTGenerator.WPFGUI")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("EpicorSwaggerRESTGenerator.WPFGUI")]
15 | [assembly: AssemblyCopyright("Copyright © 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/Properties/Resources.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 EpicorSwaggerRESTGenerator.WPFGUI.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EpicorSwaggerRESTGenerator.WPFGUI.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/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 EpicorSwaggerRESTGenerator.WPFGUI.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/generator.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
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 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/generator.xaml.cs:
--------------------------------------------------------------------------------
1 | using EpicorSwaggerRESTGenerator.Models;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Net;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Controls;
12 | using System.Windows.Data;
13 | using System.Windows.Documents;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Shapes;
18 |
19 | namespace EpicorSwaggerRESTGenerator.WPFGUI
20 | {
21 | ///
22 | /// Interaction logic for generator.xaml
23 | ///
24 | public partial class generator : Window
25 | {
26 | service services;
27 | public generator()
28 | {
29 | InitializeComponent();
30 |
31 | }
32 | private void CheckService_Click(object sender, RoutedEventArgs e)
33 | {
34 | if (string.IsNullOrEmpty(serviceURLTextBox.Text))
35 | {
36 | MessageBox.Show("Epicor API URL is Required");
37 | return;
38 | }
39 | if((bool)useCredentialsCheckBox.IsChecked)
40 | {
41 | if(string.IsNullOrEmpty(usernameTextBox.Text))
42 | {
43 | MessageBox.Show("Username is required");
44 | return;
45 | }
46 | if(string.IsNullOrEmpty(passwordTextBox.Text))
47 | {
48 | MessageBox.Show("Password is required");
49 | return;
50 | }
51 | }
52 |
53 | isvalidURL(serviceURLTextBox.Text + "/api/v1/");
54 |
55 | MessageBoxResult result = MessageBox.Show("Do you want to generate a client for oData? Selecting No will default to custom methods", "", MessageBoxButton.YesNo);
56 | switch (result)
57 | {
58 | case MessageBoxResult.Yes:
59 | ERPAPIURLTextBox.Text = serviceURLTextBox.Text + "/api/swagger/v1/odata/";
60 | ICEAPIURLTextBox.Text = serviceURLTextBox.Text + "/api/swagger/v1/odata/";
61 | break;
62 | case MessageBoxResult.No:
63 | ERPAPIURLTextBox.Text = serviceURLTextBox.Text + "/api/swagger/v1/methods/";
64 | ICEAPIURLTextBox.Text = serviceURLTextBox.Text + "/api/swagger/v1/methods/";
65 | break;
66 | }
67 | BAQAPIURLTextBox.Text = serviceURLTextBox.Text + "/api/swagger/v1/baq/";
68 |
69 | ERPAPIURLServiceTextBox.Text = serviceURLTextBox.Text + "/api/v1/";
70 | ICEAPIURLServiceTextBox.Text = serviceURLTextBox.Text + "/api/v1/";
71 | BAQAPIURLServiceTextBox.Text = serviceURLTextBox.Text + "/api/v1/BaqSvc/";
72 |
73 |
74 |
75 | tabControl.IsEnabled = true;
76 | }
77 |
78 |
79 | private void GetBAQServicesButton_Click(object sender, RoutedEventArgs e)
80 | {
81 | PopulateService(BAQAPIURLServiceTextBox, BAQServiceListBox, "");
82 | }
83 | private void GetICEServicesButton_Click(object sender, RoutedEventArgs e)
84 | {
85 | PopulateService(ICEAPIURLServiceTextBox, ICEServiceListBox, "ICE");
86 | }
87 | private void GetERPServicesButton_Click(object sender, RoutedEventArgs e)
88 | {
89 | PopulateService(ERPAPIURLServiceTextBox, ERPServiceListBox, "ERP");
90 | }
91 |
92 |
93 | private void GeneratERPButton_Click(object sender, RoutedEventArgs e)
94 | {
95 | if (!isValid(ERPAPIURLServiceTextBox) || !isvalidURL(ERPAPIURLServiceTextBox.Text)) { MessageBox.Show("Please provide a services URL for the ERP Services", ""); return; }
96 | if (!isValid(ERPProjectTextBox) || !fileExists(ERPProjectTextBox)) { MessageBox.Show("Please provide the ERP project directory", ""); return; }
97 | if (!isValid(ERPAPIURLTextBox)) { MessageBox.Show("Please provide the ERP API URL", ""); return; }
98 | if (ERPServiceListBox.SelectedItems.Count == 0) { MessageBox.Show("Please select the service you wish to generate a client for!", ""); return; }
99 | IsEnabled = false;
100 | services.workspace.collection = services.workspace.collection.Where(o => ERPServiceListBox.SelectedItems.Contains(o.href)).ToArray();
101 | var r = generate(ERPAPIURLTextBox.Text, ERPProjectTextBox.Text).Result;
102 | IsEnabled = true;
103 | }
104 | private void GeneratICEButton_Click(object sender, RoutedEventArgs e)
105 | {
106 | if (!isValid(ICEAPIURLServiceTextBox) || !isvalidURL(ICEAPIURLServiceTextBox.Text)) { MessageBox.Show("Please provide a services URL for the ICE Services", ""); return; }
107 | if (!isValid(ICEProjectTextBox) || !fileExists(ICEProjectTextBox)) { MessageBox.Show("Please provide the ICE project directory", ""); return; }
108 | if (!isValid(ICEAPIURLTextBox)) { MessageBox.Show("Please provide the ICE API URL", ""); return; }
109 | if (ICEServiceListBox.SelectedItems.Count == 0) { MessageBox.Show("Please select the service you wish to generate a client for!", ""); return; }
110 | IsEnabled = false;
111 | services.workspace.collection = services.workspace.collection.Where(o => ICEServiceListBox.SelectedItems.Contains(o.href)).ToArray();
112 | var r = generate(ICEAPIURLTextBox.Text, ICEProjectTextBox.Text).Result;
113 | IsEnabled = true;
114 | }
115 | private void GeneratBAQButton_Click(object sender, RoutedEventArgs e)
116 | {
117 | if (!isValid(BAQAPIURLServiceTextBox) || !isvalidURL(BAQAPIURLServiceTextBox.Text)) { MessageBox.Show("Please provide a services URL for the BAQ Services", ""); return; }
118 | if (!isValid(BAQProjectTextBox) || !fileExists(BAQProjectTextBox)) { MessageBox.Show("Please provide the BAQ project directory", ""); return; }
119 | if (!isValid(BAQAPIURLTextBox)) { MessageBox.Show("Please provide the BAQ API URL", ""); return; }
120 | if (BAQServiceListBox.SelectedItems.Count == 0) { MessageBox.Show("Please select the service you wish to generate a client for!", ""); return; }
121 | IsEnabled = false;
122 | services.workspace.collection = services.workspace.collection.Where(o => BAQServiceListBox.SelectedItems.Contains(o.href)).ToArray();
123 | var r = generate(BAQAPIURLTextBox.Text, BAQProjectTextBox.Text).Result;
124 | IsEnabled = true;
125 | }
126 |
127 |
128 | private void PopulateService(TextBox textBox, ListBox listBox, string type)
129 | {
130 | if (string.IsNullOrEmpty(textBox.Text))
131 | {
132 | MessageBox.Show("Services URL is Required");
133 | }
134 | if (!isvalidURL(textBox.Text)) return;
135 |
136 | EpicorDetails details = new EpicorDetails();
137 | if((bool)useCredentialsCheckBox.IsChecked)
138 | {
139 | details.Username = usernameTextBox.Text;
140 | details.Password = passwordTextBox.Text;
141 | }
142 |
143 | services = service.getServices(textBox.Text, details);
144 | services.workspace.collection = services.workspace.collection.Where(o => o.href.ToUpper().StartsWith(type)).ToArray();
145 | listBox.ItemsSource = services.workspace.collection.Select(o => o.href);
146 | }
147 | private bool isValid(TextBox textBox)
148 | {
149 | return !String.IsNullOrEmpty(textBox.Text);
150 | }
151 | private bool isvalidURL(string url)
152 | {
153 | EpicorDetails details = new EpicorDetails();
154 | if ((bool)useCredentialsCheckBox.IsChecked)
155 | {
156 | details.Username = usernameTextBox.Text;
157 | details.Password = passwordTextBox.Text;
158 | }
159 | try
160 | {
161 | var valid = service.getServices(url, details);
162 | if (valid.workspace != null && valid.workspace.collection != null && valid.workspace.collection.Count() == 0)
163 | {
164 | MessageBox.Show("Service is invalid");
165 | return false;
166 | }
167 | }
168 | catch (WebException ex)
169 | {
170 | if(ex.Response != null)
171 | {
172 | using (WebResponse response = ex.Response)
173 | {
174 | HttpWebResponse httpResponse = (HttpWebResponse)response;
175 | MessageBox.Show(string.Format("Error code: {0}", httpResponse.StatusDescription));
176 | string text = "";
177 | using (Stream data = response.GetResponseStream())
178 | using (var reader = new StreamReader(data))
179 | {
180 | // text is the response body
181 | text = reader.ReadToEnd();
182 | }
183 | MessageBox.Show(text);
184 | return false;
185 | }
186 | }
187 | else
188 | {
189 | MessageBox.Show(ex.Message);
190 | return false;
191 | }
192 | }
193 | catch(Exception ex)
194 | {
195 | MessageBox.Show(ex.Message);
196 | return false;
197 | }
198 | return true;
199 | }
200 | private bool fileExists(TextBox textBox)
201 | {
202 | return File.Exists(textBox.Text);
203 | }
204 | private async Task generate(string url, string proj)
205 | {
206 | EpicorDetails details = new EpicorDetails();
207 | details.BaseClass = BaseClassTextBox.Text;
208 | details.APIURL = url;
209 | details.Project = proj;
210 | details.Namespace = NamespaceTextBox.Text;
211 | details.useBaseClass = (bool)UseBaseClassCheckBox.IsChecked;
212 |
213 | var test = await service.generateCode(services, details);
214 | if (test)
215 | MessageBox.Show("Success");
216 | else
217 | MessageBox.Show("Somehing went wrong");
218 | return true;
219 | }
220 | private void OnTabItemChanged(object sender, SelectionChangedEventArgs e)
221 | {
222 | services = null;
223 | ERPServiceListBox.ItemsSource = null;
224 | ICEServiceListBox.ItemsSource = null;
225 | BAQServiceListBox.ItemsSource = null;
226 | }
227 |
228 | private void ServiceListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
229 | {
230 | e.Handled = true;
231 | }
232 |
233 | private void useCredentialsCheckBox_Checked(object sender, RoutedEventArgs e)
234 | {
235 | usernameTextBox.IsEnabled = true;
236 | passwordTextBox.IsEnabled = true;
237 | }
238 | private void useCredentialsCheckBox_UnChecked(object sender, RoutedEventArgs e)
239 | {
240 | usernameTextBox.IsEnabled = false;
241 | passwordTextBox.IsEnabled = false;
242 | }
243 |
244 | private void button1_Click(object sender, RoutedEventArgs e)
245 | {
246 | richTextBox.Document = new FlowDocument();
247 |
248 | OpenFileDialog openFile1 = new OpenFileDialog();
249 | openFile1.DefaultExt = "*.cs";
250 | openFile1.Filter = "CS Files|*.cs";
251 |
252 | var hasValue = openFile1.ShowDialog().HasValue;
253 | if (hasValue)
254 | {
255 | Paragraph paragraph = new Paragraph();
256 | paragraph.Inlines.Add(System.IO.File.ReadAllText(openFile1.FileName));
257 | FlowDocument document = new FlowDocument(paragraph);
258 | richTextBox.Document = document;
259 | }
260 | }
261 | private void button_Click(object sender, RoutedEventArgs e)
262 | {
263 | SaveFileDialog dialog = new SaveFileDialog();
264 | dialog.DefaultExt = "*.cs";
265 | dialog.Filter = "CS Files|*.cs";
266 |
267 | if (dialog.ShowDialog() == true)
268 | {
269 | TextRange t = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
270 | FileStream file = new FileStream(dialog.FileName, FileMode.Create);
271 | t.Save(file, System.Windows.DataFormats.Text);
272 | file.Close();
273 | //File.WriteAllText(dialog.FileName, richTextBox.Document.);
274 | }
275 | }
276 | }
277 | }
278 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.WPFGUI/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/EpicorRESTGenerator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EpicorRESTGenerator.WPFGUI", "EpicorRESTGenerator.WPFGUI\EpicorRESTGenerator.WPFGUI.csproj", "{72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EpicorSwaggerRESTGenerator", "EpicorSwaggerRESTGenerator\EpicorSwaggerRESTGenerator.csproj", "{120492FF-9E4A-41C7-8CB0-555975DAC5F1}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {72726F18-A0D8-4615-8AA4-C1B35CC9D6EA}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/ClientBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Net.Http;
6 | using System.Net.Http.Headers;
7 | using System.Net.Security;
8 | using System.Security.Cryptography.X509Certificates;
9 | using System.Text;
10 | using System.Threading;
11 | using System.Threading.Tasks;
12 |
13 | namespace EpicorRESTClient.Base
14 | {
15 | public class ClientBase
16 | {
17 | private string certFilePath;//.cer file
18 | public ClientBase(string certPath = "")
19 | {
20 | certFilePath = certPath;
21 | }
22 | protected HttpClient CreateHttpClientAsync()
23 | {
24 | return CreateHttpClientAsync(CancellationToken.None);
25 | }
26 | protected HttpClient CreateHttpClientAsync(CancellationToken cancellationToken)
27 | {
28 | //default set to true for internal use,
29 | //may want to make into a method call and validate the cert based off of hash
30 | ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
31 | {
32 | if(!string.IsNullOrEmpty(certFilePath))
33 | {
34 | var hash = X509Certificate.CreateFromCertFile(certFilePath).GetCertHashString();
35 | return errors == SslPolicyErrors.None && hash == certificate.GetCertHashString();
36 | }
37 | return errors == SslPolicyErrors.None;
38 | };
39 |
40 | //for windows authentication
41 | var handler = new HttpClientHandler { UseDefaultCredentials = true };
42 | var client = new HttpClient(handler);
43 |
44 | //for token authentication
45 | //var client = new HttpClient();
46 | //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", getToken());
47 |
48 | //for basic authentication
49 | //var credentials = Encoding.ASCII.GetBytes("{Username}:{Password}");
50 | //var client = new HttpClient();
51 | //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(credentials));
52 |
53 | return client;
54 | }
55 | }
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/EpicorSwaggerRESTGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {120492FF-9E4A-41C7-8CB0-555975DAC5F1}
8 | Library
9 | Properties
10 | EpicorSwaggerRESTGenerator
11 | EpicorSwaggerRESTGenerator
12 | v4.5.2
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 | ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
36 | True
37 |
38 |
39 | ..\packages\NJsonSchema.9.3.1\lib\net45\NJsonSchema.dll
40 | True
41 |
42 |
43 | ..\packages\NJsonSchema.CodeGeneration.9.3.1\lib\net451\NJsonSchema.CodeGeneration.dll
44 | True
45 |
46 |
47 | ..\packages\NJsonSchema.CodeGeneration.CSharp.9.3.1\lib\net451\NJsonSchema.CodeGeneration.CSharp.dll
48 | True
49 |
50 |
51 | ..\packages\NSwag.CodeGeneration.11.3.1\lib\net451\NSwag.CodeGeneration.dll
52 | True
53 |
54 |
55 | ..\packages\NSwag.CodeGeneration.CSharp.11.3.1\lib\net451\NSwag.CodeGeneration.CSharp.dll
56 | True
57 |
58 |
59 | ..\packages\NSwag.Core.11.3.1\lib\net45\NSwag.Core.dll
60 | True
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
93 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/Client.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace EpicorSwaggerRESTGenerator.Models
9 | {
10 | public static class Client
11 | {
12 | public static WebClient getWebClient(string username = "", string password = "")
13 | {
14 | WebClient client = new WebClient();
15 | ServicePointManager.ServerCertificateValidationCallback += (senderC, cert, chain, sslPolicyErrors) => true;
16 | if (!string.IsNullOrEmpty(username))
17 | {
18 | client.Credentials = new NetworkCredential() { UserName = username, Password = password };
19 | }else
20 | {
21 | client.UseDefaultCredentials = true;
22 | }
23 | return client;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/EpicorDetails.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 EpicorSwaggerRESTGenerator.Models
8 | {
9 | public class EpicorDetails
10 | {
11 | public string Namespace { get; set; }
12 | public bool useBaseClass { get; set; }
13 | public string BaseClass { get; set; }
14 | public string APIURL { get; set; }
15 | public string Project { get; set; }
16 | public string Username { get; set; }
17 | public string Password { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/Service.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using NSwag;
3 | using NSwag.CodeGeneration.CSharp;
4 | using NSwag.CodeGeneration.OperationNameGenerators;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Net;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace EpicorSwaggerRESTGenerator.Models
14 | {
15 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.w3.org/2007/app")]
16 | [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.w3.org/2007/app", IsNullable = false)]
17 | public partial class service
18 | {
19 | private serviceWorkspace workspaceField;
20 | private string baseField;
21 | ///
22 | public serviceWorkspace workspace
23 | {
24 | get
25 | {
26 | return this.workspaceField;
27 | }
28 | set
29 | {
30 | this.workspaceField = value;
31 | }
32 | }
33 | ///
34 | [System.Xml.Serialization.XmlAttributeAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, Namespace = "http://www.w3.org/XML/1998/namespace")]
35 | public string @base
36 | {
37 | get
38 | {
39 | return this.baseField;
40 | }
41 | set
42 | {
43 | this.baseField = value;
44 | }
45 | }
46 | public static service getServices(string serviceURL, EpicorDetails details)
47 | {
48 | using (WebClient client = Client.getWebClient(string.IsNullOrEmpty(details.Username) ? "" : details.Username, string.IsNullOrEmpty(details.Password) ? "" : details.Password))
49 | {
50 | service services = new service();
51 | System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(service));
52 | string xml = client.DownloadString(serviceURL);
53 | using (StringReader sr = new StringReader(xml))
54 | {
55 | services = (service)serializer.Deserialize(sr);
56 | }
57 | return services;
58 | }
59 | }
60 | public static async Task generateCode(service services, EpicorDetails details)
61 | {
62 | using (WebClient client = Client.getWebClient(string.IsNullOrEmpty(details.Username) ? "" : details.Username, string.IsNullOrEmpty(details.Password) ? "" : details.Password))
63 | {
64 | foreach (var service in services.workspace.collection)
65 | {
66 | var name = service.href.Replace(".", "").Replace("-", "");
67 | try
68 | {
69 | string x = client.DownloadString(details.APIURL + service.href);
70 |
71 | dynamic jsonObj = JsonConvert.DeserializeObject(x);
72 | if (!details.APIURL.Contains("baq"))
73 | {
74 | foreach (var j in jsonObj["paths"])
75 | {
76 | var post = j.First["post"];
77 | if (post != null)
78 | {
79 | var postOpID = j.First["post"]["operationId"];
80 | if (postOpID != null)
81 | {
82 | j.First["post"]["operationId"] = j.Name.Replace(@"\", "").Replace("/", "");
83 | }
84 | }
85 | }
86 | }
87 |
88 | string output = JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
89 |
90 | var document = await SwaggerDocument.FromJsonAsync(output);
91 | var settings = new SwaggerToCSharpClientGeneratorSettings() { ClassName = name, OperationNameGenerator = new SingleClientFromOperationIdOperationNameGenerator() };
92 | var generator = new SwaggerToCSharpClientGenerator(document, settings);
93 | if (details.useBaseClass) generator.Settings.ClientBaseClass = details.BaseClass;
94 | generator.Settings.UseHttpClientCreationMethod = true;
95 | generator.Settings.AdditionalNamespaceUsages = new[] { "Newtonsoft.Json", "Newtonsoft.Json.Linq" };
96 | generator.Settings.GenerateSyncMethods = true;
97 |
98 | var code = generator.GenerateFile();
99 | code = code
100 | //need to replace with my actual namespace
101 | .Replace("MyNamespace", details.Namespace + "." + service.href.Replace("-", ""))
102 | //Had an error so added but I dont think this replacement is needed for all scenarios, maybe add flag in details later
103 | .Replace("var client_ = await CreateHttpClientAsync(cancellationToken).ConfigureAwait(false);", "var client_ = CreateHttpClientAsync(cancellationToken);")
104 | //.Replace("var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);", "var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken);")
105 | //.Replace("var responseData_ = await response_.Content.ReadAsStringAsync().ConfigureAwait(false);", "var responseData_ = await response_.Content.ReadAsStringAsync();")
106 | //no need
107 | .Replace("#pragma warning disable // Disable all warnings", "")
108 | //cant use so had to replace
109 | .Replace("k", "Keyk")
110 | //cant use so had to replace
111 | .Replace("k", "Valuek")
112 | //cant use so had to replace
113 | .Replace("_tLСTotalCost", "_tLDTotalCost")
114 | //cant use so had to replace
115 | .Replace("TLСTotalCost", "TLDTotalCost")
116 | //had to change to dictionary, additial properties may return a list, parse into jtoken
117 | .Replace("private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary();", "private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary();")
118 | .Replace("public System.Collections.Generic.IDictionary AdditionalProperties", " public System.Collections.Generic.IDictionary AdditionalProperties")
119 | //I dont like the required attribute, changed to allow nulls
120 | .Replace(", Required = Newtonsoft.Json.Required.Always)]", ", Required = Newtonsoft.Json.Required.AllowNull)]")
121 | .Replace("[System.ComponentModel.DataAnnotations.Required]", "")
122 | .Replace(@"public string BaseUrl", "public new string BaseUrl")
123 | //.Replace("get { return _baseUrl; }", "get;")
124 | //.Replace("set { _baseUrl = value; }", "set;");
125 | ;
126 | //addReference(details.Project, service.href + ".cs");
127 | File.WriteAllText(Path.GetDirectoryName(details.Project) + "\\" + service.href + ".cs", code);
128 | }
129 | catch (Exception ex)
130 | {
131 | Console.WriteLine("{1} : <------> {0}", ex, name);
132 | string directory = AppDomain.CurrentDomain.BaseDirectory + @"/Logs/";
133 | if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
134 | File.AppendAllText(directory + DateTime.Now.ToString("MMDDYYYY_hhmmssfffff") + ".txt", name + Environment.NewLine + ex);
135 | }
136 | }
137 | }
138 | return true;
139 | }
140 | private static void addReference(string projectFile, string filename)
141 | {
142 | using (var collection = new Microsoft.Build.Evaluation.ProjectCollection())
143 | {
144 | collection.LoadProject(projectFile);
145 | var project = collection.LoadedProjects.FirstOrDefault(o => o.FullPath == projectFile);
146 | var items = project.GetItems("Compile");
147 | if (!items.Any(o => o.EvaluatedInclude == filename || o.UnevaluatedInclude == filename))
148 | {
149 | project.AddItem("Compile", filename);
150 | project.Save();
151 | }
152 |
153 | collection.UnloadProject(project);
154 | }
155 | }
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/serviceWorkspace.cs:
--------------------------------------------------------------------------------
1 | using EpicorSwaggerRESTGenerator.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace EpicorSwaggerRESTGenerator.Models
9 | {
10 | ///
11 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.w3.org/2007/app")]
12 | public partial class serviceWorkspace
13 | {
14 |
15 | private title titleField;
16 |
17 | private serviceWorkspaceCollection[] collectionField;
18 |
19 | ///
20 | [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://www.w3.org/2005/Atom")]
21 | public title title
22 | {
23 | get
24 | {
25 | return this.titleField;
26 | }
27 | set
28 | {
29 | this.titleField = value;
30 | }
31 | }
32 |
33 | ///
34 | [System.Xml.Serialization.XmlElementAttribute("collection")]
35 | public serviceWorkspaceCollection[] collection
36 | {
37 | get
38 | {
39 | return this.collectionField;
40 | }
41 | set
42 | {
43 | this.collectionField = value;
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/serviceWorkspaceCollection.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 EpicorSwaggerRESTGenerator.Models
8 | {
9 |
10 | ///
11 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.w3.org/2007/app")]
12 | public partial class serviceWorkspaceCollection
13 | {
14 |
15 | private title titleField;
16 |
17 | private string[] textField;
18 |
19 | private string hrefField;
20 |
21 | ///
22 | [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://www.w3.org/2005/Atom")]
23 | public title title
24 | {
25 | get
26 | {
27 | return this.titleField;
28 | }
29 | set
30 | {
31 | this.titleField = value;
32 | }
33 | }
34 |
35 | ///
36 | [System.Xml.Serialization.XmlTextAttribute()]
37 | public string[] Text
38 | {
39 | get
40 | {
41 | return this.textField;
42 | }
43 | set
44 | {
45 | this.textField = value;
46 | }
47 | }
48 |
49 | ///
50 | [System.Xml.Serialization.XmlAttributeAttribute()]
51 | public string href
52 | {
53 | get
54 | {
55 | return this.hrefField;
56 | }
57 | set
58 | {
59 | this.hrefField = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Models/title.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 EpicorSwaggerRESTGenerator.Models
8 | {
9 | ///
10 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.w3.org/2005/Atom")]
11 | [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.w3.org/2005/Atom", IsNullable = false)]
12 | public partial class title
13 | {
14 |
15 | private string typeField;
16 |
17 | private string valueField;
18 |
19 | ///
20 | [System.Xml.Serialization.XmlAttributeAttribute()]
21 | public string type
22 | {
23 | get
24 | {
25 | return this.typeField;
26 | }
27 | set
28 | {
29 | this.typeField = value;
30 | }
31 | }
32 |
33 | ///
34 | [System.Xml.Serialization.XmlTextAttribute()]
35 | public string Value
36 | {
37 | get
38 | {
39 | return this.valueField;
40 | }
41 | set
42 | {
43 | this.valueField = value;
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("EpicorSwaggerRESTGenerator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("EpicorSwaggerRESTGenerator")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("120492ff-9e4a-41c7-8cb0-555975dac5f1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/EpicorSwaggerRESTGenerator/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Edward Welsh
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 | # EpicorRESTClientGenerator
2 | This genertor was created to maintain Business Objects in third party and custom integration software applications
3 |
4 | This generator uses NSwag.CodeGeneration.CSharp
5 |
6 | I have included a WPF client for working with the class library
7 |
8 | You may need to make a few modifications to the source code for your implementation
9 |
10 | I have included a ClientBase class that creates the HttpClient used to make all the rest calls, it also sets up the authentication
11 |
12 | You may have to edit this class depending on your security needs
13 |
14 | I use this when adding a new BAQ or when Epicor updates the services
15 |
--------------------------------------------------------------------------------