Example #1
0
        public int NewUserId(bool isPerson = true)
        {
            int?untn = isPerson ? QM.QueryInteger(Connection, "select untn from v_kadr_fin k where not exists(select null from user_name u where u.untn = k.untn) and k.r_u = 'Работает' and rownum < 2", null) : null;

            var username = RandomString(10);

            using (var fsis = new OracleConnection("Direct=True;User Id = fsis;Password=fs;Host=testfin;SID=B;Port=1521;Pooling=false"))
            {
                fsis.Open();

                var command = new OracleCommand
                {
                    Connection  = fsis,
                    CommandType = System.Data.CommandType.StoredProcedure,
                    CommandText = "create_username"
                };

                command.Parameters.Add("p_username", username);
                command.Parameters.Add("p_untn", untn);

                command.ExecuteNonQuery();

                fsis.Commit();
            }

            Commit();

            return(NUserPack.GetUserId(Connection, username));
        }
Example #2
0
        internal int RandomUntn()
        {
            var max = (int)QM.QueryInteger(Connection, "select max(untn) from v_kadr_fin", new object[0]);

            max = random.Next(max);

            return((int)QM.QueryInteger(Connection, "select max(untn) from v_kadr_fin where untn<:0", new object[] { max }));
        }
Example #3
0
        internal void AddPermission(string username, Permission permission)
        {
            var roleName = GetRoleName(permission);

            var roleId = QM.QueryInteger(connection, "select agr_role_id from agr_role where agr_role=:0", roleName);

            if (roleId == null)
            {
                throw new Exception($"role not found {roleName}");
            }

            var userId = NUserPack.GetUserId(connection, username.ToUpper());

            if (AgrAppPkg.UserHasRole(connection, userId, (int)roleId))
            {
                return;
            }

            AgrCorePkg.GrantRoleToUser(connection, (int)roleId, userId, true);
        }