コード例 #1
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";
        }
コード例 #2
0
        public JsonResult Login(AccountDTO.LoginModel model)
        {
            if (!ModelState.IsValid)
                return ModelState.GetFirstErrorMessageResult();


            var js = new AjaxResult() { Success = true, Message = "登录成功" };
            var entity = userPrivoder.CheckLogin(model.Source);
            if (entity == null)
            {
                js.Success = false;
                js.Message = "用户名或密码错误";
            }
            else
            {
                if (entity.Name != model.LoginName || entity.Password != model.LoginPwd)
                {
                    js.Success = false;
                    js.Message = "用户名或密码错误";
                }
                else
                {
                    this.Authent.SetAuth(entity.Id, model.IsRemenberMe);
                }
            }
            return Json(js);
        }
コード例 #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 bool merge(AccountDTO entityDTO)
    {
        try
         {
        var obj = (from p in ctx.Accounts
                   where p.userName == @entityDTO.userName
                   select p).Single();

        model.Account accObj = (Account)obj;

        /*Update*/
        accObj.userName = entityDTO.userName;
        accObj.password = entityDTO.password;
        accObj.status = entityDTO.status;
        accObj.accountType = entityDTO.accountType;

        ctx.SubmitChanges();
        return true;
          }
          catch (Exception)
          {
              ctx.Dispose();
              ctx = new ModelDataContext();
              return false;
          }
    }
コード例 #5
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"));
        }
コード例 #6
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");
        }
コード例 #7
0
        public int addAccount(AccountDTO account)
        {
            StringBuilder query = new StringBuilder();
            query.AppendLine("INSERT INTO Accounts");
            query.AppendLine("(Code, AccountRangeId, Deleted, RegularizingAccount, Name)");
            query.AppendLine("VALUES (@code, @accountRangeId, @deleted, @regularizingAccount, @name);");
            query.AppendLine("SELECT SCOPE_IDENTITY();");

            SqlCommand command = new SqlCommand(query.ToString(), this.conection);
            command.CommandType = CommandType.Text;

            command.Parameters.AddWithValue("@code", account.Code);
            command.Parameters.AddWithValue("@name", account.Name);
            command.Parameters.AddWithValue("@accountRangeId", account.AccountRange.Id);
            command.Parameters.AddWithValue("@deleted", account.Deleted);
            command.Parameters.AddWithValue("@regularizingAccount", account.RegularizingAccount);

            int id;

            try
            {
                this.conection.Open();
                id = (int)(decimal)command.ExecuteScalar();
            }
            finally
            {
                if (this.conection.State == ConnectionState.Open)
                    this.conection.Close();
            }

            return id;
        }
コード例 #8
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);
        }
コード例 #9
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");
        }
コード例 #10
0
 public FormModifyAccount(DataValidation dataValidation, AccountRangeDTO accountRange, AccountDTO account)
     : base(dataValidation, accountRange)
 {
     this.account = account;
     InitializeComponent();
     this.Text = "Modificación de cuenta";
     this.bAccept.Text = "Modificar";
     this.nudCode.Value = account.Code;
     this.tbName.Text = account.Name;
     this.cbRegularizingAccount.Checked = account.RegularizingAccount;
 }
コード例 #11
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);
        }
コード例 #12
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");
        }
コード例 #13
0
    public AccountDTO find(string userName)
    {
        var obj = (from p in ctx.Accounts
                   where p.userName == @userName
                   select p).Single();

        AccountDTO acc = new AccountDTO();
        acc.userName = obj.userName;
        acc.password = obj.password;
        acc.status = obj.status;
        acc.accountType = obj.accountType;
        return acc;
    }
コード例 #14
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");
        }
コード例 #15
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");
        }
コード例 #16
0
    public AccountDTO find(string userName)
    {
        AccountDTO acc = new AccountDTO();
            SqlConnection oConn = new SqlConnection();
            SqlCommand sqlCmd = null;

            try
            {
                oConn.ConnectionString = ConfigurationManager.AppSettings["conn"];
                oConn.Open();

                sqlCmd = oConn.CreateCommand();
                sqlCmd.CommandType = CommandType.Text;
                sqlCmd.CommandText = "select * from account where userName = '******'";

                SqlDataReader rdr = sqlCmd.ExecuteReader();

                if (rdr.HasRows)
                {
                    while (rdr.Read())
                    {

                        acc.userName = rdr["userName"].ToString();
                        acc.password = rdr["password"].ToString();
                        acc.status = rdr["status"].ToString();
                        acc.accountType = rdr["accountType"].ToString();
                    }
                }

            }
            catch
            { }
            finally
            {
                if (sqlCmd != null)
                {
                    sqlCmd = null;
                }
                if (oConn != null)
                {
                    if (oConn.State.Equals(ConnectionState.Open))
                    {
                        oConn.Close();
                    }
                    oConn = null;
                }
            }
            return acc;
    }
コード例 #17
0
 public JuridicPersonDTO(string businessName, JuridicPersonTypeDTO type, DocumentTypeDTO documentType, long document, int companyId, LocationDTO location, ConditionRegardingVatDTO conditionRegardingVat, string phone, int zipCode, AccountDTO account, string address)
 {
     this.Id = null;
     this.BusinessName = businessName;
     this.Type = type;
     this.DocumentType = (DocumentTypeDTO)documentType;
     this.Document = document;
     this.CompanyId = companyId;
     this.Location = (LocationDTO)location;
     this.ConditionRegardingVat = (ConditionRegardingVatDTO)conditionRegardingVat;
     this.Phone = phone;
     this.ZipCode = zipCode;
     this.Account = account;
     this.Address = address;
 }
コード例 #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 List<AccountDTO> findAll()
    {
        var objs = (from p in ctx.Accounts
                   select p);
        AccountDTO acc = null;
        List<AccountDTO> accounts = new List<AccountDTO>();
        foreach(Account obj in objs)
        {
            acc = new AccountDTO();
            acc.userName = obj.userName;
            acc.password = obj.password;
            acc.status = obj.status;
            acc.accountType = obj.accountType;

            accounts.Add(acc);
        }
        return accounts;
    }
