public ActionInfo GetActionInfo(string actionID) { actionID.NullTest(nameof(actionID)); if (!_actionsCache.TryGetValue(actionID, out ActionInfo ai)) { using (var dr = SysCatDbContext.GetReader(_sql_actions.ToFormat(actionID, _schemaName))) { if (dr.Read()) { ai = SetActionAttributes(dr); } } if (ai != null) { using (var dr = SysCatDbContext.GetReader(_sql_parameters.ToFormat(ai.IID, _schemaName))) { ParamInfoList pil = ai.InterfaceParameters; for (; dr.Read();) { pil.Add(SetParamAttributes(dr)); } } } else { throw new KeyNotFoundException($"Action {actionID} not found"); } _actionsCache.TryAdd(actionID, ai); } return(ai); }
public void ExecuteTest() { using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" })) { MdbContextOptions.GetOptions().CommandTimeout = 120; using (var ctx = new MdbContext(_cn)) { l.Debug("Test 1 Start "); int i = 0; string sql = @"Create Table TestTable( ID uniqueidentifier not null primary key, Name varchar(128) not null, DateOper datetime not null, Notes varchar(256) null, Handle int not null)" ; i = ctx.Execute(sql); l.Debug($"Test 1 Finish rows result {i}"); l.Debug("Test 2 Start "); sql = @"Insert Into TestTable (ID, Name, DateOper, Handle) Values(@ID, @Name, @DateOper, @Handle)" ; i = 0; for (; i < 1000; i++) { ctx.Execute(sql, new MdbParameter("@ID", Guid.NewGuid()), new MdbParameter("@Name", "Тестовая строка № " + i.ToString()), new MdbParameter("@DateOper", vbo.Date().AddDays(i - 1000)), new MdbParameter("@Handle", i) { NullIfEmpty = false });; } l.Debug($"Test 2 Finish rows result {i}"); l.Debug("Test 3 Start "); i = 0; using (var dr = ctx.GetReader("Select * From TestTable Order By Handle")) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } l.Debug($"Test 3 Finish rows result {i}"); l.Debug("Test 4 Start "); sql = "Drop Table TestTable"; i = ctx.Execute(sql); l.Debug($"Test 4 Finish rows result {i}"); } } }
public void GetReaderSpeedTest() { using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" })) { DateTime t = DateTime.MinValue; //Caching pool int i = 0; for (i = 0; i < 100; i++) { using (var ctx = new MdbContext(_cn)) { } } using (var ctx = new MdbContext(_cn)) { l.Debug("SpeedTest 1 Start "); MdbContextOptions.GetOptions().CommandTimeout = 120; for (i = 0; i < 1000; i++) { using (var dr = ctx.GetReader("Select * From PayDocs Where Handle = @handle", new MdbParameter("@handle", 3999758))) { dr.Read(); } } l.Debug($"SpeedTest 1 Finish {i} count result {i}"); l.Debug("SpeedTest 2 Start "); for (i = 0; i < 1000; i++) { using (var dr = ctx.GetReader("Select * From PayDocs Where Handle = @handle", "@handle", 3999758)) { dr.Read(); } } l.Debug($"SpeedTest 2 Finish {i} count result {i}"); } } }
static void selectTestTable(MdbContext ctx, FileLogger l) { l.Debug("Select Test Table Start"); int i = 0; using (var dr = ctx.GetReader("Select * From TestTable Order By Handle")) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } l.Debug($"Select Test Table Finish rows result {i}"); }
public void GetReaderTest() { using (FileLogger l = new FileLogger("MdbContextTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" })) { MdbContextOptions.GetOptions().CommandTimeout = 120; using (var ctx = new MdbContext(_cn)) { l.Debug("Test 1 Start "); int i = 0; using (var dr = ctx.GetReader("Select * From PayDocs Where Handle In @handle", "@handle", Enumerable.Range(3999750, 100))) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } l.Debug($"Test 1 Finish rows result {i}"); l.Debug("Test 2 Start "); i = 0; using (var dr = ctx.GetReader("Select * From PayDocs Where Handle = @handle", "@handle", 3999750)) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } l.Debug($"Test 2 Finish rows result {i}"); l.Debug("Test 3 Start "); i = 0; using (var dr = ctx.GetReader("Select * From PayDocs Where DateOper Between @d1 And @d2", "@d1", vbo.Date().AddDays(-4), "@d2", vbo.Date())) { for (; dr.Read();) { i++; } } l.Debug($"Test 3 Finish rows result {i}"); l.Debug("Test 4 Start "); i = 0; using (var dr = ctx.GetReader("Select * From PayDocs Where DateOper In @handle", "@handle", Enumerable.Range(1, 5).Select(item => vbo.Date().AddDays(-5).AddDays(item)))) { for (; dr.Read();) { i++; } } l.Debug($"Test 4 Finish rows result {i}"); l.Debug("Test 5 Start "); i = 0; using (var dr = ctx.GetReader(@"Select * From PayDocs Inner Join Memorials On PayDocs.DocId = Memorials.DocId Where DateOper In @handle And Contents Like @RUR" , "@handle", Enumerable.Range(1, 5).Select(item => vbo.Date().AddDays(-5).AddDays(item)), "@RUR", "%'RUB'%")) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } l.Debug($"Test 5 Finish rows result {i}"); l.Debug("Test 6 Start "); i = 0; using (var dr = ctx.GetReader("Select * From PayDocs Where DateOper Between @d1 And @d2", new MdbParameter("@d1", vbo.Date().AddDays(-4)), new MdbParameter("@d2", vbo.Date()))) { for (; dr.Read();) { i++; } } l.Debug($"Test 6 Finish rows result {i}"); l.Debug("Test 7 Start "); i = 0; using (var dr = ctx.GetReader("select * from VClients where clnum between 37361-100 and 37361")) { DisplayData(dr.ToDataTable(), l); } l.Debug($"Test 7 Finish rows result {i}"); } } }