public async Task ProcessTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var hookService = new HookService { new (new Command("process-job"), ConsoleKey.K, isProcessing : true), }; await using var moduleService = new StaticModuleService( TestModules.CreateProcessJobRunnerCommand() ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); }
public async Task TelegramRecordedAudioTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); await using var recognitionService = new RecognitionService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); var bytes = await recognitionService.StartRecordMp3_5Second_Stop_Async(cancellationToken); await runnerService.RunAsync( new Command("telegram audio", new Value(string.Empty, nameof(TelegramRecordedAudioTest)) { Data = bytes, }), cancellationToken); }
public ManagerPair GetStrategyTradeManagerPair(Guid strategyId) { lock (_locker) { var sleepService = new SleepService(); var apiClientFactory = new ApiClientFactory(); var runnerService = new RunnerService(apiClientFactory); var orderPlacer = new OrderPlacer(apiClientFactory); var stakeCalculator = new ClosingStakeCalculator(); var openingStakeProviderFactory = new OpeningStakeProviderFactory(); var test = new List <string>() { "255f49e7-28e7-4f2b-acb9-34a2898866f4", "5331775e-fc1f-46c5-b665-f3d478b7d09f", "984950bb-210e-4e4b-b76c-cf668fe40a6a" }; if (test.Contains(strategyId.ToString())) { return(new ManagerPair(new TestOpeningOrderManager(), new TestClosingOrderManager())); } var orderPriceFinder = new OrderPriceFinder(openingStakeProviderFactory); return(new ManagerPair(new OpeningOrderManager(orderPlacer, runnerService, sleepService, orderPriceFinder), new ClosingOrderManager(sleepService, runnerService, orderPlacer, stakeCalculator))); } }
public async Task SelectTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var hookService = new HookService { new (new Command("select"), ConsoleKey.S, isProcessing : true), }; await using var moduleService = new StaticModuleService( new SelectRunner(app.Dispatcher) ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); await runnerService.WaitAllAsync(cancellationToken); }
public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var hookService = new HookService { new (new Command("send-telegram-voice-message"), new Keys(Key.L, Key.RAlt), true), }; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); await hookService.InitializeAsync(cancellationToken); moduleService.Add(new RecognitionServiceRunner(recognitionService)); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); }
public async Task SendTelegramVoiceMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateDefaultRecorder(), TestModules.CreateDefaultRecognizer(), TestModules.CreateTelegramRunner() ); await using var recognitionService = new RecognitionService(moduleService); await using var runnerService = new RunnerService(moduleService, moduleService, recognitionService); using var exceptions = new IServiceBase[] { moduleService, recognitionService, runnerService }.EnableLogging(cancellationTokenSource); moduleService.Add(new RecognitionServiceRunner(recognitionService)); var process = runnerService.Start(new Command("send-telegram-voice-message"), cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); var value = await process.StopAsync(cancellationToken); Assert.AreNotEqual(0, value.Output.Data.Length); }
public void Service_is_created() { var mockLogger = new Mock <ILogger>(); var mockHistoryRepo = new Mock <IHistoryRepository>(); var sut = new RunnerService(mockLogger.Object, mockHistoryRepo.Object); Assert.IsInstanceOf <RunnerService>(sut); }
public static async Task StartRecord5SecondsStopRecordTestAsync( this RunnerService service, CancellationToken cancellationToken = default) { await service.RunAsync(new Command("start-recognition"), cancellationToken); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); await service.RunAsync(new Command("stop-recognition"), cancellationToken); }
public void RunMethod_RunSourceCodeAndReturnTheResult() { const string sourceCode = "public class stubClass{ public int stubMethod(){ return 1; }}"; var stubQuestion = new Question(new Definition { ClassName = "stubClass", MethodName = "stubMethod" }) { SourceCode = sourceCode }; var compilationService = new CompilationService(); CompilerResults compilerResults = compilationService.CompileSourceCode(stubQuestion.SourceCode); var runnerService = new RunnerService(); var result = runnerService.RunMethod(compilerResults.CompiledAssembly, stubQuestion); Assert.AreEqual("1", result.Result); }
private static void Export() { var path = string.Empty; while (!Directory.Exists(path)) { path = readPath(); } var context = new RunnerDbContext(new DbContextOptionsBuilder <RunnerDbContext>() .UseSqlServer(Configuration.GetConnectionString("Default")) .Options); var runnerService = new RunnerService(context); var categories = context.Categories.ToImmutableList(); foreach (var c in categories) { var(maenner, frauen) = runnerService.GetResultsForCategory(c.Id); CreateFile(maenner, Path.Combine(path, $"{c.Name.Replace(" ", "")}_Maenner.csv")); CreateFile(frauen, Path.Combine(path, $"{c.Name.Replace(" ", "")}_Frauen.csv")); } var(aeltesteMaenner, aeltesteFrauen) = runnerService.GetOldestRunner(); CreateFile <ExportRunner, ExportOldestRunnerMap>(aeltesteMaenner, Path.Combine(path, $"Aelteste_Maenner.csv")); CreateFile <ExportRunner, ExportOldestRunnerMap>(aeltesteFrauen, Path.Combine(path, $"Aelteste_Frauen.csv")); var vereine = runnerService.GetSportclubsRangs(); CreateFile(vereine, Path.Combine(path, $"Vereine.csv")); var angemeldeteVereine = runnerService.GetAngemeldeteSportclubsRangs(); CreateFile(angemeldeteVereine, Path.Combine(path, $"AngemeldeteLaeufer_Vereine.csv")); var alleLäufer = runnerService.GetAllRunners(); CreateFile <ExportRunnerSimple, ExportRunnerSimpleMap>(alleLäufer, Path.Combine(path, $"Alle_Laeufer.csv")); CreateFile <ExportRunnerSimple, ExportRunnerSimpleMap>(alleLäufer.OrderBy(r => r.Startnummer), Path.Combine(path, $"Alle_Laeufer_nach_Startnummer.csv")); string readPath() { Write("Export Directory Path: "); return(ReadLine()); } }
public async Task TelegramMessageTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync( new Command("telegram message", nameof(TelegramMessageTest)), cancellationToken); }
public void DoWork_handles_ChangedData() { RacconHistory spiedHistory = null; var mockLogger = new Mock <ILogger>(); var historyRepository = new Mock <IHistoryRepository>(); historyRepository .Setup(h => h.InsertHistory(It.IsAny <RacconHistory>()) ) .Callback <RacconHistory>((h) => { spiedHistory = h; } ) .Returns(1); var sut = new RunnerService(mockLogger.Object, historyRepository.Object); var job = new Job { Entity = eWiftEntity.Runner, SubjectName = "Test Runner 1", RunnerId = Guid.Parse("C56A4180-65AA-42EC-A945-5FD21DEC0538"), ChangeProperty = "Rider", ChangeData = "Ivy OCampo", RunnerNumber = 12, RunnerName = "Runner 12", Rider = "Ivy OCampo", RaceNumber = 4 }; sut.DoWork(job); Assert.AreEqual("success", spiedHistory.status); Assert.AreEqual("Test Runner 1", spiedHistory.subjectname); Assert.AreEqual("C56A4180-65AA-42EC-A945-5FD21DEC0538", spiedHistory.subjectkey.ToString().ToUpper()); dynamic dyn = JsonConvert.DeserializeObject(spiedHistory.data); Assert.AreEqual("Ivy OCampo", dyn.runners[0].RiderName.ToString()); }
public async Task SelectScreenshotClipboardTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var hookService = new HookService { new (new Command( "process-sequence", "3", "select", "screenshot", "clipboard-set-image" ), new Keys(Key.RAlt), true), }; await using var moduleService = new StaticModuleService( new SelectRunner(app.Dispatcher), new ScreenshotRunner(), new ClipboardRunner(app.Dispatcher) ); await using var runnerService = new RunnerService( moduleService, moduleService, hookService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, hookService }.EnableLogging(cancellationTokenSource); moduleService.Add(new ProcessSequenceRunner(runnerService)); await hookService.InitializeAsync(cancellationToken); await Task.Delay(TimeSpan.FromSeconds(15), cancellationToken); await runnerService.WaitAllAsync(cancellationToken); }
public async Task TelegramAudioTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateTelegramRunner() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync( new Command("telegram audio", new Value(string.Empty, nameof(TelegramAudioTest)) { Data = ResourcesUtilities.ReadFileAsBytes("test.mp3"), }), cancellationToken); }
public async Task LongJobTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; await using var moduleService = new StaticModuleService( TestModules.CreateLongJobRunnerCommand() ); await using var runnerService = new RunnerService(moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); var values = await runnerService.RunAsync( new Command("long-job", "5000"), cancellationToken); Assert.AreEqual(1, values.Length); Assert.AreEqual("5000", values[0].Input.Argument); }
public async Task SimpleTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(15)); var cancellationToken = cancellationTokenSource.Token; await using var deskbandService = new DeskbandService { ConnectedCommandFactory = _ => new Command("print", "Connected to H.DeskBand."), DisconnectedCommandFactory = _ => new Command("print", "Disconnected from H.DeskBand."), }; await using var moduleService = new StaticModuleService( TestModules.CreateTimerNotifierWithDeskbandDateTimeEach1Seconds(), TestModules.CreateRunnerWithPrintCommand() ); await using var runnerService = new RunnerService( moduleService, moduleService, deskbandService ); using var exceptions = new IServiceBase[] { moduleService, runnerService, deskbandService }.EnableLogging(cancellationTokenSource); moduleService.Add(new DeskbandServiceRunner(deskbandService)); await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken); try { await runnerService.RunAsync( new Command("deskband", "clear-preview"), cancellationToken); } catch (OperationCanceledException) { // ignore cancelling on Github Actions. } }
public async Task <ListTestsResponse> ListTests(ListTestsRequest request) { var lstRequest = new ListTestsDataRequest(request.FilteringOrders, request.Range, false, request.ReturnNotSaved); var tests = await TestsStorage.ListTestsDataAsync(lstRequest); var testsIds = tests.Tests.Select(c => c.TestId).ToArray(); var getInfosR = new RunnerService.API.Models.GetTestsInfoRequest(testsIds); RunnerService.API.Models.GetTestsInfoResponse getInfosResp = request.ReturnNotSaved ? (RunnerService.API.Models.GetTestsInfoResponse)null : (RunnerService.API.Models.GetTestsInfoResponse) await RunnerService.GetTestsInfoAsync(getInfosR); var fullInfos = tests.Tests.Select(c => (Case: c, RunInfo: getInfosResp == null ? (RunnerService.API.Models.TestRunInfo)null : getInfosResp.RunInfos.FirstOrDefault(r => r.TestId == c.TestId))); //var fullInfos = tests.Tests.Zip(getInfosResp?.RunInfos ?? ((RunnerService.API.Models.TestRunInfo)null).Repeat(tests.Tests.Length).ToArray() , (Case, RunInfo) => (Case, RunInfo)); var response = new ListTestsResponse(ddd().ToArray(), tests.TotalCount); return(response); IEnumerable <TestInfo> ddd() { foreach (var info in fullInfos) { yield return(new TestInfo() { TestId = info.Case.TestId, TestName = info.Case.TestName, Author = info.Case.AuthorName == null ? null : new GetUserInfoResponse(info.Case.AuthorName, null, null), Target = new TestCaseInfo() { DisplayName = info.Case.TestDescription, TargetType = info.Case?.Data?.Type, Parameters = info.Case?.Data?.Parameters, CreateDate = info.Case?.CreationDate ?? default, KeyParameters = info.Case?.Data?.KeyParameters.Select(p => p.Key + "###" + p.Value).Aggregate(Environment.NewLine) // Someone, pls, rewrite :D },
public async Task RussianNameTest() { using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); var cancellationToken = cancellationTokenSource.Token; using var app = await TestWpfApp.CreateAsync(cancellationToken); await using var moduleService = new StaticModuleService( new AliasRunner( new Command("sequence", "2", "clipboard-set-text", "keyboard CTRL+V"), "вставь"), new KeyboardRunner(), new ClipboardRunner(app.Dispatcher), new SequenceRunner() ); await using var runnerService = new RunnerService(moduleService, moduleService); using var exceptions = new IServiceBase[] { moduleService, runnerService }.EnableLogging(cancellationTokenSource); await runnerService.RunAsync(Command.Parse("вставь 123"), cancellationToken); }
public RunnersController() { this._runnerService = new RunnerService(); }
public CorrectionProcess() { _compilationService = new CompilationService(); _runnerService = new RunnerService(); }
public CorrectionProcess(CompilationService compilationService, RunnerService runnerService) { _compilationService = compilationService; _runnerService = runnerService; }
public RunnerController(RunnerService runnerService) { _runnerService = runnerService; }
public static void Main(string[] args) { _queueService = new JobQueueService(); _runnerService = new RunnerService(); _runnerPermissionService = new RunnerPermissionService(); var i = 1; AddRunnerInfo(); while (true) { if (!_runnerPermissionService.HasPermissions(_runnerId)) { Console.WriteLine(string.Format("Запуск запрещён")); Thread.Sleep(Delay); continue; } try { Console.WriteLine(string.Format("{0} запуск", i)); var accounts = new HomeService(new JobService(), new BackgroundJobService()).GetAccounts(); var spyAccounts = new SpyService(new JobService()).GetSpyAccounts(); var overdueQueues = _queueService.RemoveOverdueQueue(OverdueMin); if (overdueQueues != 0) { Console.WriteLine(string.Format("Из очереди исключено {0} задач с превышением времени выполнения ({1} min.)", overdueQueues, OverdueMin)); } var queues = _queueService.GetGroupedQueue(); Console.WriteLine(string.Format("{0} аккаунтов в очереди", queues.Count)); foreach (var queue in queues) { var firstElement = queue.FirstOrDefault(); if (firstElement == null) { continue; } Console.WriteLine(string.Format("{0} задач в очереди для аккаунта {1}", queue.Count, firstElement.AccountId)); AccountViewModel account; if (firstElement.IsForSpy) { var spyAccount = spyAccounts.FirstOrDefault(model => model.Id == firstElement.AccountId); if (spyAccount == null) { continue; } account = new AccountViewModel { Id = spyAccount.Id, Login = spyAccount.Login, Proxy = spyAccount.Proxy, FacebookId = spyAccount.FacebookId, ProxyLogin = spyAccount.ProxyLogin, Name = spyAccount.Name, ProxyPassword = spyAccount.ProxyPassword, ConformationDataIsFailed = spyAccount.ConformationIsFailed, AuthorizationDataIsFailed = spyAccount.AuthorizationDataIsFailed, ProxyDataIsFailed = spyAccount.ProxyDataIsFailed, Cookie = spyAccount.Cookie, PageUrl = spyAccount.PageUrl, Password = spyAccount.Password }; } else { account = accounts.FirstOrDefault(model => model.Id == firstElement.AccountId); } foreach (var currentQueue in queue) { _queueService.MarkIsProcessedQueue(currentQueue); // помечаем задачу как "в процессе" } var queueData = queue; var runnerTask = new Task(() => RunnerTask(queueData, account)); runnerTask.Start(); } Console.WriteLine($"ждем {Delay / 1000} сек. для следующего запуска"); Thread.Sleep(Delay); i++; _runnerService.UpdateRunnerActivityDate(_runnerId); } catch (Exception ex) { LogWriter.LogWriter.AddToLog(string.Format("{0} ({1})", ex.Message, ex.InnerException)); } } }
public RunnerBinder(RunnerService <T> service) { _service = service; }