コード例 #21
0
        public void ChangeAchievement(AccountDTO account_dto)
        {
            if (account_dto == null)
                throw new ArgumentNullException("account_dto");

            var account = Mapper.Map<Account>(account_dto);
            var achievement = new Achievement(account);

            if (achievement.Year.Year < DateTime.Now.Year)
            {
                // TODO: throw custermized exception
                return;
            }

            IUnityContainer container = new UnityContainer();

            IRepository<Account> accountRepository = container.Resolve<IRepository<Account>>();
            if (accountRepository.Get(achievement.AccountId) != null)
            {
                using (TransactionScope scope = new TransactionScope())
                {

                    IRepository<Achievement> achievementRepository = container.Resolve<IRepository<Achievement>>();
                    achievementRepository.TrackEntity(achievement);
                    achievementRepository.Commit();

                    var history = new AchievementHistory(achievement);
                    IRepository<AchievementHistory> archievementHistoryRepository = container.Resolve<IRepository<AchievementHistory>>();
                    archievementHistoryRepository.Add(history);
                    archievementHistoryRepository.Commit();

                    var changeTimes = archievementHistoryRepository.GetFiltered(a => a.AccountId == achievement.Id).Count<AchievementHistory>();
                    if (changeTimes > 2)
                    {
                        var accountLock = Mapper.Map<Account>(account_dto);
                        accountRepository.TrackEntity(accountLock);
                        accountLock.LockAccount();
                        accountRepository.Commit();
                    }

                    scope.Complete();
                }
            }
        }
コード例 #22
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");
        }
コード例 #23
0
        public void ChangeAchievement(AccountDTO account_dto)
        {
            if (account_dto == null)
                throw new ArgumentNullException("account_dto");

            AccountRepository accountRepository = new AccountRepository();
            var account = accountRepository.Get(account_dto.Id);
            if (account != null)
            {
                var achievement = new Achievement(account);
                achievement.ACEENumber = account_dto.ACEENumber;
                achievement.Score = account_dto.Score;
                achievement.SpecialityType = account_dto.SpecialityType;
                achievement.Province = account_dto.Zone.Province;
                achievement.City=account_dto.Zone.City;
                accountService.ChangeAchievement(account, achievement);
                accountRepository.Commit();
            }
        }
コード例 #24
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");
        }
コード例 #25
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");
        }
コード例 #26
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");
        }
コード例 #27
0
        public void ChangePassword(AccountDTO account_dto, string password)
        {
            if (account_dto == null)
                throw new ArgumentNullException("account_dto");
            if (string.IsNullOrEmpty(password))
                throw new ArgumentNullException("password");

            //Account account = Mapper.Map<Account>(account_dto);

            IUnityContainer container = new UnityContainer();
            IRepository<Account> accountRepository = container.Resolve<IRepository<Account>>();
            Account account = accountRepository.Get(account_dto.Id);
            if (account != null)
            {
                account.ChangePassword(password);
                accountRepository.Commit();
            }
            else
            {
                // TODO: throw custermized exception
            }
        }
コード例 #28
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");
        }
コード例 #29
0
ファイル: AccountDAL.cs プロジェクト: noragalvin/ATM_manager
 public AccountDTO VanTinSoDu(string accountNo)
 {
     try
     {
         conn.Open();
         string     query = "SELECT * FROM tblAccount WHERE AccountNo=@accNo";
         SqlCommand cmd   = new SqlCommand(query, conn);
         cmd.Parameters.AddWithValue("accNo", accountNo);
         SqlDataReader dr = cmd.ExecuteReader();
         if (dr.Read())
         {
             AccountDTO acc = new AccountDTO(
                 dr["AccountNo"].ToString(),
                 int.Parse(dr["Balance"].ToString()));
             conn.Close();
             return(acc);
         }
         return(null);
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #30
0
        public async Task <ActualResult <AccountDTO> > GetAccountRoleAsync(string hashId)
        {
            try
            {
                var user = await _userManager.FindByIdAsync(hashId);

                if (user != null)
                {
                    var roles = await _userManager.GetRolesAsync(user);

                    var result = new AccountDTO {
                        HashId = hashId, Role = TranslatorHelper.ConvertToUkrainianLang(roles.FirstOrDefault())
                    };
                    return(new ActualResult <AccountDTO> {
                        Result = result
                    });
                }
                return(new ActualResult <AccountDTO>(Errors.UserNotFound));
            }
            catch (Exception exception)
            {
                return(new ActualResult <AccountDTO>(DescriptionExceptionHelper.GetDescriptionError(exception)));
            }
        }
コード例 #31
0
        public ActionResult Login(string returnUrl)
        {
            var adminAccount = new AccountDTO()
            {
                FullName = ConfigurationManager.AppSettings["AdminFullName"],
                Email    = ConfigurationManager.AppSettings["AdminEmail"],
                Password = ConfigurationManager.AppSettings["AdminPassword"],
                RoleName = RoleTypes.Admin
            };

            var isAdminAccountExists = AccountBL.IsAccountExists(adminAccount, this._DB);

            if (isAdminAccountExists == false)
            {
                AccountBL.Create(adminAccount, this._DB);
            }

            var model = new LoginViewModel()
            {
                ReturnUrl = returnUrl
            };

            return(View(model));
        }
コード例 #32
0
 public bool EditAccounts(AccountDTO dto)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         try
         {
             var EmployeeUpdated = uow.Accounts.EditAccount(dto);
             if (EmployeeUpdated != false)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             ex.Data.Add("EditAccounts", "An error occurred while trying to create EditEmployee Record - BLL");
             uow.Rollback();
             return(false);
         }
     }
 }
コード例 #33
0
        public IServiceMessage <AccountDTO> Create(AccountDTO dto)
        {
            return(base.ProcessMessage <AccountDTO>(msg =>
            {
                validateCreateOrUpdateAccount(dto);

                var entity = new Account
                {
                    Role = Policy.Customer,
                    CreatedOn = DateTime.Now
                };

                setAccountMetadata(dto, entity);

                base.UnitOfWork.Accounts.Add(entity);
                base.UnitOfWork.Complete();

                msg.Data = new AccountDTO(entity)
                {
                    Token = base.JWTService.GenerateAccountJWTToken(entity),
                };
                msg.Success = true;
            }));
        }
