async Task _getReadersTestAsync() { 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; var drs = await ctx.GetReadersAsync(@" Select * From PayDocs Where Handle = @handle; Select * From PayDocs Where Handle = @handle1 Select * From PayDocs Where Handle = @handle1+1" , new MdbParameter("@handle", 3999750), new MdbParameter("@handle1", 3999751) ); foreach (var dr in drs) { using (dr) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } } l.Debug($"Test 1 Finish rows result {i}"); } } }
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 GetSysCatReadersTest() { using (FileLog l = new FileLog("MdbContextTest", new FileLogSettings() { DateFolderMask = "yyyy-MM-dd" })) { MdbContextOptions.GetOptions().CommandTimeout = 120; using (var ctx = new MdbContext(_syscat)) { l.Debug("Test 1 Start "); int i = 0; var drs = ctx.GetReaders(@" select u.ID ,u.StructuralUnitID ,u.AccessLevelID ,u.UserName ,COALESCE(u.DomainName, '') as DomainName ,COALESCE(u.PersonID, 0) as PersonID ,COALESCE(u.Name, '') as Name ,COALESCE(u.JData, '') as JData from Users u where u.UserName LIKE '{0}'; select Upper(r.RoleName) as RoleName from Users u inner join Users2Roles ur on u.ID = ur.UserID inner join Roles r on r.ID = ur.RoleID where u.UserName LIKE '{0}'" .ToFormat(@"DESKTOP-14MM2MF\sergey") ); foreach (var dr in drs) { using (dr) { for (; dr.Read(); i++) { l.Debug(dr.GetRowJSON()); } } } l.Debug($"Test 1 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}"); } } }
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}"); } } }