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}"); } } }
/// <summary> /// Null - if login not found no catalog /// </summary> /// <param name="login"></param> /// <returns></returns> public virtual async Task <UserInfo> GetUserInfoAsync(string login) { var dr = await mdb.GetReadersAsync(_sql_get_user_info_2.ToFormat(login)); UserInfo ui = null; if (dr[0].Read()) { ui = JsonSerializer.DeserializeObject <UserInfo>((string)dr[0]["JData"]); ui.StructuralUnitID = (int)dr[0]["StructuralUnitID"]; ui.AccessLevelID = (int)dr[0]["AccessLevelID"]; ui.PersonID = dr[0]["PersonID"].CastAs <int>(); ui.DomainName = (string)dr[0]["DomainName"]; ui.Name = (string)dr[0]["Name"]; ui.Roles.Clear(); ui.UserPermissions.Clear(); if (dr[1].Read()) { ui.Roles.Add((string)dr[1]["RoleName"]); } for (; dr[2].Read();) { ui.UserPermissions.Add(new Permission() { ActionID = (string)dr[2]["ActionID"], ObjectName = (string)dr[2]["ObjectName"], RoleID = (string)dr[2]["RoleID"], IsGranted = (bool)dr[2]["IsGranted"] }); } } dr[0].Dispose(); dr[1].Dispose(); dr[2].Dispose(); return(ui); }