コード例 #34
0
        public async Task <IActionResult> CreateAccount(AccountDTO data)
        {
            if (ModelState.IsValid)
            {
                var result = await accountService.CreateAccount(data, await userManager.FindByNameAsync(User.Identity.Name));

                await unitOfWork.SaveChanges();

                return(CreatedAtAction(nameof(GetAccount),
                                       new { id = result.AccountId },
                                       new
                {
                    id = result.AccountId,
                    number = result.AccountNumber,
                    name = result.Name,
                    openingDate = result.OpeningDate,
                    balance = result.Balance,
                    interestRate = result.InterestRate,
                    isBlocked = result.IsBlocked,
                    ownerId = result.OwnerId
                }));
            }
            return(Conflict(ModelState));
        }
コード例 #35
0
ファイル: AccountDAO.cs プロジェクト: Toxic1594/Bluenos
        public SaveResult InsertOrUpdate(ref AccountDTO account)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long    accountId = account.AccountId;
                    Account entity    = context.Account.FirstOrDefault(c => c.AccountId.Equals(accountId));

                    if (entity == null)
                    {
                        account = insert(account, context);
                        return(SaveResult.Inserted);
                    }
                    account = update(entity, account, context);
                    return(SaveResult.Updated);
                }
            }
            catch (Exception e)
            {
                Logger.Error(string.Format(Language.Instance.GetMessageFromKey("UPDATE_ACCOUNT_ERROR"), account.AccountId, e.Message), e);
                return(SaveResult.Error);
            }
        }
コード例 #36
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");
        }
コード例 #37
0
    public void OnRegPanleOkBtnClick()
    {
        if (regPassword.text != regCountersignPassword.text)
        {
            // 提示弹窗密码和确认密码不一致
            WarrningManager.warringList.Add(new WarringModel("密码和确认密码不一致", null, 2));
            return;
        }
        if (regAccount.text.Length <= 3 || regPassword.text.Length <= 3)
        {
            // 提示弹窗账号密码格式错误
            WarrningManager.warringList.Add(new WarringModel("账号密码格式错误", null, 2));
            return;
        }
        // 向服务器发送注册消息
        AccountDTO accountDto = new AccountDTO
        {
            account  = regAccount.text,
            password = regPassword.text
        };

        NetIO.Instance.Write(Protocol.Accaount, 0, AccountProtocol.Reg_CREQ, accountDto);
        SetButtonState(false);
    }
コード例 #38
0
        public async Task Get_AllAccounts()
        {
            var transactions = await _client.GetAsync("/Account");

            var data = JsonConvert.DeserializeObject <List <AccountDTO> >
                       (
                (await transactions.Content.ReadAsStringAsync())
                       );

            Assert.Equal(HttpStatusCode.OK, transactions.StatusCode);

            var expectedAccount = new AccountDTO()
            {
                Agency  = 1111,
                Number  = 99999999,
                Balance = 1500,
                UserId  = 1,
            };

            Assert.Equal(expectedAccount.Agency, data.FirstOrDefault().Agency);
            Assert.Equal(expectedAccount.Number, data.FirstOrDefault().Number);
            Assert.Equal(expectedAccount.Balance, data.FirstOrDefault().Balance);
            Assert.Equal(expectedAccount.UserId, data.FirstOrDefault().UserId);
        }
