コード例 #1
0
        /*
         * 1 Successfull
         * 2 Invalid User
         * 3 E-mail Address not found
         * 4 Unable to send E-mail - contact administrator
         * 5 E-mail successfully sent
         */
        public int forgotPassword(string userName,string message)
        {
            string newPassword = System.Web.Security.Membership.GeneratePassword(8, 2);
            int flag = 2;//Invalid user

            AccountDAO acc_context = new AccountDAO();
            ContactInfoDAO con_context = new ContactInfoDAO();

            if (acc_context.isFound(userName))
            {
                if (con_context.isFound(userName, "e-mail"))
                {
                    ContactInfoDTO email = con_context.find(userName, "e-mail");
                    AccountDTO account = acc_context.find(userName);
                    account.password = newPassword;
                    acc_context.merge(account);

                    message.Replace("PASSWORD", newPassword);
                    flag = sendMail(email.data, message);

                }
                else
                {
                    flag = 3; //Email Address not found
                }

            }
            return flag;
        }
コード例 #2
0
        public void AccountDAO_Test()
        {
            /*Context*/
            AccountDAO target = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            string userName = "******"; // TODO: Initialize to an appropriate value
            Assert.AreEqual(false, target.isFound(userName));
            Assert.AreEqual(true,target.presist(acc));

            Assert.AreEqual(true, target.isFound(userName));//

            /*Update*/
            acc.status = "inactive";
            target.merge(acc);

            string expectedUpdate = "inactive";
            AccountDTO upd =  target.find("griddy");
            Assert.AreEqual(expectedUpdate, upd.status);

            /*Delete*/
            Assert.AreEqual(false, target.removeByUserId("griddy"));
        }
コード例 #3
0
        public void LicenseDAOConstructorTest()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            LicenseDAO lic_context = new LicenseDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LicenseDTO lic = new LicenseDTO();
            lic.userName = "******";
            lic.type = "car";

            lic_context.presist(lic);
            Assert.AreEqual(lic.type, lic_context.find("john","car").type);

            /*Update*/
            //N/A

            /*Delete*/
            lic_context.removeByUserId("john","car");
            Assert.AreEqual(lic_context.isFound("john","car"), false);

            acc_context.removeByUserId("john");
        }
コード例 #4
0
        public void SupportDocDAOConstructorTest()
        {
            /*context*/
            SupportDocDAO sup_context = new SupportDocDAO(); // TODO: Initialize to an appropriate value
            AccountDAO acc_context = new AccountDAO();
            /*insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            SupportDocDTO supp = new SupportDocDTO();
            supp.userName = "******";
            byte[] bits = { 1, 0, 1, 0, 0, 1 };
            supp.content = bits;
            supp.description = "Supporting doc";
            supp.title = "help";

            sup_context.presist(supp);
            Assert.AreEqual(supp.title, sup_context.find("john", "help").title);
            /*Update*/
            supp.description = "NEW doc";
            sup_context.merge(supp);
            Assert.AreEqual("NEW doc", sup_context.find("john", "help").description);

            /*Delete*/
            sup_context.removeByUserId("john", "help");
            Assert.AreEqual(sup_context.isFound("john", "help"), false);
            acc_context.removeByUserId("john");
        }
コード例 #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AccountDAO context = new AccountDAO();
            AccountDTO acc = new AccountDTO();
            if (!context.isFound("skippy"))
                Label1.Text = "Not found";
            else
                Label1.Text = "Found";
            acc.userName = null;
            acc.password = "******";
            acc.accountType = "admin";
            acc.status = "active";

            context.presist(acc);

            acc.userName = "******";

            if( !   context.presist(acc) )
                Label2.Text = "Error";
            else
                Label2.Text = "OK";

            //if(context.isFound("skippy"))
            //    text = "found";
            //else
            //TextBox1.Text = "not found";
        }
コード例 #6
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            DAO_Account_Interface user_ctx = new AccountDAO();
            if (user_ctx.isFound(txtUserName.Text))
            {
                btnValidUser.Enabled = false;
                btnDelUser.Enabled = true;
                btnResetPassword.Enabled = true;
                txtStatus.Text = "";
                txtUserName.Enabled = false;

                if (service.isAccountBlocked(txtUserName.Text))
                    btnUnblock.Enabled = true;
                else
                    btnUnblock.Enabled = false;

            }
            else
            {
                btnValidUser.Enabled = true;
                btnResetPassword.Enabled = false;
                btnDelUser.Enabled = false;
                btnResetPassword.Enabled = false;
                txtStatus.Text = "Invalid User Name Entered!";
                txtUserName.Enabled = true;
            }
        }
コード例 #7
0
        public void lockAccount(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.LOCKED.ToString();
            accountDao.merge(accountDto);
        }
コード例 #8
0
        public void requestAccountUnlock(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.UNLOCKED.ToString();
            accountDao.merge(accountDto);
        }
コード例 #9
0
        public void setAccountActive(String username)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.status = AccountStatus.ACTIVE.ToString();
            accountDao.merge(accountDto);
        }
コード例 #10
0
        public void setUserRole(String username, AccountType accountType)
        {
            AccountDAO accountDao = new AccountDAO();
            AccountDTO accountDto = accountDao.find(username);

            accountDto.accountType = accountType.ToString();
            accountDao.merge(accountDto);
        }
コード例 #11
0
        public void ApplicationDAO_Test()
        {
            AccountDAO account_context = new AccountDAO();
            ApplicationDAO app_context = new ApplicationDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);
            bool expectedVac = true;
            bool actualVac;
            actualVac = vac_context.isFound("1");
            Assert.AreEqual(expectedVac, actualVac);

            ApplicationDTO application = new ApplicationDTO();
            application.userName = "******";
            application.vacancyNumber = "1";
            application.status = "open";

            app_context.presist(application);
            bool expected = true;
            bool actual;
            actual = app_context.isFound("griddy", "1");
            Assert.AreEqual(expected, actual);

            /*Update*/
            application.status = "closed";
            expected = true;
            actual = app_context.merge(application);
            Assert.AreEqual(expected, actual);

            /*Delete*/
            Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true);
            Assert.AreEqual(vac_context.removeByUserId("1"), true);
            Assert.AreEqual(account_context.removeByUserId("griddy"), true);
        }
