public PersonResponse AuthenticateUser(string userName_, string password_)
        {
            PersonResponse personResponse = new PersonResponse();

            try
            {
                //WebRequestLogManager objWebRequestLogManager = new WebRequestLogManager();
                //decimal requestId = objWebRequestLogManager.AddRequest(string.Format("Project {0}, Page {1}, Method {2}, currentCulture {3}, clientID {4}, statusids {5}, partnertypecodes {6}", "ELSBackendBLL", "masterManager.cs", "GetAllPartners", culture, clientId, statusids, partnertypecodes), 0, CommonFunctions.RequestSource.WEB.ToString());
                AccountDB accountDB = new AccountDB();
                personResponse = accountDB.AuthenticateUser(userName_, password_);
                //objWebRequestLogManager.AddResponse(masterResponse.Status.ToString(), requestId, 0);
            }
            //catch (CustomException ex)
            //{
            //    masterResponse = new MasterResponse(ex.ResponseStatus);
            //}
            catch (Exception ex)
            {
                //var Error = "Exception : " + ex.Message + ", Inner Exception : " + (ex.InnerException == null ? "" : ex.InnerException.Message);
                //ExceptionLogDB.LogException("ELSBAL", "MasterManager.cs", "GetAllRoles", CommonFunctions.RequestSource.WEB.ToString(), Error);
                personResponse = new PersonResponse(BaseResponse.ResponseStatus.Error);
            }

            return(personResponse);
        }
Exemple #2
0
        public String Deposit(Transaction transaction)
        {
            TransactionDB.Deposit(transaction);
            double balance = AccountDB.getBalance(transaction.Acctno);

            return("Deposit of $" + transaction.Amount + " made to account " + transaction.Acctno + " ($" + balance + " remaining)");
        }
Exemple #3
0
        public async Task <IActionResult> Register(RegisterViewModel reg)
        {
            if (ModelState.IsValid)
            {
                // Check username is not taken
                if (!await AccountDB.IsUsernameTaken(reg.Username, _context))
                {
                    Account acc = new Account()
                    {
                        Email    = reg.Email,
                        FullName = reg.FullName,
                        Password = reg.Password,
                        Username = reg.Username
                    };
                    // Add account to database
                    await AccountDB.Register(_context, acc);

                    //Create user session
                    SessionHelper.CreateUserSession(acc.AccountId, acc.Username, _http);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    // Display error with other username error messages
                    ModelState.AddModelError(nameof(Account.Username), "Username is already taken.");
                }
            }
            return(View(reg));
        }
Exemple #4
0
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public RPCResult <Guid> CreateAccount(Account account)
        {
            Guid guid = System.Guid.NewGuid();

            if (string.IsNullOrWhiteSpace(account.AccountID))
            {
                account.AccountID = guid.ToString();
            }
            else
            {
                guid = Guid.Parse(account.AccountID);
            }
            account.SMSNumber = 0;
            try
            {
                if (AccountDB.CreateAccount(account))
                {
                    return(new RPCResult <Guid>(true, guid, "创建用户成功!"));
                }
                LogHelper.LogWarn("SMSService", "SMSService.CreateAccount", "创建账号数据库失败");
                return(new RPCResult <Guid>(false, guid, "创建账号失败!"));
            }
            catch (Exception ex)
            {
                LogHelper.LogError("SMSService", "SMSService.CreateAccount", ex.ToString());
                return(new RPCResult <Guid>(false, guid, "创建账号异常"));
            }
        }
Exemple #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new TellerForm());

            //Construct the models.
            CustomerDB cDatabase = new CustomerDB();
            AccountDB  aDatabase = new AccountDB();

            //Create virtual Donald Trump.
            cDatabase.addNewCustomer("D. Trump", "Atlantic City, NJ");
            aDatabase.addNewAccount(1, 80);
            MessageBox.Show("Account number 100 constructed for D.Trump.", "New Customer Created");

            //Create Virtual Bill Gates. He gets $10,000 and a custoemr number of 2.
            cDatabase.addNewCustomer("Bill Gates", "Microsoft Lane, United States");
            aDatabase.addNewAccount(2, 10000);
            MessageBox.Show("Account number 101 constructed for Bill Gates.", "New Customer Created");

            //Construct the controllers for the ATM's.
            AtmPresenter ATMController1 = new AtmPresenter(cDatabase, aDatabase);
            AtmPresenter ATMController2 = new AtmPresenter(cDatabase, aDatabase);

            //Construct the controller for the Teller form.
            TellerController TellerConroller1 = new TellerController(aDatabase, cDatabase);

            //Construct the threads for the ATM's.
            new Thread(ATMThread1).Start(ATMController1);
            new Thread(ATMThread2).Start(ATMController2);

            //Construct the thread for the Teller assmebly.
            new Thread(TellerThread1).Start(TellerConroller1);
        }