コード例 #39
0
 private void bAccept_Click(object sender, EventArgs e)
 {
     if (validate_data())
     {
         if (this.account == null)
         {
             this.account = new AccountDTO((int)nudCode.Value, tbName.Text, this.accountRange, cbRegularizingAccount.Checked, false);
         }
         else
         {
             this.account = new AccountDTO(this.account.Id, (int)nudCode.Value, tbName.Text, this.accountRange, cbRegularizingAccount.Checked, false);
         }
         try
         {
             this.dataValidation.saveAccount(this.account);
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #40
0
ファイル: AccountService.cs プロジェクト: Saphirox/LittleBlog
        public async void Create(AccountDTO accountDto)
        {
            accountDto.RoleName = accountDto.RoleName ?? "User";

            var userManager = this.UnitOfWork.UserManager;

            var user = await userManager.FindByEmailAsync(accountDto.Email);

            if (user != null)
            {
                throw IdentityException.UserIsExists(accountDto.Email);
            }

            var account = Mapper.Map <AccountDTO, Account>(accountDto);

            user = new AppUser
            {
                Email    = accountDto.Email,
                UserName = accountDto.Email,
                Account  = account
            };

            var userResult = userManager.Create(user, accountDto.Password);

            if (!userResult.Succeeded)
            {
                throw IdentityException.CreateingUserFailure(accountDto.Email);
            }

            var roleResult = UnitOfWork.UserManager.AddToRole(user.Id, accountDto.RoleName);

            if (!roleResult.Succeeded)
            {
                throw IdentityException.AddToRoleUserFailure(accountDto.Email, accountDto.RoleName);
            }
        }
コード例 #41
0
        public static FakeNetworkClient InitializeTestEnvironment()
        {
            System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");

            // initialize Logger
            Logger.InitializeLogger(LogManager.GetLogger(typeof(BasicPacketHandlerTest)));

            // create server entities (this values would have been imported)
            CreateServerItems();
            CreateServerMaps();
            CreateServerSkills();

            // initialize servermanager
            ServerManager.Initialize();

            // initialize WCF
            ServiceFactory.Instance.Initialize();

            // register mappings for items
            DAOFactory.InventoryDAO.RegisterMapping(typeof(SpecialistInstance));
            DAOFactory.InventoryDAO.RegisterMapping(typeof(WearableInstance));
            DAOFactory.InventoryDAO.RegisterMapping(typeof(UsableInstance));
            DAOFactory.InventoryDAO.InitializeMapper(typeof(ItemInstance));

            // initialize PacketSerialization
            PacketFactory.Initialize <WalkPacket>();

            // initialize new manager
            _sessionManager = new NetworkManager <TestEncryption>("127.0.0.1", 1234, typeof(CharacterScreenPacketHandler), typeof(TestEncryption), true);
            FakeNetworkClient client = new FakeNetworkClient();

            _sessionManager.AddSession(client);

            AccountDTO account = new AccountDTO()
            {
                AccountId   = 1,
                Authority   = AuthorityType.Admin,
                LastSession = 12345,
                Name        = "test",
                Password    = "******"
            };

            DAOFactory.AccountDAO.InsertOrUpdate(ref account);

            // register for account login
            ServiceFactory.Instance.CommunicationService.RegisterAccountLogin("test", 12345);

            // OpenNosEntryPoint -> LoadCharacterList
            client.ReceivePacket("12345");
            client.ReceivePacket("test");
            client.ReceivePacket("test");

            string clistStart = WaitForPacket(client);

            string clistEnd = WaitForPacket(client);

            // creation of character
            client.ReceivePacket("Char_NEW Test 2 1 0 9");

            List <string> clistAfterCreate = WaitForPackets(client, 3);
            CListPacket   cListPacket      = PacketFactory.Serialize <CListPacket>(clistAfterCreate[1]);

            // select character
            client.ReceivePacket($"select {cListPacket.Slot}");
            string okPacket = WaitForPacket(client);

            // start game
            client.ReceivePacket("game_start");
            List <string> gameStartPacketsFirstPart  = WaitForPackets(client, "p_clear");
            List <string> gameStartPacketsSecondPart = WaitForPackets(client, "p_clear");

            return(client);
        }
コード例 #42
0
        public ChatDTO GetOrCreateChat(AccountDTO accountDTO, string token)
        {
            IChatLogic <ChatDTO> chatLogic = new SoloChatLogic();

            return(chatLogic.GetOrCreateChat(accountDTO, token));
        }
コード例 #43
0
ファイル: UserService.cs プロジェクト: NAUoneLove/E_WalletWEB
 public void AddAccount(AccountDTO account)
 {
     throw new NotImplementedException();
 }
コード例 #44
0
        public async Task <IActionResult> UpdateAccountAsync([FromRoute] string accountId, [FromBody] AccountUpdateModel model)
        {
            var functions = GetCurrentAccountFunctionCodes();

            if (!functions.Contains("Account_Full"))
            {
                if (accountId != CurrentAccountId)
                {
                    throw new ForbiddenException();
                }
            }

            var account = await _accountRepository.GetAccountByIdAsync(accountId);

            if (account == null)
            {
                throw new NotFound404Exception("account");
            }

            if (model.Password != null)
            {
                if (model.Password.Length < 8 || model.Password.Length > 20)
                {
                    throw new PasswordIsInvalidException();
                }
            }

            if (model.Name != null)
            {
                if (model.Name.Length > 50)
                {
                    throw new NameIsInvalidException();
                }
            }

            if (model.BirthDate.HasValue)
            {
                if (model.BirthDate.Value.Year < Constants.MinBirthDate.Year || model.BirthDate.Value.Year > DateTime.Now.Year - Constants.MinAge)
                {
                    throw new BirthDateIsInvalidException();
                }
            }

            if (model.Email != null)
            {
                if (!model.Email.IsEmail())
                {
                    throw new EmailIsInvalidException();
                }

                if (model.Email != account.Email && await _accountRepository.AnyByEmailAsync(model.Email))
                {
                    throw new AlreadyExistsException("email");
                }
            }

            if (model.Phone != null)
            {
                if (!model.Phone.IsMobile())
                {
                    throw new PhoneIsInvalidException();
                }

                if (model.Phone != account.Phone && await _accountRepository.AnyByPhoneAsync(model.Phone))
                {
                    throw new AlreadyExistsException("phone");
                }
            }

            if (model.WardId.HasValue)
            {
                if (!await _wardRepository.AnyByIdAsync(model.WardId.Value))
                {
                    throw new NotFound400Exception("ward");
                }
            }

            // bind data
            account.WardId      = model.WardId.HasValue ? model.WardId.Value : account.WardId;
            account.Password    = model.Password != null ? model.Password : account.Password;
            account.Name        = model.Name != null ? model.Name : account.Name;
            account.Gender      = model.Gender.HasValue ? model.Gender.Value : account.Gender;
            account.BirthDate   = model.BirthDate.HasValue ? model.BirthDate : account.BirthDate;
            account.Address     = model.Address != null ? model.Address : account.Address;
            account.Email       = model.Email != null ? model.Email : account.Email;
            account.Phone       = model.Phone != null ? model.Phone : account.Phone;
            account.Avatar      = model.Avatar != null ? model.Avatar : account.Avatar;
            account.Description = model.Description != null ? model.Description : account.Description;
            account.UpdatedDate = DateTime.Now;

            await _accountRepository.UpdateAccountAsync(account);

            return(Ok(AccountDTO.GetFrom(account)));
        }
コード例 #45
0
        private void Save(object sender, EventArgs e)
        {
            AccountDTO dto = new AccountDTO();

            foreach (DataRow row in gd_list.Rows)//
            {
                if (row[0].ToString().Length > 0)
                {
                    if (rdoBank.Checked)
                    {
                        dto.ACC_ID       += ";" + row[0];
                        dto.ACC_DT       += ";" + DateTime.Parse(row[1].ToString()).ToString("yyyy-MM-dd");
                        dto.CASH         += ";" + row[7];
                        dto.CASH_DESC    += ";" + row[8];
                        dto.ACCOUNT_DESC += ";" + row[9];
                        dto.OUT_BANK_NM  += ";" + row[2];
                        dto.OUT_BANK_NO  += ";" + row[3];
                        dto.IN_BANK_NM   += ";" + row[4];
                        dto.IN_BANK_NO   += ";" + row[5];
                        dto.IN_NAME      += ";" + row[6];
                    }
                    else if (rdoCard.Checked)
                    {
                        dto.ACC_ID          += ";" + row[0];
                        dto.ACC_DT          += ";" + DateTime.Parse(row[1].ToString()).ToString("yyyy-MM-dd");
                        dto.CASH            += ";" + row[8];
                        dto.CASH_DESC       += ";" + row[9];
                        dto.ACCOUNT_DESC    += ";" + row[10];
                        dto.ACC_TYPE        += ";" + row[2];
                        dto.CARD_NM         += ";" + row[3];
                        dto.CARD_NO         += ";" + row[4];
                        dto.ACC_NO          += ";" + row[5];
                        dto.OUT_COMP_NM     += ";" + row[6];
                        dto.OUT_COMP_REG_ID += ";" + row[7];
                    }
                }
            }

            try
            {
                ClearSearchData();
                SetSearchData("ACC_ID", dto.ACC_ID != null && dto.ACC_ID.Length > 0 ? dto.ACC_ID.Substring(1) : "");
                SetSearchData("ACC_DT", dto.ACC_DT != null && dto.ACC_DT.Length > 0 ? dto.ACC_DT.Substring(1) : "");
                SetSearchData("CASH", dto.CASH != null && dto.CASH.Length > 0 ? dto.CASH.Substring(1) : "");
                SetSearchData("CASH_DESC", dto.CASH_DESC != null && dto.CASH_DESC.Length > 0 ? dto.CASH_DESC.Substring(1) : "");
                SetSearchData("ACCOUNT_DESC", dto.ACCOUNT_DESC != null && dto.ACCOUNT_DESC.Length > 0 ? dto.ACCOUNT_DESC.Substring(1) : "");
                SetSearchData("OUT_BANK_NM", dto.OUT_BANK_NM != null && dto.OUT_BANK_NM.Length > 0 ? dto.OUT_BANK_NM.Substring(1) : "");
                SetSearchData("OUT_BANK_NO", dto.OUT_BANK_NO != null && dto.OUT_BANK_NO.Length > 0 ? dto.OUT_BANK_NO.Substring(1) : "");
                SetSearchData("IN_BANK_NM", dto.IN_BANK_NM != null && dto.IN_BANK_NM.Length > 0 ? dto.IN_BANK_NM.Substring(1) : "");
                SetSearchData("IN_BANK_NO", dto.IN_BANK_NO != null && dto.IN_BANK_NO.Length > 0 ? dto.IN_BANK_NO.Substring(1) : "");
                SetSearchData("IN_NAME", dto.IN_NAME != null && dto.IN_NAME.Length > 0 ? dto.IN_NAME.Substring(1) : "");
                SetSearchData("ACC_TYPE", dto.ACC_TYPE != null && dto.ACC_TYPE.Length > 0 ? dto.ACC_TYPE.Substring(1) : "");
                SetSearchData("CARD_NM", dto.CARD_NM != null && dto.CARD_NM.Length > 0 ? dto.CARD_NM.Substring(1) : "");
                SetSearchData("CARD_NO", dto.CARD_NO != null && dto.CARD_NO.Length > 0 ? dto.CARD_NO.Substring(1) : "");
                SetSearchData("ACC_NO", dto.ACC_NO != null && dto.ACC_NO.Length > 0 ? dto.ACC_NO.Substring(1) : "");
                SetSearchData("OUT_COMP_NM", dto.OUT_COMP_NM != null && dto.OUT_COMP_NM.Length > 0 ? dto.OUT_COMP_NM.Substring(1) : "");
                SetSearchData("OUT_COMP_REG_ID", dto.OUT_COMP_REG_ID != null && dto.OUT_COMP_REG_ID.Length > 0 ? dto.OUT_COMP_REG_ID.Substring(1) : "");
                SetSearchData("LINK_CODE", "");
                SetSearchData("UPT_USER_ID", DTOFactory.UserId);
                SetServiceId(rdoBank.Checked ? "SetBankAccountImport" : "SetCardAccountImport");
                DTOFactory.Transaction(new AccountDTO());

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                ViewMessage.Error(ex.Message);
                DialogResult = DialogResult.Cancel;
            }

            if (DialogResult == DialogResult.OK)
            {
                ViewMessage.Info("등록이 완료 되었습니다.");
            }

            Close();
        }
コード例 #46
0
        internal static void SendStats(this ClientSession session, CharacterDTO characterDto)
        {
            session.SendPacket(session.Character.GenerateSay("----- CHARACTER -----", 13));
            session.SendPacket(session.Character.GenerateSay($"Name: {characterDto.Name}", 13));
            session.SendPacket(session.Character.GenerateSay($"Id: {characterDto.CharacterId}", 13));
            session.SendPacket(session.Character.GenerateSay($"State: {characterDto.State}", 13));
            session.SendPacket(session.Character.GenerateSay($"Gender: {characterDto.Gender}", 13));
            session.SendPacket(session.Character.GenerateSay($"Class: {characterDto.Class}", 13));
            session.SendPacket(session.Character.GenerateSay($"Level: {characterDto.Level}", 13));
            session.SendPacket(session.Character.GenerateSay($"JobLevel: {characterDto.JobLevel}", 13));
            session.SendPacket(session.Character.GenerateSay($"HeroLevel: {characterDto.HeroLevel}", 13));
            session.SendPacket(session.Character.GenerateSay($"Gold: {characterDto.Gold}", 13));
            session.SendPacket(session.Character.GenerateSay($"Bio: {characterDto.Biography}", 13));
            session.SendPacket(session.Character.GenerateSay($"MapId: {characterDto.MapId}", 13));
            session.SendPacket(session.Character.GenerateSay($"MapX: {characterDto.MapX}", 13));
            session.SendPacket(session.Character.GenerateSay($"MapY: {characterDto.MapY}", 13));
            session.SendPacket(session.Character.GenerateSay($"Reputation: {characterDto.Reputation}", 13));
            session.SendPacket(session.Character.GenerateSay($"Dignity: {characterDto.Dignity}", 13));
            session.SendPacket(session.Character.GenerateSay($"Rage: {characterDto.RagePoint}", 13));
            session.SendPacket(session.Character.GenerateSay($"Compliment: {characterDto.Compliment}", 13));
            session.SendPacket(session.Character.GenerateSay(
                                   $"Fraction: {(characterDto.Faction == FactionType.Demon ? Language.Instance.GetMessageFromKey("DEMON") : Language.Instance.GetMessageFromKey("ANGEL"))}",
                                   13));
            session.SendPacket(session.Character.GenerateSay("----- --------- -----", 13));
            AccountDTO account = DAOFactory.AccountDAO.LoadById(characterDto.AccountId);

            if (account != null)
            {
                session.SendPacket(session.Character.GenerateSay("----- ACCOUNT -----", 13));
                session.SendPacket(session.Character.GenerateSay($"Id: {account.AccountId}", 13));
                session.SendPacket(session.Character.GenerateSay($"Name: {account.Name}", 13));
                session.SendPacket(session.Character.GenerateSay($"Authority: {account.Authority}", 13));
                session.SendPacket(session.Character.GenerateSay($"RegistrationIP: {account.RegistrationIP}", 13));
                session.SendPacket(session.Character.GenerateSay($"Email: {account.Email}", 13));
                session.SendPacket(session.Character.GenerateSay("----- ------- -----", 13));
                IEnumerable <PenaltyLogDTO> penaltyLogs = ServerManager.Instance.PenaltyLogs
                                                          .Where(s => s.AccountId == account.AccountId).ToList();
                PenaltyLogDTO penalty = penaltyLogs.LastOrDefault(s => s.DateEnd > DateTime.UtcNow);
                session.SendPacket(session.Character.GenerateSay("----- PENALTY -----", 13));
                if (penalty != null)
                {
                    session.SendPacket(session.Character.GenerateSay($"Type: {penalty.Penalty}", 13));
                    session.SendPacket(session.Character.GenerateSay($"AdminName: {penalty.AdminName}", 13));
                    session.SendPacket(session.Character.GenerateSay($"Reason: {penalty.Reason}", 13));
                    session.SendPacket(session.Character.GenerateSay($"DateStart: {penalty.DateStart}", 13));
                    session.SendPacket(session.Character.GenerateSay($"DateEnd: {penalty.DateEnd}", 13));
                }

                session.SendPacket(
                    session.Character.GenerateSay($"Bans: {penaltyLogs.Count(s => s.Penalty == PenaltyType.Banned)}",
                                                  13));
                session.SendPacket(
                    session.Character.GenerateSay($"Mutes: {penaltyLogs.Count(s => s.Penalty == PenaltyType.Muted)}",
                                                  13));
                session.SendPacket(
                    session.Character.GenerateSay(
                        $"Warnings: {penaltyLogs.Count(s => s.Penalty == PenaltyType.Warning)}", 13));
                session.SendPacket(session.Character.GenerateSay("----- ------- -----", 13));
            }

            session.SendPacket(session.Character.GenerateSay("----- SESSION -----", 13));
            foreach (long[] connection in CommunicationServiceClient.Instance.RetrieveOnlineCharacters(characterDto
                                                                                                       .CharacterId))
            {
                if (connection != null)
                {
                    CharacterDTO character = DAOFactory.CharacterDAO.LoadById(connection[0]);
                    if (character != null)
                    {
                        session.SendPacket(session.Character.GenerateSay($"Character Name: {character.Name}", 13));
                        session.SendPacket(session.Character.GenerateSay($"ChannelId: {connection[1]}", 13));
                        session.SendPacket(session.Character.GenerateSay("-----", 13));
                    }
                }
            }

            session.SendPacket(session.Character.GenerateSay("----- ------------ -----", 13));
        }
コード例 #47
0
ファイル: fAccount.cs プロジェクト: hoangntse140253/Cshape
 private void loadUserAccount(AccountDTO account)
 {
     txtUsername.Text = account.Username;
     txtFullName.Text = account.Fullname;
     txtPassword.Text = account.Password;
 }
コード例 #48
0
ファイル: fAccount.cs プロジェクト: hoangntse140253/Cshape
 public fAccount(AccountDTO account)
 {
     InitializeComponent();
     loadUserAccount(account);
     this.FormBorderStyle = FormBorderStyle.FixedSingle;
 }
コード例 #49
0
 public string Remove(AccountDTO obj)
 {
     return(accountAc.Remove(obj.ToAccount()));
 }
コード例 #50
0
        /// <summary>
        /// Load Characters, this is the Entrypoint for the Client, Wait for 3 Packets.
        /// </summary>
        /// <param name="packet"></param>
        /// <returns></returns>
        public void LoadCharacters(EntryPointPacket packet)
        {
            if (Session.Account == null)
            {
                AccountDTO account = null;

                string name = packet.Name;
                account = DAOFactory.AccountDAO.FirstOrDefault(s => s.Name == name);

                if (account != null)
                {
                    if (account.Password.ToLower().Equals(EncryptionHelper.Sha512(packet.Password).ToLower()))
                    {
                        AccountDTO accountobject = new AccountDTO
                        {
                            AccountId = account.AccountId,
                            Name      = account.Name,
                            Password  = account.Password.ToLower(),
                            Authority = account.Authority
                        };
                        accountobject.Initialize();
                        Session.InitializeAccount(accountobject);
                        //Send Account Connected
                    }
                    else
                    {
                        Logger.Log.ErrorFormat(LogLanguage.Instance.GetMessageFromKey("INVALID_PASSWORD"));
                        Session.Disconnect();
                        return;
                    }
                }
                else
                {
                    Logger.Log.ErrorFormat(LogLanguage.Instance.GetMessageFromKey("INVALID_ACCOUNT"));
                    Session.Disconnect();
                    return;
                }
            }


            if (Session.Account == null)
            {
                return;
            }

            IEnumerable <CharacterDTO> characters = DAOFactory.CharacterDAO.Where(s => s.AccountId == Session.Account.AccountId && s.State == CharacterState.Active);

            Logger.Log.InfoFormat(LogLanguage.Instance.GetMessageFromKey("ACCOUNT_ARRIVED"), Session.Account.Name);

            // load characterlist packet for each character in Character
            Session.SendPacket(new ClistStartPacket()
            {
                Type = 0
            });
            foreach (Character character in characters)
            {
                WearableInstance[] equipment = new WearableInstance[16];

                /* IEnumerable<ItemInstanceDTO> inventory = DAOFactory.IteminstanceDAO.Where(s => s.CharacterId == character.CharacterId && s.Type == (byte)InventoryType.Wear);
                 *
                 *
                 * foreach (ItemInstanceDTO equipmentEntry in inventory)
                 * {
                 *   // explicit load of iteminstance
                 *   WearableInstance currentInstance = equipmentEntry as WearableInstance;
                 *   equipment[(short)currentInstance.Item.EquipmentSlot] = currentInstance;
                 *
                 * }
                 */
                List <short?>  petlist = new List <short?>();
                List <MateDTO> mates   = DAOFactory.MateDAO.Where(s => s.CharacterId == character.CharacterId).ToList();
                for (int i = 0; i < 26; i++)
                {
                    if (mates.Count > i)
                    {
                        petlist.Add(mates.ElementAt(i).Skin);
                        petlist.Add(mates.ElementAt(i).VNum);
                    }
                    else
                    {
                        petlist.Add(-1);
                    }
                }

                // 1 1 before long string of -1.-1 = act completion
                Session.SendPacket(new ClistPacket()
                {
                    Slot       = character.Slot,
                    Name       = character.Name,
                    Unknown    = 0,
                    Gender     = (byte)character.Gender,
                    HairStyle  = (byte)character.HairStyle,
                    HairColor  = (byte)character.HairColor,
                    Unknown1   = 0,
                    Class      = (CharacterClassType)character.Class,
                    Level      = character.Level,
                    HeroLevel  = character.HeroLevel,
                    Equipments = new List <short?>()
                    {
                        { equipment[(byte)EquipmentType.Hat]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.Armor]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.WeaponSkin]?.VNum ?? (equipment[(byte)EquipmentType.MainWeapon]?.VNum ?? -1) },
                        { equipment[(byte)EquipmentType.SecondaryWeapon]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.Mask]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.Fairy]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.CostumeSuit]?.VNum ?? -1 },
                        { equipment[(byte)EquipmentType.CostumeHat]?.VNum ?? -1 }
                    },
                    JobLevel        = character.JobLevel,
                    QuestCompletion = 1,
                    QuestPart       = 1,
                    Pets            = petlist,
                    Design          = (equipment[(byte)EquipmentType.Hat] != null && equipment[(byte)EquipmentType.Hat].Item.IsColored ? equipment[(byte)EquipmentType.Hat].Design : 0),
                    Unknown3        = 0
                });
            }
            Session.SendPacket(new ClistEndPacket());
        }
