File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
MidasCivil_Adapter/AdapterActions Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 3232using System . Runtime . InteropServices ;
3333using System . Threading . Tasks ;
3434using System . Net . Http ;
35+ using System . Net . NetworkInformation ;
3536
3637namespace BH . Adapter . MidasCivil
3738{
@@ -319,6 +320,52 @@ public async Task<bool> RunCommand(Analyse command)
319320 }
320321
321322 /***************************************************/
323+ public async Task < bool > RunCommand ( ImportFile command )
324+ {
325+ if ( m_midasCivilVersion == "9.5.0.nx" )
326+ {
327+ string endpoint = "" ;
328+ string filePath = command . FilePath ;
329+
330+ if ( File . Exists ( filePath ) )
331+ {
332+ string extension = Path . GetExtension ( filePath ) . ToLower ( ) ;
333+
334+ if ( extension == ".mct" || extension == ".mgt" || extension == ".txt" )
335+ endpoint = "doc/IMPORTMXT" ;
336+
337+ else if ( extension == ".json" )
338+ endpoint = "doc/IMPORT" ;
339+
340+ else
341+ {
342+ Engine . Base . Compute . RecordError ( "The given file type is not supported by this Adapter." ) ;
343+ return false ;
344+ }
345+
346+ }
347+
348+ else
349+ {
350+ Engine . Base . Compute . RecordError ( "The given file path does not exist." ) ;
351+ return false ;
352+ }
353+
354+ filePath = filePath . Replace ( "\\ " , "\\ \\ " ) ;
355+
356+ string jsonPayload = "{\" Argument\" : \" " + filePath + "\" }" ;
357+
358+ await SendRequestAsync ( endpoint , HttpMethod . Post , jsonPayload ) . ConfigureAwait ( false ) ;
359+
360+ return true ;
361+ }
362+
363+ else
364+ {
365+ Engine . Base . Compute . RecordWarning ( $ "The command { command . GetType ( ) . Name } is not supported by this Adapter version.") ;
366+ return false ;
367+ }
368+ }
322369
323370 public bool RunCommand ( AnalyseLoadCases command )
324371 {
You can’t perform that action at this time.
0 commit comments