Exemple #6
0
 public UserModel GetUserRole(int pfid)
 {
     log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
     try
     {
         using (AccountDB accountDB = new AccountDB())
         {
             UserModel     userModel     = null;
             UserRoleModel userRoleModel = accountDB.GetUserRole(pfid);
             if (userRoleModel != null)
             {
                 userModel = new UserModel
                 {
                     Pfid   = pfid,
                     Name   = userRoleModel.Name,
                     RoleId = userRoleModel.RoleId
                 };
             }
             return(userModel);
         }
     }
     catch (Exception exception)
     {
         errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
         throw;
     }
     finally
     {
         log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
     }
 }
Exemple #7
0
        /// <summary>
        /// 提交短信,并扣费
        /// </summary>
        /// <param name="sms"></param>
        /// <returns></returns>
        public RPC_Result <SMS.DTO.SMSDTO> SendSMS(SMS.DTO.SMSDTO sms)
        {
            try
            {
                Account account = AccountDB.GetAccount(sms.Message.AccountID);//AccountServer.Instance.GetAccount(sms.Message.AccountID);
                if (account == null)
                {
                    LogHelper.LogWarn("Pretreatment", "PretreatmentService.SendSMS", "系统中不存在此用户 -> {Account=" + sms.Message.AccountID + "}");
                    MessageTools.MessageHelper.Instance.WirteInfo("提交短信失败,PretreatmentService.SendSMS,系统中不存在此用户 -> {Account=" + sms.Message.AccountID + "}");
                    return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "用户不存在"));
                }
                if (account.SMSNumber < sms.Message.NumberCount)
                {
                    return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "总共要发 " + sms.Message.FeeTotalCount + " 条短信,账号余额不足!"));
                }
                if (string.IsNullOrEmpty(sms.Message.SPNumber))
                {
                    sms.Message.SPNumber = defaultSPNumber.Split(',')[0];
                }

                SMS.DB.SMSDAL.AddSMS(sms);
                account = AccountDB.GetAccount(sms.Message.AccountID);

                return(new RPC_Result <SMS.DTO.SMSDTO>(true, sms, "短信已提交成功,扣费:" + sms.Message.FeeTotalCount + "条,剩余" + account.SMSNumber + "条"));
            }
            catch (Exception ex)
            {
                MessageTools.MessageHelper.Instance.WirteError("发送短信时发生了异常", ex);
                return(new RPC_Result <SMS.DTO.SMSDTO>(false, sms, "发送短信时发生了异常"));
            }
        }
        private void AccountlistView_SelectedIndexChanged(object sender, EventArgs e)
        {
            dictAccount  = AccountDB.ReadFromFile();
            dictCustomer = CustomerDB.ReadFromFile();
            Dictionary <int, Transaction> tempDictTrans = new Dictionary <int, Transaction>();

            if (AccountlistView.SelectedIndices.Count > 0)
            {
                Account  anAcc;
                Customer aCustomer;
                dictAccount.TryGetValue(Int32.Parse(AccountlistView.SelectedItems[0].SubItems[0].Text), out anAcc);
                this.AccountNumbertextBox.Text        = Convert.ToString(anAcc.AccNumber);
                this.AccCustIDtextBox.Text            = Convert.ToString(anAcc.CustomerId);
                this.AccountTypecomboBox.SelectedItem = anAcc.Acctype;
                dictCustomer.TryGetValue(Int32.Parse(AccountlistView.SelectedItems[0].SubItems[2].Text), out aCustomer);
                this.CustomerIDtextBox.Text   = Convert.ToString(aCustomer.PersonId);
                this.FirstNametextBox.Text    = aCustomer.Fn;
                this.LastNametextBox.Text     = aCustomer.Ln;
                this.EmailtextBox.Text        = aCustomer.Email.ToString();
                this.PhonetextBox.Text        = aCustomer.Phone.ToString();
                this.StreetNumbertextBox.Text = Convert.ToString(aCustomer.Address.StreetNo);
                this.StreetNametextBox.Text   = aCustomer.Address.StreetName;
                this.AptNumbertextBox.Text    = Convert.ToString(aCustomer.Address.AptNo);
                this.CitytextBox.Text         = aCustomer.Address.City;
                this.ProvincetextBox.Text     = aCustomer.Address.Province;
                this.CountrytextBox.Text      = aCustomer.Address.Country;
                this.PostalCodetextBox.Text   = aCustomer.Address.PostalCode;
                this.AccCustIDtextBox.Text    = this.CustomerIDtextBox.Text;
                tempDictTrans = anAcc.accTransactionDict;
                ShowAllTransactions(tempDictTrans);
            }
        }
        /// <summary>
        /// Apaga o usuário.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void strip_delete_Click(object sender, EventArgs e)
        {
            if (pData.ID == 0)
            {
                DarkMessageBox.ShowInformation("Você precisa carregar um usuário para fazer essa ação.", "Aviso");
                return;
            }

            var result = DarkMessageBox.ShowWarning("Deseja realmente apagar este usuário?", "Aviso", DarkDialogButton.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }

            if (AccountDB.DeleteAccountData(pData.ID) > 0)
            {
                DarkMessageBox.ShowInformation("Usuário deletado.", "Aviso");

                CharacterDB.DeleteAllCharacter(pData.ID);

                Clear();
                pData.Clear();
                return;
            }

            DarkMessageBox.ShowWarning("Não foi possível fazer a exclusão.", "Aviso");
        }
