예제 #1
0
        public Guid VerifyDetails(string username, string password, string consultant, string trainee)
        {
            // Get the type_id of part of the application
            string type_id = GetAppType(consultant);

            // Get the type_id of part of the application
            string type_id2 = GetAppType(trainee);

            // Get list of usernames and passwords of relevant type of user
            string qry = "SELECT user_id, username, password FROM FDMUser WHERE type_id = '" + type_id + "' OR type_id = '" + type_id2 + "'";
            IReadOneCommand cmd = new ReadOneCommand();
            string u = cmd.Execute(qry);

            // Compare inputs with usernames and passwords of users
            for (int i = 1; i < u.Count(); i += 3)
            {
                // if the username matches, check the password
                if (username == u[i].ToString())
                {
                    // if the password matches as well - success
                    if (password == u[i + 1].ToString())
                    {
                        ISessionControlCommand sessionControl = new SessionControlCommand();
                        return sessionControl.SessionStart(int.Parse(u), int.Parse(type_id));
                    }
                }
            }
            return Guid.Empty;
        }
예제 #2
0
        public void TerminateSession(Guid sessionId)
        {
            Console.WriteLine(sessionId);
            ISessionControlCommand sessionControl = new SessionControlCommand();

            sessionControl.EndSession(sessionId);
        }
예제 #3
0
        public Guid VerifyDetails(string username, string password, string type)
        {
            // Get the type_id of the application
            int type_id = int.Parse(GetAppType(type));

            // Get userid from username and password
            string          qry = "SELECT user_id FROM FDMUser WHERE username = '******' AND password = '******'";
            IReadOneCommand cmd = new ReadOneCommand();
            string          u   = cmd.Execute(qry);

            Console.WriteLine(u.Count());
            if (u != "")
            {
                string          qry2 = "SELECT type_id FROM FDMUser WHERE user_id = " + u;
                IReadOneCommand cmd2 = new ReadOneCommand();
                string          t    = cmd.Execute(qry2);

                if (int.Parse(t) == type_id)
                {
                    ISessionControlCommand sessionControl = new SessionControlCommand();
                    return(sessionControl.SessionStart(int.Parse(u), int.Parse(t)));
                }
            }
            return(Guid.Empty);
        }
예제 #4
0
        public Guid VerifyDetails(string username, string password, string consultant, string trainee)
        {
            // Get the type_id of part of the application
            string type_id = GetAppType(consultant);

            // Get the type_id of part of the application
            string type_id2 = GetAppType(trainee);

            // Get list of usernames and passwords of relevant type of user
            string          qry = "SELECT user_id, username, password FROM FDMUser WHERE type_id = '" + type_id + "' OR type_id = '" + type_id2 + "'";
            IReadOneCommand cmd = new ReadOneCommand();
            string          u   = cmd.Execute(qry);

            // Compare inputs with usernames and passwords of users
            for (int i = 1; i < u.Count(); i += 3)
            {
                // if the username matches, check the password
                if (username == u[i].ToString())
                {
                    // if the password matches as well - success
                    if (password == u[i + 1].ToString())
                    {
                        ISessionControlCommand sessionControl = new SessionControlCommand();
                        return(sessionControl.SessionStart(int.Parse(u), int.Parse(type_id)));
                    }
                }
            }
            return(Guid.Empty);
        }
예제 #5
0
 public void Test_FindUserClass_GetUserIdBySessionIdMethod_Returns_Correct_UserId()
 {
     FindUser user = new FindUser();
     SessionControlCommand cmd = new SessionControlCommand();
     Guid session_id = cmd.SessionStart(1, 3);
     Assert.AreEqual("katie.hodgkiss", user.GetUsernameBySessionId(session_id));
 }
예제 #6
0
 public void Test_FindUserClass_GetUserIdBySessionIdMethod_Returns_An_Int()
 {
     FindUser user = new FindUser();
     SessionControlCommand cmd = new SessionControlCommand();
     Guid session_id = cmd.SessionStart(1, 3);
     Assert.IsInstanceOf(typeof(string), user.GetUsernameBySessionId(session_id));
 }
