/// <summary> /// 注册所有需要使用的包 /// </summary> /// <param name="RequireManager"></param> /// <param name="options"></param> public static void Register(RequireManager RequireManager, TabrisOptions options = null) { //tabris RequireManager.RegisterPackage(new TabrisPackage()); //sql SqlPackageHelpers.RegisterPackage(RequireManager, options?.DbExecutor ?? new AntOrmDbExecutor()); //http HttpPackageHelpers.RegisterPackage(RequireManager); //log LogPackageHelpers.RegisterPackage(RequireManager, options?.LogExecutor); }
public async void TestSql1() { var subject = new TestObject(); var manager = new RuntimeManager(new ManualManagerSettings { ScriptTimeoutMilliSeconds = 0 }); SqlPackageHelpers.RegisterPackage(manager.RequireManager, new AntOrmDbExecutor()); manager.AddConsoleReference = true; var options = new ExecutionOptions(); options.HostObjects.Add(new HostObject { Name = "subject", Target = subject }); var code = "var dbFactory = require('javascript_sql_factory');" + "var content = this.dbFactory.create({name:'testorm',type:'mysql'});" + //"subject.StatusCode = content.ExecuteNonQuery(\"update school set address ='1' where id = 1\");"; "var arr = content.insert(\"insert into school (name,address,datachange_lasttime) values (@name,@address,now())\",{name:'test111',address:'wowowo'});"; await manager.ExecuteAsync("testScript", code, options); subject.StatusCode.ShouldEqual(0); }
public async void TestSql1() { var subject = new TestObject(); var manager = new RuntimeManager(new ManualManagerSettings { ScriptTimeoutMilliSeconds = 0 }); SqlPackageHelpers.RegisterPackage(manager.RequireManager, new AntOrmDbExecutor()); manager.AddConsoleReference = true; var options = new ExecutionOptions(); options.HostObjects.Add(new HostObject { Name = "subject", Target = subject }); var code = "var dbFactory = require('javascript_sql_factory');" + "var content = this.dbFactory.create('testorm','mysql');" + //"subject.StatusCode = content.ExecuteNonQuery(\"update school set address ='1' where id = 1\");"; "var arr = content.query(\"SELECT DataChange_LastTime FROM school LIMIT 1\");Console.WriteLine(arr.ToString('yyyy-MM-dd'))"; await manager.ExecuteAsync("testScript", code, options); subject.StatusCode.ShouldEqual(0); }