コード例 #12
0
        public void inboxMessagesTest()
        {
            InboxService inboxService = new InboxServiceImpl();

            /*Context*/
            InboxDAO inbox_context = new InboxDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            InboxDTO inbox = new InboxDTO();
            inbox.date = new DateTime(2012, 9, 30);
            inbox.message = "success";
            inbox.messageId = 1;
            inbox.unread = "unread";
            inbox.userName = "******";

            inbox_context.presist(inbox);

            bool expected = true;
            bool actual;
            actual = inbox_context.isFound("griddy", 1);
            Assert.AreEqual(expected, actual);

            //Test getInboxMessagesByDate method
            Assert.AreEqual(true, inboxService.hasUnreadMessage("griddy"));

            //Test getInboxMessagesByMessage method
            int inboxMessageNumber = inboxService.getNumberOfInboxMessages("griddy");
            Assert.AreEqual(1, inboxMessageNumber);

            //Test setMessagesRead method
            inboxService.setMessagesRead("griddy", 1);
            InboxMessageSearchService inboxSearchService = new InboxMessageSearchServiceImpl();
            List<InboxDTO> inboxDtoList = inboxSearchService.getInboxMessagesByUsername("griddy");

            Assert.AreEqual("read", inboxDtoList[0].unread);
            inboxDtoList.RemoveRange(0, inboxDtoList.Count);
            inboxDtoList = null;
            inbox = null;

            /*Delete*/
            inbox_context = new InboxDAO();
            inbox_context.removeByUserId("griddy", 1);
            bool expectedDelete = false;
            bool actualDelete = inbox_context.isFound("griddy", 1);
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
コード例 #13
0
        public void securityServiceTest()
        {
            SecurityService sercutiryService = CreateSecurityService(); // TODO: Initialize to an appropriate value

            /*Context*/
            AccountDAO target = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = AccountType.USER.ToString();
            acc.status = "active";

            target.presist(acc);

            string username = "******"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.isFound(username);
            Assert.AreEqual(expected, actual);

            //sercutiryService.resetPassword(username);

            sercutiryService.lockAccount(username);
            target = new AccountDAO();
            AccountDTO account = target.find(username);
            Assert.AreEqual(AccountStatus.LOCKED.ToString(), account.status);

            sercutiryService.activateAccount(username);
            target = new AccountDAO();
            AccountDTO account2 = target.find(username);
            Assert.AreEqual(AccountStatus.ACTIVE.ToString(), account2.status);

            sercutiryService.setUserRole(username, AccountType.MANAGER);
            target = new AccountDAO();
            AccountDTO account3 = target.find(username);
            Assert.AreEqual(AccountType.MANAGER.ToString(), account3.accountType);

            sercutiryService.requestAccountUnlock(username);
            target = new AccountDAO();
            AccountDTO account4 = target.find(username);
            Assert.AreEqual(AccountStatus.UNLOCKED.ToString(), account4.status);

            sercutiryService.setAccountActive(username);
            target = new AccountDAO();
            AccountDTO account5 = target.find(username);
            Assert.AreEqual(AccountStatus.ACTIVE.ToString(), account5.status);

            /*Delete*/
            target.removeByUserId("griddy");
            bool expectedDelete = false;
            bool actualDelete = target.isFound("griddy");
            Assert.AreEqual(expectedDelete, actualDelete);
        }
コード例 #14
0
        public void EmploymentDAO_Test()
        {
            /*Context*/
            EmploymentDAO emp_context = new EmploymentDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            EmploymentDTO employment = new EmploymentDTO();
            employment.company = "fuzion";
            employment.country = "SA";
            employment.currentEmployer = "Apple";
            employment.empType = "Contract";
            employment.endDate = new DateTime(2012, 12, 30);
            employment.gross = 10000;
            employment.industry = "IT";
            employment.province = "WP";
            employment.responsibilities = "web development";
            employment.startDate = new DateTime(2012, 6, 7);
            employment.title = "web developer";
            employment.town = "cape town";
            employment.userName = "******";

            emp_context.presist(employment);

            bool expected = true;
            bool actual;
            actual = emp_context.isFound("griddy", new DateTime(2012, 6, 7) );
            Assert.AreEqual(expected, actual);

            /*Update*/
            employment.gross = 125000;
            emp_context.merge(employment);

            double expectedUpdate = 125000;
            EmploymentDTO contUpd = emp_context.find("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedUpdate, contUpd.gross);

            /*Delete*/
            emp_context.removeByUserId("griddy", new DateTime(2012, 6, 7));
            bool expectedDelete = false;
            bool actualDelete = emp_context.isFound("griddy", new DateTime(2012, 6, 7));
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
コード例 #15
0
 public Server()
 {
     ServerLog logWindow = new ServerLog();
     this.logger = logWindow.logger;
     accountDAO = new AccountDAOImplementation(this.logger);
     accountDAO.loadAccounts();
     accountDAO.loadCards();
     authService = new AuthenticationService(accountDAO);
     accountService = new AccoutService(accountDAO, this.logger);
     logWindow.Show();
     this.logger("Server Started");
 }
コード例 #16
0
        public void HigherEducation_Test()
        {
            /*Context*/
            HigherEducationDAO higher_context = new HigherEducationDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            HigherEducationDTO higherEdu = new HigherEducationDTO();
            higherEdu.userName = "******";
            higherEdu.country = "SA";
            higherEdu.educationType = "BTECH";
            higherEdu.industry = "Information Technology";
            higherEdu.institution = "CPUT";
            higherEdu.length = "four years";
            higherEdu.major = "Technical Programming";
            higherEdu.nqf = "7";
            higherEdu.province = "WP";
            higherEdu.town = "Cape Town";

            higher_context.presist(higherEdu);

            bool expected = true;
            bool actual;
            actual = higher_context.isFound("griddy", "Technical Programming");
            Assert.AreEqual(expected, actual);

            /*Update*/
            higherEdu.institution = "UWC";
            higher_context.merge(higherEdu);

            string expectedUpdate = "UWC";
            HigherEducationDTO contUpd = higher_context.find("griddy", "Technical Programming");
            Assert.AreEqual(expectedUpdate, contUpd.institution);

            /*Delete*/
            higher_context.removeByUserId("griddy", "Technical Programming");
            bool expectedDelete = false;
            bool actualDelete = higher_context.isFound("griddy", "Technical Programming");
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
コード例 #17
0
        public void BasicEduSubject_Test()
        {
            /*Context*/
            BasicEduSubjectDAO basicEdu_context = new BasicEduSubjectDAO();
            BasicEduDAO edu_context = new BasicEduDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            BasicEduDTO basic_Edu = new BasicEduDTO();
            basic_Edu.userName = "******";
            basic_Edu.country = "South Africa";
            basic_Edu.levelCompleted = 12;
            basic_Edu.province = "WP";
            basic_Edu.school = "Brackenfell High School";
            basic_Edu.town = "Cape Town";

            edu_context.presist(basic_Edu);

            BasicEduSubjectDTO basicEduSub = new BasicEduSubjectDTO();
            basicEduSub.subjectName = "Technical Programming";
            basicEduSub.subjectDescription = "Mr Kabaso is Awesome";
            basicEduSub.userName = "******";

            basicEdu_context.presist(basicEduSub);

            /*Update*/
            basicEduSub.subjectDescription = "Mr Kabaso is Awesome!";
            basicEdu_context.merge(basicEduSub);

            string expectedUpdate = "Mr Kabaso is Awesome!";
            BasicEduSubjectDTO updateEduSub = basicEdu_context.find("griddy","Technical Programming");
            Assert.AreEqual(expectedUpdate, updateEduSub.subjectDescription);

            /*Delete*/
            basicEdu_context.removeByUserId("griddy", "Technical Programming");
            bool expectedDelBasicEduSub = false;
            bool actualDelBasicEduSub = basicEdu_context.isFound("griddy", "Technical Programming");
            Assert.AreEqual(expectedDelBasicEduSub, actualDelBasicEduSub);
            edu_context.removeByUserId("griddy");
            acc_context.removeByUserId("griddy");
        }
コード例 #18
0
        public void UserDAO_Test()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            UserDAO user_context = new UserDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            UserDTO user = new UserDTO();
            user.basicEducation = true;
            user.citizenship = true;
            user.disabled = true;
            user.employed = true;
            user.employmentHistory = true;
            user.fullName = "Andre";
            user.gender = "male";
            user.higherEducation = true;
            user.id = "8630302930";
            user.idType = "SA";
            user.language = true;
            user.license = true;
            user.nickName = "WIlliem";
            user.postalAddress = true;
            user.race = "white";
            user.residentialAddress = true;
            user.surname = "Pretorious";
            user.userName = "******";

              //  user_context.presist(user);
            //Assert.AreEqual(user.race, user_context.find("griddy","8630302930").race);

            ///*Update*/
            //user.nickName = "willi";
            //user_context.merge(user);
            //Assert.AreEqual(user.nickName, user_context.find("griddy", "8630302930").nickName);

            ///*Delete*/
            //user_context.removeByUserId("griddy", "8630302930");
            //Assert.AreEqual(user_context.isFound("griddy", "8630302930"), false);

            acc_context.removeByUserId("griddy");
        }
コード例 #19
0
        public void InboxDAOConstructorTest()
        {
            /*Context*/
            InboxDAO inbox_context = new InboxDAO();
            AccountDAO account_context = new AccountDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            InboxDTO inbox = new InboxDTO();
            inbox.date = new DateTime(2012, 9, 30);
            inbox.message = "success";
            inbox.vacancyNumber = "1";
            inbox.unread = "read";
            inbox.userName = "******";
            inbox.status = "applied";

            inbox_context.presist(inbox);

            bool expected = true;
            bool actual;
            actual = inbox_context.isFound("john", "1");
            Assert.AreEqual(expected, actual);

            /*Update*/
            inbox.unread = "not read";
            inbox_context.merge(inbox);
            string expectedUpdate = "not read";
            InboxDTO contUpd = inbox_context.find("john", "1");
            Assert.AreEqual(expectedUpdate, contUpd.unread);

            /*Delete*/
            inbox_context.removeByUserId("john", "1");
            bool expectedDelete = false;
            bool actualDelete = inbox_context.isFound("john", "1");
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("john");
        }
コード例 #20
0
        public void ContactInfo_Test()
        {
            /*Context*/
            ContactInfoDAO contactInfo_context = new ContactInfoDAO();
            AccountDAO acc_context = new AccountDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            ContactInfoDTO contact = new ContactInfoDTO();
            contact.userName = "******";
            contact.contactType = "skype";
            contact.data = "skippy";

            contactInfo_context.presist(contact);

            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expected, actual);

            /*Update*/
            contact.data = "Gready";
            contactInfo_context.merge(contact);

            string expectedUpdate = "Gready";
            ContactInfoDTO contUpd = contactInfo_context.find("griddy", "skype");
            Assert.AreEqual(expectedUpdate, contUpd.data);

            /*Delete*/
            contactInfo_context.removeByUserId("griddy", "skype");

            bool expectedDelete = false;
            bool actualDelete = contactInfo_context.isFound("griddy", "skype");
            Assert.AreEqual(expectedDelete, actualDelete);

            acc_context.removeByUserId("griddy");
        }
コード例 #21
0
        public void Disability_Test()
        {
            /*Context*/
            DisabilityDAO disability_context = new DisabilityDAO();
            AccountDAO account_context = new AccountDAO();
            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            DisabilityDTO disability = new DisabilityDTO();
            disability.disabilityType = "hearing";
            disability.description = "loss of hearing";
            disability.userName = "******";

            disability_context.presist(disability);

            bool expected = true;
            bool actual;
            actual = disability_context.isFound("griddy", "hearing");
            Assert.AreEqual(expected, actual);

            /*Update*/
            disability.description = "no hearing";
            disability_context.merge(disability);
            string expectedUpdate = "no hearing";
            DisabilityDTO contUpd = disability_context.find("griddy", "hearing");
            Assert.AreEqual(expectedUpdate, contUpd.description);

            /*Delete*/
            disability_context.removeByUserId("griddy", "hearing");

            bool expectedDelete = false;
            bool actualDelete = disability_context.isFound("griddy", "hearing");
            Assert.AreEqual(expectedDelete, actualDelete);

            account_context.removeByUserId("griddy");
        }
コード例 #22
0
        public ActionResult LoginFrm(FormCollection objFormCollect)
        {
            pl_objAcctDao        = new AccountDAO();
            pl_intLoginChkRetVal = pl_objAcctDao.LoginUser(objFormCollect["UserID"], objFormCollect["UserPwd"]);
            switch (pl_intLoginChkRetVal) // 로그인 성공 : 0 , 아이디 오류 : -1
            {
            case 0:
                ViewBag.Message = "login Success...!";
                FormsAuthentication.SetAuthCookie(objFormCollect["UserID"], false);
                return(RedirectToAction("Index", "Home"));

            case -1:
                ViewBag.Message = "Admin is not valid...!";
                return(View());

            default:
                ViewBag.Message = "password is not correct...!";
                return(View());
            }
        }
コード例 #23
0
        public ActionResult Login(string email, string password, string remember_me)
        {
            Account account = AccountDAO.GetByEmail(email);

            if (Authentication.IsSigned())
            {
                return(Redirect("/Home/Index"));
            }
            bool loginIsValid = AccountDAO.Login(email, password);

            if (loginIsValid)
            {
                Authentication.SignIn(account.Id, account.Email, account.Password);

                //if (remember_me == "true") {
                //    Authentication.RememberMe();
                //}
            }
            return(Json(new { isValid = loginIsValid, url = "/Home/Index", message = "Dados Incorretos", type = 1 }));
        }
コード例 #24
0
ファイル: FrmUser.cs プロジェクト: checkteam191/QLNS
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         string username = txbTenDangNhap.Text;
         if (AccountDAO.DeleteAccount(username) == 1)
         {
             MessageBox.Show("Thành công");
         }
         else
         {
             MessageBox.Show("Thất bại");
         }
     }
     catch
     {
         return;
     }
     LoadAccount();
 }
