Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance with the service to use and the app settings.
 /// </summary>
 /// <param name="service">The service.</param>
 /// <param name="appSettings">The app settings.</param>
 public Functions(ISevisBatchProcessingService service, AppSettings appSettings)
 {
     Contract.Requires(service != null, "The service must not be null.");
     Contract.Requires(appSettings != null, "The app settings must not be null.");
     this.service     = service;
     this.appSettings = appSettings;
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.service is IDisposable)
         {
             ((IDisposable)this.service).Dispose();
             this.service = null;
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new Functions instance.
 /// </summary>
 /// <param name="service">The sevis batch processing service.</param>
 /// <param name="appSettings">The app settings.</param>
 public Functions(ISevisBatchProcessingService service, ISevisApiResponseHandler responseHandler, IEcaHttpMessageHandlerService theEcaHttpMessageHandlerService, AppSettings appSettings)
 {
     Contract.Requires(service != null, "The service must not be null.");
     Contract.Requires(responseHandler != null, "The response handler must not be null.");
     Contract.Requires(appSettings != null, "The app settings must not be null.");
     Contract.Requires(theEcaHttpMessageHandlerService != null, "The app settings must not be null.");
     this.responseHandler = responseHandler;
     this.service         = service;
     this.ecaHttpMessageHandlerService = theEcaHttpMessageHandlerService;
     this.appSettings = appSettings;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs processing of the SEVIS batch records.
        /// </summary>
        /// <param name="service">The SEVIS batch services to get and update batches.</param>
        /// <param name="sevisComm">The sevis batch comm object.</param>
        /// <param name="settings">The app settings.</param>
        public async Task ProcessAsync(ISevisBatchProcessingService service, SevisComm sevisComm, AppSettings settings)
        {
            Contract.Requires(service != null, "The SEVIS service must not be null.");
            Contract.Requires(settings != null, "The settings must not be null.");
            Contract.Requires(sevisComm != null, "The sevis comm must not be null.");
            logger.Info("Starting SEVIS Batch Processing");
            await DownloadBatchesAsync(sevisComm);
            await UploadBatchesAsync(sevisComm);

            logger.Debug("Removing processed batches");
            await service.DeleteProcessedBatchesAsync();

            logger.Info("Finished Batch Processing.");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new instance with the sevis batch processing service and the zip archive delegate.
        /// </summary>
        /// <param name="service">The service to use when processing a zip archive.</param>
        /// <param name="zipArchiveDelegate">The zip archive delegate, useful when unit testing, otherwise set null and it will be initialized.</param>
        public ZipArchiveSevisApiResponseHandler(ISevisBatchProcessingService service, Func <Stream, ZipArchive> zipArchiveDelegate = null)
        {
            Contract.Requires(service != null, "The sevis batch processing service must not be null.");
            this.service = service;
            if (zipArchiveDelegate != null)
            {
                this.zipArchiveDelegate = zipArchiveDelegate;
            }
            else
            {
                this.zipArchiveDelegate = (s) =>
                {
#if DEBUG
                    //using (var fileStream = File.Open(@"c:\dev\test.zip", FileMode.Create))
                    //{
                    //    s.CopyTo(fileStream);
                    //    s.Seek(0, SeekOrigin.Begin);
                    //}
#endif
                    return(new ZipArchive(s));
                };
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.service is IDisposable)
         {
             logger.Trace("Disposing of service " + this.service.GetType());
             ((IDisposable)this.service).Dispose();
             this.service = null;
         }
         if (this.responseHandler is IDisposable)
         {
             logger.Trace("Disposing of response handler " + this.responseHandler.GetType());
             ((IDisposable)this.responseHandler).Dispose();
             this.responseHandler = null;
         }
         if (this.ecaHttpMessageHandlerService is IDisposable)
         {
             logger.Trace("Disposing of response handler " + this.ecaHttpMessageHandlerService.GetType());
             ((IDisposable)this.ecaHttpMessageHandlerService).Dispose();
             this.ecaHttpMessageHandlerService = null;
         }
     }
 }