public Session StartSession(Account anAccount)
 {
     if (anAccount == null)
     {
         throw new ArgumentNullException("Account can not be null!");
     }
     else
     {
       return   AccountServiceCore.NewSession(anAccount);
     }
 }
        public static Session NewSession(Account anAccount)
        {
            if (SystemAccountDao.IsExist(anAccount.Name))
            {
                SystemAccount sysAccount = SystemAccountDao.Login(anAccount);
                Session session = new Session(sysAccount);

                sessionList.Add(session, DateTime.Now);
                return session;
            }
            else
            {
                return null;
            }
        }
        public static SystemAccount Login(Account anAccount)
        {
            List<string> roles = new List<string>();
               using (SqlConnection conn = Utilities.GetConnection())
               {
               SqlCommand comm = new SqlCommand(@"select UserName, Status
                                                                                from ApplicationUser
                                                                                where AccountName = @accountName and Password=@pwd", conn);
               comm.Parameters.Add("@accountName", SqlDbType.VarChar, 255);
               comm.Parameters.Add("@pwd", SqlDbType.VarChar, 255);
               comm.Parameters["@accountName"].Value = anAccount.Name;
               comm.Parameters["@pwd"].Value = anAccount.Password;
               try
               {
                   conn.Open();

                   SqlDataReader reader = comm.ExecuteReader();

                   if (reader.Read())
                   {
                       SystemAccount account = new SystemAccount();
                       account.Status =(AccountStatus)Enum.Parse(typeof(AccountStatus),reader["Status"].ToString());
                       account.UserId = anAccount.Name;
                       account.UserName = reader["UserName"].ToString();
                       account.UserRole = GetRoles(account);

                       return account;
                   }
                   else return null;
               }
               catch (SqlException sqlException)
               {
                   throw new HCSMSException(sqlException.Message);
               }
               finally
               {
                   if (conn != null)
                   {
                       conn.Close();
                   }
               }
               }
        }
Exemplo n.º 4
0
 private void LoginForm_Load(object sender, EventArgs e)
 {
     account = new Account();
     aUI = new LoginUI(account);
 }
Exemplo n.º 5
0
 public LoginUI(Account acc)
 {
     this.Account = acc;
 }