static async void ReadLogs(long chatid) { if (UserLogs.GetLogs(chatid) != null) { UserLogs.GetLogs(chatid).ToList().ForEach((s) => Console.WriteLine(s)); } }
} //Placed, Delivered, PushMoney, PushMoneyAgency, ClosingCashAgent, ClosingCashManager public async override void OnActionExecuted(ActionExecutedContext context) { int orderId = Convert.ToInt32(context.HttpContext.Items["orderId"]); if (orderId == 0) { return; } string orderStatus = Convert.ToString(context.HttpContext.Items["orderStatus"]); string userFullName = Convert.ToString(context.HttpContext.Items["userFullName"]); int userId = int.Parse(context.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value); decimal orderTotal = Convert.ToDecimal(context.HttpContext.Items["total"]); string eventType = Convert.ToString(context.HttpContext.Items["eventType"]); var userLog = new UserLogs(); if (orderStatus == "Processed" || orderStatus == "Ready") { if (eventType == "Transfer") { var repo = context.HttpContext.RequestServices.GetService <IMoveMoneyRepository>(); userLog.UserId = userId; userLog.EventType = "Transfer"; userLog.Description = $"{userFullName} fully processed the order {orderId}"; userLog.Amount = orderTotal; userLog.AgencyId = Convert.ToInt32(context.HttpContext.Items["agencyId"]); await repo.CreateUserLog(userLog); } } }
///<summary> /// Adds the userlog. /// </summary> /// <param name="userlog">The userlog.</param> public void AddUserLog(UserLog userlog) { if (UserLogs == null) { UserLogs = new List <UserLog>(); } // set this one as latest. userlog.IsLatest = true; // If this is the new latest userlog. if (userlog.IsLatest) { foreach (UserLog log in UserLogs) { log.IsLatest = false; } } // If the userlog is not already in the list if (!UserLogs.Any(x => x.PrimaryKey == userlog.PrimaryKey)) { UserLogs.Add(userlog); userlog.User = this; } }
public void Insert(UserLogs objUserLogs) { string sqlQuery = InsertUserLogs; try { conn.Open(); SqlCommand cmd = new SqlCommand(sqlQuery, conn); cmd.Parameters.Add(new SqlParameter("Content", objUserLogs.Content)); cmd.Parameters.Add(new SqlParameter("ControlType", objUserLogs.ControlType)); cmd.Parameters.Add(new SqlParameter("ControlUsageCount", objUserLogs.ControlUsageCount)); cmd.Parameters.Add(new SqlParameter("Hostname", objUserLogs.Hostname)); cmd.Parameters.Add(new SqlParameter("Pagename", objUserLogs.Pagename)); cmd.Parameters.Add(new SqlParameter("PageUsageTime", objUserLogs.PageUsageTime)); cmd.Parameters.Add(new SqlParameter("UserEnter", objUserLogs.UserEnter)); cmd.Parameters.Add(new SqlParameter("UserExit", objUserLogs.UserExit)); cmd.Parameters.Add(new SqlParameter("UserIp", objUserLogs.UserIp)); cmd.Parameters.Add(new SqlParameter("UserAgent", objUserLogs.UserAgent)); cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { } }
private UserLogs CreateModel(ActionExecutingContext context) { string userId = null; var user = context.HttpContext.User; var identity = user?.Identity; if (identity != null && identity.IsAuthenticated && _userManager != null) { userId = _userManager.GetUserId(user); } var request = context.HttpContext.Request; UserLogs audit = new UserLogs() { ActionName = (string)context.RouteData.Values["action"], Controller = (string)context.RouteData.Values["controller"], Data = JsonConvert.SerializeObject(new { request.Cookies, request.Headers, request.QueryString }), Ip = request.HttpContext.Connection.RemoteIpAddress.ToString(), RequestMethod = request.Method, ServerTimeUtc = DateTime.UtcNow, UserId = userId }; return(audit); }
// UserLog functions public async Task <UserLogs> CreateUserLog(UserLogs userLogs) { await _context.UserLogs.AddAsync(userLogs); await _context.SaveChangesAsync(); return(userLogs); }
public User ControllerAuth(UserLogs userlogs) { if (this.userSrv.Authentifier(userlogs.Mail, userlogs.Password)) { return(this.userSrv.GetUserByEmail(userlogs.Mail)); } return(null); }
public ActionResult DeleteConfirmed(int id) { UserLogs userLogs = db.UserLogs.Find(id); db.UserLogs.Remove(userLogs); db.SaveChanges(); return(RedirectToAction("Index")); }
public string RecoverDBFinal(string path) { Location loc = new Location(db); string result = loc.Recover(path); UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress, "Restored the database from XML files."); return(result); }
/// <summary> /// 添加日志 /// </summary> /// <param name="userLogs"></param> /// <returns></returns> public int AddLogs(UserLogs userLogs) { using (OracleConnection conn = DapperHelper.GetConnString()) { conn.Open(); string sql = @"insert into UserLogs(Userid,Storeid,Createtime) values(:Userid,:Storeid,:Createtime)"; int result = conn.Execute(sql, userLogs); return(result); } }
public OutPut Login(AuthLogin dataLogin, IHttpContextAccessor iHttpContextAccessor) { OutPut op = new OutPut(); Dictionary <string, object> ObjOutput = new Dictionary <string, object>(); List <Donatur> don = new List <Donatur>(); UserLogs uslog = new UserLogs(); try { var IpAddress = iHttpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(); int TokenExpire = Convert.ToInt32(config.GetValue <string>("appSetting:TokenExpire")); dataLogin.Psswd = Helper.md5(Helper.md5(dataLogin.Psswd)).ToLower(); don = AuthRepo.getDataAuth(dataLogin); if (don.Count > 0) { DateTime ExpireOn = DateTime.Now.AddMinutes(TokenExpire); string Token = fn.GenerateToken(dataLogin, ExpireOn, IpAddress); //save session uslog.UserLog = dataLogin.Account; uslog.Token = Token; uslog.ExpireOn = ExpireOn; uslog.IpAddress = IpAddress; uslog.Device = dataLogin.Device; uslog.UserInput = don[0].Nama; uslog.UserEdit = don[0].Nama; userlogRepo.Save(uslog); Dictionary <string, string> OutData = new Dictionary <string, string>(); OutData.Add(dataLogin.Device, dataLogin.Account); ObjOutput.Add("Akun", OutData); ObjOutput.Add("Token", Token); ObjOutput.Add("Email", don[0].Email); ObjOutput.Add("ExpireOn", ExpireOn); op.Data = ObjOutput; } else { op.Status = 401; op.Error = true; op.Message = "User name or password is incorrect."; return(op); } //validasi } catch (Exception ex) { op.Error = true; op.Message = ex.Message; fn.InsetErrorLog("Error Login", ex.Message + " " + ex.StackTrace); } return(op); }
public void SaveUserSearch(string ip, long time, string sortedWord, string originalWord) { var sortedWordID = anagramEntities.CachedWords.Where(x => x.Word == sortedWord).Select(x => x.Id).FirstOrDefault(); var recordToSave = new UserLogs { UserIp = ip, CachedWordId = sortedWordID, Word = originalWord, SearchTime = (int)time }; anagramEntities.UserLogs.Add(recordToSave); anagramEntities.SaveChanges(); }
public ActionResult Edit([Bind(Include = "Id,UserId,LoginTime,LogoutTime,UserIP")] UserLogs userLogs) { if (ModelState.IsValid) { db.Entry(userLogs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userLogs)); }
public ActionResult AddNewFTPSite(string name, string code, string host, string username, string password, string port, string directory = "") { //System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@username" + (username == null)); //System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@username" + (password == null) + (password == "")); //System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@touchffgvg"); Boolean flag = false; if (db.Location.Any(o => o.Code.Trim().Equals(code.Trim(), StringComparison.InvariantCultureIgnoreCase))) { flag = true; } if (!flag) { Location l = new Location(db); l.Name = name.Trim(); l.Code = code.Trim(); l.Host = host.Trim(); if (username != null) { l.Username = username.Trim(); } if (password != null) { l.Passwrd = _protector.Protect(password); //protecting the payload } l.Port = port.Trim(); System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@controller" + password); l.CreatedAt = DateTime.Now; l.UpdatedAt = DateTime.Now; l.IsFTP = "Y"; if (directory != null) { l.DirectoryPath = directory.Trim(); } //System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@controller"); db.Location.Add(l); int res = db.SaveChanges(); UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress, "Added new FTP site: " + l.Name); //System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@controller" + res); TempData["msg"] = "The site has been added successfully"; return(RedirectToAction("Index", "Home")); } TempData["code"] = code; TempData["name"] = name; TempData["username"] = username; TempData["password"] = password; TempData["host"] = host; TempData["directory"] = directory; TempData["port"] = port; ModelState.AddModelError("CustomError", "The Location Already exists. Please change the location code"); return(View("AddNewFTPForm")); }
public ActionResult Create([Bind(Include = "Id,UserId,LoginTime,LogoutTime,UserIP")] UserLogs userLogs) { if (ModelState.IsValid) { db.UserLogs.Add(userLogs); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userLogs)); }
public async Task <long> Track(UserLogs log) { if (log == null) { return(0); } await _context.UserLogs.AddAsync(log); await _context.SaveChangesAsync(); return(log.Id); }
public void Add(byte userAction, string userId) { var userLogs = new UserLogs() { ActionDate = DateTime.Now, UserAgent = _useragent?.ToString(), UserId = userId, UserActionId = userAction }; _context.Add(userLogs); _context.SaveChanges(); }
public ActionResult RemoveLocation(string site) { Location loc = new Location(db); loc.RemoveLocation(site); TempData["msg"] = "The site has been deleted successfully"; UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress.ToString(), "Deleted site: " + site); return(RedirectToAction("Index", "Home")); }
///<summary> /// Removes the userlog. /// </summary> /// <param name="userlog">The userlog.</param> public void RemoveUserLog(UserLog userlog) { if (UserLogs == null) { return; } UserLogs.Remove(userlog); if (userlog.IsLatest) { UserLogs.LastOrDefault().IsLatest = true; } }
// GET: UserLogs/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserLogs userLogs = db.UserLogs.Find(id); if (userLogs == null) { return(HttpNotFound()); } return(View(userLogs)); }
//public void PostUserActivities() public void PostUserActivities(UserLogs objUserLogs) { objUserLogs.Content = "TestContent"; objUserLogs.ControlType = "TestControl"; objUserLogs.ControlUsageCount = 2; objUserLogs.Hostname = "TestHostName"; objUserLogs.Pagename = "TestPage"; objUserLogs.PageUsageTime = 20; objUserLogs.UserAgent = "TestAgent"; objUserLogs.UserEnter = DateTime.Now; objUserLogs.UserExit = DateTime.Now; objUserLogs.UserIp = "Test"; _bUserInteractions.Insert(objUserLogs); }
protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); if (Session["useridentity"] != null) { if (Session["useridentity"] != string.Empty) { UserLogs track2 = new UserLogs(HttpContext.Current, long.Parse(Session["useridentity"].ToString())); } else { UserLogs track3 = new UserLogs(HttpContext.Current); } } }
public async Task <IActionResult> Logout() { if (_accessor.HttpContext.User.Identity.IsAuthenticated) { UserLogs u = new UserLogs(db); u.LogDetails(_accessor.HttpContext.User.Claims.FirstOrDefault().Value, IPAddress, "Logged Out"); } await HttpContext.SignOutAsync(); TempData["logout"] = "You have been logged out. Please close the browser tab for security purposes"; return(RedirectToAction("LoginForm", "Login")); }
public async Task <ActionResult> Authenticate(string username, string password, string returnURL = "") { var authorizedUserIDs = db.Users.Select(o => o.UserId); //authorized users if (!authorizedUserIDs.Contains(username)) { TempData["loginfailed"] = "You are not Authorized to login. Please Contact Admin."; return(RedirectToAction("LoginForm", "Login")); } if (LDAP.Authenticate(username, password)) { var claims = new List <Claim> //create a Claims list. { new Claim(ClaimTypes.Name, username) }; //build an identity, a principal, and then set the cookie using the SignInAsync method. ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); if (returnURL != null && returnURL.ToString() != "") { //System.Diagnostics.Debug.WriteLine("!!!!!!!!!!!!!!!!!1" + returnURL); UserLogs u = new UserLogs(db); u.LogDetails(username, IPAddress, "Logged In"); return(Redirect(returnURL)); } else { UserLogs u = new UserLogs(db); u.LogDetails(username, IPAddress, "Logged In"); TempData["msg"] = "Login Successfull"; return(RedirectToAction("Index", "Home")); } } else { TempData["loginfailed"] = "Invalid username/ password"; return(RedirectToAction("LoginForm", "Login")); } }
public String PublishSelectedOrALL(string path = "", string code = "") { Location loc = new Location(db); String message = loc.PublishSelectedOrALL(_protector, path, code); if (message.Contains("@@")) { if (code != "") { UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress, "Published config files at site: " + code + " " + ". Version: " + message.Split("@@")[1]); } else { UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress, "Published config files at all sites. " + " " + ". Version: " + message.Split("@@")[1]); } } return(message.Split("@@")[0]); }
public ActionResult LoginAccount(string UserName, string Pass, string IPpublic, string UserAgent) { string codeMd5 = security.HashPass(Pass, UserName); //Session["userid"] = 1; //Session["userName"] = "******"; //Session["fullName"] = "Le Anh Duc"; //Session["avatar"] = "~/Data/img/files/ingUser/2.jpg"; var user = Db.Accounts.SingleOrDefault(x => x.UserName == UserName && x.Password == codeMd5); if (user != null) { if (user.Allowed == 1) { Session["userid"] = user.UserId; Session["username"] = user.UserName; Session["fullname"] = user.FullName; Session["avatar"] = user.Avatar; // ghi log phien dang nhap var logUser = new UserLogs(); logUser.IDUser = user.UserId; logUser.DateAccess = DateTime.Now; logUser.IPpublic = IPpublic; logUser.UserAgent = UserAgent; Db.UserLogss.Add(logUser); Db.SaveChanges(); return(RedirectToAction("Index", "Accounts")); } else if (user.Allowed == 0) { Session["Error"] = "Tài khoản của bạn đã bị khóa vui lòng liên hệ với Admin!"; return(RedirectToAction("Login")); } } ViewBag.Error = "Tài khoản hoặc mật khẩu ko chính xác!"; return(RedirectToAction("Login")); //return RedirectToAction("Login"); }
public ActionResult EditSite(string name, string servername, string path, string code, string status, string diagnostic, string retention, string username, string password, string host, string port, string directory) { System.Diagnostics.Debug.WriteLine("@@@@@@@@@@@@@@@@@@@@@controller"); System.Diagnostics.Debug.WriteLine(code); System.Diagnostics.Debug.WriteLine(name); var result = db.Location.Where(o => o.Code.Trim() == code.Trim()).First(); if (result != null) { result.Name = name.Trim(); if (result.IsFTP == "N") { result.Server = servername.Trim(); result.Path = path.Trim(); result.Status = status.Trim(); result.DiagnosticLevel = Convert.ToInt32(diagnostic.Trim()); result.RetentionPeriod = Convert.ToInt32(retention.Trim()); } else { result.Host = host.Trim(); result.Username = username == null ? null : username.Trim(); result.Passwrd = password == null ? null : _protector.Protect(password); result.Port = port.Trim(); result.DirectoryPath = directory == null ? null : directory.Trim(); } result.UpdatedAt = DateTime.Now; db.SaveChanges(); UserLogs u = new UserLogs(db); u.LogDetails(currentUserID, IPAddress, "Edited site: " + result.Name); } TempData["msg"] = "The site has been updated successfully"; return(RedirectToAction("Index", "Home")); }
public async Task AddUserLog(string userId, string logType, string logMessage) { try { using (var context = new ApiMohoContext()) { var log = new UserLogs() { UserId = userId, LogType = logType, LogMessage = logMessage }; await context.AddAsync(log); await context.SaveChangesAsync(); } } catch (Exception e) { Console.WriteLine(e); throw; } }
public int AddLogs(UserLogs userLogs) { int result = UserLogs.AddLogs(userLogs); return(result); }
public void Insert(UserLogs objUserLogs) { _dUserInteractions.Insert(objUserLogs); }