/// <summary> /// Update an imported file in the Db. /// </summary> /// <param name="existing">The existing imported file event from the database</param> /// <param name="fileDescriptor"></param> /// <param name="surveyedUtc"></param> /// <param name="minZoom"></param> /// <param name="maxZoom"></param> /// <param name="fileCreatedUtc"></param> /// <param name="fileUpdatedUtc"></param> /// <param name="importedBy"></param> /// <param name="log"></param> /// <param name="serviceExceptionHandler"></param> /// <param name="projectRepo"></param> /// <returns></returns> public static async Task <UpdateImportedFileEvent> UpdateImportedFileInDb( ImportedFile existing, string fileDescriptor, DateTime?surveyedUtc, int minZoom, int maxZoom, DateTime fileCreatedUtc, DateTime fileUpdatedUtc, string importedBy, ILogger log, IServiceExceptionHandler serviceExceptionHandler, IProjectRepository projectRepo) { var nowUtc = DateTime.UtcNow; var updateImportedFileEvent = AutoMapperUtility.Automapper.Map <UpdateImportedFileEvent>(existing); updateImportedFileEvent.FileDescriptor = fileDescriptor; updateImportedFileEvent.SurveyedUtc = surveyedUtc; updateImportedFileEvent.MinZoomLevel = minZoom; updateImportedFileEvent.MaxZoomLevel = maxZoom; updateImportedFileEvent.FileCreatedUtc = fileCreatedUtc; // as per Barret 19th June 2017 updateImportedFileEvent.FileUpdatedUtc = fileUpdatedUtc; updateImportedFileEvent.ImportedBy = importedBy; updateImportedFileEvent.ActionUTC = nowUtc; log.LogInformation( $"UpdateImportedFileInDb. UpdateImportedFileEvent: {JsonConvert.SerializeObject(updateImportedFileEvent)}"); if (await projectRepo.StoreEvent(updateImportedFileEvent).ConfigureAwait(false) == 1) { return(updateImportedFileEvent); } serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 52); return(updateImportedFileEvent); }
public ProjectsController(ILoggerFactory loggerFactory, IServiceExceptionHandler serviceExceptionHandler, ICwsAccountClient accountProxy, IProjectProxy projectProxy, IFileImportProxy fileImportProxy) : base(loggerFactory, serviceExceptionHandler) { this.accountProxy = accountProxy; this.projectProxy = projectProxy; this.fileImportProxy = fileImportProxy; }
public ExecutorTestFixture() { var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("IntegrationTests.ExecutorTests.log", null)); var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging() .AddSingleton(loggerFactory) .AddHttpClient() .AddSingleton <IConfigurationStore, GenericConfiguration>() .AddTransient <IRepository <IProjectEvent>, ProjectRepository>() .AddTransient <ICwsProjectClient, CwsProjectClient>() .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>() // for serviceDiscovery .AddServiceDiscovery() .AddTransient <IWebRequest, GracefulWebRequest>() .AddMemoryCache() .AddSingleton <IDataCache, InMemoryDataCache>() .AddTransient <IProductivity3dV1ProxyCoord, Productivity3dV1ProxyCoord>() .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>() .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>() .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>(); _serviceProvider = serviceCollection.BuildServiceProvider(); ConfigStore = _serviceProvider.GetRequiredService <IConfigurationStore>(); Logger = _serviceProvider.GetRequiredService <ILoggerFactory>(); ServiceExceptionHandler = _serviceProvider.GetRequiredService <IServiceExceptionHandler>(); ProjectRepo = _serviceProvider.GetRequiredService <IRepository <IProjectEvent> >() as ProjectRepository; CwsProjectClient = _serviceProvider.GetRequiredService <ICwsProjectClient>(); Productivity3dV2ProxyCompaction = _serviceProvider.GetRequiredService <IProductivity3dV2ProxyCompaction>(); }
/// <summary> /// Used by Create/Update project to check if any new boundary overlaps any OTHER project /// </summary> public static async Task <bool> DoesProjectOverlap(Guid customerUid, Guid?projectUid, Guid userUid, string projectBoundary, ILogger log, IServiceExceptionHandler serviceExceptionHandler, ICwsProjectClient cwsProjectClient, IHeaderDictionary customHeaders) { // get all active projects for customer, excluding this projectUid (i.e. update) // todo what are the rules e.g. active, for manual import? var projectDatabaseModelList = (await GetProjectListForCustomer(customerUid, userUid, log, serviceExceptionHandler, cwsProjectClient, CwsProjectType.AcceptsTagFiles, ProjectStatus.Active, false, true, customHeaders)) .Where(p => !p.IsArchived && p.ProjectType.HasFlag(CwsProjectType.AcceptsTagFiles) && (projectUid == null || string.Compare(p.ProjectUID.ToString(), projectUid.ToString(), StringComparison.OrdinalIgnoreCase) != 0)); // return once we find any overlapping projects foreach (var project in projectDatabaseModelList) { if (string.IsNullOrEmpty(project.Boundary)) { continue; } if (PolygonUtils.OverlappingPolygons(projectBoundary, project.Boundary)) { return(true); } } log.LogDebug($"{nameof(DoesProjectOverlap)}: No overlapping projects."); return(false); }
/// <summary> /// Creates a new instance of the <see cref="WorldGeocoder"/> class for the specified /// service configuration. /// </summary> /// <param name="serviceInfo">The instance of the geocoding service configuration /// specifying World geocoder service to create geocoder for.</param> /// <param name="exceptionHandler">Exception handler.</param> /// <returns>A new instance of the <see cref="WorldGeocoder"/> class.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="serviceInfo"/> is a null /// reference.</exception> public static GeocoderBase CreateWorldGeocoder(GeocodingServiceInfo serviceInfo, IServiceExceptionHandler exceptionHandler) { CodeContract.RequiresNotNull("serviceInfo", serviceInfo); // Create binding for the geocoder REST service. var webBinding = ServiceHelper.CreateWebHttpBinding("WorldGeocoder"); var binding = new CustomBinding(webBinding); var messageEncodingElement = binding.Elements.Find<WebMessageEncodingBindingElement>(); messageEncodingElement.ContentTypeMapper = new ArcGisWebContentTypeMapper(); // Create endpoint for the geocoder REST service. var contract = ContractDescription.GetContract(typeof(IGeocodingService)); var serviceAddress = new EndpointAddress(serviceInfo.RestUrl); var endpoint = new WebHttpEndpoint(contract, serviceAddress); endpoint.Binding = binding; // Replace default endpoint behavior with a customized one. endpoint.Behaviors.Remove<WebHttpBehavior>(); endpoint.Behaviors.Add(new GeocodingServiceWebHttpBehavior()); // Create the geocoder instance. var channelFactory = new WebChannelFactory<IGeocodingService>(endpoint); var client = new GeocodingServiceClient(channelFactory, serviceInfo, exceptionHandler); return new WorldGeocoder(serviceInfo, client); }
/// <summary> /// get file content from TCC /// note that is is intended to be used for small, DC files only. /// If/when it is needed for large files, /// e.g. surfaces, you should use a smaller buffer and loop to read. /// </summary> public static async Task <Stream> GetFileStreamFromTcc(BusinessCenterFile businessCentreFile, ILogger log, IServiceExceptionHandler serviceExceptionHandler, IFileRepository fileRepo) { Stream memStream = null; var tccPath = $"{businessCentreFile.Path}/{businessCentreFile.Name}"; try { log.LogInformation( $"GetFileStreamFromTcc: getBusinessCentreFile fielspaceID: {businessCentreFile.FileSpaceId} tccPath: {tccPath}"); memStream = await fileRepo.GetFile(businessCentreFile.FileSpaceId, tccPath).ConfigureAwait(false); if (memStream == null || !memStream.CanRead || memStream.Length < 1) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 80, $" isAbleToRead: {memStream != null && memStream.CanRead} bytesReturned: {memStream?.Length ?? 0}"); } } catch (Exception e) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 79, e.Message); } log.LogInformation($"GetFileStreamFromTcc: Successfully read memstream. bytesReturned: {memStream?.Length ?? 0}"); return(memStream); }
public GetDeviceBySerialExecutorTests() { var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Project.WebApi.log")); var serviceCollection = new ServiceCollection(); serviceCollection.AddLogging(); serviceCollection.AddSingleton(loggerFactory); serviceCollection .AddSingleton <IConfigurationStore, GenericConfiguration>() .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>() .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>(); ServiceProvider = serviceCollection.BuildServiceProvider(); _serviceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>(); _configStore = ServiceProvider.GetRequiredService <IConfigurationStore>(); _logger = ServiceProvider.GetRequiredService <ILoggerFactory>(); _serviceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>(); _customHeaders = new HeaderDictionary(); _customerUid = Guid.NewGuid().ToString(); _deviceUid = Guid.NewGuid().ToString(); _deviceName = "the Device Name"; _serialNumber = "67567576SN"; _relationStatus = RelationStatusEnum.Active; _tccDeviceStatus = TCCDeviceStatusEnum.Registered; }
/// <summary> /// Creates a new instance of the <see cref="WorldGeocoder"/> class for the specified /// service configuration. /// </summary> /// <param name="serviceInfo">The instance of the geocoding service configuration /// specifying World geocoder service to create geocoder for.</param> /// <param name="exceptionHandler">Exception handler.</param> /// <returns>A new instance of the <see cref="WorldGeocoder"/> class.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="serviceInfo"/> is a null /// reference.</exception> public static GeocoderBase CreateWorldGeocoder(GeocodingServiceInfo serviceInfo, IServiceExceptionHandler exceptionHandler) { CodeContract.RequiresNotNull("serviceInfo", serviceInfo); // Create binding for the geocoder REST service. var webBinding = ServiceHelper.CreateWebHttpBinding("WorldGeocoder"); var binding = new CustomBinding(webBinding); var messageEncodingElement = binding.Elements.Find <WebMessageEncodingBindingElement>(); messageEncodingElement.ContentTypeMapper = new ArcGisWebContentTypeMapper(); // Create endpoint for the geocoder REST service. var contract = ContractDescription.GetContract(typeof(IGeocodingService)); var serviceAddress = new EndpointAddress(serviceInfo.RestUrl); var endpoint = new WebHttpEndpoint(contract, serviceAddress); endpoint.Binding = binding; // Replace default endpoint behavior with a customized one. endpoint.Behaviors.Remove <WebHttpBehavior>(); endpoint.Behaviors.Add(new GeocodingServiceWebHttpBehavior()); // Create the geocoder instance. var channelFactory = new WebChannelFactory <IGeocodingService>(endpoint); var client = new GeocodingServiceClient(channelFactory, serviceInfo, exceptionHandler); return(new WorldGeocoder(serviceInfo, client)); }
public static async Task <GeofenceDataListResult> GetProjectBoundaries( ILogger log, IServiceExceptionHandler serviceExceptionHandler, string projectUid, IProjectRepository projectRepository, IGeofenceRepository geofenceRepository) { IEnumerable <Geofence> geofences = null; try { var associations = await projectRepository .GetAssociatedGeofences(projectUid) .ConfigureAwait(false); var projectGeofences = associations.ToList(); if (projectGeofences.Any()) { geofences = await geofenceRepository .GetGeofences(projectGeofences.Select(a => a.GeofenceUID.ToString())) .ConfigureAwait(false); } } catch (Exception e) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.InternalServerError, 49, e.Message); } // may be none, return success and empty list return(new GeofenceDataListResult { GeofenceData = (geofences ?? new List <Geofence>()) .Select(x => AutoMapperUtility.Automapper.Map <GeofenceData>(x)) .ToImmutableList() }); }
/// <summary> /// Validates all properties /// </summary> public void Validate(IServiceExceptionHandler serviceExceptionHandler) { var validator = new DataAnnotationsValidator(); validator.TryValidate(this, out ICollection <ValidationResult> results); if (results.Any()) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, results.FirstOrDefault().ErrorMessage)); } ValidateRange(useMachineTargetPassCount, customTargetPassCountMinimum, customTargetPassCountMaximum, "pass count"); ValidateRange(useMachineTargetTemperature, customTargetTemperatureMinimum, customTargetTemperatureMaximum, "temperature"); ValidateRange(useDefaultTargetRangeCmvPercent, customTargetCmvPercentMinimum, customTargetCmvPercentMaximum, "CMV %"); ValidateRange(useDefaultTargetRangeMdpPercent, customTargetMdpPercentMinimum, customTargetMdpPercentMaximum, "MDP %"); ValidateRange(useDefaultTargetRangeSpeed, customTargetSpeedMinimum, customTargetSpeedMaximum, "Speed"); ValidateValue(useMachineTargetCmv, customTargetCmv, "CMV"); ValidateValue(useMachineTargetMdp, customTargetMdp, "MDP"); ValidateValue(useDefaultVolumeShrinkageBulking, customBulkingPercent, "bulking %"); ValidateValue(useDefaultVolumeShrinkageBulking, customShrinkagePercent, "shrinkage %"); ValidateCutFill(); ValidatePassCounts(); ValidateCMVs(); ValidateTemperatures(); }
/// <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, IConfigurationStore configStore, IServiceExceptionHandler serviceExceptionHandler, string customerUid = null, string userId = null, string userEmailAddress = null, IHeaderDictionary headers = null, IProductivity3dV1ProxyCoord productivity3dV1ProxyCoord = null, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null, ITransferProxyFactory persistantTransferProxyFactory = null, IFilterServiceProxy filterServiceProxy = null, ITRexImportFileProxy tRexImportFileProxy = null, IProjectRepository projectRepo = null, IHttpContextAccessor httpContextAccessor = null, IDataOceanClient dataOceanClient = null, ITPaaSApplicationAuthentication authn = null, ISchedulerProxy schedulerProxy = null, IPegasusClient pegasusClient = null, ICwsProjectClient cwsProjectClient = null, ICwsDeviceClient cwsDeviceClient = null, ICwsProfileSettingsClient cwsProfileSettingsClient = null, IWebRequest gracefulClient = null, INotificationHubClient notificationHubClient = null ) where TExecutor : RequestExecutorContainer, new() { ILogger log = null; if (logger != null) { log = logger.CreateLogger <RequestExecutorContainer>(); } var executor = new TExecutor(); executor.Initialise( log, configStore, serviceExceptionHandler, customerUid, userId, userEmailAddress, headers, productivity3dV1ProxyCoord, productivity3dV2ProxyCompaction, persistantTransferProxyFactory, filterServiceProxy, tRexImportFileProxy, projectRepo, httpContextAccessor, dataOceanClient, authn, schedulerProxy, pegasusClient, cwsProjectClient, cwsDeviceClient, cwsProfileSettingsClient, gracefulClient, notificationHubClient ); return(executor); }
public UnitTestsDIFixture() { AutoMapperUtility.AutomapperConfiguration.AssertConfigurationIsValid(); var loggerFactory = new LoggerFactory().AddSerilog(SerilogExtensions.Configure("VSS.Project.UnitTests.log")); ServiceCollection = new ServiceCollection(); ServiceCollection.AddLogging(); ServiceCollection.AddSingleton(loggerFactory); ServiceCollection .AddTransient <IProjectRepository, ProjectRepository>() .AddSingleton <IConfigurationStore, GenericConfiguration>() .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>() .AddTransient <IProductivity3dV1ProxyCoord, Productivity3dV1ProxyCoord>() .AddTransient <IProductivity3dV2ProxyNotification, Productivity3dV2ProxyNotification>() .AddTransient <IProductivity3dV2ProxyCompaction, Productivity3dV2ProxyCompaction>() .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>(); ServiceProvider = ServiceCollection.BuildServiceProvider(); ServiceExceptionHandler = ServiceProvider.GetRequiredService <IServiceExceptionHandler>(); _log = ServiceProvider.GetRequiredService <ILoggerFactory>().CreateLogger <T>(); _loggerFactory = ServiceProvider.GetRequiredService <ILoggerFactory>(); _customHeaders = new HeaderDictionary(); _configStore = ServiceProvider.GetRequiredService <IConfigurationStore>(); _userUid = Guid.NewGuid(); _customerUid = Guid.NewGuid(); _customerTrn = TRNHelper.MakeTRN(_customerUid, TRNHelper.TRN_ACCOUNT); _projectUid = Guid.NewGuid(); _projectTrn = TRNHelper.MakeTRN(_projectUid); _customHeaders.Add("X-VisionLink-CustomerUID", new StringValues(_customerUid.ToString())); }
private async Task <T> GetProjectSettings <T>(string projectUid, string userId, IHeaderDictionary customHeaders, ProjectSettingsType settingsType, IServiceExceptionHandler serviceExceptionHandler) where T : IValidatable, IDefaultSettings, new() { T ps = default; var uri = string.Empty; switch (settingsType) { case ProjectSettingsType.Targets: uri = $"/projectsettings/{projectUid}"; break; case ProjectSettingsType.Colors: uri = $"/projectcolors/{projectUid}"; break; default: throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(-10, "Unsupported project settings type.")); } var result = await GetMasterDataItemServiceDiscovery <ProjectSettingsResult>(uri, $"{projectUid}{settingsType}", userId, customHeaders); if (result.Code == ContractExecutionStatesEnum.ExecutedSuccessfully) { var jsonSettings = result.Settings; if (jsonSettings != null) { try { ps = jsonSettings.ToObject <T>(); if (settingsType == ProjectSettingsType.Colors) { (ps as CompactionProjectSettingsColors).UpdateCmvDetailsColorsIfRequired(); } ps.Validate(serviceExceptionHandler); } catch (Exception ex) { log.LogInformation( $"JObject conversion to Project Settings validation failure for projectUid {projectUid}. Error is {ex.Message}"); } } else { log.LogDebug($"No Project Settings for projectUid {projectUid}. Using defaults."); } } else { log.LogWarning($"Failed to get project settings, using default values: {result.Code}, {result.Message}"); } if (ps == null) { ps = new T(); ps.Defaults(); } return(ps); }
/// <summary> /// Default constructor. /// </summary> protected BaseController(ILoggerFactory loggerFactory, ILogger log, IServiceExceptionHandler serviceExceptionHandler, IConfigurationStore configStore) { LoggerFactory = loggerFactory; Log = log; ServiceExceptionHandler = serviceExceptionHandler; ConfigStore = configStore; }
Build <TExecutor>(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler, RepositoryBase repository, RepositoryBase auxRepository, IProjectProxy projectProxy = null, IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification = null, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction = null, IFileImportProxy fileImportProxy = null /*, IGeofenceProxy geofenceProxy = null, * IUnifiedProductivityProxy unifiedProductivityProxy = null */ ) where TExecutor : RequestExecutorContainer, new() { var executor = new TExecutor { configStore = configStore, log = logger.CreateLogger <TExecutor>(), serviceExceptionHandler = serviceExceptionHandler, projectProxy = projectProxy, Productivity3dV2ProxyNotification = productivity3dV2ProxyNotification, Productivity3dV2ProxyCompaction = productivity3dV2ProxyCompaction, fileImportProxy = fileImportProxy, Repository = repository, auxRepository = auxRepository, //GeofenceProxy = geofenceProxy, //UnifiedProductivityProxy = unifiedProductivityProxy }; return(executor); }
public virtual void Validate(IServiceExceptionHandler serviceExceptionHandler) { if (!string.IsNullOrEmpty(BoundaryUid) && Guid.TryParse(BoundaryUid, out Guid boundaryUidGuid) == false) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 59); } if (string.IsNullOrEmpty(Name)) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 3); } var result = GeofenceValidation.ValidateWKT(BoundaryPolygonWKT); if (string.CompareOrdinal(result, GeofenceValidation.ValidationOk) != 0) { if (string.CompareOrdinal(result, GeofenceValidation.ValidationNoBoundary) == 0) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 69); } if (string.CompareOrdinal(result, GeofenceValidation.ValidationLessThan3Points) == 0) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 70); } if (string.CompareOrdinal(result, GeofenceValidation.ValidationInvalidFormat) == 0) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 71); } } }
/// <summary> /// Constructor. /// </summary> /// <param name="geocodingServiceInfo">Geocoding service info.</param> /// <param name="geocodeServer">Geocode server.</param> /// <param name="exceptionHandler">Exception handler.</param> /// <exception cref="System.ArgumentException">Is thrown in case if geocodingServiceInfo /// or geocodeServer parameters is null.</exception> internal ArcGiscomGeocoder(GeocodingServiceInfo geocodingServiceInfo, AgsServer geocodeServer, IServiceExceptionHandler exceptionHandler) : base(geocodingServiceInfo, geocodeServer, exceptionHandler) { if (geocodingServiceInfo == null) { throw new ArgumentException("geocodingServiceInfo"); } if (geocodeServer == null) { throw new ArgumentException("geocodeServer"); } var list = new List <string>(); // Fill collection with names of exact locators types. foreach (var locator in geocodingServiceInfo.ExactLocators.Locators) { list.Add(locator.Type); } // Local storage is exact locator. list.Add(LOCAL_STORAGE_ADDRESS_TYPE); ExactLocatorsTypesNames = list; }
public static void GetFilterFileNames(ILogger log, IServiceExceptionHandler serviceExceptionHandler, IFileImportProxy fileImportProxy, FilterRequestFull filterRequestFull) { log.LogInformation($"{nameof(GetFilterFileNames)}: Resolving filenames for Filter JSON."); var tmpFilter = filterRequestFull.FilterModel(serviceExceptionHandler); if (string.IsNullOrEmpty(tmpFilter.DesignUid) && string.IsNullOrEmpty(tmpFilter.AlignmentUid)) { log.LogInformation($"{nameof(GetFilterFileNames)}: No filenames to resolve."); return; } var fileList = fileImportProxy.GetFiles(filterRequestFull.ProjectUid, filterRequestFull.UserId, filterRequestFull.CustomHeaders).Result; if (fileList == null || fileList.Count == 0) { return; } if (!string.IsNullOrEmpty(tmpFilter.DesignUid)) { tmpFilter.SetFilenames(designName: fileList.FirstOrDefault(data => data.ImportedFileUid == tmpFilter.DesignUid)?.Name); log.LogInformation($"{nameof(GetFilterFileNames)}: Resolved: {tmpFilter.DesignFileName}"); } if (!string.IsNullOrEmpty(tmpFilter.AlignmentUid)) { tmpFilter.SetFilenames(alignmentName: fileList.FirstOrDefault(data => data.ImportedFileUid == tmpFilter.AlignmentUid)?.Name); log.LogInformation($"{nameof(GetFilterFileNames)}: Resolved: {tmpFilter.AlignmentFileName}"); } filterRequestFull.FilterJson = JsonConvert.SerializeObject(tmpFilter); }
/// <summary> /// Constructor /// </summary> public SchedulerAuthentication(RequestDelegate next, ICwsAccountClient cwsAccountClient, IConfigurationStore store, ILoggerFactory logger, IEntitlementProxy entitlementProxy, IServiceExceptionHandler serviceExceptionHandler) : base(next, cwsAccountClient, store, logger, entitlementProxy, serviceExceptionHandler) { }
/// <summary> /// /// </summary> public void Initialise(ILogger logger, IServiceExceptionHandler serviceExceptionHandler, IPreferenceRepository preferenceRepo = null) { log = logger; this.serviceExceptionHandler = serviceExceptionHandler; this.preferenceRepo = preferenceRepo; }
/// <summary> /// This constructor allows us to mock raptorClient /// </summary> protected FilterExecutorBase(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler, IProjectProxy projectProxy, IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IFileImportProxy fileImportProxy, RepositoryBase repository, RepositoryBase auxRepository /*, IGeofenceProxy geofenceProxy, IUnifiedProductivityProxy unifiedProductivityProxy */) : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, fileImportProxy, repository, auxRepository /*, geofenceProxy, unifiedProductivityProxy*/) { }
public ContractExecutionResult ValidateProjectSettings([FromBody] ProjectSettingsRequest request, [FromServices] IServiceExceptionHandler serviceExceptionHandler) { log.LogDebug($"UpsertProjectSettings: {JsonConvert.SerializeObject(request)}"); request.Validate(); return(ValidateProjectSettingsEx(request.projectUid, request.Settings, request.ProjectSettingsType, serviceExceptionHandler)); }
/// <summary> /// This constructor allows us to mock raptorClient /// </summary> public GetFiltersExecutor(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler, IProjectProxy projectProxy, IProductivity3dV2ProxyNotification productivity3dV2ProxyNotification, IProductivity3dV2ProxyCompaction productivity3dV2ProxyCompaction, IFileImportProxy fileImportProxy, RepositoryBase repository) : base(configStore, logger, serviceExceptionHandler, projectProxy, productivity3dV2ProxyNotification, productivity3dV2ProxyCompaction, fileImportProxy, repository, null /*, null, null*/) { }
public FakeBackgroundService(IServiceExceptionHandler exceptionHandler) : base(exceptionHandler) { this.StubbedDispose = new Mock <Action <bool> >(); this.StubbedDisposeAsyncCore = new Mock <Func <ValueTask> >(); this.StubbedExecuteAsync = new Mock <Func <CancellationToken, Task> >(); this.StubbedPostExecuteAsync = new Mock <Func <CancellationToken, Task> >(); this.StubbedPreExecuteAsync = new Mock <Func <CancellationToken, Task> >(); }
public override void Validate(IServiceExceptionHandler serviceExceptionHandler) { base.Validate(serviceExceptionHandler); if (string.IsNullOrEmpty(BoundaryUid) || Guid.TryParse(BoundaryUid, out Guid boundaryUidGuid) == false) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 59); } }
public override void Validate(IServiceExceptionHandler serviceExceptionHandler) { base.Validate(serviceExceptionHandler); if (Request == null) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, 60); } Request.Validate(serviceExceptionHandler); }
/// <summary> /// Injected constructor. /// </summary> protected RequestExecutorContainer(IConfigurationStore configStore, ILoggerFactory logger, IServiceExceptionHandler serviceExceptionHandler) : this() { this.configStore = configStore; if (logger != null) { log = logger.CreateLogger <RequestExecutorContainer>(); } this.serviceExceptionHandler = serviceExceptionHandler; }
/// <summary> /// Initializes a new instance of the <see cref="RaptorAuthentication"/> class. /// </summary> public RaptorAuthentication(RequestDelegate next, ICwsAccountClient cwsAccountClient, IConfigurationStore store, ILoggerFactory logger, IEntitlementProxy entitlementProxy, IServiceExceptionHandler serviceExceptionHandler, IProjectProxy projectProxy) : base(next, cwsAccountClient, store, logger, entitlementProxy, serviceExceptionHandler) { this.projectProxy = projectProxy; }
public ContractExecutionResult ValidateProjectSettings( [FromQuery] Guid projectUid, [FromQuery] string projectSettings, [FromQuery] ProjectSettingsType?settingsType, [FromServices] IServiceExceptionHandler serviceExceptionHandler) { log.LogInformation("ValidateProjectSettings: " + Request.QueryString); return(ValidateProjectSettingsEx(projectUid.ToString(), projectSettings, settingsType, serviceExceptionHandler)); }
public void Validate(IServiceExceptionHandler serviceExceptionHandler) { if (string.IsNullOrEmpty(FilespaceId) || string.IsNullOrEmpty(Path) || string.IsNullOrEmpty(FileName)) { serviceExceptionHandler.ThrowServiceException(HttpStatusCode.BadRequest, ContractExecutionStatesEnum.ValidationError, "Filespace Id, filespace name, path and file name are all required"); } }
public ImportFileV6ValidationTests() { var serviceCollection = new ServiceCollection(); serviceCollection .AddTransient <IServiceExceptionHandler, ServiceExceptionHandler>() .AddTransient <IErrorCodesProvider, ProjectErrorCodesProvider>(); var serviceProvider = serviceCollection.BuildServiceProvider(); ServiceExceptionHandler = serviceProvider.GetRequiredService <IServiceExceptionHandler>(); }
/// <summary> /// Initializes a new instance of the <see cref="GeocodingServiceClient"/> class. /// </summary> /// <param name="channelFactory">The reference to the channel factory instance /// to be used for creating communication channels for the geocoder service.</param> /// <param name="serviceInfo">The configuration information for the geocoder /// service.</param> /// <param name="exceptionHandler">Exception handler.</param> /// <exception cref="ArgumentNullException"><paramref name="channelFactory"/> or /// <paramref name="serviceInfo"/> is a null reference.</exception> public GeocodingServiceClient( ChannelFactory<IGeocodingService> channelFactory, GeocodingServiceInfo serviceInfo, IServiceExceptionHandler exceptionHandler) { CodeContract.RequiresNotNull("channelFactory", channelFactory); CodeContract.RequiresNotNull("serviceInfo", serviceInfo); CodeContract.RequiresNotNull("exceptionHandler", exceptionHandler); _serviceClient = new RestServiceClient<IGeocodingService>( channelFactory, serviceInfo.Title, exceptionHandler); }
/// <summary> /// Sets the exception handler global to all services. /// </summary> /// <param name="exceptionHandler">The exception handler.</param> /// <returns>The configuration options object.</returns> public RestOptions WithGlobalExceptionHandler(IServiceExceptionHandler exceptionHandler) { if (exceptionHandler == null) { throw new ArgumentNullException("exceptionHandler"); } ServiceExceptionHandlerRegistry.SetGlobalExceptionHandler(exceptionHandler); return this; }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Constructor. /// </summary> /// <param name="mapInfo">Map information.</param> /// <param name="servers">Servers collection.</param> /// <param name="exceptionHandler">Exceptions handler.</param> internal Map(MapInfoWrap mapInfo, ICollection<AgsServer> servers, IServiceExceptionHandler exceptionHandler) { Debug.Assert(mapInfo != null); Debug.Assert(exceptionHandler != null); _exceptionHandler = exceptionHandler; // create layers _CreateLayers(mapInfo.Services, servers); // set selected basemap layer _SetSelectedBaseMap(); _mapInfo = mapInfo; // Set current map server. _mapServer = _GetMapServer(_layers); // Map should be initialized later. _inited = false; }
public static void SetExceptionHandler(IRestServiceHandler handler, IServiceExceptionHandler exceptionHandler) { handlerExceptionHandlers.AddOrUpdate(handler, handlerToAdd => exceptionHandler, (handlerToUpdate, exceptionHandlerToUpdate) => exceptionHandler); }
public static void SetGlobalExceptionHandler(IServiceExceptionHandler exceptionHandler) { globalExceptionHandler = exceptionHandler; }
/// <summary> /// Constructor. /// </summary> /// <param name="geocodingServiceInfo">Geocoding service info.</param> /// <param name="geocodeServer">Geocode server.</param> /// <param name="exceptionHandler">Exception handler.</param> internal Geocoder(GeocodingServiceInfo geocodingServiceInfo, AgsServer geocodeServer, IServiceExceptionHandler exceptionHandler) { Debug.Assert(exceptionHandler != null); _exceptionHandler = exceptionHandler; // Init geocoding properties. _propMods = new PropertySet(); _propMods.PropertyArray = new PropertySetProperty[2]; _propMods.PropertyArray[0] = _CreateProp("WritePercentAlongField", "TRUE"); _propMods.PropertyArray[1] = _CreateProp("MatchIfScoresTie", "TRUE"); _geocodingServiceInfo = geocodingServiceInfo; if (_geocodingServiceInfo == null) { throw new SettingsException(Properties.Resources.DefaultGeocodingInfoIsNotSet); } _geocodingServer = geocodeServer; // Create address fields. _CreateAddressFields(); _actualGeocodingInfo = new GeocodingInfo(geocodingServiceInfo); _locatorsInfos = new ReadOnlyCollection<LocatorInfo>( _actualGeocodingInfo.Locators ?? new LocatorInfo[] { }); foreach (var locator in _locatorsInfos) { if (!_locators.ContainsKey(locator.Name)) { _locators.Add(locator.Name, locator); } } var fields = _geocodingServiceInfo.FieldMappings.FieldMapping.Select(mapping => (AddressPart)Enum.Parse( typeof(AddressPart), mapping.AddressField, true)); _defaultLocator = new LocatorInfo( string.Empty, string.Empty, true, true, SublocatorType.Streets, fields); // Geocoder should be initialized later. _inited = false; }