Exemple #10
0
        private void LoadData()
        {
            var db      = new AccountDB();
            var dbError = db.Open();

            if (dbError.Number != 0)
            {
                var errorText = $"Cannot connect to database {Environment.NewLine}";
                errorText += $"Error Number: {dbError.Number}{Environment.NewLine}";
                errorText += $"Error Message: {dbError.Message}";

                MessageBox.Show(errorText);
            }
            else
            {
                if (db.Connected)
                {
                    var character = db.GetCharacter(CharacterId);

                    FillControlData(ref character);

                    name = character.Name;
                }
                else
                {
                    MessageBox.Show("Database is not connected.");
                }
            }
        }
Exemple #11
0
 /// <summary>
 /// 账号充值
 /// </summary>
 /// <param name="accountID">充值账号</param>
 /// <param name="quantity">充值数</param>
 /// <param name="operatorAccount">操作人</param>
 /// <returns></returns>
 public RPCResult AccountPrepaid(string accountID, uint quantity, string operatorAccount)
 {
     try
     {
         if (string.IsNullOrEmpty(accountID))
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountPrepaid", "充值账号为空");
             return(new RPCResult(false, "充值账号不能为空!"));
         }
         Account account = AccountDB.GetAccount(accountID);//AccountServer.Instance.GetAccount(accountID);
         if (account == null)
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountPrepaid", "充值账号不存在");
             return(new RPCResult(false, "账号不存在"));
         }
         if (account.SMSNumber + (int)quantity < 0 && quantity > 10000000)
         {
             return(new RPCResult(false, "充值金额太大"));
         }
         if (AccountDB.AccountPrepaid(account.AccountID, (int)quantity))
         {
             PrepaidRecordDB.Add(operatorAccount, accountID, quantity);
             return(new RPCResult(true, "充值成功"));
         }
         LogHelper.LogWarn("SMSService", "SMSService.AccountPrepaid", "充值数据库操作失败");
         return(new RPCResult(false, "充值失败"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.AccountPrepaid", ex.ToString());
         return(new RPCResult(false, "充值失败"));
     }
 }
Exemple #12
0
        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.errMessage = "Please enter valid information.";
                return(View(model));
            }

            Account account = AccountDB.FindActivatedAccount(model.username);

            if (account == null)
            {
                model.errMessage = "Account not found";
                return(View(model));
            }

            string code = Guid.NewGuid().ToString();

            AccountDB.UpdateCode(account.Username, code);

            string subject = "Password Reset Link.";
            string url     = "http://*****:*****@"

<p><a href='" + url + @"'>" + url + @"<a/></p>

Thank you, <br>
hANNGry
";

            EmailNotifier.SendHtmlEmail(account.Email, subject, body);
            model.message = "Link Sent";
            return(View(model));
        }
