private void buttonSendFiles_Click(object sender, EventArgs e) { OpenFileDialog fdlg = new OpenFileDialog(); fdlg.Multiselect = true; fdlg.ShowDialog(); List <string> result = fdlg.FileNames.ToList(); if (result.Count > 0) { string form1Text = this.Text; this.Text = form1Text + " - sending..."; try { ExecutorFactory.CreateExecutor(new DBExecutor(), string.Empty).SendFiles(result, this.textBoxKey.Text.ToString()); MessageBox.Show("Files sent successfully"); } catch (Exception ex) { MessageBox.Show("Files were not sent!" + ex.ToString()); } this.Text = form1Text; } }
public void CallCreateTest() { ExecutorFactory factory = new ExecutorFactory(new IocContainer()); Assert.IsType <Simple1Executor>(factory.Create(new Simple1Command()).Executor); Assert.IsType <Simple2Executor>(factory.Create(new Simple2Command()).Executor); }
/// <summary> /// 初始化测试。 /// </summary> protected TestBase() { var container = ObjectFactory.CreateContainer(); this._factory = new ExecutorFactory(container); var type = this.GetType(); var db = type.GetAttribute <DbAttribute>(); var provider = db == null ? "ce" : db.Provider; switch (provider) { case "sql": this._testManager = new MsSqlTestManager(); break; default: this._testManager = new MsCeTestManager(); break; } this._Engine = this._testManager.Engine; container.Add <IDbEngine>(this._Engine); var classScripts = this.GetType().GetAttribute <ScriptsAttribute>(); if (classScripts != null) { this._testManager.Execute(classScripts.Keys); } }
public TaskMessageHandler(IServiceProvider rootServices) { RootServices = rootServices; Type loggerType = typeof(ILogger <>); this.Logger = (ILogger)RootServices.GetRequiredService(loggerType.MakeGenericType(this.GetType())); this.ExecutorFactory = new Lazy <IExecutorFactory>(() => { var res = new ExecutorFactory(); res.LoadExecutorInfo(); return(res); }, true); }
private void createJson(bool sendFiles = false) { string saveFolder; if (sendFiles) { saveFolder = Path.GetTempPath(); } else { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); // export cancelled - do nothing if (result != DialogResult.OK) { return; } saveFolder = fbd.SelectedPath; } try { this.SaveDialogSettings(); DBExecutor dbExecutor = new DBExecutor(); this.BuildConnectionString(dbExecutor); // create filesystem configuration file, Executor will use this if (checkboxUseFS.Checked) { CreateFileSystemCfgFile(); } string myName = this.textBoxUserName.Text; Guid myKey; if (!Guid.TryParse(this.textBoxKey.Text, out myKey)) { throw new SQLDepException("Invalid or missing API key. Get one in your dashboard on SQLdep website."); } string sqlDialect = this.GetDatabaseTypeName(this.comboBoxDatabase.SelectedIndex); Executor executor = ExecutorFactory.CreateExecutor(dbExecutor, sqlDialect); string filename = "DBexport_" + executor.runId + "_" + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".json"; string exportFileName = Path.Combine(saveFolder, filename); this.AsyncExecutor = new AsyncExecutor(myName, myKey, sqlDialect, exportFileName, executor, checkboxUseFS.Checked, sendFiles); this.AsyncExecutorThread = new Thread(AsyncExecutor.Run); this.AsyncExecutorThread.Start(); //new Thread(this.ShowProgress).Start(); } catch (Exception ex) { string msg = ex.Message; Logger.Log(msg); MessageBox.Show(msg); } }
/// <summary> /// 释放测试。 /// </summary> public virtual void Dispose() { if (this._Engine != null) { this._Engine.ResetContext(); } this._factory = null; this._testManager.Dispose(); }
public BaseTest() { SeleniumToolsFactory toolsFactory = new SeleniumToolsFactory(); toolsFactory.CreateInstance(); ExecutorFactory.RegisterToolFactory(toolsFactory); Driver = (IWebDriver)ExecutorFactory.GetToolFactory().GetInstance <IWebDriver>(); Driver.Navigate().GoToUrl(RunSettingsHelper.SiteUrl); }
public ExecutorBoltSchedulerProvider(Config config, ExecutorFactory executorFactory, JobScheduler scheduler, LogService logService) { this._config = config; this._executorFactory = executorFactory; this._scheduler = scheduler; this._logService = logService; this._internalLog = logService.GetInternalLog(this.GetType()); this._boltSchedulers = new ConcurrentDictionary <string, BoltScheduler>(); }
static async Task Main(string[] args) { var factory = new ExecutorFactory(); var executor = factory.GetMultiplicativePersistenceExecutor(); executor.OnResult += Executor_SubResults; await executor.Execute(); }
public ExecutorBoltScheduler(string connector, ExecutorFactory executorFactory, JobScheduler scheduler, LogService logService, int corePoolSize, int maxPoolSize, Duration keepAlive, int queueSize, ExecutorService forkJoinPool) { this._connector = connector; this._executorFactory = executorFactory; this._scheduler = scheduler; this._log = logService.GetInternalLog(this.GetType()); this._corePoolSize = corePoolSize; this._maxPoolSize = maxPoolSize; this._keepAlive = keepAlive; this._queueSize = queueSize; this._forkJoinPool = forkJoinPool; }
private List <Tuple <IInstallCmd, ICmdExecutor> > CreateCommandExecutorPairs() { var results = new List <Tuple <IInstallCmd, ICmdExecutor> >(); foreach (var cmd in CommandGroup.Commands) { var executor = ExecutorFactory.CreateForCommand(cmd); results.Add(new Tuple <IInstallCmd, ICmdExecutor>(cmd, executor)); } return(results); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void initShouldCreateThreadPool() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void InitShouldCreateThreadPool() { ExecutorFactory mockExecutorFactory = mock(typeof(ExecutorFactory)); when(mockExecutorFactory.Create(anyInt(), anyInt(), any(), anyInt(), anyBoolean(), any())).thenReturn(Executors.newCachedThreadPool()); ExecutorBoltScheduler scheduler = new ExecutorBoltScheduler(CONNECTOR_KEY, mockExecutorFactory, _jobScheduler, _logService, 0, 10, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool()); scheduler.Start(); verify(_jobScheduler).threadFactory(Group.BOLT_WORKER); verify(mockExecutorFactory, times(1)).create(anyInt(), anyInt(), any(typeof(Duration)), anyInt(), anyBoolean(), any(typeof(ThreadFactory))); }
public void ExecuteFromUntil(int begin, int end) { Task.Factory.StartNew(() => { for (int i = begin; i < end; i++) { Executor clientExecutor = ExecutorFactory.Factory(this.Logger[i], i + 1); // Add request to queue Log.Debug($"Trying to add request #{opNumber} in the Execution Queue"); OrderedQueue.AddRequestToQueue(this, this.Logger[i], clientExecutor); } }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shutdownShouldTerminateThreadPool() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShutdownShouldTerminateThreadPool() { ExecutorService cachedThreadPool = Executors.newCachedThreadPool(); ExecutorFactory mockExecutorFactory = mock(typeof(ExecutorFactory)); when(mockExecutorFactory.Create(anyInt(), anyInt(), any(), anyInt(), anyBoolean(), any())).thenReturn(cachedThreadPool); ExecutorBoltScheduler scheduler = new ExecutorBoltScheduler(CONNECTOR_KEY, mockExecutorFactory, _jobScheduler, _logService, 0, 10, Duration.ofMinutes(1), 0, ForkJoinPool.commonPool()); scheduler.Start(); scheduler.Stop(); assertTrue(cachedThreadPool.Shutdown); }
/// <summary> /// Executes each of the given scripts against the specified database. /// </summary> /// <param name="connectionInfo">The database connection information.</param> /// <param name="scripts">The list of scripts or xml data to execute.</param> public virtual void Execute(IConnectionSettings connectionInfo, IList <IScriptFile> scripts) { Throw.If(connectionInfo, "connectionInfo").IsNull(); Throw.If(scripts, "scripts").IsNull(); IDatabase db = DatabaseConnectionFactory.CreateDbConnection(connectionInfo); foreach (IScriptFile curScript in scripts) { // I'm betting there's a pattern for this // new AbstractExecutor.Execute(db, curScript); IExecutor executor = ExecutorFactory.CreateExecutor(db, curScript); executor.Execute(db, curScript); } }
public void CreateExecutor_ThrowsIfTypeIsNotAValidReturnType(string methodName) { // Arrange var methodInfo = typeof(TestPageModel).GetMethod(methodName); var handler = new HandlerMethodDescriptor() { MethodInfo = methodInfo, Parameters = CreateParameters(methodInfo), }; // Act & Assert var ex = Assert.Throws <InvalidOperationException>(() => ExecutorFactory.CreateExecutor(handler)); Assert.Equal($"Unsupported handler method return type '{methodInfo.ReturnType}'.", ex.Message); }
private static PageHandlerExecutorDelegate[] GetHandlerExecutors(CompiledPageActionDescriptor actionDescriptor) { if (actionDescriptor.HandlerMethods == null || actionDescriptor.HandlerMethods.Count == 0) { return(Array.Empty <PageHandlerExecutorDelegate>()); } var results = new PageHandlerExecutorDelegate[actionDescriptor.HandlerMethods.Count]; for (var i = 0; i < actionDescriptor.HandlerMethods.Count; i++) { results[i] = ExecutorFactory.CreateExecutor(actionDescriptor.HandlerMethods[i]); } return(results); }
private void button1_Click(object sender, EventArgs e) { // only one execution at time is allowed, do nothing now if (this.AsyncExecutor != null) { return; } FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); try { this.SaveDialogSettings(); DBExecutor dbExecutor = new DBExecutor(); this.BuildConnectionString(dbExecutor); string myName = this.textBoxUserName.Text.ToString(); Guid myKey; if (!Guid.TryParse(this.textBoxKey.Text.ToString(), out myKey)) { throw new Exception("Invalid or missing API key! Get one at https://www.sqldep.com/browser/upload/api"); } string sqlDialect = this.GetDatabaseTypeName(this.comboBoxDatabase.SelectedIndex); List <string> failedDbs = new List <string>(); Executor executor = ExecutorFactory.CreateExecutor(dbExecutor, sqlDialect); string exportFileName = fbd.SelectedPath + "\\DBexport_" + executor.runId + "_" + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".json"; this.AsyncExecutor = new AsyncExecutor(myName, myKey, sqlDialect, exportFileName, executor); this.AsyncExecutorThread = new Thread(AsyncExecutor.Run); this.AsyncExecutorThread.Start(); new Thread(this.ShowProgress).Start(); } catch (Exception ex) { string msg = ex.Message; MessageBox.Show(msg); } }
public async Task CreateExecutor_ForMethodReturningConcreteSubtypeOfIActionResult() { // Arrange var handler = new HandlerMethodDescriptor() { MethodInfo = typeof(TestPage).GetMethod(nameof(TestPage.ConcreteActionResult)), Parameters = new HandlerParameterDescriptor[0], }; // Act var executor = ExecutorFactory.CreateExecutor(handler); // Assert Assert.NotNull(executor); var actionResultTask = executor(new TestPage(), null); var actionResult = await actionResultTask; Assert.IsType <ViewResult>(actionResult); }
public async Task CreateExecutor_ForTaskOfIActionResultReturningMethod() { // Arrange var methodInfo = typeof(TestPage).GetMethod(nameof(TestPage.GenericTaskHandler)); var handler = new HandlerMethodDescriptor() { MethodInfo = methodInfo, Parameters = CreateParameters(methodInfo), }; // Act var executor = ExecutorFactory.CreateExecutor(handler); // Assert Assert.NotNull(executor); var actionResultTask = executor(new TestPage(), null); var actionResult = await actionResultTask; Assert.IsType <EmptyResult>(actionResult); }
public void RegisterService(object service, bool isOverride) { var originalAsmName = new AssemblyName("NTSock" + service.GetType().FullName); var assemblyBuilderHelper = new AssemblyBuilderHelper(originalAsmName.Name + ".dll"); servicesLock.EnterWriteLock(); try { var serviceType = service.GetType(); var methods = serviceType.GetMethods(); if (methods != null) { for (var i = 0; i < methods.Length; i++) { var method = methods[i]; if (method.GetCustomAttributes(typeof(ServiceMethodAttribute), false).Length == 0) { continue; } var executor = ExecutorFactory.CreateExecutor(service, method, i, assemblyBuilderHelper); if (methodMaps.ContainsKey(executor.ExecutorKey)) { if (!isOverride) { throw new ArgumentException("Cannot override an existing service."); } methodMaps.Remove(executor.ExecutorKey); } methodMaps.Add(executor.ExecutorKey, executor); } ExecutorFactory.CreateProxy(service, assemblyBuilderHelper); } #if DEBUG assemblyBuilderHelper.Save(); #endif } finally { servicesLock.ExitWriteLock(); } }
public async Task CreateExecutor_ForActionResultReturningMethod_WithParameters() { // Arrange var methodInfo = typeof(TestPage).GetMethod(nameof(TestPage.ActionResultReturnHandlerWithParameters)); var handler = new HandlerMethodDescriptor() { MethodInfo = methodInfo, Parameters = CreateParameters(methodInfo), }; // Act var executor = ExecutorFactory.CreateExecutor(handler); // Assert Assert.NotNull(executor); var actionResultTask = executor(new TestPage(), CreateArguments(methodInfo)); var actionResult = await actionResultTask; var contentResult = Assert.IsType <ContentResult>(actionResult); Assert.Equal("Hello 0", contentResult.Content); }
public IStitchingBuilder AddQueryExecutor( NameString name, ExecutorFactory factory) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } name.EnsureNotEmpty(nameof(name)); if (_schemas.ContainsKey(name) || _execFacs.ContainsKey(name)) { throw new ArgumentException( StitchingResources.StitchingBuilder_SchemaNameInUse, nameof(name)); } _execFacs.Add(name, factory); return(this); }
public async Task CreateExecutor_ForVoidReturningMethod() { // Arrange var handler = new HandlerMethodDescriptor() { MethodInfo = typeof(TestPage).GetMethod(nameof(TestPage.VoidReturningHandler)), Parameters = new HandlerParameterDescriptor[0], }; var page = new TestPage(); // Act var executor = ExecutorFactory.CreateExecutor(handler); // Assert Assert.NotNull(executor); var actionResultTask = executor(page, null); var actionResult = await actionResultTask; Assert.Null(actionResult); Assert.True(page.SideEffects); }
public void RegisterService(string serviceName, object service, bool isOverride) { servicesLock.EnterWriteLock(); try { if (methodMaps.ContainsKey(serviceName)) { if (!isOverride) { throw new ArgumentException("Cannot add service: " + serviceName); } methodMaps.Remove(serviceName); } var serviceType = service.GetType(); var methods = serviceType.GetMethods(); if (methods != null) { foreach (var method in methods) { var builder = new StringBuilder(serviceName + " " + method.Name + " "); var parameters = method.GetParameters(); if (parameters.Length > 0) { foreach (ParameterInfo parameter in parameters) { builder.Append(parameter.ParameterType + " "); } } var executor = ExecutorFactory.CreateExecutor(service, method); methodMaps.Add(builder.ToString().Trim(), executor); } } } finally { servicesLock.ExitWriteLock(); } }
public void CallCreateTest() { ExecutorFactory factory = new ExecutorFactory(new IocContainer()); //- 普通 Assert.IsType <Simple1Executor>(factory.Create(new Simple1Command()).Executor); Assert.IsType <Simple2Executor>(factory.Create(new Simple2Command()).Executor); Assert.IsType <Simple3Executor>(factory.Create(new Simple3()).Executor); //- 泛型 Assert.IsType <Simple4Executor <int, string> >(factory.Create(new Simple4 <int, string>()).Executor); Assert.Throws <NotSupportedException>(() => factory.Create(new Simple4_Error <int, string>())); //- 嵌套 Assert.IsType(Simple5 <int, string> .ExecutorType, factory.Create(new Simple5 <int, string>()).Executor); Assert.Throws <NotSupportedException>(() => factory.Create(new Simple5_Error <int, string>())); //- 特性 Assert.IsType <TestSimple6>(factory.Create(new Simple6()).Executor); //- 特性泛型 Assert.IsType <TestSimple7 <string, double> >(factory.Create(new Simple7 <string, double>()).Executor); }
public async Task Executor_Factory_Deploys_Child_Contract() { var inactivePeriod = TimeSpan.FromDays(50).Seconds; var bounty = 1000; var contract = await ExecutorFactory.DeployFactoryAsync(_web3Geth, _contractInfo); var createExecutorFunction = contract.GetFunction("createExecutor"); var gas = await createExecutorFunction.EstimateGasAsync( Credentials.Sender, Credentials.BackupAddress, inactivePeriod, bounty); var txHash = await createExecutorFunction.SendTransactionAsync( Credentials.Sender, new HexBigInteger(gas.Value), new HexBigInteger(0), Credentials.Sender, Credentials.BackupAddress, inactivePeriod, bounty); var receipt = await Miner.MineAndGetReceiptAsync(_web3Geth, txHash); var countFunction = contract.GetFunction("getExecutorsCount"); var exesCount = await countFunction.CallAsync <int>(); Assert.Equal(1, exesCount); }
public DrivingRangeController(AzureFunctionsService azureFunctionsService) { _executorFactory = new ExecutorFactory(azureFunctionsService); }
public IStitchingBuilder AddQueryExecutor( NameString name, ExecutorFactory factory) { Executors[name] = factory; return(this); }
static int Main(string[] args) { string dbType = string.Empty; string auth_type = "sql_auth"; string server = string.Empty; string port = string.Empty; string database = string.Empty; string loginName = string.Empty; string loginpassword = string.Empty; string customSqlSetName = string.Empty; string exportFileName = string.Empty; string sMyKey = string.Empty; string sendFile = string.Empty; string help = string.Empty; string driverName = string.Empty; Guid myKey; var p = new OptionSet() { { "dbType=", "database type MsSQL(mssql)/Oracle(oracle)", v => dbType = v }, { "a|auth=", "authorization SQL(default: sql_auth)/Windows (win_auth)", v => { if (v != null) { auth_type = v; } } }, { "s|server=", "server", v => server = v }, { "p|port=", "port", v => { if (v != null) { port = v; } } }, { "d|database=", "database (SID for Oracle)", v => database = v }, { "u|user="******"loginName", v => { if (v != null) { loginName = v; } } }, { "pwd|password="******"loginpassword", v => { if (v != null) { loginpassword = v; } } }, { "n|name=", "name of export", v => customSqlSetName = v }, { "f|file=", "output file", v => exportFileName = v }, { "k|key=", "api key (Guid)", v => sMyKey = v }, { "h|help", "show help", v => help = "set" }, { "driver", "driver name", v => driverName = v }, { "send=", "SEND or SENDONLY, default do not send", v => sendFile = v.ToUpper() }, }; try { p.Parse(args); if (help.Equals("set") || (args.Length == 0)) { ShowHelp(p); } else { myKey = Guid.Parse(sMyKey); DBExecutor dbExecutor = new DBExecutor(); bool runDb = (sendFile != "SENDONLY"); bool sendIt = (sendFile == "SEND" || sendFile == "SENDONLY"); string connectString = dbExecutor.BuildConnectionString(dbType, string.Empty, auth_type, server, port, database, loginName, loginpassword, driverName, DBExecutor.UseDriver.DEFAULT); dbExecutor.ConnectString = connectString; if (runDb) { dbExecutor.Connect(); } Executor executor = ExecutorFactory.CreateExecutor(dbExecutor, dbType); if (runDb) { executor.Run(customSqlSetName, myKey, dbType, exportFileName); } if (sendIt) { List <string> sendFiles = new List <string>(); FileAttributes fileattr; foreach (var item in exportFileName.Split(',')) { fileattr = File.GetAttributes(item); if ((fileattr & FileAttributes.Directory) == FileAttributes.Directory) { // add whole directory content foreach (string fileName in Directory.EnumerateFiles(item, "*.*")) { // skip inner directories fileattr = File.GetAttributes(fileName); if ((fileattr & FileAttributes.Directory) == 0) { sendFiles.Add(fileName); } } } else { sendFiles.Add(item); } } executor.SendFiles(sendFiles, sMyKey); } } } catch (Exception e) { Console.WriteLine(e.Message); return(-1); } return(0); // standard success }