コード例 #25
0
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            stoppingToken.ThrowIfCancellationRequested();
            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                var               body           = ea.Body;
                var               message        = Encoding.UTF8.GetString(body);
                var               messageAccount = JsonConvert.DeserializeObject <MessageAccount>(message);
                var               result         = AccountDAO.GenerateCompanyAccount(context, messageAccount).Split('_');
                Producer          producer       = new Producer();
                MessageAccountDTO messageDTO     = new MessageAccountDTO(result[0], result[1], messageAccount.Email);
                producer.PublishMessage(message: JsonConvert.SerializeObject(messageDTO), "AccountToEmail");
            };
            channel.BasicConsume(queue: queueName,
                                 autoAck: false,
                                 consumer: consumer);
            return(Task.CompletedTask);
        }
コード例 #26
0
        void addStaff()
        {
            string cusID     = (string)Request.Form["id"];
            string cusName   = (string)Request.Form["name"];
            string cusDate   = (string)Request.Form["date"];
            string cusGender = (string)Request.Form["gender"];
            string cusAdress = (string)Request.Form["adress"];
            string cusNote   = (string)Request.Form["note"];
            string username  = (string)Request.Form["username"];
            string pass      = (string)Request.Form["pass"];
            string email     = (string)Request.Form["email"];
            int    type;

            if (cusID.Equals("admin"))
            {
                type = 1;
            }
            else
            {
                type = 0;
            }
            AccountDAO     aDAO        = new AccountDAO();
            List <Account> listAccount = new List <Account>();

            listAccount = aDAO.getAllAccount();
            for (int i = 0; i < listAccount.Count; i++)
            {
                if (listAccount[i].Username.Equals(username))
                {
                    string er = "Tài Khoản Đã Tồn Tại";
                    Session["er"] = er;
                    return;
                }
            }
            aDAO.addAccount(username, pass, type, email);
            StaffDAO sDAO = new StaffDAO();

            sDAO.AddStaff(username, cusName, cusDate, cusGender, cusAdress, cusNote);
            Session["listStaff"] = sDAO.GetStaff();
            Response.Redirect("StaffManagement.aspx");
        }