Exemple #13
0
        public ActionResult ResetPassword(ChangePasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.errMessage = "Please enter valid information.";
                return(View(model));
            }

            Account existingAccount = AccountDB.FindAccountByCode(model.code);

            if (existingAccount == null)
            {
                return(RedirectToAction("Login"));
            }
            if (ModelState.IsValid)
            {
                AccountDB.ResetPassword(model.code, model.psw);
                model.message = "Reset successfully";
            }
            else
            {
                model.errMessage = "Please enter valid information.";
            }
            return(View(model));
        }
Exemple #14
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     // Application.Run(new MainForm(AccountDB.FindAccount("employee")));
     Application.Run(new MainForm(AccountDB.FindActivatedAccount("manager")));
 }
Exemple #15
0
        public ActionResult Staff_ChangePassword(ChangPasswordModel model, string returnURL)
        {
            if (ModelState.IsValid)
            {
                string username = model.Username;
                string password = model.Password;
                string confirm  = model.ConfirmPassword;
                if (confirm.Equals(password))
                {
                    AccountDB accountDB = new AccountDB();
                    bool      check     = accountDB.ChangePass(username, password);
                    if (check)
                    {
                        TempData["alertMessage"] = "Success";
                        return(RedirectToAction("Staff_Product", "Staff"));
                    }
                    else
                    {
                        TempData["alertMessage"] = "Fail";
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Password must match Confirm");
                }
            }

            return(View());
        }
        /// <summary>
        /// Salva os dados.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void strip_save_Click(object sender, EventArgs e)
        {
            if (!VerifyTextbox())
            {
                return;
            }

            FillPlayerData();

            if (pData.ChangePass)
            {
                if (pData.LastPassword.CompareTo(pData.Password) == 0)
                {
                    pData.ChangePass = false;
                }
            }

            if (pData.ChangePin)
            {
                if (pData.LastPin.CompareTo(pData.Pin) == 0)
                {
                    pData.ChangePin = false;
                }
            }

            if (AccountDB.SaveAccountData(pData) > 0)
            {
                DarkMessageBox.ShowInformation("As informações do usuário foram atualizadas.", "Aviso");

                Clear();
                return;
            }

            DarkMessageBox.ShowWarning("Não foi possível salvar os dados.", "Aviso");
        }
        public async Task <IActionResult> Register(RegisterViewModel reg)
        {
            if (ModelState.IsValid)
            {
                // Check username is not taken
                if (!await AccountDB.IsUsernameTaken(reg.Username, _context))
                {
                    Account acc = new Account()
                    {
                        FullName = reg.FullName,
                        Username = reg.Username,
                        Password = reg.Password,
                        Email    = reg.Email
                    };

                    await AccountDB.Register(acc, _context);

                    SessionHelper.CreateUserSession(acc.AccountID, acc.Username, _http);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError(nameof(Account.Username), "That username is taken");
                }
            }

            return(View(reg));
        }
Exemple #18
0
 /// <summary>
 /// 账号扣费,返费
 /// </summary>
 /// <param name="accountID">扣费账号</param>
 /// <param name="quantity">扣费数 可以为负</param>
 /// <returns></returns>
 public RPCResult AccountDeductSMSCount(string accountID, int quantity)
 {
     try
     {
         if (string.IsNullOrEmpty(accountID))
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "账号为空");
             return(new RPCResult(false, "扣费账号不能为空!"));
         }
         Account account = AccountDB.GetAccount(accountID);// AccountServer.Instance.GetAccount(accountID);
         if (account == null)
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "账号不存在");
             return(new RPCResult(false, "账号不存在"));
         }
         if (AccountDB.DeductAccountSMSCharge(account.AccountID, (int)quantity))
         {
             return(new RPCResult(true, ""));
         }
         LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "扣费数据库操作失败");
         return(new RPCResult(false, "扣费失败"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.AccountDeductSMSCharge", ex.ToString());
         return(new RPCResult(false, "扣费失败"));
     }
 }
        public ActionResult Login(string username, string password)
        {
            try
            {
                AccountDB accountDB = new AccountDB();
                int       role      = accountDB.CheckRole(username, password);
                if (role == 0)
                {
                    FormsAuthentication.SetAuthCookie(username, false);
                    return(RedirectToAction("Show_Product", "Admin"));
                }
                else if (role == 1)
                {
                    FormsAuthentication.SetAuthCookie(username, false);
                    return(RedirectToAction("Staff_Product", "Staff"));
                }
                else if (role == 2)
                {
                    ModelState.AddModelError("", "Your Role is not Supported");
                }
                else
                {
                    ModelState.AddModelError("", "Wrong username or password");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(RedirectToAction("Error", "Error"));
            }


            return(View());
        }
Exemple #20
0
        public bool Consume(string username, string product, int quantity)
        {
            IAccountDB      accountDB      = new AccountDB();
            IAccountManager accountManager = new AccountManager(accountDB);

            return(accountManager.Consume(username, product, quantity));
        }
Exemple #21
0
        public bool LoadWithUsername(string username, decimal quota)
        {
            IAccountDB      accountDB      = new AccountDB();
            IAccountManager accountManager = new AccountManager(accountDB);

            return(accountManager.TransferMoneyWithUsername(username, quota));
        }
Exemple #22
0
        public bool LoadWithUID(int UID, decimal quota)
        {
            IAccountDB      accountDB      = new AccountDB();
            IAccountManager accountManager = new AccountManager(accountDB);

            return(accountManager.TransferMoneyWithUID(UID, quota));
        }
Exemple #23
0
        public Account DisplayAccountByUsername(string username)
        {
            IAccountDB      accountDB      = new AccountDB();
            IAccountManager accountManager = new AccountManager(accountDB);
            var             account        = accountManager.GetAccountByUsername(username);

            return(account);
        }
Exemple #24
0
        public Account DisplayAccountByUID(int UID)
        {
            IAccountDB      accountDB      = new AccountDB();
            IAccountManager accountManager = new AccountManager(accountDB);
            var             account        = accountManager.GetAccountByUID(UID);

            return(account);
        }
Exemple #25
0
        public String AddAccount(Account account)
        {
            var successful = AccountDB.CreateAccount(ref account);

            return(successful ?
                   "Account " + account.Acctno + " created for user " + account.Username :
                   "******" + account.Username + " does not exist");
        }
Exemple #26
0
 public LoginQueue(Authentication configuration, Common.Database.DatabaseConnection db, Logger logger)
 {
     this.Log                   = logger.CreateLogChannel("LoginQueue");
     this.mConfiguration        = configuration;
     this.m_mDatabaseConnection = db;
     this.mAccountDB            = new AccountDB(this.m_mDatabaseConnection);
     this.mThread               = new Thread(Run);
 }
 public GuestListingForm(GuestController aController, AccountDB acctDB)
 {
     InitializeComponent();
     guestController  = aController;
     this.Load       += GuestListingForm_Load;
     this.FormClosed += GuestListingForm_FormClosed;
     this.Activated  += GuestListingForm_Activated;
     accountDB        = acctDB;
 }
 public GuestMDIParent()
 {
     InitializeComponent();
     guestController   = new GuestController();
     accountDB         = new AccountDB(guestController);
     bookingController = new BookingController(guestController);
     accountDB.setBookingController(bookingController);
     this.WindowState = FormWindowState.Maximized;
 }
Exemple #29
0
        public LoginQueue(Authentication configuration, AccountDB db, Logger logger)
        {
            this.Log           = logger.CreateLogChannel("LoginQueue");
            this.Configuration = configuration;
            this.AccountDB     = db;

            // start the queue thread
            new Thread(Run).Start();
        }
 private void CloseAccountButton_Click(object sender, EventArgs e)
 {
     dictCustomer[Int32.Parse(AccCustIDtextBox.Text)].customerAccount.Remove(Int32.Parse(AccountNumbertextBox.Text));
     dictAccount.Remove(Convert.ToInt32(AccountNumbertextBox.Text));
     AccountDB.SaveToFile(dictAccount);
     Reset();
     ShowAllAccounts(dictAccount);
     this.AccountTypecomboBox.SelectedItem = EnumType.Undefined;
 }
Exemple #31
0
 public static bool StartDatabase()
 {
     try
     {
         charDB = new MySQLActorDB(Configuration.Instance.DBHost, Configuration.Instance.DBPort,
              Configuration.Instance.DBName, Configuration.Instance.DBUser, Configuration.Instance.DBPass);
         accountDB = new MySQLAccountDB(Configuration.Instance.DBHost, Configuration.Instance.DBPort,
             Configuration.Instance.DBName, Configuration.Instance.DBUser, Configuration.Instance.DBPass); charDB.Connect();
         accountDB.Connect();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }