public ActionResult Login(string username, string password) { Customer cus = db.Customers.SingleOrDefault(n => n.Account.UserName == username && n.Account.Role_Account.FirstOrDefault().Role.Role_Name == "Customer"); if (cus == null) { ViewBag.Error = "Username or password is incorrect"; } else { if (!HashPwdTool.CheckPassword(password, cus.Account.PasswordHash)) { ViewBag.Error = "Username or password is incorrect"; } else { if (cus.Blocks != null && (cus.Blocks.LastOrDefault().UnBlockDate == null || cus.Blocks.LastOrDefault().UnBlockDate > DateTime.Now)) { ViewBag.Error = "Username is blocking"; } else { Session["Account"] = cus.Account; AccountLog accLog = new AccountLog(); accLog.Account = cus.Account; db.AccountLogs.Add(accLog); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } } } return(View("Login")); }
public bool LogAction_LOGOUT(CurrentUserModel cuM, string clientIP) { try { #warning do poprawy Account ac = logUnityOfWork.AccountRepo.GetById(cuM.AccountId); logUnityOfWork.AccountRepo.Attach(ref ac); AccountLog al = new AccountLog { Account = ac, Action = "Uzytkownik " + cuM.UserName + " wylogował się do konta z adresu " + clientIP, ActionDescription = "Użytkownik wylogowal się pomyślnie o " + DateTime.Now, ActionType = ActionType.LogOut, EndDate = DateTime.Now, StartDate = DateTime.Now }; logUnityOfWork.AccountLogRepo.Add(al); logUnityOfWork.UnityOfWork.SaveChanges(); return(true); } catch (Exception) { throw; } finally { logUnityOfWork.UnityOfWork.Dispose(); } }
public bool LogAction_LOGIN(Account ac, string clientIP) { try { logUnityOfWork.AccountRepo.Attach(ref ac); AccountLog al = new AccountLog { Account = ac, Action = "Uzytkownik " + ac.UserName + " logował się do konta z adresu " + clientIP, ActionDescription = "Użytkownik zalogowal się pomyślnie o " + DateTime.Now, ActionType = ActionType.Login, EndDate = DateTime.Now, StartDate = DateTime.Now }; logUnityOfWork.AccountLogRepo.Add(al); logUnityOfWork.UnityOfWork.SaveChanges(); return(true); } catch (Exception) { throw; } }
/// <summary> /// 账户花销(包含写帐户日志) /// </summary> /// <param name="orderId"></param> /// <returns></returns> public bool AccountExpend(decimal orderId, string ip) { Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL(); Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL(); TOrder o = obll.Get(orderId); MAccount acc = GetByUserId(o.UserId); if (acc.Amount >= o.Total) { AccountLog accLog = new AccountLog() { UserId = o.UserId, OrderId = o.OrderId, Amount = -o.Total, AccountWay = (int)AmountWay.Out, Ip = ip }; albll.Insert(accLog); acc.Amount = acc.Amount - o.Total; return(Update(acc)); } return(false); }
public async Task <ActionResult> Create(AccountLogViewModel viewModel) { try { var user = await GetCurrentUserAsync(); var newLog = new AccountLog() { ApplicationUserId = user.Id, Amount = viewModel.Amount, LogTypeId = viewModel.LogTypeId, Deposit = viewModel.Deposit, AccountId = viewModel.AccountId, Date = viewModel.Date, Name = viewModel.Name }; _context.AccountLogs.Add(newLog); await _context.SaveChangesAsync(); // TODO: Add insert logic here return(RedirectToAction(nameof(Index))); } catch (Exception ex) { return(View()); } }
public void LogAccount(AccountLog log) { log.DomainName = VMGlobal.DomainName; log.IPAddress = VMGlobal.IPAddress; log.LogTimestamp = new DateTime?(DateTime.Now); log.MachineAccount = VMGlobal.MachineAccount; log.MachineID = VMGlobal.MachineID; log.MachineName = VMGlobal.MachineName; if (VMGlobal.AccountRecord == null) { log.AccountId = new Guid?(Guid.Empty); log.AccountName = "n/a"; log.BadgeNumber = "n/a"; } else { log.AccountId = new Guid?(VMGlobal.AccountRecord.Id); log.AccountName = VMGlobal.AccountRecord.ToString(); log.BadgeNumber = VMGlobal.AccountRecord.BadgeNumber; } try { context.AccountLogs.Add(log); Save(); } catch { } }
internal static void Delete(UserData user) { File.Delete(MakeUrl(user.Name)); foreach (var account in user.Accounts) { AccountLog.Delete(account.Value); } }
public Account(IUser owner) { this.owner = owner; this.isCallInitiator = false; this.AccountBalance = new Balance(); accountLog = new AccountLog(); Status = AccountStatus.Deactivated; ActivateAccount(); }
private void CreateLog(string loginName, SessionWapper sessionWapper) { AccountLog log = new AccountLog(); log.LoginName = loginName; log.SessionKey = sessionWapper.SessionKey; log.CreateTime = sessionWapper.CreateTime; log.ActionName = "Login"; loginLogDao.Create(log); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(AccountLog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "AccountLog.Insert"; return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(AccountLog obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "AccountLog.Update"; int result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj); return(result > 0 ? true : false); }
private void WriteLog(VMGlobal.LOG_ACTION action, string memo) { try { AccountLog log = new AccountLog(); log.Action = action.ToString(); log.Memo = memo; using (RPM_Logs rpmLogs = new RPM_Logs()) rpmLogs.LogAccount(log); } catch { } }
public IHttpActionResult Post(AccountLog accountsBankDetails) { if (ModelState.IsValid) { int c = _accountLogBll.Insert(accountsBankDetails); if (c == 1) { return(Json(new { Msg = "1" })); } return(Json(new { Msg = "0" })); } else { return(Json(new { Msg = "0" })); } }
public static void WriteAccountLog(VMGlobal.LOG_ACTION action, string memo, Guid Id) { if (Id != Guid.Empty) { using (RPM_Account rpmAccount = new RPM_Account()) { Account account = rpmAccount.GetAccount(Id); memo = string.Format("{0} [{1}]\n", account.ToString(), account.BadgeNumber) + memo; } } AccountLog log = new AccountLog(); log.Action = action.ToString(); log.Memo = memo; using (RPM_Logs rpmLogs = new RPM_Logs()) rpmLogs.LogAccount(log); }
public void DoExchange(decimal orderId) { OrderService os = Context.GetService <OrderService>(); TOrder o = os.TOrderBll.Get(orderId); o.Status = (int)OrderStatus.AdminDoExchange; o.UpdateTime = DateTime.Now; os.TOrderBll.Update(o); //写账户日志 AccountLog accLog = new AccountLog() { AccountWay = (int)AmountWay.EOut, Amount = -o.Total, CreateTime = DateTime.Now, Ip = Utils.TmmUtils.IPAddress(), OrderId = o.OrderId, UserId = o.UserId, PayWay = 0, AdminRemark = "兑换" }; os.MAccountLogBll.Insert(accLog); //更新账户信息 MAccount acc = os.MAccountBll.GetByUserId(o.UserId); acc.FrozenAmount -= o.Total; acc.TotalExchange += o.Total; acc.UpdateTime = DateTime.Now; os.MAccountBll.Update(acc); //发系统消息 M_Message msg = new M_Message() { SenderId = Helper.ConfigHelper.AdminUserId, RecieverId = o.UserId, CreateTime = DateTime.Now, IsRead = false, Mtype = (int)Model.Enums.MessageType.Inform, Title = "您的兑换申请已经被受理", Content = string.Format("您的兑换申请已被管理员受理,请注意查收您的{0}账号", o.Remark == "1" ? "支付宝" : "银行") }; Service.Bll.User.M_MessageBLL msgBll = new TMM.Service.Bll.User.M_MessageBLL(); msgBll.Insert(msg); base.SuccessInfo(); RedirectToReferrer(); }
private void WriteLog(VMGlobal.LOG_ACTION action, string memo, Guid Id) { if (Id != Guid.Empty) { DbSet <Account> accounts = context.Accounts; object[] id = new object[] { Id }; Account account = accounts.Find(id); memo = string.Concat(string.Format("{0} [{1}]\n", account.ToString(), account.BadgeNumber), memo); } AccountLog accountLog = new AccountLog() { Action = action.ToString(), Memo = memo }; using (RPM_Logs rPMLog = new RPM_Logs()) { rPMLog.LogAccount(accountLog); } }
public static void Log(AccountLog log) { try { log.DomainName = Environment.UserDomainName; log.LogTimestamp = new DateTime?(DateTime.Now); log.MachineAccount = Environment.UserName; log.MachineName = Environment.MachineName; log.AccountId = new Guid?(GlobalAccount.Id); log.AccountName = GlobalAccount.ToString(); log.BadgeNumber = GlobalAccount.BadgeNumber; log.IPAddress = IPAddress; log.MachineID = MachineID; using (RPM_Logs rpmLogs = new RPM_Logs()) rpmLogs.LogAccount(log); } catch { } }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (this.IsCaptchaValid("Mã kiểm tra không đúng")) { if (user != null) { await SignInAsync(user, model.RememberMe); //Insert Logaccount var db = new ApplicationDbContext(); var _TEN_TTP = ""; _TEN_TTP = (new FDBContext()).DTINHTP.FirstOrDefault(o => o.MA_TINHTP == user.MA_TINHTP).TEN_TINHTP; //var _accountlog = new AccountLog { Username = model.UserName, Logtime = DateTime.Now, Fullname = user.FirstName + " " + user.LastName, MA_TTP = user.MA_TINHTP, TEN_TTP = _TEN_TTP }; var _accountlog = new AccountLog { Username = model.UserName, Logtime = DateTime.Now, Fullname = user.FirstName + " " + user.LastName, MA_TTP = user.MA_TINHTP, TEN_TTP = _TEN_TTP }; db.AccountLogs.Add(_accountlog); db.SaveChanges(); Session["IdLog"] = _accountlog.Id; return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "Sai tên đăng nhập hoặc mật khẩu!"); } } else { ViewBag.ErrMessage = "Lỗi: Mã kiểm tra không đúng"; } } // If we got this far, something failed, redisplay form return(View(model)); }
public static void AccountLog(string ip, string eventtext, string description, long acctid) { using (VendingModelContainer dc = new VendingModelContainer()) { try { DateTime cdt = DateTime.Now; string cdtstr = cdt.ToString("dd.MM.yyyy HH:mm:ss"); long cdtl = Convert.ToInt64(cdt.ToString("yyyyMMddHHmmss")); AccountLog tmplog = new AccountLog() { AccountID = acctid, DateTime = cdtl, DateTimeStr = cdtstr, IPAddress = ip, EventText = eventtext, Description = description }; dc.AccountLog.Add(tmplog); dc.SaveChanges(); } catch { } } }
public ActionResult Login(string username, string password) { Employee emp = db.Employees.SingleOrDefault(n => n.Account.UserName == username && n.Account.Role_Account.FirstOrDefault().Role.Role_Name == "Censor"); if (emp == null) { ViewBag.Error = "Username or password is incorrect"; return(View("Login")); } if (emp.Block1.LastOrDefault() != null && (emp.Block1.LastOrDefault().UnBlockDate == null || emp.Block1.LastOrDefault().UnBlockDate > DateTime.Now)) { ViewBag.Error = "Account was blocked"; return(View("Login")); } if (emp.Quits.LastOrDefault() != null) { ViewBag.Error = "Account was quited"; return(View("Login")); } if (emp != null && HashPwdTool.CheckPassword(password, emp.Account.PasswordHash)) { Session["Account_Censor"] = emp; AccountLog accLog = new AccountLog(); accLog.Account = emp.Account; db.AccountLogs.Add(accLog); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } ViewBag.Error = "Cannot connect to server. Please try again!"; return(View("Login")); }
public Account Authenticate(string loginId, string Pwd) { AccountLog accountLog = new AccountLog(); Account account1 = context.Accounts.Where(account => account.LogonID == loginId && account.Password == Pwd && account.IsEnabled == true).SingleOrDefault(); Account account2 = account1; if (account2.Expiration.HasValue) { DateTime dateTime = account2.Expiration.Value; if (account2.IsExpires.Value && dateTime < DateTime.Now) { account2 = null; } } if (account2 == null) { return(null); } VMGlobal.AccountRecord = account2; WriteLog(VMGlobal.LOG_ACTION.LOGON, string.Format("{0} {1}/ {2}", account2.ToString(), account2.BadgeNumber, loginId)); return(account1); }
/// <summary> /// 帐户充值 for 投稿收入(包含写帐户日志) /// </summary> /// <param name="userId">投稿人</param> /// <param name="amount"></param> /// <param name="ip"></param> /// <param name="payway"></param> /// <param name="remark">将悬赏文档的名称写入备注</param> /// <returns></returns> public bool AddAmount(int userId, decimal amount, string ip, string remark) { Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL(); //写账户日志 AccountLog accLog = new AccountLog() { UserId = userId, Amount = amount, AccountWay = (int)AmountWay.INCOME_TG, Ip = ip, PayWay = 0, AdminRemark = remark }; albll.Insert(accLog); //更新账户 MAccount acc = GetByUserId(userId); acc.Amount = acc.Amount + amount; return(Update(acc)); }
/// <summary> /// 支付成功后给上传人返利 /// </summary> protected void AddAmountForUploader( decimal orderId, int uploaderId, decimal amount, OrderService os, int docId, string docTitle, int buyerId, int payway) { //先写入账户日志 AccountLog al = new AccountLog() { OrderId = orderId, UserId = uploaderId, Amount = amount, AccountWay = (int)AmountWay.INCOME, Ip = Utils.TmmUtils.IPAddress(), PayWay = payway }; int a = os.MAccountLogBll.Insert(al); //账户增加收入 if (a > 0) { os.MAccountBll.AddAmount(uploaderId, amount); } //发送系统通知 string tmp = "您的文档<a href='/p-{0}.html' target='_blank'>{1}</a>" + "被<a href='/home/{2}.html' target='_blank'>{3}</a>下载,获得收入¥{4}"; M_Message msg = new M_Message() { SenderId = Helper.ConfigHelper.AdminUserId, Title = "恭喜您获得文档销售收入", CreateTime = DateTime.Now, Content = string.Format(tmp, docId, docTitle, buyerId, Helper.UserHelper.GetUserById(buyerId).TmmDispName, amount), IsRead = false, Mtype = (int)Model.Enums.MessageType.Inform, RecieverId = uploaderId }; Service.Bll.User.M_MessageBLL mbll = new TMM.Service.Bll.User.M_MessageBLL(); mbll.Insert(msg); }
public IHttpActionResult UpdateAccountLog(int id, AccountLog accountsBankDetails) { if (!ModelState.IsValid) { //return BadRequest(ModelState); return(Json(new { Msg = "0" })); } if (id != accountsBankDetails.Id) { //return BadRequest(); return(Json(new { Msg = "0" })); } try { int s = _accountLogBll.Update(accountsBankDetails); if (s == 1) { return(Json(new { Msg = "1" })); } return(Json(new { Msg = "0" })); } catch (DbUpdateConcurrencyException) { if (!BankMappingExists(id)) { //return NotFound(); return(Json(new { Msg = "0", Reason = "No row affected!" })); } else { throw; } } }
/// <summary> /// 账户充值 for 订单 /// </summary> /// <param name="orderId">订单ID</param> /// <param name="amount">金额</param> public bool AddAmount(decimal orderId, decimal amount, string ip, int payway) { Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL(); Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL(); TOrder o = obll.Get(orderId); //写账户日志 AccountLog accLog = new AccountLog() { UserId = o.UserId, OrderId = o.OrderId, Amount = amount, AccountWay = (int)AmountWay.In, Ip = ip, PayWay = payway }; albll.Insert(accLog); //更新账户 MAccount acc = GetByUserId(o.UserId); acc.Amount = acc.Amount + amount; return(Update(acc)); }
/// <summary> /// 帐户花销 for 购买悬赏文档(包含写帐户日志) /// </summary> /// <param name="userId"></param> /// <param name="total"></param> /// <param name="ip"></param> /// <returns></returns> public bool AccountExpend(int userId, decimal total, string ip, string remark) { Bll.Order.AccountLogBLL albll = new TMM.Service.Bll.Order.AccountLogBLL(); MAccount acc = GetByUserId(userId); if (acc.Amount >= total) { AccountLog accLog = new AccountLog() { UserId = userId, Amount = -total, AccountWay = (int)AmountWay.ROut, Ip = ip, PayWay = 0, AdminRemark = remark }; albll.Insert(accLog); acc.Amount = acc.Amount - total; return(Update(acc)); } return(false); }
public int Update(AccountLog accountsBankDetails) { return(_reposirory.Update(accountsBankDetails)); }
public int Insert(AccountLog accountsBankDetails) { return(_reposirory.Insert(accountsBankDetails)); }
public List <ILog> Grab() { List <ILog> logs = new List <ILog>(); if (Check()) { try { long KeySlot = 0; string dataSource = signon; TSECItem tSecDec = new TSECItem(); TSECItem tSecDec2 = new TSECItem(); AccountLog accountLog = new AccountLog(); byte[] bvRet = null; SQLiteBase5 db = new SQLiteBase5(dataSource); string ff = null; System.Data.DataTable table = db.ExecuteQuery("SELECT * FROM moz_logins;"); System.Data.DataTable table2 = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;"); foreach (System.Data.DataRow row in table2.Rows) { } KeySlot = PK11_GetInternalKeySlot(); PK11_Authenticate(KeySlot, true, 0); foreach (System.Data.DataRow Zeile in table.Rows) { string formurl = System.Convert.ToString(Zeile["formSubmitURL"].ToString()); if (!string.IsNullOrEmpty(formurl)) { accountLog.SetService(formurl); } StringBuilder se = new StringBuilder(Zeile["encryptedUsername"].ToString()); int hi2 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length); TSECItem item = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem)); if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0) { if (tSecDec.SECItemLen != 0) { bvRet = new byte[tSecDec.SECItemLen]; Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen); accountLog.SetLogin(System.Text.Encoding.ASCII.GetString(bvRet)); } } StringBuilder se2 = new StringBuilder(Zeile["encryptedPassword"].ToString()); int hi22 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se2, se2.Length); TSECItem item2 = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi22), typeof(TSECItem)); if (PK11SDR_Decrypt(ref item2, ref tSecDec2, 0) == 0) { if (tSecDec2.SECItemLen != 0) { bvRet = new byte[tSecDec2.SECItemLen]; Marshal.Copy(new IntPtr(tSecDec2.SECItemData), bvRet, 0, tSecDec2.SECItemLen); accountLog.SetPassword(System.Text.Encoding.ASCII.GetString(bvRet)); } } } logs.Add(accountLog); } catch (Exception) { } } return(logs); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(AccountLog obj) { return(dal.Update(obj)); }