public async Task <IActionResult> PostSnsTagFile( [FromServices] IWebRequest webRequest, [FromServices] ILoggerFactory loggerFactory, [FromServices] IConfigurationStore configStore, [FromServices] IDataCache dataCache, [FromServices] ITRexTagFileProxy trexTagFileProxy, [FromServices] ITransferProxyFactory transferProxyFactory) { // https://forums.aws.amazon.com/thread.jspa?threadID=69413 // AWS SNS is in text/plain, not application/json - so need to parse manually var payloadMs = new MemoryStream(); await Request.Body.CopyToAsync(payloadMs); var payload = JsonConvert.DeserializeObject <SnsPayload>(Encoding.UTF8.GetString(payloadMs.ToArray())); if (payload == null) { return(BadRequest()); } var result = await RequestExecutorContainer.Build <TagFileSnsProcessExecutor>(loggerFactory, configStore, dataCache, trexTagFileProxy, transferProxyFactory, webRequest) .ProcessAsync(payload); if (result != null) { return(Ok()); } // Note sure if we return bad request or not on failed processing - will updated if needed return(BadRequest()); }
public async Task <ContractExecutionResult> PostTagFile([FromBody] CompactionTagFileRequest request, [FromServices] ILoggerFactory loggerFactory, [FromServices] IConfigurationStore configStore, [FromServices] IDataCache dataCache, [FromServices] ITRexTagFileProxy trexTagFileProxy, [FromServices] ITransferProxyFactory transferProxyFactory, [FromServices] IWebRequest webRequest) { var isDirect = Request.Path.Value.Contains("/direct"); _logger.LogInformation($"{nameof(PostTagFile)} Attempting to process {(isDirect ? "Direct" : "Non-Direct")} tag file {request?.FileName}"); var executor = RequestExecutorContainer .Build <TagFileProcessExecutor>(loggerFactory, configStore, dataCache, trexTagFileProxy, transferProxyFactory, webRequest); executor.ArchiveOnInternalError = true; var result = await executor.ProcessAsync(request); _logger.LogInformation($"{nameof(PostTagFile)} Got result {JsonConvert.SerializeObject(result)} for Tag file: {request?.FileName}"); // If we uploaded, return a successful result // (as the tag file may not have been processed for legitimate reasons) // We don't want the machine sending tag files over and over again in this instance return(new ContractExecutionResult()); }
public void Initialise(ILoggerFactory loggerFactory, ILogger logger, #if RAPTOR IASNodeClient raptorClient, ITagProcessor tagProcessor, #endif IConfigurationStore configStore, List <FileData> fileList, ICompactionProfileResultHelper profileResultHelper, ITRexTagFileProxy tRexTagFileProxy, ITRexCompactionDataProxy trexCompactionDataProxy, IFileImportProxy fileImportProxy, IHeaderDictionary customHeaders, string customerUid, string userId) { this.loggerFactory = loggerFactory; this.log = logger; #if RAPTOR this.raptorClient = raptorClient; this.tagProcessor = tagProcessor; #endif this.configStore = configStore; this.fileList = fileList; this.profileResultHelper = profileResultHelper; this.tRexTagFileProxy = tRexTagFileProxy; this.trexCompactionDataProxy = trexCompactionDataProxy; this.fileImportProxy = fileImportProxy; this.customHeaders = customHeaders; this.customerUid = customerUid; this.userId = userId; }
/// <summary> /// Default constructor. /// </summary> public TagFileController( ILoggerFactory logger, ITRexTagFileProxy tRexTagFileProxy, IConfigurationStore configStore) { _logger = logger; _log = logger.CreateLogger <TagFileController>(); _tRexTagFileProxy = tRexTagFileProxy; _configStore = configStore; }
public TagFileDispatchSvc(ITPaaSApplicationAuthentication authn, ILoggerFactory logFactory, IConfigurationStore config, ITRexTagFileProxy serviceProxy) { _log = logFactory.CreateLogger <TagFileDispatchSvc>(); _authn = authn; _config = config; _serviceProxy = serviceProxy; _path = Path.Combine(_config.GetValueString("InstallFolder"), TagConstants.TAGFILE_FOLDER); }
/// <summary> /// Sends tag file to TRex endpoint, retrieving result /// </summary> public static async Task <ContractExecutionResult> SendTagFileToTRex(CompactionTagFileRequest compactionTagFileRequest, ITRexTagFileProxy tagFileProxy, ILogger log, IHeaderDictionary customHeaders) { try { return(await tagFileProxy.SendTagFile(compactionTagFileRequest, customHeaders)); } catch (Exception e) { log.LogError(e, $"{nameof(SendTagFileToTRex)}: returned exception"); } return(new ContractExecutionResult((int)TRexTagFileResultCode.TRexUnknownException)); }
public static TExecutor Build <TExecutor>(ILoggerFactory loggerFactory, IConfigurationStore configStore, IDataCache dataCache, ITRexTagFileProxy trexTagFileProxy, ITransferProxyFactory transferProxyFactory, IWebRequest webRequest) where TExecutor : RequestExecutorContainer, new() { var executor = new TExecutor() { LoggerFactory = loggerFactory, ConfigStore = configStore, DataCache = dataCache, TRexTagFileProxy = trexTagFileProxy, TransferProxyFactory = transferProxyFactory, WebRequest = webRequest }; return(executor); }
/// <summary> /// Builds this instance for specified executor type. /// </summary> /// <typeparam name="TExecutor">The type of the executor.</typeparam> public static TExecutor Build <TExecutor>(ILoggerFactory logger, #if RAPTOR IASNodeClient raptorClient = null, ITagProcessor tagProcessor = null, #endif IConfigurationStore configStore = null, List <FileData> fileList = null, ICompactionProfileResultHelper profileResultHelper = null, ITRexTagFileProxy tRexTagFileProxy = null, ITRexCompactionDataProxy trexCompactionDataProxy = null, IFileImportProxy fileImportProxy = null, IHeaderDictionary customHeaders = null, string customerUid = null, string userId = null) where TExecutor : RequestExecutorContainer, new() { ILogger log = null; if (logger != null) { log = logger.CreateLogger <TExecutor>(); } var executor = new TExecutor(); executor.Initialise( logger, log, #if RAPTOR raptorClient, tagProcessor, #endif configStore, fileList, profileResultHelper, tRexTagFileProxy, trexCompactionDataProxy, fileImportProxy, customHeaders, customerUid, userId); return(executor); }