コード例 #27
0
        public ActionResult Register(RegisterModel model)
        {
            var dao = new AccountDAO();

            if (this.IsCaptchaValid("Captcha is not valid"))
            {
                if (dao.CheckUserName(model.UserName))
                {
                    ModelState.AddModelError("", "Tài khoản đã tồn tại");
                }
                else if (dao.CheckUserEmail(model.Email))
                {
                    ModelState.AddModelError("", "Email đã tồn tại");
                }
                else
                {
                    var user = new ClientAccount();
                    user.Name     = model.Name;
                    user.UserName = model.UserName;
                    user.Password = Encryptor.MD5Hash(model.Password);
                    user.Address  = model.Address;
                    user.Email    = model.Email;
                    user.Phone    = model.Phone;
                    var result = dao.Insert(user);
                    if (result > 0)
                    {
                        ViewBag.Success = "Chào mừng bạn đến với UMA";
                        model           = new RegisterModel();
                    }
                    else
                    {
                        ModelState.AddModelError("", "Đăng ký không thành công");
                    }
                }
            }
            else
            {
                ViewBag.ThongBaoCaptcha = "Mã captcha không đúng!";
            }
            return(View(model));
        }
コード例 #28
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var accountDao = new AccountDAO();
                var result     = accountDao.Login(model.Email, Encryptor.MD5Hash(model.Password));

                if (result.Length != 0)
                {
                    Account account = accountDao.GetAccountByID(result);
                    FormsAuthentication.SetAuthCookie(account.email, false);
                    var userSession = new UserSession();
                    userSession.AccountID = account.accountID;
                    userSession.UserName  = account.username;
                    Session.Add("USER_SESSION", userSession);

                    // return admin
                    //if (account.roleAcc)
                    ViewBag.acc = account;
                    if (account.roleAcc == true)
                    {
                        return(RedirectToAction("Index", "Admin", new { area = "Admin" }));
                    }
                    else if (account.roleAcc == false)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    /* if (accountDao.GetAccountByID(model).roleAcc == true)*/
                    //return index
                    ViewBag.errorMessage = "Wrong password or Email";
                    ModelState.AddModelError("", "Wrong password or Email");

                    /* else
                     *   return RedirectToAction("Detail", "Home");*/
                }
            }
            return(View());
        }
