public SimilarityController(SimilarityService similarityService, DumpRepository dumpRepository, BundleRepository bundleRepository, ILoggerFactory loggerFactory) { this.similarityService = similarityService; this.dumpRepository = dumpRepository; this.bundleRepository = bundleRepository; this.logger = loggerFactory.CreateLogger <SimilarityController>(); }
public BundlesController(ILoggingService loggingService, ITaskRunner taskRunner, BundleRepository bundleRepository, ProjectRepository projectRepository, SourceRepository sourceRepository, PublicationRepository publicationRepository) : base(loggingService) { this.taskRunner = taskRunner; this.bundleRepository = bundleRepository; this.projectRepository = projectRepository; this.sourceRepository = sourceRepository; this.publicationRepository = publicationRepository; }
public HomeController(IHostingEnvironment environment, SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo, DumpStorageFilebased dumpStorage, PathHelper pathHelper) { this.environment = environment; this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.dumpStorage = dumpStorage; this.pathHelper = pathHelper; }
private void FixupLoadedBundle(Scene scene) { if (!currentLevel.keepSkybox) { RenderSettings.skybox = skyboxMaterial; RenderSettings.ambientMode = AmbientMode.Flat; RenderSettings.ambientLight = skyColor; } BundleRepository.RebindScene(scene); }
public HomeController(IHostingEnvironment environment, SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo, DumpStorageFilebased dumpStorage, IOptions <SuperDumpSettings> settings, PathHelper pathHelper, RelationshipRepository relationshipRepo, SimilarityService similarityService) { this.environment = environment; this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.dumpStorage = dumpStorage; this.settings = settings.Value; this.pathHelper = pathHelper; this.relationshipRepo = relationshipRepo; this.similarityService = similarityService; }
public DumpsController( SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo, ILoggerFactory loggerFactory, SearchService searchService) { this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; logger = loggerFactory.CreateLogger <DumpsController>(); this.searchService = searchService; }
public HomeController(IHostingEnvironment environment, SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo, DumpStorageFilebased dumpStorage, IOptions <SuperDumpSettings> settings, PathHelper pathHelper, RelationshipRepository relationshipRepo, SimilarityService similarityService, ILoggerFactory loggerFactory, IAuthorizationHelper authorizationHelper) { this.environment = environment; this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.dumpStorage = dumpStorage; this.settings = settings.Value; this.pathHelper = pathHelper; this.relationshipRepo = relationshipRepo; this.similarityService = similarityService; logger = loggerFactory.CreateLogger <HomeController>(); this.authorizationHelper = authorizationHelper; }
public async Task AcknowledgeAsync_NullBundleId_ThrowsException() { // Arrange var bundleRepositoryContainer = new Mock <IBundleRepositoryContainer>(); var marketOperatorDataStorageService = new Mock <IMarketOperatorDataStorageService>(); var storageHandler = new Mock <IStorageHandler>(); var target = new BundleRepository( storageHandler.Object, bundleRepositoryContainer.Object, marketOperatorDataStorageService.Object); // Act + Assert await Assert .ThrowsAsync <ArgumentNullException>(() => target.AcknowledgeAsync(new LegacyActorId(null !), null !)) .ConfigureAwait(false); }
public async Task AcknowledgeAsync_NullRecipient_ThrowsException() { // Arrange var bundleRepositoryContainer = new Mock <IBundleRepositoryContainer>(); var marketOperatorDataStorageService = new Mock <IMarketOperatorDataStorageService>(); var storageHandler = new Mock <IStorageHandler>(); var target = new BundleRepository( storageHandler.Object, bundleRepositoryContainer.Object, marketOperatorDataStorageService.Object); // Act + Assert await Assert .ThrowsAsync <ArgumentNullException>(() => target.AcknowledgeAsync(null !, new Uuid("E6C4A3CA-D49A-4F09-929A-605C403DEEB9"))) .ConfigureAwait(false); }
public AdminController(SimilarityService similarityService, DumpRepository dumpRepository, BundleRepository bundleRepository, ILoggerFactory loggerFactory, IdenticalDumpRepository identicalDumpRepository, JiraIssueRepository jiraIssueRepository, IOptions <SuperDumpSettings> settings, ElasticSearchService elasticService) { this.similarityService = similarityService; this.bundleRepository = bundleRepository; this.identicalDumpRepository = identicalDumpRepository; this.jiraIssueRepository = jiraIssueRepository; this.elasticService = elasticService; logger = loggerFactory.CreateLogger <AdminController>(); this.settings = settings.Value; }
public async Task GetNextUnacknowledgedAsync_NullDomains_ThrowsException() { // Arrange var bundleRepositoryContainer = new Mock <IBundleRepositoryContainer>(); var marketOperatorDataStorageService = new Mock <IMarketOperatorDataStorageService>(); var storageHandler = new Mock <IStorageHandler>(); var marketOperator = new LegacyActorId(new GlobalLocationNumber("fake_value")); var target = new BundleRepository( storageHandler.Object, bundleRepositoryContainer.Object, marketOperatorDataStorageService.Object); // Act + Assert await Assert .ThrowsAsync <ArgumentNullException>(() => target.GetNextUnacknowledgedAsync(marketOperator, null !)) .ConfigureAwait(false); }
public async Task TryAddNextUnacknowledgedAsync_NullBundle_ThrowsException() { // Arrange var cabinetReader = new Mock <ICabinetReader>(); var bundleRepositoryContainer = new Mock <IBundleRepositoryContainer>(); var marketOperatorDataStorageService = new Mock <IMarketOperatorDataStorageService>(); var storageHandler = new Mock <IStorageHandler>(); var target = new BundleRepository( storageHandler.Object, bundleRepositoryContainer.Object, marketOperatorDataStorageService.Object); // Act + Assert await Assert .ThrowsAsync <ArgumentNullException>(() => target.TryAddNextUnacknowledgedAsync(null !, cabinetReader.Object)) .ConfigureAwait(false); }
public DashboardStatsToken GetAuthorDashboardStats(int userId) { try { var dto = new DashboardStatsToken { Courses = CourseRepository.Count(c => c.AuthorUserId == userId), UnpublishedCourses = CourseRepository.Count(c => c.AuthorUserId == userId && c.StatusId == (short)CourseEnums.CourseStatus.Draft), Bundles = BundleRepository.Count(c => c.AuthorId == userId), Stores = _GetOwnerStores(userId).Count(), ActiveSubscribers = OrderLinesViewRepository.Count(x => x.SellerUserId == userId && x.LineTypeId == (byte)BillingEnums.eOrderLineTypes.SUBSCRIPTION && x.OrderStatusId == (byte)BillingEnums.eOrderStatuses.ACTIVE) }; return(dto); } catch (Exception ex) { Logger.Error("get course statistic for dashboard", userId, ex, CommonEnums.LoggerObjectTypes.Dashboard); return(new DashboardStatsToken()); } }
public AnalyzerPipeline( DumpRepository dumpRepo, BundleRepository bundleRepo, PathHelper pathHelper, IOptions <SuperDumpSettings> settings, ElasticSearchService elasticSearch, SimilarityService similarityService, IOneAgentSdk dynatraceSdk) { var analyzers = new List <AnalyzerJob>(); analyzers.Add(new DumpAnalyzerJob(dumpRepo, settings, pathHelper, dynatraceSdk)); analyzers.Add(new EmptyAnalyzerJob(dumpRepo)); var postAnalyzers = new List <PostAnalysisJob>(); postAnalyzers.Add(new ElasticSearchJob(bundleRepo, dumpRepo, elasticSearch)); postAnalyzers.Add(new SimilarityAnalyzerJob(similarityService, settings)); Analyzers = analyzers; InitialAnalyzers = analyzers.Where(analyzerJob => analyzerJob is InitalAnalyzerJob).Cast <InitalAnalyzerJob>(); PostAnalysisJobs = postAnalyzers; }
public SearchServiceBenchmarks() { /// fake a repository of N very similar dumps. Then let similarity calculation run /// simulate filesystem access with Thread.Sleep in FakeDumpStorage N = 100000; var settings = Options.Create(new SuperDumpSettings { WarnBeforeDeletionInDays = 2, UseJiraIntegration = false, JiraIntegrationSettings = new JiraIntegrationSettings() }); var settingsWithJira = Options.Create(new SuperDumpSettings { WarnBeforeDeletionInDays = 2, UseJiraIntegration = true, JiraIntegrationSettings = new JiraIntegrationSettings() }); this.pathHelper = new PathHelper("", "", ""); this.loggerFactory = new LoggerFactory(); this.dumpStorage = new FakeDumpStorage(CreateFakeDumps(N)); this.dumpRepo = new DumpRepository(dumpStorage, pathHelper, settings); this.bundleRepo = new BundleRepository(dumpStorage, dumpRepo); this.identicalDumpStorage = new FakeIdenticalDumpStorage(); this.identicalDumpRepository = new IdenticalDumpRepository(identicalDumpStorage, bundleRepo); this.jiraIssueStorage = new FakeJiraIssueStorage(); this.jiraApiService = new FakeJiraApiService(); this.jiraIssueRepository = new JiraIssueRepository(settings, jiraApiService, bundleRepo, jiraIssueStorage, identicalDumpRepository, loggerFactory); // The Similarity Service and Elastic Search Service is not initialized since it is not required for testing the SimpleSearch this.searchService = new SearchService(bundleRepo, dumpRepo, null, null, settings, jiraIssueRepository); this.searchServiceWithJira = new SearchService(bundleRepo, dumpRepo, null, null, settingsWithJira, jiraIssueRepository); }
public async Task TestJiraIssueRepository() { // setup dependencies var settings = Options.Create(new SuperDumpSettings { UseJiraIntegration = true, JiraIntegrationSettings = new JiraIntegrationSettings { } }); var pathHelper = new PathHelper("", "", ""); var dumpStorage = new FakeDumpStorage(CreateFakeDumps()); var bundleStorage = dumpStorage; var dumpRepo = new DumpRepository(dumpStorage, pathHelper); var bundleRepo = new BundleRepository(bundleStorage, dumpRepo); var jiraApiService = new FakeJiraApiService(); var jiraIssueStorage = new FakeJiraIssueStorage(); var identicalDumpStorage = new FakeIdenticalDumpStorage(); var identicalDumpRepository = new IdenticalDumpRepository(identicalDumpStorage, bundleRepo); var loggerFactory = new LoggerFactory(); var jiraIssueRepository = new JiraIssueRepository(settings, jiraApiService, bundleRepo, jiraIssueStorage, identicalDumpRepository, loggerFactory); // population await jiraIssueStorage.Store("bundle1", new List <JiraIssueModel> { new JiraIssueModel("JRA-1111") }); await jiraIssueStorage.Store("bundle2", new List <JiraIssueModel> { new JiraIssueModel("JRA-2222"), new JiraIssueModel("JRA-3333") }); await jiraIssueStorage.Store("bundle9", new List <JiraIssueModel> { new JiraIssueModel("JRA-9999") }); await bundleRepo.Populate(); await jiraIssueRepository.Populate(); // actual test Assert.Collection(jiraIssueRepository.GetIssues("bundle1"), item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle2"), item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-3333", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle9"), item => Assert.Equal("JRA-9999", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle3")); // fake, that in jira some bundles have been referenced in new issues jiraApiService.SetFakeJiraIssues("bundle1", new JiraIssueModel[] { new JiraIssueModel("JRA-1111") }); // same jiraApiService.SetFakeJiraIssues("bundle2", new JiraIssueModel[] { new JiraIssueModel("JRA-2222"), new JiraIssueModel("JRA-4444") }); // one added, one removed jiraApiService.SetFakeJiraIssues("bundle3", new JiraIssueModel[] { new JiraIssueModel("JRA-1111"), new JiraIssueModel("JRA-5555") }); // new jiraApiService.SetFakeJiraIssues("bundle9", null); // removed jira issues await jiraIssueRepository.SearchBundleIssuesAsync(bundleRepo.GetAll(), true); Assert.Collection(jiraIssueRepository.GetIssues("bundle1"), item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle2"), item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-4444", item.Key)); Assert.Collection(jiraIssueRepository.GetIssues("bundle3"), item => Assert.Equal("JRA-1111", item.Key), item => Assert.Equal("JRA-5555", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle9")); var res = await jiraIssueRepository.GetAllIssuesByBundleIdsWithoutWait(new string[] { "bundle1", "bundle2", "bundle7", "bundle666", "bundle9" }); Assert.Equal(2, res.Count()); Assert.Collection(res["bundle1"], item => Assert.Equal("JRA-1111", item.Key)); Assert.Collection(res["bundle2"], item => Assert.Equal("JRA-2222", item.Key), item => Assert.Equal("JRA-4444", item.Key)); Assert.Empty(jiraIssueRepository.GetIssues("bundle7")); Assert.Empty(jiraIssueRepository.GetIssues("bundle666")); Assert.Empty(jiraIssueRepository.GetIssues("bundle9")); }
public ElasticSearchJob(BundleRepository bundleRepo, DumpRepository dumpRepo, ElasticSearchService elasticSearch) { this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; this.elasticSearch = elasticSearch; }
public DumpsController(SuperDumpRepository superDumpRepo, BundleRepository bundleRepo, DumpRepository dumpRepo) { this.superDumpRepo = superDumpRepo; this.bundleRepo = bundleRepo; this.dumpRepo = dumpRepo; }
public CouponValidationToken ValidateCoupon(int priceLineId, int couponOwnerId, int?courseId, int?bundleId, int couponInstanceId) { var result = new CouponValidationToken { IsValid = false , Discount = 0 }; var inst = CouponInstanceRepository.GetById(couponInstanceId); if (inst == null) { result.Message = "coupon instance not found"; return(result); } var coupon = CouponRepository.GetById(inst.CouponId).Entity2AuthorCouponDTO(); if (coupon == null) { result.Message = "coupon not found"; return(result); } var priceToken = GetItemPriceToken(priceLineId); if (priceToken == null) { result.Message = "Price Line not found"; return(result); } decimal basePrice; if (courseId != null) { var course = CourseRepository.GetById((int)courseId); if (course == null) { result.Message = "course not found"; return(result); } if (coupon.CourseId != null) { if (coupon.CourseId != courseId) { result.Message = "coupon not allowed to this course"; return(result); } } else { if (coupon.OwnerUserId == null || (coupon.OwnerUserId != course.AuthorUserId)) { result.Message = "coupon not allowed to this course"; return(result); } } var itemPrice = priceToken.Price; if (itemPrice == 0) { result.Message = "invalid price"; return(result); } basePrice = itemPrice; } else if (bundleId != null) { var bundle = BundleRepository.GetById((int)bundleId); if (bundle == null) { result.Message = "bundle not found"; return(result); } if (coupon.BundleId != null) { if (coupon.BundleId != bundleId) { result.Message = "coupon not allowed to this bundle"; return(result); } } else { if (coupon.OwnerUserId == null || (coupon.OwnerUserId != bundle.AuthorId)) { result.Message = "coupon not allowed to this bundle"; return(result); } } var itemPrice = priceToken.Price; if (itemPrice == 0) { result.Message = "invalid price"; return(result); } basePrice = itemPrice; } else { result.Message = "course or bundle required"; return(result); } var objectName = courseId != null ? "course" : "bundle"; result.OriginalPrice = basePrice; result.FinalPrice = basePrice; if ((coupon.CourseId.HasValue && coupon.CourseId != courseId)) { result.Message = "This coupon is not allowed for this " + objectName; } else if (coupon.ExpirationDate < DateTime.Now.AddDays(-1)) { result.Message = "This coupon is expired"; } else if (inst.UsageLimit != -1 && inst.SALE_OrderLines.Count >= inst.UsageLimit) { result.Message = "This coupon is no longer valid"; } else { if (priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION && coupon.Type != CourseEnums.CouponType.SUBSCRIPTION) { result.Message = "This coupon is not allowed for this " + objectName; return(result); } result.IsValid = true; switch (coupon.Type) { case CourseEnums.CouponType.PERCENT: case CourseEnums.CouponType.SUBSCRIPTION: result.Discount = (decimal)(coupon.Amount != null ? basePrice * (coupon.Amount / 100) : 0); result.FinalPrice = CalculateDiscountedPrice(basePrice, coupon.Amount ?? 0, CourseEnums.CouponType.PERCENT); result.IsFree = result.FinalPrice == 0; result.Message = priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION ? String.Format("The price of this {2} is now {1:0.00} for the initial {0} months of your subscription. After that, regular rates shall apply", coupon.SubscriptionMonths ?? 0, result.FinalPrice, objectName) : String.Format("Coupon code is valid for a discount of {0}%. Your price is: {1} {2:0.00}", coupon.Amount, priceToken.Currency.ISO, result.FinalPrice); break; case CourseEnums.CouponType.FIXED: if (priceToken.PriceType == BillingEnums.ePricingTypes.SUBSCRIPTION) { result.IsValid = false; result.Message = "Fixed amount coupon can't be applied to subscription"; } else { result.Discount = coupon.Amount ?? 0; result.FinalPrice = CalculateDiscountedPrice(basePrice, coupon.Amount ?? 0, CourseEnums.CouponType.FIXED); result.IsFree = result.FinalPrice == 0; result.Message = string.Format("Coupon code is valid for a discount of {1} {0:0.00}, Your price is: {1} {2:0.00}", result.Discount, priceToken.Currency.ISO, result.FinalPrice); } break; case CourseEnums.CouponType.FREE: result.Discount = basePrice; result.FinalPrice = 0; result.IsFree = true; result.Message = "This coupon entitles you to get this course for free. Click the button below to complete the process."; break; } } return(result); }
public BundlesController(BundleRepository bundleRepository) { _bundleRepository = bundleRepository; }
public BundleService() { _bundleRepository = new BundleRepository(); _productRepository = new ProductRepository(); }