public void Setup() { AgentId = 1234567; MockSqlQueryHelper = new Mock <ISqlQueryHelper>(); MockAgentHelper = new Mock <IAgentHelper>(); MockLogger = new Mock <IAPILog>(); MockArtifactQueries = new Mock <IArtifactQueries>(); RsapiApiOptions = new APIOptions(); MockRsapiRepositoryGroup = new Mock <IRsapiRepositoryGroup>(); MockAuthenticationHelper = new Mock <IAuthenticationHelper>(); MockSerializationHelper = new Mock <ISerializationHelper>(); WorkspaceResourceGroupIdList = new List <Int32> { 10000, 20000 }; Sut = new ExportWorkerJob( agentId: AgentID, agentHelper: MockAgentHelper.Object, sqlQueryHelper: MockSqlQueryHelper.Object, processedOnDateTime: DateTime.Now, resourceGroupIds: WorkspaceResourceGroupIdList, logger: MockLogger.Object, artifactQueries: MockArtifactQueries.Object, rsapiApiOptions: RsapiApiOptions, rsapiRepositoryGroup: MockRsapiRepositoryGroup.Object, authenticationHelper: MockAuthenticationHelper.Object, serializationHelper: MockSerializationHelper.Object); }
public void Setup() { MockSqlQueryHelper = new Mock <ISqlQueryHelper>(); MockAgentHelper = new Mock <IAgentHelper>(); MockLogger = new Mock <IAPILog>(); MockArtifactQueries = new Mock <IArtifactQueries>(); RsapiApiOptions = new APIOptions(); MockRsapiRepositoryGroup = new Mock <IRsapiRepositoryGroup>(); MockSerializationHelper = new Mock <ISerializationHelper>(); WorkspaceResourceGroupIdList = new List <Int32> { 10000, 20000 }; Sut = new ExportManagerJob( agentId: AGENT_ID, agentHelper: MockAgentHelper.Object, sqlQueryHelper: MockSqlQueryHelper.Object, processedOnDateTime: DateTime.Now, resourceGroupIds: WorkspaceResourceGroupIdList, logger: MockLogger.Object, artifactQueries: MockArtifactQueries.Object, rsapiApiOptions: RsapiApiOptions, rsapiRepositoryGroup: MockRsapiRepositoryGroup.Object, serializationHelper: MockSerializationHelper.Object ); MockSqlQueryHelper.Setup(x => x.RetrieveAllExportManagerQueueRecords(It.IsAny <IDBContext>())).Returns(Task.FromResult(new DataTable())); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { MockAgentHelper = null; MockSqlQueryHelper = null; MockLogger = null; MockArtifactQueryHelper = null; MockLoginManager = null; MockUserRepo = null; MockClientRepo = null; MockGroupRepo = null; MockRSAPIRepositoryGroup = null; OffHoursStartTime = null; OffHoursEndTime = null; AgentId = 0; JobArtifactID = 0; FileName = null; MockGroupName = null; MockUserArtifactID = 0; MockClientName = null; FileFieldArtifactID = 0; ResourceGroupIdList = null; APIOptions = null; RecordedImportJobErrors = null; MockChoiceResult = null; MockClientResult = null; MockGroupResult = null; } } _disposed = true; }
private void SetupRsapiHelper() { try { APIOptions rsapiApiOptions = new APIOptions { WorkspaceID = -1 }; IRSAPIClient rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System); rsapiClient.APIOptions = rsapiApiOptions; IGenericRepository <RDO> rdoRepository = rsapiClient.Repositories.RDO; IGenericRepository <Choice> choiceRepository = rsapiClient.Repositories.Choice; IGenericRepository <Workspace> workspaceRepository = rsapiClient.Repositories.Workspace; IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository = rsapiClient.Repositories.User; IGenericRepository <Group> groupRepository = rsapiClient.Repositories.Group; _rsapiHelper = new RsapiHelper( rsapiApiOptions: rsapiApiOptions, rdoRepository: rdoRepository, choiceRepository: choiceRepository, workspaceRepository: workspaceRepository, userRepository: userRepository, groupRepository: groupRepository); } catch (Exception ex) { throw new Exception(Constants.ErrorMessages.RSAPI_HELPER_SETUP_ERROR, ex); } }
public override async Task <IEnumerable <String> > ImportAsync(APIOptions apiOptions, IRsapiRepositoryGroup repositoryGroup, IArtifactQueries artifactQueryHelper, IHelper helper, IDBContext eddsDbContext, ISqlQueryHelper sqlQueryHelper) { var violations = new List <string>(); try { // Skip import if user already exists if (await UserExistsInRelativity(apiOptions, repositoryGroup.UserRepository, artifactQueryHelper, (String)(await EmailAddress.GetDataValueAsync() ?? ""))) { var msg = String.Format(Constant.ErrorMessages.UserAlreadyExists, (String)await EmailAddress.GetDataValueAsync()); violations.Add(msg); } else { // Make sure user is validated if (Validated == false) { violations.AddRange(await ValidateAsync(apiOptions, repositoryGroup, artifactQueryHelper, eddsDbContext, sqlQueryHelper)); } // Import user object if (!violations.Any()) { violations.AddRange(await ImportUserAsync(apiOptions, repositoryGroup.UserRepository)); } // Save the User's keywords and notes if (!violations.Any()) { violations.AddRange(await SaveUserKeywordAndNotesAsync(sqlQueryHelper, eddsDbContext)); } // Import the Login Method Object if (!violations.Any()) { violations.AddRange(await ImportLoginMethodAsync(helper)); } if (violations.Any()) { // Check to see if user was partially imported if (await UserExistsInRelativity(apiOptions, repositoryGroup.UserRepository, artifactQueryHelper, (String)(await EmailAddress.GetDataValueAsync() ?? ""))) { // Only prepend msg and present to user if the user didn't already exists var userAlreadyExistsMsg = String.Format(Constant.ErrorMessages.UserAlreadyExists, (String)await EmailAddress.GetDataValueAsync()); if (!violations.Any(x => x.Contains(userAlreadyExistsMsg))) { violations = violations.Select(x => Constant.ErrorMessages.UserPartiallyImportedPrepend + x).ToList(); } } } } } catch (Exception ex) { violations.Add(ex.ToString()); } return(violations); }
public async Task <APIOptions> Get() { var options = new APIOptions() { AppInsights = _appInsightsOptions }; return(await Task.FromResult(options)); }
public RsapiHelper(APIOptions rsapiApiOptions, IGenericRepository <RDO> rdoRepository, IGenericRepository <Choice> choiceRepository, IGenericRepository <Workspace> workspaceRepository, IGenericRepository <User> userRepository, IGenericRepository <Group> groupRepository) { RsapiApiOptions = rsapiApiOptions; RdoRepository = rdoRepository; ChoiceRepository = choiceRepository; WorkspaceRepository = workspaceRepository; UserRepository = userRepository; GroupRepository = groupRepository; }
public void Setup() { Sut = new ArtifactQueries(); MockUserRepository = new Mock <IGenericRepository <User> >(); MockGroupRepository = new Mock <IGenericRepository <Group> >(); MockRdoRepository = new Mock <IGenericRepository <RDO> >(); MockWorkspaceRepository = new Mock <IGenericRepository <Workspace> >(); RsapiApiOptions = new APIOptions(); }
public void TearDown() { Sut = null; MockUserRepository = null; MockGroupRepository = null; MockRdoRepository = null; MockWorkspaceRepository = null; RsapiApiOptions = null; }
public OrdersUnitTest() { string[] timeOfDays = { "morning", "night" }; var apiOptions = Options.Create(new APIOptions() { AllowedTimeOfDays = timeOfDays }); _apiOptions = apiOptions.Value; }
private async Task <Boolean> UserExistsInRelativity(APIOptions apiOptions, IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository, IArtifactQueries artifactQueryHelper, String emailAddress) { var retVal = false; var userArtifactID = await artifactQueryHelper.FindUserByEmailAddressAsync(apiOptions, userRepository, emailAddress); if (userArtifactID != null) { retVal = true; } return(retVal); }
public static Boolean UserIsAdmin(IHelper helper, Int32 userArtifactID, IArtifactQueries artifactQueries) { using (var proxy = helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { var apiOptions = new APIOptions() { WorkspaceID = -1 }; proxy.APIOptions = apiOptions; return(artifactQueries.UserIsInAdministratorGroup(apiOptions, proxy.Repositories.User, proxy.Repositories.Group, userArtifactID).Result); } }
public void TearDown() { MockSqlQueryHelper = null; MockAgentHelper = null; MockLogger = null; MockArtifactQueries = null; MockRsapiRepositoryGroup = null; WorkspaceResourceGroupIdList = null; RsapiApiOptions = null; MockSerializationHelper = null; Sut = null; }
private async Task <IEnumerable <String> > ImportUserAsync(APIOptions apiOptions, IGenericRepository <kCura.Relativity.Client.DTOs.User> userRepository) { List <String> violations = new List <string>(); kCura.Relativity.Client.DTOs.User user = null; try { apiOptions.WorkspaceID = -1; user = new kCura.Relativity.Client.DTOs.User() { FirstName = (String)await FirstName.GetDataValueAsync(), LastName = (String)await LastName.GetDataValueAsync(), EmailAddress = (String)await EmailAddress.GetDataValueAsync(), Groups = _groupList, Type = _userType, Client = _client, RelativityAccess = ((Boolean?)await RelativityAccess.GetDataValueAsync()).GetValueOrDefault(), DocumentSkip = _documentSkip, BetaUser = ((Boolean?)await BetaUser.GetDataValueAsync()).GetValueOrDefault(), ChangeSettings = ((Boolean?)await ChangeSettings.GetDataValueAsync()).GetValueOrDefault(), KeyboardShortcuts = ((Boolean?)await KeyboardShortcuts.GetDataValueAsync()).GetValueOrDefault(), ItemListPageLength = ((Int32?)await ItemListPageLength.GetDataValueAsync()).GetValueOrDefault(), DefaultSelectedFileType = _defaultSelectedFileType, SkipDefaultPreference = _skipDefaultPreference, EnforceViewerCompatibility = ((Boolean?)await EnforceViewerCompatibility.GetDataValueAsync()).GetValueOrDefault(), AdvancedSearchPublicByDefault = ((Boolean?)await AdvancedSearchPublicByDefault.GetDataValueAsync()).GetValueOrDefault(), NativeViewerCacheAhead = ((Boolean?)await NativeViewerCacheAhead.GetDataValueAsync()).GetValueOrDefault(), CanChangeDocumentViewer = ((Boolean?)await ChangeDocumentViewer.GetDataValueAsync()).GetValueOrDefault(), DocumentViewer = _documentViewer, TrustedIPs = String.Empty, ChangePassword = ((Boolean?)await CanChangePassword.GetDataValueAsync()).GetValueOrDefault(), MaximumPasswordAge = ((Int32?)await MaximumPasswordAgeInDays.GetDataValueAsync()).GetValueOrDefault(), DataFocus = 1, // This field is no longer utilized in Relativity, however it's hardcoded because it is required ChangePasswordNextLogin = ((Boolean?)await UserMustChangePasswordOnNextLogin.GetDataValueAsync()).GetValueOrDefault() }; ArtifactId = userRepository.CreateSingle(user); } catch (Exception ex) { String msg = null; if (ex.ToString().Contains("The entered E-Mail Address is already associated with a user") && user != null && !String.IsNullOrWhiteSpace(user.EmailAddress)) { msg = String.Format(Constant.ErrorMessages.UserAlreadyExists, user.EmailAddress); } else { msg = ex.ToString(); } violations.Add(msg); } return(violations); }
public async Task ExecuteAsync() { var sqlQueryHelper = new SqlQueryHelper(); var resourceGroupIds = GetResourceGroupIDs(); _logger = Helper.GetLoggerFactory().GetLogger(); var rsapiApiOptions = new APIOptions { WorkspaceID = -1 }; var rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser); rsapiClient.APIOptions = rsapiApiOptions; var rsapiGroupRepository = new RSAPIiRepositoryGroup(rsapiClient); var artifactQueries = new ArtifactQueries(); var job = new ImportWorkerJob(AgentID, Helper, sqlQueryHelper, artifactQueries, DateTime.Now, rsapiGroupRepository, resourceGroupIds, _logger, rsapiApiOptions, new SerializationHelper()); job.OnMessage += MessageRaised; try { RaiseMessage("Enter Agent", 10); await job.ExecuteAsync(); RaiseMessage("Exit Agent", 10); } catch (Exception ex) { //Raise an error on the agents tab and event viewer RaiseError(ex.ToString(), ex.ToString()); _logger.LogError(ex, $"{Constant.Names.ApplicationName} - {ex}"); //Add the error to our custom Errors table sqlQueryHelper.InsertRowIntoImportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ExportWorkerQueue, job.TableRowId, job.AgentId, ex.ToString()).Wait(); //Add the error to the Relativity Errors tab //this second try catch is in case we have a problem connecting to the RSAPI try { ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex); } catch (Exception rsapiException) { RaiseError(rsapiException.ToString(), rsapiException.ToString()); _logger.LogError(rsapiException, $"{Constant.Names.ApplicationName} - {rsapiException}"); } } finally { rsapiClient.Dispose(); } }
public CollisionService( ILogger <CollisionService> logger, APIOptions options, INeighborhoodRepository neighborhoodRepository, IPatternAreaRepository patternAreaRepository ) { Logger = logger; NeighborhoodRepository = neighborhoodRepository; PatternAreaRepository = patternAreaRepository; HttpClient = new HttpClient(); HttpClient.BaseAddress = new Uri(options.BaseAddress); }
public ImportWorkerJob(Int32 agentId, IAgentHelper agentHelper, ISqlQueryHelper sqlQueryHelper, IArtifactQueries artifactQueryHelper, DateTime processedOnDateTime, IRsapiRepositoryGroup rsapiRepositoryGroup, IEnumerable <Int32> resourceGroupIds, IAPILog logger, APIOptions apiOptions, ISerializationHelper serializationHelper) { TableRowId = 0; WorkspaceArtifactId = -1; AgentId = agentId; AgentHelper = agentHelper; SqlQueryHelper = sqlQueryHelper; QueueTable = Constant.Tables.ImportWorkerQueue; ProcessedOnDateTime = processedOnDateTime; AgentResourceGroupIds = resourceGroupIds; Logger = logger; _repositoryGroup = rsapiRepositoryGroup; _artifactQueryHelper = artifactQueryHelper; _apiOptions = apiOptions; _serializationHelper = serializationHelper; }
public void SetUp() { MockRdoRepository = new Mock <IGenericRepository <RDO> >(); MockChoiceRepository = new Mock <IGenericRepository <Choice> >(); MockWorkspaceRepository = new Mock <IGenericRepository <Workspace> >(); MockUserRepository = new Mock <IGenericRepository <User> >(); MockGroupRepository = new Mock <IGenericRepository <Group> >(); APIOptions rsapiApiOptions = new APIOptions { WorkspaceID = -1 }; Sut = new RsapiHelper( rsapiApiOptions: rsapiApiOptions, rdoRepository: MockRdoRepository.Object, choiceRepository: MockChoiceRepository.Object, workspaceRepository: MockWorkspaceRepository.Object, userRepository: MockUserRepository.Object, groupRepository: MockGroupRepository.Object); }
public override Response Execute() { Response response = new Response() { Success = true, Message = string.Empty }; if (!ActiveArtifact.IsNew) { var statusField = ActiveArtifact.Fields[Constant.Guids.Field.ImportUtilityJob.Status.ToString()].Value; var expectedField = ActiveArtifact.Fields[Constant.Guids.Field.ImportUtilityJob.Expected.ToString()].Value; var submittedForMigrationField = ActiveArtifact.Fields[Constant.Guids.Field.ImportUtilityJob.SubmittedForMigration.ToString()].Value; if (statusField != null && statusField.Value != null & expectedField != null && submittedForMigrationField != null && submittedForMigrationField.Value != null) { String currentStatus = (String)statusField.Value; Int32 expectedNumberOfImports = ((Int32?)expectedField.Value).GetValueOrDefault(); Boolean submittedForMigration = ((Boolean?)submittedForMigrationField.Value).GetValueOrDefault(); if (currentStatus == Constant.Status.Job.IN_PROGRESS_WORKER && submittedForMigration && expectedNumberOfImports > 0) { using (var proxy = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System)) { var apiOptions = new APIOptions(); proxy.APIOptions = apiOptions; ISqlQueryHelper sqlQueryHelper = new SqlQueryHelper(); IArtifactQueries artifactQueries = new ArtifactQueries(); Int32 numberOfWorkerRecords = sqlQueryHelper.CountImportWorkerRecordsAsync(Helper.GetDBContext(-1), Helper.GetActiveCaseID(), ActiveArtifact.ArtifactID).Result; IEnumerable <ImportJobError> jobErrors = artifactQueries.GetImportJobErrorsAsync(apiOptions, Helper.GetActiveCaseID(), proxy.Repositories.RDO, ActiveArtifact.ArtifactID).Result; ActiveArtifact.Fields[Constant.Guids.Field.ImportUtilityJob.Imported.ToString()].Value.Value = Utility.CalculateImportJobImports(jobErrors, expectedNumberOfImports, numberOfWorkerRecords); ActiveArtifact.Fields[Constant.Guids.Field.ImportUtilityJob.NotImported.ToString()].Value.Value = Utility.CalculateImportJobObjectsThatWereNotImported(jobErrors, expectedNumberOfImports, numberOfWorkerRecords); } } } } return(response); }
public TripService( ILogger <TripService> logger, APIOptions options, INeighborhoodRepository neighborhoodRepository, IPatternAreaRepository patternAreaRepository, IStreetSegmentRepository streetSegmentRepository, IStreetSegmentGroupRepository streetSegmentGroupRepository, IBicyclePathRepository bicyclePathRepository, IBicyclePathGroupRepository bicyclePathGroupRepository ) { Logger = logger; NeighborhoodRepository = neighborhoodRepository; PatternAreaRepository = patternAreaRepository; StreetSegmentRepository = streetSegmentRepository; StreetSegmentGroupRepository = streetSegmentGroupRepository; BicyclePathRepository = bicyclePathRepository; BicyclePathGroupRepository = bicyclePathGroupRepository; HttpClient = new HttpClient(); HttpClient.BaseAddress = new Uri(options.BaseAddress); }
public override async Task <IEnumerable <String> > ValidateAsync(APIOptions apiOptions, IRsapiRepositoryGroup rsapiRepositoryGroup, IArtifactQueries artifactQueryHelper, IDBContext eddsDbContext, ISqlQueryHelper sqlQueryHelper) { var violations = new List <String>(); await AddPasswordValidationToPasswordFieldsAsync(); // Add Client Validator await AddValidationToColumnAsync(Client, new ValidationClient(apiOptions, rsapiRepositoryGroup.ClientRepository, x => _client = x)); // Add Validators for userType, documentSkip, defaultSelectedFileType, skipDefaultPreference & documentViewer await AddValidationToColumnAsync(Type, new ValidationCodeName(sqlQueryHelper, eddsDbContext, Constant.CodeTypeName.UserType, x => _userType = x)); await AddValidationToColumnAsync(DocumentSkip, new ValidationCodeName(sqlQueryHelper, eddsDbContext, Constant.CodeTypeName.DocumentSkip, x => _documentSkip = x)); await AddValidationToColumnAsync(DefaultSelectedFileType, new ValidationCodeName(sqlQueryHelper, eddsDbContext, Constant.CodeTypeName.DefaultSelectedFileType, x => _defaultSelectedFileType = x)); await AddValidationToColumnAsync(SkipDefaultPreference, new ValidationCodeName(sqlQueryHelper, eddsDbContext, Constant.CodeTypeName.SkipDefaultPreference, x => _skipDefaultPreference = x)); await AddValidationToColumnAsync(DocumentViewer, new ValidationCodeName(sqlQueryHelper, eddsDbContext, Constant.CodeTypeName.DocumentViewer, x => _documentViewer = x)); // Add Validator for Groups await AddValidationToColumnAsync(Groups, new ValidationGroup(apiOptions, rsapiRepositoryGroup.GroupRepository, x => _groupList = x)); // Call Validation on each ObjectColumn. Note performance does NOT increase by turning this into a parallel loop foreach (var column in (await GetColumnsAsync())) { var validationResults = await column.ValidateAsync(); if (validationResults != null && validationResults.Any()) { var columnViolations = String.Join(Constant.ViolationDelimiter, validationResults); var finalViolationMessage = String.Format(Constant.Messages.Violations.GeneralColumnViolation, column.ColumnName, columnViolations); violations.Add(finalViolationMessage); } } // Update this user's validation status Validated = !violations.Any(); return(violations); }
static async Task Main(string[] args) { var pathToContentRoot = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var host = new HostBuilder() /* set cwd to the path we are executing in since * running 'dotnet run' would otherwise * set cwd to the folder it is executing from * and the json files we need are being copied to the output directory */ .UseContentRoot(pathToContentRoot) .ConfigureHostConfiguration((builder) => { builder.AddJsonFile("appsettings.json"); }) .ConfigureServices((context, services) => { // AutoMapper setup using profiles. Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); cfg.AddProfile <NeighborhoodProfile>(); cfg.AddProfile <PatternAreaProfile>(); cfg.AddProfile <StreetSegmentProfile>(); cfg.AddProfile <BicyclePathProfile>(); cfg.AddProfile <GeoJsonProfile>(); }); // use a different container with more features than the default .NET Core one var container = new Container(); container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle(); container.Register <ScootertownDbContext>(() => { var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseNpgsql( context.Configuration.GetConnectionString("postgres"), o => o.UseNetTopologySuite() ); var options = builder.Options; var dbContext = new ScootertownDbContext( options, new VehicleStoreOptions()); return(dbContext); }, Lifestyle.Scoped); container.Register <AreasOfInterest>(() => { var options = new AreasOfInterest { NeighborhoodsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("NeighborhoodsFile") ), PatternAreasFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("PatternAreasFile") ), StreetSegmentsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("StreetSegmentsFile") ), BicyclePathsFile = Path.Combine( context.HostingEnvironment.ContentRootPath, context.Configuration.GetValue <string>("BicyclePathsFile") ) }; return(options); }, Lifestyle.Scoped); container.Register <APIOptions>(() => { var options = new APIOptions { BaseAddress = context.Configuration.GetValue <string>("BaseAddress") }; return(options); }, Lifestyle.Scoped); // add generic services for repositories for any geojson we'll read in container.Register <INeighborhoodRepository, NeighborhoodRepository>(Lifestyle.Scoped); container.Register <IPatternAreaRepository, PatternAreaRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentRepository, StreetSegmentRepository>(Lifestyle.Scoped); container.Register <IStreetSegmentGroupRepository, StreetSegmentGroupRepository>(Lifestyle.Scoped); container.Register <IBicyclePathRepository, BicyclePathRepository>(Lifestyle.Scoped); container.Register <IBicyclePathGroupRepository, BicyclePathGroupRepository>(Lifestyle.Scoped); container.Register <ITripService, TripService>(Lifestyle.Scoped); container.Register <IDeploymentService, DeploymentService>(Lifestyle.Scoped); container.Register <ICollisionService, CollisionService>(Lifestyle.Scoped); container.Register <IComplaintService, ComplaintService>(Lifestyle.Scoped); container.Register <INeighborhoodService, NeighborhoodService>(Lifestyle.Scoped); container.Register <IPatternAreaService, PatternAreaService>(Lifestyle.Scoped); container.Register <IStreetSegmentService, StreetSegmentService>(Lifestyle.Scoped); container.Register <IBicyclePathService, BicyclePathService>(Lifestyle.Scoped); container.Register(ConfigureLogger, Lifestyle.Singleton); container.Register(typeof(ILogger <>), typeof(LoggingAdapter <>), Lifestyle.Scoped); container.Register <IMemoryCache>(() => { return(new MemoryCache(new MemoryCacheOptions())); }, Lifestyle.Singleton); container.Verify(); // use the default DI to manage our new container services.AddSingleton(container); services.AddSingleton <ILoggerFactory, LoggerFactory>(); // tell the DI container to start the application services.AddSingleton <IHostedService, Host>(); }) .ConfigureLogging((context, logging) => { logging.AddConfiguration(context.Configuration.GetSection("Logging")); logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); logging.AddNLog(); NLog.LogManager.LoadConfiguration("nlog.config"); }) .ConfigureAppConfiguration((context, builder) => { }); await host.RunConsoleAsync(); }
public InventoryController(IOptions<APIOptions> optionsAccessor) { _options = optionsAccessor.Value; _broker = new InventoryBroker(); _broker.PullAsync(_options.StorageConnectionString).Wait(); }
public TrolleyController(IOptions <APIOptions> optionsAccessor) { _broker = new TrolleyBroker(); _options = optionsAccessor.Value; }
public DocketSystemServiceFactory(APIOptions options) { _Options = options; _BaseUrl = options.Base_url; }
public PurchaseController(IOptions <APIOptions> apiOptionsAccessor, IOptions <PurchaseOptions> purchaseOptionsAccessor) { _apiOptions = apiOptionsAccessor.Value; _purchaseOptions = purchaseOptionsAccessor.Value; _broker = new PurchaseBroker(); }
public async Task ExecuteAsync() { ISqlQueryHelper sqlQueryHelper = new SqlQueryHelper(); IEnumerable <Int32> resourceGroupIds = GetResourceGroupIDs(); _logger = Helper.GetLoggerFactory().GetLogger(); IArtifactQueries artifactQueries = new ArtifactQueries(); //Setup RSAPI repositories APIOptions rsapiApiOptions = new APIOptions { WorkspaceID = -1 }; IRSAPIClient rsapiClient = Helper.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.CurrentUser); rsapiClient.APIOptions = rsapiApiOptions; IRsapiRepositoryGroup rsapiRepositoryGroup = new RSAPIiRepositoryGroup(rsapiClient); ILoginProfileManager loginProfileManager = Helper.GetServicesManager().CreateProxy <ILoginProfileManager>(ExecutionIdentity.CurrentUser); IAuthenticationHelper authenticationHelper = new AuthenticationHelper(loginProfileManager); ISerializationHelper serializationHelper = new SerializationHelper(); ExportWorkerJob job = new ExportWorkerJob( agentId: AgentID, agentHelper: Helper, sqlQueryHelper: sqlQueryHelper, processedOnDateTime: DateTime.Now, resourceGroupIds: resourceGroupIds, logger: _logger, artifactQueries: artifactQueries, rsapiApiOptions: rsapiApiOptions, rsapiRepositoryGroup: rsapiRepositoryGroup, authenticationHelper: authenticationHelper, serializationHelper: serializationHelper); job.OnMessage += MessageRaised; try { RaiseMessage("Enter Agent", 10); await job.ExecuteAsync(); RaiseMessage("Exit Agent", 10); } catch (Exception ex) { //Raise an error on the agents tab and event viewer RaiseError(ex.ToString(), ex.ToString()); _logger.LogError(ex, $"{Constant.Names.ApplicationName} - {ex}"); //Add the error to our custom Errors table sqlQueryHelper.InsertRowIntoExportErrorLogAsync(Helper.GetDBContext(-1), job.WorkspaceArtifactId, Constant.Tables.ExportWorkerQueue, job.TableRowId, job.AgentId, ex.ToString()).Wait(); //Add the error to the Relativity Errors tab //this second try catch is in case we have a problem connecting to the RSAPI try { ErrorQueries.WriteError(Helper.GetServicesManager(), ExecutionIdentity.System, job.WorkspaceArtifactId, ex); } catch (Exception rsapiException) { RaiseError(rsapiException.ToString(), rsapiException.ToString()); _logger.LogError(rsapiException, $"{Constant.Names.ApplicationName} - {rsapiException}"); } //Set the status in the queue to error sqlQueryHelper.UpdateStatusInExportWorkerQueueAsync(Helper.GetDBContext(-1), Constant.Status.Queue.ERROR, job.BatchTableName).Wait(); } finally { rsapiClient.Dispose(); } }
public ValidationClient(APIOptions apiOptions, IGenericRepository <Client> repository, ClientDelegate callback) { _apiOptions = apiOptions; _clientRepository = repository; _callback = callback; }
public override async Task <IEnumerable <String> > ValidateAsync(APIOptions apiOptions, IRsapiRepositoryGroup rsapiRepositoryGroup, IArtifactQueries artifactQueryHelper, IDBContext eddsDbContext, ISqlQueryHelper sqlQueryHelper) { return(await Task.Run(() => { return new List <string>(); })); }
public abstract Task <IEnumerable <String> > ValidateAsync(APIOptions apiOptions, IRsapiRepositoryGroup rsapiRepositoryGroup, IArtifactQueries artifactQueryHelper, IDBContext eddsDbContext, ISqlQueryHelper sqlQueryHelper);