コード例 #29
0
        void btBanAn_Click(object sender, EventArgs e)
        {
            int idBanAn = Convert.ToInt32((sender as Button).Tag.ToString());

            tbSelectedTable.Text = idBanAn.ToString(); //  lưu lại id của bàn ăn vào text box

            ShowBill(idBanAn);

            lvBill.Tag = HoaDonDAO.GetUnCheckBillIDByTableID(idBanAn); // lưu id hóa đơn của bàn ăn hiện tại vào lvbill tag

            int idNhanVien = AccountDAO.GetIdNhanVien(TenNguoiDung);   // Lấy id người đăng nhập

            if (lvBill.Tag.ToString() == "-1")                         // nếu bàn đang trống
            {
                DialogResult dialog = MessageBox.Show("Bạn có muốn thêm bill cho bàn ăn này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dialog == DialogResult.OK)
                {
                    HoaDonDAO.InsertBill(idBanAn, idNhanVien);                           // Thêm hóa đơn trống
                    BanAnDAO.ChangeTableStatus(idBanAn.ToString(), "1");                 // thay đổi status của bàn thành đang có khách
                    lvBill.Tag           = HoaDonDAO.GetUnCheckBillIDByTableID(idBanAn); // lưu id của bill vào lvBill tag
                    btAddFood.Enabled    = true;                                         // enable nút thêm
                    btDeleteFood.Enabled = true;                                         // enable nút delete
                    btCheckOut.Enabled   = true;
                    DisplayTable();
                }
                else
                {
                    btAddFood.Enabled    = false;
                    btDeleteFood.Enabled = false;
                    btCheckOut.Enabled   = false;
                }
            }
            else
            {
                btAddFood.Enabled    = true;
                btDeleteFood.Enabled = true;
                // không để ở ngoài vì: loại trừ trường hợp click vào bàn đang trống mà không có bill => thêm bị lỗi

                btCheckOut.Enabled = true;
            }
        }
コード例 #30
0
        public ActionResult Create(ACCOUNT aCCOUNT)
        {
            var session = (UserLogin)Session[CommonConstants.USER_SESSION];

            if (ModelState.IsValid)
            {
                aCCOUNT.ACCOUNT_CREATOR = session.UserID;
                var dao  = new AccountDAO();
                var user = dao.Create(aCCOUNT);
                if (user != null)
                {
                    string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/templates/CreateAccount.html"));

                    content = content.Replace("{{FullName}}", user.ACCOUNT_Name);
                    content = content.Replace("{{Telephone}}", user.ACCOUNT_Telephone);
                    content = content.Replace("{{Email}}", user.ACCOUNT_Email);
                    content = content.Replace("{{Address}}", user.ACCOUNT_Address);
                    content = content.Replace("{{Username}}", user.ACCOUNT_Username);
                    if (user.FACULTY_Id != null)
                    {
                        content = content.Replace("{{Faculty}}", new FacultyDAO().GetById(user.FACULTY_Id).FACULTY_Descriptions);
                    }
                    else
                    {
                        content = content.Replace("{{Faculty}}", "");
                    }
                    content = content.Replace("{{Password}}", aCCOUNT.ACCOUNT_Password);

                    var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();
                    new MailHelper().SendMail(user.ACCOUNT_Email, "Account University Magazine Management.", content, "Account University Magazine Management.");
                    new MailHelper().SendMail(toEmail, "Account University Magazine Management.", content, "Account University Magazine Management.");
                    SetAlert("Create Account Success! Username and password sent to email.", "success");
                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    SetAlert("Error!!!", "warning");
                }
            }
            return(View());
        }
コード例 #31
0
        public void AddressDAO_Test()
        {
            /*Context*/
            AccountDAO acc_context = new AccountDAO();
            AddressDAO address_context = new AddressDAO();
            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            AddressDTO address = new AddressDTO();
            address.userName = "******";
            address.addressType = "postal";
            address.country = "South Africa";
            address.province = "WP";
            address.street = "Frans";
            address.suburb = "Parow";
            address.town = "Cape Town";
            address.unitNumber = 22;

            address_context.presist(address);
            /*Update*/
            address.town = "Pretoria";
            address_context.merge(address);

            string expectedUpdate = "Pretoria";
            AddressDTO upd = address_context.find("griddy", "postal");
            Assert.AreEqual(expectedUpdate, upd.town);

            /*Delete*/
            address_context.removeByUserId("griddy", "postal");
            bool expectedDelAddress = false;
            bool actualDeleteAddress = address_context.isFound("griddy", "postal");
            Assert.AreEqual(expectedDelAddress, actualDeleteAddress);

            acc_context.removeByUserId("griddy");
        }
コード例 #32
0
        public void BasicEduDAO_Test()
        {
            /*Context*/
            BasicEduDAO edu_context = new BasicEduDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            BasicEduDTO basic_Edu = new BasicEduDTO();
            basic_Edu.userName = "******";
            basic_Edu.country = "South Africa";
            basic_Edu.levelCompleted = 12;
            basic_Edu.province = "WP";
            basic_Edu.school = "Brackenfell High School";
            basic_Edu.town = "Cape Town";

            edu_context.presist(basic_Edu);

            /*Update*/
            basic_Edu.province = "PE";
            edu_context.merge(basic_Edu);

            string expectedUpdate = "PE";
            BasicEduDTO updateEdu = edu_context.find("griddy");
            Assert.AreEqual(expectedUpdate, updateEdu.province);

            ///*Delete*/
            edu_context.removeByUserId("griddy");
            bool expectedDelBasicEdu = false;
            bool actualDelBasicEdu = edu_context.isFound("griddy");
            Assert.AreEqual(expectedDelBasicEdu, actualDelBasicEdu);

            acc_context.removeByUserId("griddy");
        }
コード例 #33
0
        public JsonResult ExecuteLogin(User model)
        {
            model.Password = CommonConstant.HashPassword(model.Password);
            bool check = new AccountDAO().checkAccount(model.Username, model.Password);

            if (check)
            {
                var roleID = db.Users.Where(a => a.Username == model.Username).FirstOrDefault().UserRoleID;
                Session["roleID"] = roleID;
                if (check && ((int)Session["roleID"] == 1))
                {
                    Session["UserName"] = model.Username;
                    return(Json(new { status = true }));
                }
                else
                {
                    return(Json(new { status = false }));
                }
            }
            return(Json(new { status = false }));
        }
コード例 #34
0
        //
        // GET: /Film/View/id

        public ActionResult View(int?ID)
        {
            if (ID == null)
            {
                return(RedirectToAction("Home", "HomePage"));
            }
            int             filmId     = ID ?? 1;
            FilmDAO         fiDao      = new FilmDAO();
            AccountDAO      accDao     = new AccountDAO();
            CategoryDAO     cDao       = new CategoryDAO();
            CommentDAO      commentDao = new CommentDAO();
            FilmDetailModel model      = new FilmDetailModel
            {
                ListCategory = cDao.GetAllCategory(),
                Account      = null,
                Film         = fiDao.GetDetailAFilm(filmId),
                ListComment  = commentDao.GetAllCommentOfAFilm(filmId)
            };

            return(View(model));
        }
コード例 #35
0
        public string TransferMoney(PostTransferMoneyGame p)
        {
            if (AccountSession.AccountID <= 0)
            {
                NLogManager.LogMessage("TransferMoney Account NULL!");
                return(string.Empty);
            }
            var accountInfo = AccountDAO.GetAccountInfo(AccountSession.AccountID);

            NLogManager.LogMessage("TransferMoney: " + JsonConvert.SerializeObject(p) +
                                   "\r\nAccount: " + JsonConvert.SerializeObject(accountInfo));
            string msg       = "";
            string receiptID = "";
            long   r         = AccountDAO.TransferSubMoneyGames(accountInfo.AccountID, "", p.amount, Utilities.IP.IPAddressHelper.GetClientIP(), p.gameId, ref msg, ref receiptID);

            return(JsonConvert.SerializeObject(new
            {
                Status = r,
                Msg = msg
            }));
        }
コード例 #36
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            string pass     = textBox2.Text;

            if (AccountDAO.Login(username, pass))
            {
                AccountDTO acc  = AccountDAO.GetAccount(username);
                string     type = acc.Type.ToString();
                if (type == "Admin")
                {
                    FrmMain frm = new FrmMain(1);
                    frm.Show();
                }
                else
                {
                    FrmMain frm = new FrmMain(0);
                    frm.Show();
                }
            }
        }