예제 #7
0
        public Guid VerifyDetails(string username, string password, string consultant, string trainee)
        {
            // Get the type_id of part of the application
            string type_id = GetAppType(consultant);

            // Get the type_id of part of the application
            string type_id2 = GetAppType(trainee);

            // Get list of usernames and passwords of relevant type of user
            string       qry = "SELECT user_id, username, password FROM FDMUser WHERE type_id = " + type_id + " OR type_id = " + type_id2;
            IReadCommand cmd = new ReadCommand();

            List <DbUser> u = new List <DbUser>();


            DataTable dt = cmd.Execute(qry);

            u = (from DataRow row in dt.Rows

                 select new DbUser
            {
                UserId = (int)row["USER_ID"],
                Username = row["USERNAME"].ToString(),
                Password = row["PASSWORD"].ToString()
            }).ToList();

            // Compare inputs with usernames and passwords of users
            for (int i = 1; i < u.Count(); i += 3)
            {
                // if the username matches, check the password
                if (username == u[i].ToString())
                {
                    // if the password matches as well - success
                    if (password == u[i + 1].ToString())
                    {
                        ISessionControlCommand sessionControl = new SessionControlCommand();
                        return(sessionControl.SessionStart(int.Parse(u[i].UserId.ToString()), int.Parse(type_id)));
                    }
                }
            }
            return(Guid.Empty);
        }
예제 #8
0
        public Guid VerifyDetails(string username, string password, string type)
        {
            // Get the type_id of the application
            string type_id = GetAppType(type.ToLower());

            string qry = "SELECT user_id, username, password FROM FDMUser WHERE type_id = " + type_id;

            // Get list of usernames and passwords of relevant type of user
            IReadCommand cmd = new ReadCommand();
            List<DbUser> u = new List<DbUser>();

            DataTable dt = cmd.Execute(qry);

            u = (from DataRow row in dt.Rows

                     select new DbUser
                     {
                         UserId = (int)row["USER_ID"],
                         Username = row["USERNAME"].ToString(),
                         Password = row["PASSWORD"].ToString()

                     }).ToList();

            //Guid g = new Guid("{00000000 - 0000 - 0000 - 0000 - 000000000000}");

            // Compare inputs with usernames and passwords of users
            for (int i = 1; i < u.Count(); i+=3)
            {
                // if the username matches, check the password
                if (username == u[i].ToString())
                {
                    // if the password matches as well - success
                    if (password == u[i+1].ToString())
                    {
                        ISessionControlCommand sessionControl = new SessionControlCommand();
                        return sessionControl.SessionStart(int.Parse(u[i].UserId.ToString()), int.Parse(type_id));
                    }
                }
            }
            return Guid.Empty;
        }
예제 #9
0
        public Guid VerifyDetails(string username, string password, string type)
        {
            // Get the type_id of the application
            int type_id = int.Parse(GetAppType(type));

            // Get userid from username and password
            string qry = "SELECT user_id FROM FDMUser WHERE username = '******' AND password = '******'";
            IReadOneCommand cmd = new ReadOneCommand();
            string u = cmd.Execute(qry);
            Console.WriteLine(u.Count());
            if (u != "")
            {
                string qry2 = "SELECT type_id FROM FDMUser WHERE user_id = " + u;
                IReadOneCommand cmd2 = new ReadOneCommand();
                string t = cmd.Execute(qry2);

                if (int.Parse(t) == type_id)
                {
                    ISessionControlCommand sessionControl = new SessionControlCommand();
                    return sessionControl.SessionStart(int.Parse(u), int.Parse(t));
                }
            }
                return Guid.Empty;
        }
예제 #10
0
        public void TerminateSession(Guid sessionId)
        {
            ISessionControlCommand sessionControl = new SessionControlCommand();

            sessionControl.EndSession(sessionId);
        }
예제 #11
0
 public void TerminateSession(Guid sessionId)
 {
     Console.WriteLine(sessionId);
     ISessionControlCommand sessionControl = new SessionControlCommand();
     sessionControl.EndSession(sessionId);
 }
예제 #12
0
 public void TerminateSession(Guid sessionId)
 {
     ISessionControlCommand sessionControl = new SessionControlCommand();
     sessionControl.EndSession(sessionId);
 }