コード例 #51
0
        public void AddAccount(AccountDTO account)
        {
            var acc = account.MappingAccount();

            accountRepository.Add(acc);
        }
コード例 #52
0
        private void ExecuteHandler(ClientSession session)
        {
            string BuildServersPacket(string username, int sessionId, bool ignoreUserName)
            {
                string channelPacket = CommunicationServiceClient.Instance.RetrieveRegisteredWorldServers(username, sessionId, ignoreUserName);

                if (channelPacket?.Contains(':') != true)
                {
                    // no need for this as in release the debug is ignored eitherway
                    //if (ServerManager.Instance.IsDebugMode)
                    Logger.Debug("Could not retrieve Worldserver groups. Please make sure they've already been registered.");

                    // find a new way to display this message
                    //Session.SendPacket($"fail {Language.Instance.GetMessageFromKey("NO_WORLDSERVERS")}");
                    session.SendPacket($"fail {Language.Instance.GetMessageFromKey("IDERROR")}");
                }

                return(channelPacket);
            }

            UserDTO user = new UserDTO
            {
                Name     = Name,
                Password = ConfigurationManager.AppSettings["UseOldCrypto"] == "true" ? CryptographyBase.Sha512(LoginCryptography.GetPassword(Password)).ToUpper() : Password
            };
            AccountDTO loadedAccount = DAOFactory.AccountDAO.LoadByName(user.Name);

            if (loadedAccount?.Password.ToUpper().Equals(user.Password) == true)
            {
                string ipAddress = session.IpAddress;
                DAOFactory.AccountDAO.WriteGeneralLog(loadedAccount.AccountId, ipAddress, null, GeneralLogType.Connection, "LoginServer");

                //check if the account is connected
                if (!CommunicationServiceClient.Instance.IsAccountConnected(loadedAccount.AccountId))
                {
                    AuthorityType type    = loadedAccount.Authority;
                    PenaltyLogDTO penalty = DAOFactory.PenaltyLogDAO.LoadByAccount(loadedAccount.AccountId).FirstOrDefault(s => s.DateEnd > DateTime.UtcNow && s.Penalty == PenaltyType.Banned);
                    if (penalty != null)
                    {
                        // find a new way to display date of ban
                        session.SendPacket($"fail {string.Format(Language.Instance.GetMessageFromKey("BANNED"), penalty.Reason, penalty.DateEnd.ToString("yyyy-MM-dd-HH:mm"))}");;
                    }
                    else
                    {
                        switch (type)
                        {
                        case AuthorityType.Unconfirmed:
                        {
                            session.SendPacket($"fail {Language.Instance.GetMessageFromKey("NOTVALIDATE")}");
                        }
                        break;

                        case AuthorityType.Banned:
                        {
                            session.SendPacket($"fail {string.Format(Language.Instance.GetMessageFromKey("BANNED"), penalty.Reason, penalty.DateEnd.ToString("yyyy-MM-dd-HH:mm"))}");;
                        }
                        break;

                        case AuthorityType.Closed:
                        {
                            session.SendPacket($"fail {Language.Instance.GetMessageFromKey("IDERROR")}");
                        }
                        break;

                        default:
                        {
                            if (loadedAccount.Authority == AuthorityType.User || loadedAccount.Authority == AuthorityType.BitchNiggerFaggot)
                            {
                                MaintenanceLogDTO maintenanceLog = DAOFactory.MaintenanceLogDAO.LoadFirst();
                                if (maintenanceLog != null)
                                {
                                    // find a new way to display date and reason of maintenance
                                    session.SendPacket($"fail {string.Format(Language.Instance.GetMessageFromKey("MAINTENANCE"), maintenanceLog.DateEnd, maintenanceLog.Reason)}");
                                    return;
                                }
                            }

                            int newSessionId = SessionFactory.Instance.GenerateSessionId();
                            Logger.Debug(string.Format(Language.Instance.GetMessageFromKey("CONNECTION"), user.Name, newSessionId));
                            try
                            {
                                ipAddress = ipAddress.Substring(6, ipAddress.LastIndexOf(':') - 6);
                                CommunicationServiceClient.Instance.RegisterAccountLogin(loadedAccount.AccountId, newSessionId, ipAddress);
                            }
                            catch (Exception ex)
                            {
                                Logger.Error("General Error SessionId: " + newSessionId, ex);
                            }
                            string[] clientData     = ClientData.Split('.');
                            bool     ignoreUserName = clientData.Length < 3 ? false : short.TryParse(clientData[3], out short clientVersion) && (clientVersion < 3075 || ConfigurationManager.AppSettings["UseOldCrypto"] == "true");
                            session.SendPacket(BuildServersPacket(user.Name, newSessionId, ignoreUserName));
                        }
                        break;
                        }
                    }
                }
                else
                {
                    session.SendPacket($"fail {Language.Instance.GetMessageFromKey("ALREADY_CONNECTED")}");
                }
            }
            else
            {
                session.SendPacket($"fail {Language.Instance.GetMessageFromKey("IDERROR")}");
            }
        }
