Example #1
0
        public bool regis(string t1, string t2, string t3, string t4, string t5, string t6, string t7, string t8, string t9, string t10)
        {
            string[] arr = new string[10] {
                t1, t2, t3, t4, t5, t6, t7, t8, t9, t10
            };
            Access test = new Access();

            return(test.Add(arr));
        }
Example #2
0
        public DummyAuthentication()
        {
            LoggedUsers = new Dictionary <Guid, int>();
            var rolesString = Enum.GetNames(typeof(Role)).ToList();
            var values      = Enum.GetValues(typeof(Role));

            foreach (var value in values)
            {
                var hash = new Guid();
                var role = (Role)value;
                Access.Add(role, hash);
                //    GlobalAcces.Add(hash, role);
            }
        }
Example #3
0
        /// <summary>
        /// Adds a given right to a group.
        /// </summary>
        /// <param name="g">Name of the group.</param>
        /// <param name="r">Right to add.</param>
        public void AddRight(Group g, AccessRight r)
        {
            var info = FindAccessInfo(g);

            if (info != null)
            {
                info.AddRight(r);
            }
            else
            {
                Access.Add(new AccessInfo {
                    Group = g, Right = r, GroupDummy = g.Name
                });
            }
        }
Example #4
0
        public IActionResult OnGet()
        {
            var initResult = Init();

            if (initResult != null)
            {
                return(initResult);
            }

            InitPage();

            ErpRequestContext.PageContext = PageContext;
            //Add Admin as the default roles
            Access.Add(SystemIds.AdministratorRoleId.ToString());


            BeforeRender();
            return(Page());
        }
Example #5
0
        private void FindAccessNode(Node backbone)
        {
            double RM = Radius * _maxCost;

            backbone.Status = true;
            if (!_clusters.Keys.Contains(backbone))
            {
                _clusters.Add(backbone, new List <Node>());
            }
            for (int j = 0; j < NumberOfNode; j++)
            {
                if (!Nodes[j].Status && Distance(backbone, Nodes[j]) <= RM)
                {
                    _clusters[backbone].Add(Nodes[j]);
                    //Access.Add(Nodes[j], Backbones[i]);
                    Access.Add(backbone);
                    Access.Add(Nodes[j]);
                    Nodes[j].Status = true;
                }
            }
        }
Example #6
0
 public void AddToAccess()
 {
     Access.Add(this);
 }
Example #7
0
 /// <summary>
 /// Returns the last inclusive field access.
 /// </summary>
 /// <returns>The last inclusive field access.</returns>
 public FieldAccess GetLastAccess() =>
 Access.Add(IntrinsicMath.Max(Span - 1, 0));
        private void buttonSignIn_Click(object sender, EventArgs e)
        {
            var email    = textEmail.Text;
            var password = textPassword.Text;

            var passwordHash = Cryptography.EncryptSha256(password);

            Program.Connection.Connect();

            MySqlDataReader reader = Program.Connection.Execute("SELECT ",
                                                                "user.id,",
                                                                "user.nome,",
                                                                "user.email,",
                                                                "user.usuario,",
                                                                "user.status,",
                                                                "profile.nome AS perfil,",
                                                                "profile.cad_usuario,",
                                                                "profile.cad_perfil,",
                                                                "profile.cad_setor,",
                                                                "profile.cad_funcionario,",
                                                                "profile.rel_setor,",
                                                                "profile.rel_funcionario",
                                                                " FROM tb_usuario user",
                                                                " INNER JOIN tb_perfil profile ON user.id_perfil = profile.id",
                                                                $" WHERE email = '{email}' AND senha = '{passwordHash}'");

            if (reader.Read())
            {
                int    id   = Convert.ToInt16(reader["id"]);
                string name = Convert.ToString(reader["nome"]);
                email = Convert.ToString(reader["email"]);
                string username = Convert.ToString(reader["usuario"]);
                bool   status   = Convert.ToBoolean(reader["status"]);

                string profileName = Convert.ToString(reader["perfil"]);

                Access access = new Access(profileName);
                access.Add("cad_usuario", Convert.ToBoolean(reader["cad_usuario"]));
                access.Add("cad_perfil", Convert.ToBoolean(reader["cad_perfil"]));
                access.Add("cad_setor", Convert.ToBoolean(reader["cad_setor"]));
                access.Add("cad_funcionario", Convert.ToBoolean(reader["cad_funcionario"]));
                access.Add("rel_setor", Convert.ToBoolean(reader["rel_setor"]));
                access.Add("rel_funcionario", Convert.ToBoolean(reader["rel_funcionario"]));

                User user = new User(name, email, username, status);
                user.Id     = id;
                user.Access = access;

                if (user.Status)
                {
                    Program.LoggedUser = user;

                    UserForm mainForm = new UserForm();

                    mainForm.Show();

                    this.Hide();
                }

                Console.WriteLine(user.ToString());
            }
            else
            {
                error.Text = "Usuário ou senha incorretos";
            }

            Program.Connection.Disconnect();
        }
