Example #1
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            Console.WriteLine(sw.Elapsed);
            return(0);
        }
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            Console.WriteLine(sw.Elapsed);
            return(await Task.FromResult(0));
        }
Example #3
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            var songsRepository        = serviceProvider.GetService <IDeletableEntityRepository <Song> >();
            var songMetadataRepository = serviceProvider.GetService <IDeletableEntityRepository <SongMetadata> >();
            var songsService           = serviceProvider.GetService <ISongsService>();
            var metadataService        = serviceProvider.GetService <ISongMetadataService>();
            var provider                 = new Top40ChartsDataProvider();
            var splitter                 = new SongNameSplitter();
            var youTubeDataProvider      = new YouTubeDataProvider();
            var lyricsPluginDataProvider = new LyricsPluginDataProvider();

            var songIds = songsRepository.All().Select(x => x.Id).ToList();

            for (var index = 0; index < songIds.Count; index++)
            {
                var songId = songIds[index];
                songsService.UpdateSongsSystemDataAsync(songId).GetAwaiter().GetResult();
                if (index % 100 == 0)
                {
                    songsRepository.DetachAll();
                }
            }

            Console.WriteLine(sw.Elapsed);
            return(0);
        }
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            var settingsService = serviceProvider.GetService <ISettingsService>();

            Console.WriteLine($"Count of settings: {settingsService.GetCount()}");
            Console.WriteLine("Level: ");
            var level = int.Parse(Console.ReadLine());

            Console.WriteLine("Position: ");
            var position         = Console.ReadLine();
            var attributeService = serviceProvider.GetService <IAttributesService>();
            var attributes       = await attributeService.AddAttributesAsync(position, level);

            Console.WriteLine(attributes.Id);
            Console.WriteLine(attributes.Level);
            Console.WriteLine(attributes.Position);
            Console.WriteLine(attributes.Shooting);
            Console.WriteLine(attributes.Rebounding);
            Console.WriteLine(attributes.Assisting);
            Console.WriteLine(attributes.Stealing);
            Console.WriteLine(attributes.Blocking);
            Console.WriteLine();
            Console.WriteLine(sw.Elapsed);
            return(await Task.FromResult(0));
        }
Example #5
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            var newsService       = serviceProvider.GetService <INewsService>();
            var sourcesRepository = serviceProvider.GetService <IDeletableEntityRepository <Source> >();

            foreach (var source in sourcesRepository.All().ToList())
            {
                // Run only for selected sources
                if (!new[] { "BivolBgSource" }.Any(x => source.TypeName.Contains(x)))
                {
                    continue;
                }

                var sourceProvider = ReflectionHelpers.GetInstance <BaseSource>(source.TypeName);
                Console.WriteLine($"Starting {source.TypeName}.GetAllPublications...");
                var news = sourceProvider.GetAllPublications();
                foreach (var remoteNews in news)
                {
                    newsService.AddAsync(remoteNews, source.Id).GetAwaiter().GetResult();
                }

                Console.WriteLine($"{source.TypeName}.GetAllPublications done.");
            }

            Console.WriteLine(sw.Elapsed);
            return(0);
        }
        public ApiClient ResetSandboxClient(string sandboxName, SandboxOptions sandboxOptions, User user)
        {
            var client = SetupDefaultSandboxClient(sandboxName, sandboxOptions, user);

            ProvisionSandbox(client);

            return(client);
        }
 private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
 {
     var sw = Stopwatch.StartNew();
     var settingsService = serviceProvider.GetService<ISettingsService>();
     Console.WriteLine($"Count of settings: {settingsService.GetCount()}");
     Console.WriteLine(sw.Elapsed);
     return 0;
 }
Example #8
0
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            // var settingsService = serviceProvider.GetService<ISettingsService>();
            // Console.WriteLine($"Count of settings: {settingsService.GetCount()}");
            Console.WriteLine(sw.Elapsed);
            return(await Task.FromResult(0));
        }
Example #9
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            new UpdateSearchTextSandbox().Work(serviceProvider).GetAwaiter().GetResult();
            //// new GetAllNewsSandbox().Work(serviceProvider).GetAwaiter().GetResult();

            Console.WriteLine(sw.Elapsed);
            return(0);
        }
Example #10
0
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            var recipesImporter = serviceProvider.GetService <IGotvachBgScraperService>();
            await recipesImporter.ImportRecipesAsync(1, 161000);

            Console.WriteLine(sw.Elapsed);
            return(await Task.FromResult(0));
        }
        public ApiClient ResetSandboxClient(string sandboxName, SandboxOptions sandboxOptions, User user)
        {
            var client = SetupDefaultSandboxClient(sandboxName, sandboxOptions, user);

            ProvisionSandbox(client);

            var leaIds = _templateDatabaseLeaQuery.GetLocalEducationAgencyIds(client.Key);

            _defaultApplicationCreator.AddLeaIdsToApplication(leaIds, client.Application.ApplicationId);

            return(client);
        }
