66using Entities . Utilities ;
77using Microsoft . AspNetCore . Authorization ;
88using Microsoft . AspNetCore . Cors ;
9+ using Microsoft . AspNetCore . DataProtection ;
910using Microsoft . AspNetCore . Http ;
1011using Microsoft . AspNetCore . Mvc ;
1112using Microsoft . Extensions . Caching . Memory ;
@@ -21,25 +22,26 @@ namespace DbLocalizer.Controllers
2122 [ EnableCors ( "DbLocalizerCorsPolicy" ) ]
2223 [ Route ( "api/[controller]" ) ]
2324 [ ApiController ]
24- public class SmartlingExportController : BaseController
25+ public class ExportController : BaseController
2526 {
2627 private readonly IBackgroundWorkerQueue _backgroundWorkerQueue ;
2728 private readonly AppSettings _appSettings ;
2829 private readonly ILongRunningService _longRunningService ;
2930 private readonly IExportDal _exportDal ;
3031 private readonly IFileDataService _fileDataService ;
3132
32- public SmartlingExportController (
33+ public ExportController (
3334 IBackgroundWorkerQueue backgroundWorkerQueue ,
3435 ILongRunningService longRunningService ,
3536 AppSettings appSettings ,
36- ILogger < SmartlingExportController > logger ,
37+ ILogger < ExportController > logger ,
3738 IExportDal exportDal ,
3839 IFileDataService fileDataService ,
3940 IMemoryCache memoryCache ,
4041 IConfiguration config ,
41- ISqlSchemaBuilder sqlSchemaBuilder )
42- : base ( memoryCache , config , sqlSchemaBuilder , logger )
42+ ISqlSchemaBuilder sqlSchemaBuilder ,
43+ IEncryptionService encryptionService )
44+ : base ( memoryCache , config , sqlSchemaBuilder , logger , encryptionService )
4345 {
4446 _backgroundWorkerQueue = backgroundWorkerQueue ;
4547 _appSettings = appSettings ;
@@ -76,6 +78,10 @@ public IActionResult Export()
7678 {
7779 return BadRequest ( "The required database and/or culture data is null" ) ;
7880 }
81+ if ( string . IsNullOrEmpty ( _appSettings . TMSPlugin ) )
82+ {
83+ return BadRequest ( "Please set your choice of TMSPlugin in the appSettings.json config file" ) ;
84+ }
7985
8086 Guid processId = Guid . NewGuid ( ) ;
8187 CancellationTokenSource tokenSource = new CancellationTokenSource ( ) ;
@@ -100,19 +106,27 @@ await Task.Factory.StartNew(async () =>
100106 {
101107 try
102108 {
103- ISmartlingConfiguration smartlingConfig = new SmartlingConfiguration ( _config ) ;
104- ISmartlingExportFileProcessor _fileProcessor = new SmartlingExportFileProcessor ( _logger , _exportDal , "Default" , CacheManager , _schemaBuilder , smartlingConfig ) ;
105- IExportUtility util = new SmartlingExportUtility (
106- _fileProcessor ,
107- _fileDataService ,
108- _exportDal ,
109- _appSettings ,
110- _config ,
111- smartlingConfig ,
112- _logger ,
113- processId ) ;
114-
115- result = await util . Export ( ct ) ;
109+ switch ( _appSettings . TMSPlugin )
110+ {
111+ case "Smartling" :
112+ ISmartlingConfiguration smartlingConfig = new SmartlingConfiguration ( _config ) ;
113+ IExportFileProcessor _fileProcessor = new SmartlingExportFileProcessor ( _logger , _exportDal , "Default" , CacheManager , _schemaBuilder , smartlingConfig ) ;
114+ IExportUtility util = new SmartlingExportUtility (
115+ _fileProcessor ,
116+ _fileDataService ,
117+ _exportDal ,
118+ _appSettings ,
119+ _config ,
120+ smartlingConfig ,
121+ _logger ,
122+ processId ) ;
123+
124+ result = await util . Export ( ct ) ;
125+ break ;
126+ default :
127+ throw new NotImplementedException ( "The TMSPlugin is not implemented" ) ;
128+ }
129+
116130 }
117131 catch ( Exception ex )
118132 {
0 commit comments