コード例 #53
0
ファイル: AccountDAO.cs プロジェクト: Ziratoxdu36/OpenNos
 private AccountDTO Update(Account entity, AccountDTO account, OpenNosContext context)
 {
     entity = _mapper.Map <Account>(account);
     context.SaveChanges();
     return(_mapper.Map <AccountDTO>(entity));
 }
コード例 #54
0
        public async Task <IActionResult> CreateAccountAsync([FromBody] AccountCreateModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Password))
            {
                throw new IsRequiredException("password");
            }

            if (model.Password.Length < 8 || model.Password.Length > 20)
            {
                throw new PasswordIsInvalidException();
            }

            if (model.Name != null)
            {
                if (model.Name.Length > 50)
                {
                    throw new NameIsInvalidException();
                }
            }

            if (model.BirthDate.HasValue)
            {
                if (model.BirthDate.Value.Year < Constants.MinBirthDate.Year || model.BirthDate.Value.Year > DateTime.Now.Year - Constants.MinAge)
                {
                    throw new BirthDateIsInvalidException();
                }
            }

            if (model.Email != null)
            {
                if (!model.Email.IsEmail())
                {
                    throw new EmailIsInvalidException();
                }

                if (await _accountRepository.AnyByEmailAsync(model.Email))
                {
                    throw new AlreadyExistsException("email");
                }
            }

            if (model.Phone != null)
            {
                if (!model.Phone.IsMobile())
                {
                    throw new PhoneIsInvalidException();
                }

                if (await _accountRepository.AnyByPhoneAsync(model.Phone))
                {
                    throw new AlreadyExistsException("phone");
                }
            }

            if (string.IsNullOrWhiteSpace(model.AccountId))
            {
                throw new IsRequiredException("accountId");
            }

            if (model.AccountId.Length > 20)
            {
                throw new AccountIdIsInvalidException();
            }

            if (await _accountRepository.AnyByIdAsync(model.AccountId))
            {
                throw new AlreadyExistsException("account");
            }

            if (model.WardId.HasValue)
            {
                if (!await _wardRepository.AnyByIdAsync(model.WardId.Value))
                {
                    throw new NotFound400Exception("ward");
                }
            }

            var now = DateTime.Now;

            var account = new Account
            {
                AccountId   = model.AccountId,
                GroupId     = 4,
                WardId      = model.WardId.HasValue ? model.WardId.Value : 0,
                Password    = model.Password,
                Name        = model.Name != null ? model.Name : null,
                Gender      = model.Gender.HasValue ? model.Gender.Value : null,
                BirthDate   = model.BirthDate.HasValue ? model.BirthDate : null,
                Address     = model.Address != null ? model.Address : null,
                Email       = model.Email != null ? model.Email : null,
                Phone       = model.Phone != null ? model.Phone : null,
                CreatedDate = now,
                UpdatedDate = now
            };

            await _accountRepository.CreateAccountAsync(account);

            return(Ok(AccountDTO.GetFrom(account)));
        }
コード例 #55
0
 public frm_XacNhan(string thongbao, AccountDTO accou)
 {
     InitializeComponent();
     lblThongBao.Text = thongbao;
 }
コード例 #56
0
 public string Update(AccountDTO obj)
 {
     return(accountAc.Update(obj.ToAccount()));
 }
コード例 #57
0
 public string GetOffice(AccountDTO transfer)
 {
     return(AccountDAL.Instance.GetAllInfoEmployee(transfer).Rows[0]["office"].ToString());
 }
コード例 #58
0
        public static Account ToEntity(this AccountDTO accountDTO)
        {
            var mapper = new Mapper(accountToEntityConfig);

            return(mapper.Map <Account>(accountDTO));
        }
コード例 #59
0
 public void LoadData(AccountDTO account)
 {
     Console.WriteLine($"\nPremium account - {account.CustomerType.ToString()}");
     Console.WriteLine("*Must have basic account for 3 years.");
     Console.WriteLine($"Mandatory Documents: {string.Join(',', account.MandatoryDocuments)}");
 }
コード例 #60
0
        private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            AccountDTO dto = gridAccounts.SelectedItem as AccountDTO;

            MessageBox.Show(dto.ToString());
        }