Example #9
0
 public void SetInitialDataBase(string initialDataBase)
 {
     access.Add("Data Source", initialDataBase);
 }
Example #10
0
 public void Reset()
 {
     this.access = new Access();
     access.Add("Provider", "Microsoft.ACE.OLEDB.12.0");
 }
Example #11
0
        //
        //  Function:   public void Get_List(int mode, long site_id)
        //
        //  Arguments:  int mode = Mode of list to get (0 = All Users, 1 = Only Users For This Site)
        //              long site_id = Site ID to get the list for (if mode is 1)
        //
        //  Purpose:    Gets a list of all users (mode = 0) or ones granted rights to see a site (mode = 1)
        //
        public void Get_List(int mode, long site_id = 0)
        {
            List <int> site_users = new List <int>();

            Initialize();

            // If the user name is blank then get it from the system and try to log in with AD security
            string connString = SQLConnString;

            // Query the User Database for the user
            StringBuilder query = new StringBuilder("SELECT * FROM ");

            switch (mode)
            {
            // All Users
            case 0:
                query.Append(tblUserInfo);
                query.Append(" ORDER BY User_Name");
                using (SqlConnection sqlCon = new SqlConnection(connString))
                {
                    sqlCon.Open();
                    SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                    using SqlDataReader reader = SqlCmd.ExecuteReader();
                    while (reader.Read())
                    {
                        User_ID.Add((int)reader[0]);
                        User_Name.Add(String.Format("{0}", reader[1]));
                        Access.Add((int)reader[2]);
                    }
                    sqlCon.Close();
                }
                break;

            // Site_ID users
            case 1:
                query.Append(tblSiteUsers);
                query.Append(" WHERE Site_ID = ");
                query.Append(site_id.ToString());
                // Get list of User_ID's
                using (SqlConnection sqlCon = new SqlConnection(connString))
                {
                    sqlCon.Open();
                    SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                    using SqlDataReader reader = SqlCmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Site_User_ID.Add((long)reader[0]);
                        Site_ID.Add((long)reader[1]);
                        site_users.Add((int)reader[2]);
                        User_ID.Add((int)reader[2]);
                        View_Resources.Add((bool)reader[3]);
                        Add_Resources.Add((bool)reader[4]);
                        Modify_Resources.Add((bool)reader[5]);
                        Del_Resources.Add((bool)reader[6]);
                        View_Tickets.Add((bool)reader[7]);
                        Add_Tickets.Add((bool)reader[8]);
                        Mark_Delete.Add(false);
                    }
                    sqlCon.Close();
                }

                // Convert that list to actual names for display
                foreach (int id in site_users)
                {
                    query.Clear();
                    query.Append("SELECT * FROM ");
                    query.Append(tblUserInfo);
                    query.Append(" WHERE User_ID = ");
                    query.Append(id.ToString());
                    using (SqlConnection sqlCon = new SqlConnection(connString))
                    {
                        sqlCon.Open();
                        SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                        using SqlDataReader reader = SqlCmd.ExecuteReader();
                        while (reader.Read())
                        {
                            User_Name.Add(String.Format("{0}", reader[1]));
                        }
                        sqlCon.Close();
                    }
                }
                break;
            }
        }
Example #12
0
 public void Start()
 {
     Access.Add(this);
 }