コード例 #37
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var res = DataBase.DAO.AccountDAO.Login(model.UserName, model.Password);
         if (res == true) // đăng nhập thành công
         {
             Account      acc        = AccountDAO.GetByUserName(model.UserName);
             AccountLogin accSession = new AccountLogin();
             accSession.AccountID = acc.MaACC;
             accSession.UserName  = acc.TenDangNhap;
             Session.Add("AccountSession", accSession);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "đăng nhập không đúng");
         }
     }
     return(View("Index"));
 }
コード例 #38
0
        public bool CheckLogin(string item)
        {
            AccountDAO dao = new AccountDAO();

            if (item == null)
            {
                return(false);
            }
            var old = dao.Model.UserBCs.FirstOrDefault(f => f.username == item);

            if (old == null)
            {
                Session.RemoveAll();
                return(false);
            }
            if (old.active == 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #39
0
 public ActionResult ActivatingUser(string OTP)
 {
     if (ModelState.IsValid)
     {
         var otp  = Session[CommonConstants.OTP_SESSION].ToString();
         var user = (Account)Session[CommonConstants.USER_INFO_SESSION];
         if (otp.Equals(OTP))
         {
             var isActivated = new AccountDAO().UpdateStatusUser(user.Username);
             Session[CommonConstants.OTP_SESSION]            = null;
             Session[CommonConstants.USER_INFO_SESSION]      = null;
             Session[CommonConstants.ACTIVATED_USER_SUCCESS] = "Kích hoạt thành công";
             return(Redirect("/dang-nhap"));
         }
         else
         {
             ModelState.AddModelError("", "Mã kích hoạt không chính xác");
         }
     }
     return(View());
 }
コード例 #40
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        String     username = txtUsername.Text;
        String     password = txtPassword.Text;
        AccountDAO dao      = new AccountDAO();

        String result = dao.checkLogin(username, password);

        if (result != "fail")
        {
            WebMessageBox wmb = new WebMessageBox();
            Session.Add("ID", username);
            Session.Add("NAME", dao.getName(username));
            Response.Redirect("HomePage.aspx");
        }
        else
        {
            WebMessageBox wmb = new WebMessageBox();
            wmb.Show("Invalid username or password, please try again!");
        }
    }
コード例 #41
0
        private void btnRegistrer_Click(object sender, EventArgs e)
        {
            if (MetroMessageBox.Show(this, Strings.ConfRegister, Strings.Register, MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                AccountDAO adao = new AccountDAO();

                //Tratamento da Combo Box Tickets
                TicketDAO tdao = new TicketDAO();
                idticket = tdao.FindIdByCb(mcbTicket.Text);

                Account account = new Account()
                {
                    ClientId = int.Parse(lblClientId.Text),
                    Status   = "Ativo",
                    TicketId = idticket
                };
                adao.Add(account);
                MetroMessageBox.Show(this, Strings.SuccessRegistered, Strings.Registered, MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                this.Visible = false;
            }
        }
コード例 #42
0
 private void bt_Login_Click(object sender, EventArgs e)
 {
     if (TrangThai == 1)
     {
         string username = tx_user.Text;
         string password = tx_Password.Text;
         if (Login(username, password))
         {
             List <Account> list = AccountDAO.GetAccount(username, password);
             Account        TK   = list[0] as Account;
             Form_Main      frm  = new Form_Main();
             frm.Id_TaiKhoan = TK.id;
             this.Hide();
             frm.ShowDialog();
         }
         else
         {
             MessageBox.Show("Bạn đã sai tên đăng nhập hoặc mật khẩu!");
         }
     }
     else
     {
         string username = tx_user.Text;
         string password = tx_Password.Text;
         if (ThanhVienDAO.Login_Check(username, password))
         {
             List <ThanhVien> list = ThanhVienDAO.GetAccount(username, password);
             ThanhVien        TK   = list[0] as ThanhVien;
             Form_CaNhanCuaSV f    = new Form_CaNhanCuaSV();
             f.MSVKT = TK.MaSVKT;
             f.id_TV = TK.id_ThanhVien;
             this.Hide();
             f.Show();
         }
         else
         {
             MessageBox.Show("Bạn đã sai tên đăng nhập hoặc mật khẩu!");
         }
     }
 }
コード例 #43
0
 private bool CheckCookie()
 {
     //TODO:
     //  Return true if there is a valid account being saved in cookie
     //  Return false if otherwise
     AccountDAO accountDAO = new AccountDAO();
     {
         Account savedAccount = null;
         if (FormsAuthentication.CookiesSupported == true)
         {
             if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
             {
                 try
                 {
                     string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
                     savedAccount = accountDAO.GetOne(username);
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine("Error in Global.asax.cs,  FormsAuthentication_OnAuthenticate(): " + ex.Message);
                     throw ex;
                 }
             }
         }
         if (savedAccount != null)
         {
             //Save account into session
             if (Session["CurrentAccount"] == null)
             {
                 Session.Add("CurrentAccount", savedAccount);
             }
             else
             {
                 Session["CurrentAccount"] = savedAccount;
             }
             return(true);
         }
         return(false);
     }
 }
コード例 #44
0
        public ApiAccountReponse OAuth(string username, string password, string deviceToken)
        {
            try
            {
                var account = AccountDAO.Login(username, Security.MD5Encrypt(password));
                if (account == null || account.AccountID == 0)
                {
                    return new ApiAccountReponse {
                               Code = -51
                    }
                }
                ;
                if (account.IsBlocked)
                {
                    return new ApiAccountReponse {
                               Code = -65
                    }
                }
                ;
                //string deviceT = OTP.OTP.GetCurrentAccountToken(account.AccountID);
                //if (!string.IsNullOrEmpty(deviceT) && deviceT != deviceToken)
                //    return new ApiAccountReponse { Code = -72 };
                // OTP.OTP.SetToken(account.AccountID, deviceToken);
                return(new ApiAccountReponse
                {
                    Code = 1,
                    Account = account,
                    OTPToken = GenerateToken(account.AccountID, deviceToken)
                });
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }

            return(new ApiAccountReponse
            {
                Code = -99
            });
        }
コード例 #45
0
ファイル: RegisterForm.cs プロジェクト: tvad0905/PRN292
        private void btSignUp_Click(object sender, EventArgs e)
        {
            foreach (TextBox t in listTextBox1)
            {
                if (t.Text.Trim() == string.Empty)
                {
                    MessageBox.Show("Must fill in all text box of Main information");
                    return;
                }
            }

            if (!AccountDAO.checkUsername(textBox1.Text))
            {
                MessageBox.Show("Username has existed !! Try another username !!!", "Notification !!!", MessageBoxButtons.OK);
                return;
            }

            if (AccountDAO.insertRegister(listTextBox1, listTextBox2))
            {
                usn = textBox1.Text;
                ps  = textBox2.Text;
                MessageBox.Show("Register successully !!!", "Notification", MessageBoxButtons.OK);
                DataTable dt = AccountDAO.getLogUser(usn, ps);
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("User Name or Password is incorrect");
                    return;
                }

                a = new Account();
                a.setInfor(dt);
                lgui.setAccount(a);
                this.Close();
            }
            else
            {
                MessageBox.Show("Register Fail");
                return;
            }
        }
コード例 #46
0
        public int CreatedNewPass(string tokenOTP, string newPassword)
        {
            try
            {
                string   decryptToken = Security.TripleDESDecrypt(ConfigurationManager.AppSettings["OTPKey"], System.Web.HttpUtility.UrlDecode(tokenOTP).Replace(" ", "+"));
                string[] splData      = decryptToken.Split('|');

                long time = long.Parse(splData[0]);
                if (TimeSpan.FromTicks(DateTime.Now.Ticks - time).TotalSeconds > 120)
                {
                    return(-1); //Experied captcha
                }
                long accountId = Convert.ToInt64(splData[1]);

                Regex rPassword = new Regex("^[a-zA-Z0-9_.-]{6,18}$");
                if (!rPassword.IsMatch(newPassword))
                {
                    return(-30);
                }
                if (!rPassword.IsMatch(newPassword))
                {
                    return(-30);
                }

                var account = AccountDAO.GetAccountInfo(accountId);
                if (account == null)
                {
                    return(-31);
                }

                SecurityDAO.CreateNewPassword(AccountSession.AccountID, Security.MD5Encrypt(newPassword));
                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
コード例 #47
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         string username = txbTenDangNhap.Text;
         string password = txbMatKhau.Text;
         string type     = cboPhanQuyen.Text;
         if (AccountDAO.UpdateAccount(username, password, type) == 1)
         {
             MessageBox.Show("Thành công");
         }
         else
         {
             MessageBox.Show("Thất bại");
         }
     }
     catch
     {
         return;
     }
     LoadAccount();
 }
コード例 #48
0
 public ActionResult Edit(NewAccount account)
 {
     if (ModelState.IsValid)
     {
         AccountDAO accountDAO   = new AccountDAO();
         var        AccountModel = accountDAO.GetAccount(account.Email);
         AccountModel.Name     = account.Name;
         AccountModel.Password = account.Password;
         AccountModel.Phone    = account.Phone;
         bool result = accountDAO.UpdateAccount(AccountModel);
         if (result)
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Can not update!");
             return(View("Edit"));
         }
     }
     return(View("Edit"));
 }
コード例 #49
0
        private void btLuuTK_Click(object sender, EventArgs e)
        {
            Account acc = new Account();

            acc.TenNguoiDung = tbUserName.Text;
            acc.TenHienThi   = tbDisplayName.Text;
            acc.LoaiTK       = (int)cbLoaiTK.SelectedValue;
            acc.MatKhau      = tbPassword.Text;

            // Kiểm tra tên đăng nhập có tồn tại chưa
            if (AccountDAO.CheckExistsTenNguoiDung(acc.TenNguoiDung))
            {
                MessageBox.Show("Tên người dùng đã tồn tại");
            }
            else
            {
                AccountBUS.ThemTK(acc);
                listAccounts.Items.Clear();
                DisplayListViewAccount();
                MessageBox.Show("Lưu tài khoản thành công!");
            }
        }
コード例 #50
0
 public ActionResult Edit(Account acc)
 {
     if (ModelState.IsValid)
     {
         var dao = new AccountDAO();
         if (!string.IsNullOrEmpty(acc.password))
         {
             var enMD5Pass = Encrytor.MD5Hash(acc.password);
             acc.password = enMD5Pass;
         }
         var result = dao.Update(acc);
         if (result)
         {
             return(RedirectToAction("Index", "ADNV"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật thất bại");
         }
     }
     return(View("Index"));
 }
コード例 #51
0
        public int UpdateRegisterSMSPlus(bool isCancel, string otp = "")
        {
            try
            {
                var accountId   = AccountSession.AccountID;
                var accountInfo = AccountDAO.GetAccountInfo(accountId);

                if (string.IsNullOrEmpty(accountInfo.Tel))
                {
                    return(-99);
                }

                if (isCancel)
                {
                    var    infoApp = OtpDAO.GetCurrentCounter(accountId);
                    string token   = infoApp?.AppT;
                    if (!string.IsNullOrEmpty(infoApp?.AppT))
                    {
                        if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", otp))
                        {
                            goto doneOTP;
                        }
                    }

                    if (string.IsNullOrEmpty(otp) || (!OTP.OTP.ValidateOTP(accountId, otp, accountInfo.Tel)))
                    {
                        return(-60);
                    }
                }
doneOTP:
                SecurityDAO.UpdateRegisterSMSPlus(AccountSession.AccountID, isCancel);
                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
コード例 #52
0
        protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
        {
            // Determine the currently logged on user's UserId
            //MembershipUser currentUser = Membership.GetUser();
            //Guid currentUserId = (Guid)currentUser.ProviderUserKey;

            //Create user in Account table
            DAO_Account_Interface acc_ctx = new AccountDAO();
            AccountDTO newAccount = new AccountDTO();

            newAccount.userName = CreateUserWizard1.UserName.ToLower();
            newAccount.password = "******";
            newAccount.status = "active";
            newAccount.accountType = "user";
            acc_ctx.presist(newAccount);

            //Add User Email to COntact Info
            DAO_ContactInfo_Interface info_ctx = new ContactInfoDAO();
            ContactInfoDTO mail_info = new ContactInfoDTO();
            mail_info.userName = newAccount.userName;
            mail_info.contactType = "e-mail";
            mail_info.data = CreateUserWizard1.Email;
            info_ctx.presist(mail_info);

            //Add User information to User Table
            DAO_User_Interface user_ctx = new UserDAO();
            UserDTO user_info = new UserDTO();
            user_info.userName = newAccount.userName;
            user_info.id = txtID.Text;
            user_info.fullName = txtName.Text;
            user_info.surname = txtSurname.Text;
            user_info.nickName = txtNickname.Text;
            user_info.idType = RadioIdType.SelectedValue;
            user_info.race = RadioRace.SelectedValue;
            user_info.gender = RadioGender.SelectedValue;
            user_ctx.presist(user_info);

            Roles.AddUserToRole(newAccount.userName, "User");
        }
コード例 #53
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]

        public ActionResult SignUp(LoginModel model)
        {
            //if (ModelState.IsValid)
            //{
            //    var accountDao = new AccountDAO();
            //    accountDao.Insert(acc);
            //    //return Redirect("/Login/Login");
            //    //return RedirectToRoute("Login");
            //    return RedirectToAction("Login");
            //}
            //else
            //{
            //    ViewBag.error = "Email already exists";
            //    return View();

            //}
            //return View();
            var accountDao = new AccountDAO();

            accountDao.Insert(model.Email, model.UserName, Encryptor.MD5Hash(model.Password));
            return(RedirectToAction("Login", "Login"));
        }
コード例 #54
0
 public ActionResult Create(Account account)
 {
     if (ModelState.IsValid)
     {
         var dao             = new AccountDAO();
         var EncryptingMD5Pw = Encryptor.MD5Hash(account.Password);
         account.Password   = EncryptingMD5Pw;
         account.CreateDate = DateTime.Now;
         account.Level      = 0;
         long id = dao.Insert(account);
         if (id > 0)
         {
             setAlert("Thêm tài khoản thành công", "success");
             return(RedirectToAction("Index", "Account"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm tài khoản thất bại");
         }
     }
     return(View("Index"));
 }
コード例 #55
0
        public void LanguageDAOConstructorTest()
        {
            /*Context*/
            LanguageDAO lang_context = new LanguageDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LanguageDTO lang = new LanguageDTO();
            lang.userName = "******";
            lang.languageName = "english";
            lang.speak = "Yes";
            lang.write = "Yes";
            lang.reads = "Yes";

            lang_context.presist(lang);
            Assert.AreEqual(lang.speak, lang_context.find("john", "english").speak);

            /*Update*/
            lang.speak = "No";
            lang_context.merge(lang);
            Assert.AreEqual("No", lang_context.find("john", "english").speak);

            /*Delete*/
            lang_context.removeByUserId("john", "english");
            Assert.AreEqual(lang_context.isFound("john", "english"), false);

            acc_context.removeByUserId("john");
        }
コード例 #56
0
        public void LanguageDAO_Test()
        {
            LanguageDAO lang_context = new LanguageDAO();
            AccountDAO acc_context = new AccountDAO();

            /*Insert*/
            AccountDTO acc = new AccountDTO();
            acc.userName = "******";
            acc.password = "******";
            acc.accountType = "administrator";
            acc.status = "active";

            acc_context.presist(acc);

            LanguageDTO lang = new LanguageDTO();
            lang.userName = "******";
            lang.languageName = "english";
            lang.speak = "no";
            lang.write = "Yes";
            lang.reads = "Yes";

            lang_context.presist(lang);
            Assert.AreEqual("no", lang_context.find("griddy", "english").speak);

            /*Update*/
            /*lang.speak = "X";
            lang_context.merge(lang);
            string str = lang_context.find("griddy", "english").speak;
            //Assert.AreEqual("X", str);

            /*Delete*/
            lang_context.removeByUserId("griddy", "english");
            Assert.AreEqual(false, lang_context.isFound("griddy", "english"));

            acc_context.removeByUserId("griddy");
        }
コード例 #57
0
 public AccoutService(AccountDAO dao, Server.Log logger)
 {
     accountDAO = dao;
     this.logger = logger;
 }
コード例 #58
0
        public void userServiceTest()
        {
            UserService target = CreateUserService(); // TODO: Initialize to an appropriate value

            AccountDAO account_context = new AccountDAO();
            ApplicationDAO app_context = new ApplicationDAO();
            VacancyDAO vac_context = new VacancyDAO();

            /*Insert*/
            AccountDTO account = new AccountDTO();
            account.userName = "******";
            account.status = "active";
            account.password = "******";
            account.accountType = "admin";

            account_context.presist(account);

            VacancyDTO vac = new VacancyDTO();
            vac.department = "IS";
            vac.description = "Web services";
            vac.manager = "Tom";
            vac.recruiter = "Thumi";
            vac.site = "www.petrosa.co.za";
            vac.startDate = new DateTime(2012, 10, 10);
            vac.endDate = new DateTime(2012, 12, 1);
            vac.description = "desktop support";
            vac.title = "support technician";
            vac.vacancyNumber = "1";
            vac.viewCount = 10;
            vac.viewStatus = "published";
            vac.status = "active";

            vac_context.presist(vac);
            bool expectedVac = true;
            bool actualVac;
            actualVac = vac_context.isFound("1");
            Assert.AreEqual(expectedVac, actualVac);

            ApplicationDTO applicationDto = new ApplicationDTO();
            applicationDto.userName = "******";
            applicationDto.vacancyNumber = "1";
            applicationDto.status = ApplicationStatus.APPLIED.ToString();

            app_context.presist(applicationDto);
            bool expected = true;
            bool actual;
            actual = app_context.isFound("griddy", "1");
            Assert.AreEqual(expected, actual);

            //Test changeUserApplicationStatus method
            target.changeUserApplicationStatus("griddy", "1", ApplicationStatus.SHORTLISTED);
            ApplicationDTO applicationDto2 = app_context.find("griddy", "1");
            Assert.AreEqual(ApplicationStatus.SHORTLISTED.ToString(), applicationDto2.status);

            //Test getShortListedCandidates method
            List<ApplicationDTO> candidates = target.getShortListedCandidates("1");
            Assert.AreEqual("griddy", candidates[0].userName);

            /*Delete*/
            Assert.AreEqual(app_context.removeByUserId("griddy", "1"), true);
            Assert.AreEqual(vac_context.removeByUserId("1"), true);
            Assert.AreEqual(account_context.removeByUserId("griddy"), true);
        }
コード例 #59
0
 public AuthenticationService(AccountDAO dao)
 {
     accountDAO = dao;
 }
コード例 #60
0
        protected void rptShortlistedSelect_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            String element = e.CommandName.ToString();

            if (element.Equals("username"))
            {
                AccountDAO dao = new AccountDAO();
                AccountDTO account = dao.find(e.CommandArgument.ToString());

                selectedAccountDtoList = (List<AccountDTO>)Session["ShortlistedAccountDTOList"];
                selectedAccountDtoList.Add(account);
                reloadPage();

                //ApplicationSearchService searchService = new ApplicationSearchServiceImpl();
                //searchService.selectAsShortlisted(e.CommandArgument.ToString(), getVacancyNumber());
            }
        }