Example #12
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            //// serviceProvider.GetService<INewsService>().SaveImageLocallyAsync("https://prb.bg/upload/55508/%D0%93%D0%B5%D1%80%D0%B1+%D0%92%D0%B8%D1%82%D1%80%D0%B0%D0%B6.JPG", 191333, @"C:\Temp\wwwroot", false).GetAwaiter().GetResult();
            //// new UpdateSearchTextSandbox().Work(serviceProvider).GetAwaiter().GetResult();
            new GetAllNewsSandbox().Work(serviceProvider).GetAwaiter().GetResult();
            //// new DownloadImagesSandbox().Work(serviceProvider).GetAwaiter().GetResult();

            Console.WriteLine(sw.Elapsed);
            return(0);
        }
        private ApiClient SetupDefaultSandboxClient(string sandboxName, SandboxOptions sandboxOptions, User user)
        {
            var defaultApplication = _defaultApplicationCreator
                                     .FindOrCreateUpdatedDefaultSandboxApplication(user.Vendor.VendorId, sandboxOptions.Type);

            return(_clientAppRepo.SetupDefaultSandboxClient(
                       sandboxName,
                       sandboxOptions.Type,
                       sandboxOptions.Key,
                       sandboxOptions.Secret,
                       user.UserId,
                       defaultApplication.ApplicationId));
        }
        public ApiClient CreateNewSandboxClient(string sandboxName, SandboxOptions sandboxOptions, User user)
        {
            if (user.ApiClients.Count >= _maximumSandboxesPerUser)
            {
                var message = $"The maximum of {_maximumSandboxesPerUser} sandboxes for user id {user.UserId} has been reached!";
                message += " To configure please update the 'MaximumSandboxesPerUser' app setting in the web.config.";
                _log.Error(message);
                throw new ArgumentOutOfRangeException(message);
            }

            var client = SetupDefaultSandboxClient(sandboxName, sandboxOptions, user);

            ProvisionSandbox(client);

            return(client);
        }
Example #15
0
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            var settingsService = serviceProvider.GetService <ISettingsService>();

            var list = new List <string>()
            {
                "hello", "hi ya", "new string"
            };

            var filteredResults = list.Where(i => i.Contains(string.Empty)).ToList();

            Console.WriteLine(string.Join(", ", filteredResults));
            return(await Task.FromResult(0));
        }
Example #16
0
        private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            var sw = Stopwatch.StartNew();

            //// (await ActivatorUtilities.CreateInstance<CheckFeedsJob>(serviceProvider).CheckJsonAsync(
            ////     //// "https://app.pluralsight.com/learner/user/courses/recent",
            ////     new Feed
            ////     {
            ////         Cookies = "",
            ////         Url = "https://app.pluralsight.com/learner/user/courses/recent",
            ////         Type = FeedType.Json,
            ////         ItemsSelector = "collection.[*].content.title",
            ////     })).Dump();

            Console.WriteLine(sw.Elapsed);
            return(await Task.FromResult(0));
        }
        public ApiClient CreateNewSandboxClient(string sandboxName, SandboxOptions sandboxOptions, User user)
        {
            if (user.ApiClients.Count >= _maximumSandboxesPerUser)
            {
                var message = $"The maximum of {_maximumSandboxesPerUser} sandboxes for user id {user.UserId} has been reached!";
                message += " To configure please update the 'MaximumSandboxesPerUser' app setting in the web.config.";
                _log.Error(message);
                throw new ArgumentOutOfRangeException(message);
            }

            var client = SetupDefaultSandboxClient(sandboxName, sandboxOptions, user);

            ProvisionSandbox(client);

            var leaIds = _templateDatabaseLeaQuery.GetLocalEducationAgencyIds(client.Key);

            _defaultApplicationCreator.AddLeaIdsToApplication(leaIds, client.Application.ApplicationId);

            return(client);
        }
Example #18
0
        public static void Main(string[] args)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            Interop.Wer.AddExcludedApplication("test_memlimit.exe", false);

            var sbopt = new SandboxOptions
            {
                ForbidSystemCall      = true,
                MemoryLimit           = 800 << 10,
                    ProcessCountLimit = 1,
                    TimeLimit         = 1000,
                    ExecutableFile    = "a.exe",
            };

            var ppl = new JobObjectPipeline(null);

            ppl.UseJudger(new DemoJudger());
            ppl.Options = sbopt;

            ppl.ExecuteAsync().GetAwaiter().GetResult();
        }
Example #19
0
        private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
        {
            //TEST STUFF HERE

            var        searchString = Console.ReadLine();
            TMDbClient client       = new TMDbClient(Environment.GetEnvironmentVariable("TMDB_API_KEY"));
            var        results      = client.SearchMovieAsync(searchString).Result;

            Console.WriteLine($"Got {results.Results.Count:N0} of {results.TotalResults:N0} results");
            foreach (SearchMovie result in results.Results)
            {
                Console.WriteLine(result);
            }

            var sw = Stopwatch.StartNew();
            var settingsService = serviceProvider.GetService <ISettingsService>();

            //Console.WriteLine($"Count of settings: {settingsService.GetCount()}");
            Console.WriteLine(sw.Elapsed);
            return(0);
        }
Example #20
0
 private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
 {
     return(await Task.FromResult(0));
 }
Example #21
0
 private static int SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
 {
     return(1);
 }
Example #22
0
 private static async Task <int> SandboxCode(SandboxOptions options, IServiceProvider serviceProvider)
 {
     return(0);
 }