public PartialViewResult FilterUserHistory(string filterOption) { var filterOptionSub = filterOption.Replace(" ", string.Empty); var currentUserId = User.Identity.GetUserId(); var userHistory = new UserHistoryCreation(currentUserId); UserHistory newHistory = new UserHistory(); if (Enum.TryParse <UserHistoryOptionsEnum>(filterOptionSub, out var userHistoryOption)) { switch (userHistoryOption) { case UserHistoryOptionsEnum.Feeds: newHistory = userHistory.CreateFeedModel(); break; case UserHistoryOptionsEnum.Posts: newHistory = userHistory.CreatePostModel(); break; case UserHistoryOptionsEnum.Comments: newHistory = userHistory.CreateCommentModel(); break; case UserHistoryOptionsEnum.AllHistory: newHistory = userHistory.CreateModel(); break; default: newHistory = userHistory.CreateModel(); break; } } return(PartialView("History", newHistory)); }
public async Task GetUserHistory_Nekomata_ShouldParseNekomataHistory() { UserHistory userHistory = await _jikan.GetUserHistory("Nekomata1037"); Assert.NotNull(userHistory); Assert.True(userHistory.History.Count >= 0); }
private void DrawProfilesModule() { UserHistory uh = new UserHistory(); List <string> types; types = new List <string>(); hi = uh.GetItems(); if (hi == null) { Response.Redirect(Root.Domain + "/search", true); } foreach (HistoryItem item in hi) { string hiremove; foreach (string s in item.Types) { hiremove = types.Find(delegate(string hiremoveitem) { return(hiremoveitem == s); }); if (hiremove.IsNullOrEmpty()) { types.Add(s); } } } rptHistory.DataSource = types; rptHistory.DataBind(); }
public ActionResult Rent(VideoRentViewModel model) { Video video = db.Videos.Include(v => v.Copies) .SingleOrDefault(v => v.ID == model.ID && v.Copies.Where(c => c.RentedDate == null).Count() > 0); if (video == null) { return(HttpNotFound()); } DateTime now = DateTime.UtcNow; VideoCopy copy = video.Copies.Where(c => c.RentedDate == null).First(); copy.RentedDate = now; copy.RenterID = UserID; copy.RentedDays = model.Days; db.Entry(copy).State = EntityState.Modified; UserHistory history = new UserHistory(); history.Copy = copy; history.ID = Guid.NewGuid(); history.PointsEarned = (video.Age == VideoAge.New ? 2 : 1); history.RentedDate = now; history.RentedDays = model.Days; history.UserID = UserID; db.UserHistory.Add(history); db.SaveChanges(); return(Json(true, JsonRequestBehavior.AllowGet)); }
public void FindFact() { var user = default(User); try { user = new User(new UserEntity()); user.Found += (sender, e) => Assert.Equal(1, sender.Attributes.Count); user.Attributes.Add(new UserAttributeEntity() { ItemID = 99, }); user.Create(); user.Find(); var history = new UserHistory(user.Histories.First()).Find(); Assert.Equal(1, history.Attributes.Count()); } finally { if (user != null) { user.Delete(); } } }
public UserHistory DeepCopy() { UserHistory copy = new UserHistory(); copy.nickname = nickname; copy.play_time = play_time; copy.boong_get = boong_get; copy.boong_use = boong_use; copy.heart_get = heart_get; copy.heart_use = heart_use; copy.editor_make = editor_make; copy.editor_clear = editor_clear; copy.editor_fail = editor_fail; copy.stage_clear = stage_clear; copy.stage_fail = stage_fail; copy.drops = drops; copy.crash = crash; copy.carry = carry; copy.reset = reset; copy.move = move; copy.snow = snow; copy.parfait = parfait; copy.crack = crack; copy.cloud = cloud; return(copy); }
public void NoUserHistoryUpdates() { var r = new Restrictions(); var history = new UserHistory { Id = 1 }; var updates = new Dictionary <object, Restrictions.ShadowModifiedMember[]>(); updates[history] = new Restrictions.ShadowModifiedMember[] { new Restrictions.ShadowModifiedMember { Member = typeof(UserHistory).GetProperty("Id"), CurrentValue = history.Id, OriginalValue = 2 } }; string ignored; Assert.IsFalse(r.IsValidChangeSet(updates, new List <object>(), new List <object>(), new List <object>() { history }, new List <int>() { 1 }, out ignored)); }
public RewardRequest(UserInfo info, UserHistory history, UserReward reward, UserInventory inven) { this.info = info; this.history = history; this.reward = reward; inventory = inven; }
public override CommonResponse <UserVM> SaveData(UserVM data, string transactionId) { CommonResponse <UserVM> response = ValidateParameter(data); if (response != null) { return(response); } using SHA256 hasher = SHA256.Create(); string lastId = DbContext.Users.Select(u => u.Id).OrderByDescending(u => u).FirstOrDefault(); User userData = new User { Id = CreateNewUserId(lastId), Name = data?.Name, Email = data.Email, Image = data.Image, Password = Encoding.ASCII.GetString( hasher.ComputeHash(Encoding.ASCII.GetBytes(data.Password)) ), }; DbContext.Add(userData); UserHistory userHistory = new UserHistory(); userHistory.FillFromUser( userData, transactionId, 1, TableTransactionOperation.Insert ); DbContext.Add(userHistory); if (DbContext.SaveChanges() > 0) { data.Id = userData.Id; return(new CommonResponse <UserVM> { Status = true, Code = "S", Message = "Save Data is Success!", Data = new UserVM[] { data }, }); } else { return(new CommonResponse <UserVM> { Status = false, Code = "E-003", Message = "Save Data Failed! Please Contact an Web Administrator!", Data = new UserVM[] { data }, }); } }
/// <summary> /// Change this users password, recording in their history that they have done so. /// </summary> public void ChangePassword(DateTime now, string newPassword, string comment = null) { var changeEvent = new UserHistory { Comment = comment ?? "Changed Password", CreationDate = now, UserHistoryTypeId = UserHistoryTypeId.PasswordChanged, IP = Current.RemoteIP, UserId = Id }; Current.WriteDB.UserHistory.InsertOnSubmit(changeEvent); var thisUser = Current.WriteDB.Users.Single(u => u.Id == this.Id); string salt; var pwdHash = Current.SecureHash(newPassword, out salt); thisUser.PasswordSalt = salt; thisUser.PasswordHash = pwdHash; thisUser.LastActivityDate = now; thisUser.PasswordVersion = null; // We have a strong password now, regardless of what was there before Current.WriteDB.SubmitChanges(); }
public UserHistory Mapper() { var history = new UserHistory() { email = _signUp.email, phone = _signUp.phoneNumber, name = _signUp.name, address = _signUp.address, Hlocation = _signUp.location, identities = _signUp.identity, schoolName = _signUp.schoolName, isApplyCHU = _signUp.isApplyCHU, interestedDepart = _signUp.interestedDepart, gsat_Chinese = Convert.ToInt32(_signUp.user_input.grades.gsat.Chinese), gsat_English = Convert.ToInt32(_signUp.user_input.grades.gsat.English), gsat_Math = Convert.ToInt32(_signUp.user_input.grades.gsat.Math), gsat_Science = Convert.ToInt32(_signUp.user_input.grades.gsat.Science), gsat_Society = Convert.ToInt32(_signUp.user_input.grades.gsat.Society), ELlevel = _signUp.user_input.grades.gsat.EngListeningLevel, Ulocation = MapToString(_signUp.user_input.location), UGroup = MapToString(_signUp.user_input.groups), property = MapToString(_signUp.user_input.property), salary = _signUp.user_input.expect_salary, createAt = DateTime.Now }; return(history); }
/// <summary> /// Record a login event for a user, run any needed cleanup, and give the user a session. /// </summary> public void Login(DateTime now) { // Kill the anonymous cookie Current.KillCookie(Current.AnonymousCookieName); // Write a login event var loginEvent = new UserHistory { Comment = "Logged In", CreationDate = now, UserHistoryTypeId = UserHistoryTypeId.Login, UserId = Id, IP = Current.RemoteIP }; Current.WriteDB.UserHistory.InsertOnSubmit(loginEvent); // Generate and write a session var session = Convert.ToBase64String(Current.Random(32)); var sessionHash = Current.WeakHash(session); SessionHash = sessionHash; SessionCreationDate = now; LastActivityDate = now; // Add the user session cookie Current.AddCookie(Current.UserCookieName, session, TimeSpan.FromDays(7)); Current.WriteDB.SubmitChanges(); }
public async Task <UserHistory> AddUserHistoryAsync(User userState, User byUser) { var userHistory = new UserHistory() { UserID = userState.UserID, Name = userState.Name, Email = userState.Email, Password = userState.Password, GradeID = userState.GradeID, IsDelete = userState.IsDelete, AddDate = DateTime.Now, AddBy = byUser }; db.UserHistories.Add(userHistory); var affected = await db.SaveChangesAsync(); if (affected == 1) { return(userHistory); } else { return(null); } }
protected override void DoLoad(int id, AbstractDomain domain) { UserHistory uh = domain as UserHistory; DbCommand cmd = CreateCommand("UP_USERHISTORY_GETBYID"); AddParameter(cmd, "@USERHIS_ID", DbType.Int32, id); cmd.Connection.Open(); try { DbDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.Read()) { PopulateDomain(reader, uh); } else { throw new Exception("No Records found in the database."); } reader.Close(); } finally { CloseCommand(cmd); } }
public async Task GetUserHistory_NekomataMangaHistory_ShouldParseNekomataMangaHistory() { UserHistory userHistory = await jikan.GetUserHistory("Nekomata1037", UserHistoryExtension.Manga); Assert.NotNull(userHistory); Assert.True(userHistory.History.Count >= 0); }
private void UserProjectChange(List <Project> oldProjects, ApplicationUser newUser) { var addedProjects = newUser.Projects.Except(oldProjects, new CustomComparer.ProjectComparer()).ToList(); var removedProjects = oldProjects.Except(newUser.Projects, new CustomComparer.ProjectComparer()).ToList(); var changedByUserId = HttpContext.Current.User.Identity.GetUserId(); foreach (var project in addedProjects) { var NewHistory = new UserHistory() { UserId = newUser.Id, ChangedByUserId = changedByUserId, ChangedOn = DateTime.Now, Property = $"Project added to: {newUser.FullName}", OldValue = "", NewValue = $"{project.Id}" }; db.UserHistories.Add(NewHistory); } foreach (var project in removedProjects) { var NewHistory = new UserHistory() { UserId = newUser.Id, ChangedByUserId = changedByUserId, ChangedOn = DateTime.Now, Property = $"Project removed from: {newUser.FullName}", OldValue = "", NewValue = $"{project.Id}" }; db.UserHistories.Add(NewHistory); } }
public List <UserHistory> GetUserHistory(int UserID) { List <UserHistory> Histories = new List <UserHistory>(); con = new MySqlConnection(ConnectionString()); con.Open(); if (con.State == ConnectionState.Open) { UserHistory History = new UserHistory(); MySqlCommand cmd = new MySqlCommand(@" SELECT * FROM UserHistory WHERE UserID = @UserID)", con); cmd.Parameters.AddWithValue("@UserID", UserID); MySqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { History.ID = Convert.ToInt32(rdr["ID"]); History.CategoryID = Convert.ToInt32(rdr["CategoryID"]); History.UserID = Convert.ToInt32(rdr["UserID"]); History.ChannelID = Convert.ToInt32(rdr["ChannelID"]); History.GenreID = Convert.ToInt32(rdr["GenreID"]); History.UpdatedDate = Convert.ToDateTime(rdr["UpdatedDate"]); Histories.Add(History); } rdr.Close(); con.Close(); } return(Histories); }
public bool UpdateUserHistory(UserHistory UpdateInfo) { bool result = false; con = new MySqlConnection(ConnectionString()); con.Open(); if (con.State == ConnectionState.Open) { MySqlCommand cmd = new MySqlCommand(@" UPDATE UserHistory SET ", con); cmd.CommandText += " CategoryID = @CategoryID,"; cmd.CommandText += " UserID = @UserID,"; cmd.CommandText += " UpdatedDate = @UpdatedDate,"; cmd.CommandText += " ChannelID = @ChannelID,"; cmd.CommandText += " GenreID = @GenreID,"; cmd.CommandText += " WHERE ID = @ID)"; cmd.Parameters.AddWithValue("@ID", UpdateInfo.ID); cmd.Parameters.AddWithValue("@CategoryID", UpdateInfo.CategoryID); cmd.Parameters.AddWithValue("@UserID", UpdateInfo.UserID); cmd.Parameters.AddWithValue("@UpdatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@ChannelID", UpdateInfo.ChannelID); cmd.Parameters.AddWithValue("@GenreID", UpdateInfo.GenreID); cmd.ExecuteNonQuery(); con.Close(); result = true; } return(result); }
public IHttpActionResult Put(UserHistory userHistory) { try { apiResp = new ApiResponse(); var mng = new UserHistoryManager(); mng.Update(userHistory); return(Ok(apiResp)); } catch (BussinessException bex) { var MessageManage = new ApplicationMessageManagement(); MessageManage.Create(bex.AppMessage); return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } catch (Exception ex) { ApplicationMessage msg = new ApplicationMessage { Message = ex.Message }; var MessageManage = new ApplicationMessageManagement(); MessageManage.Create(msg); return(InternalServerError(new Exception(ex.Message))); } }
public async Task <User> Authenticate(string email, string password) { var builder = Builders <User> .Filter; var filter = builder.Eq("Email", email) & builder.Eq("Password", password); var user = await _context.Users .Find(filter) .FirstOrDefaultAsync(); if (user != null) { await this.UpdateLastLogon(user.Id.ToString()); var userHistory = new UserHistory() { LoginDate = DateTime.Now, LoginSuccessful = true, UserId = user.Id.ToString() }; await this.AddUserHistory(userHistory); } if (user == null) { throw new ArgumentException("Usuário não encontrado"); } return(user); }
protected override void DoInsert(AbstractDomain domain) { UserHistory uh = domain as UserHistory; DbCommand cmd = CreateCommand("UP_USERHISTORY_INSERT"); cmd.Connection.Open(); SetModifyParameters(domain, cmd, true); try { //execute the command cmd.ExecuteNonQuery(); uh.Id = (int)cmd.Parameters["@USERHIS_ID"].Value; } catch (Exception ex) { throw ex; } finally { CloseCommand(cmd); } }
public bool SubmitComment([FromBody] CommentSubmissionModel cm) { var sanitizer = new Ganss.XSS.HtmlSanitizer(); using (var db = new ChaliceDb()) { db.BeginTransaction(); var comment = new Comment { Glyph = cm.Glyph, CommentText = sanitizer.Sanitize(cm.Text), PostedBy = User.Identity.Name, Posted = System.DateTime.Now }; var history = new UserHistory { UserName = User.Identity.Name, Action = "comment", Target = cm.Glyph, Value = "", Created = System.DateTime.Now }; db.InsertWithIdentity(comment); db.InsertWithIdentity(history); db.CommitTransaction(); } return(true); }
/// <summary> /// Record a logout event for the user, destoy their cookie, and invalidate their session. /// </summary> public void Logout(DateTime now, string careOfHost = null) { // Delete this users session cookie Current.KillCookie(Current.UserCookieName); var comment = "Logged Out"; if (careOfHost.HasValue()) { var cleanHost = careOfHost.ToLowerInvariant(); if (cleanHost.Length + 3 + comment.Length > 400) { cleanHost = cleanHost.Substring(0, 400 - 3 - comment.Length); } comment += " (" + cleanHost + ")"; } var logoutEvent = new UserHistory { Comment = comment, CreationDate = now, UserHistoryTypeId = UserHistoryTypeId.Logout, UserId = Id, IP = Current.RemoteIP }; Current.WriteDB.UserHistory.InsertOnSubmit(logoutEvent); SessionHash = null; SessionCreationDate = null; LastActivityDate = now; Current.WriteDB.SubmitChanges(); }
protected override void DoUpdate(AbstractDomain domain) { UserHistory uh = domain as UserHistory; DbCommand cmd = CreateCommand("up_UserHistory_Update"); SetModifyParameters(domain, cmd, false); cmd.Connection.Open(); try { //execute the command DbDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.Read()) { uh.Id = Convert.ToInt32(reader[0]); reader.Close(); } } finally { CloseCommand(cmd); } }
public async Task GetUserHistory_ErvelanMangaHistory_ShouldParseErvelanMangaHistory() { UserHistory userHistory = await _jikan.GetUserHistory("Ervelan", UserHistoryExtension.Manga); Assert.NotNull(userHistory); Assert.True(userHistory.History.Count >= 0); }
public ActionResult Return(Guid id) { VideoCopy copy = db.VideoCopies.Include(c => c.Video).Where(c => c.ID == id && c.RentedDate != null).SingleOrDefault(); if (copy == null) // Copy not rented out { return(HttpNotFound()); } copy.RentedDate = null; copy.RenterID = null; copy.RentedDays = 0; db.Entry(copy).State = EntityState.Modified; UserHistory historyEntry = db.UserHistory.Where(h => h.CopyID == copy.ID && h.ReturnedDate == null).SingleOrDefault(); if (historyEntry == null) { // Not rented out to this user return(HttpNotFound()); } historyEntry.ReturnedDate = DateTime.UtcNow; db.SaveChanges(); return(RedirectToAction("Details", "Videos", new { id = copy.VideoID })); }
public override CommonResponse <UserVM> DeleteData(UserVM data, string transactionId) { IQueryable <User> lastDataContext = DbContext.Users.AsQueryable(); if (string.IsNullOrEmpty(data?.Id)) { return(new CommonResponse <UserVM> { Status = false, Code = "E-001", Message = "Please fill the ID!", Data = new UserVM[] { data }, }); } lastDataContext = lastDataContext.Where(u => u.Id.Equals(data.Id) ); User lastData = lastDataContext.FirstOrDefault(); int historySequence = lastData?.UserHistories? .Select(u => u.Seq) .OrderByDescending(u => u) .FirstOrDefault() ?? 0; lastData.IsDeleted = true; UserHistory userHistory = new UserHistory(); userHistory.FillFromUser( lastData, transactionId, historySequence + 1, TableTransactionOperation.Delete ); DbContext.Add(userHistory); if (DbContext.SaveChanges() > 0) { return(new CommonResponse <UserVM> { Status = true, Code = "S", Message = "Delete Data is Success!", Data = new UserVM[] { data }, }); } else { return(new CommonResponse <UserVM> { Status = false, Code = "E-003", Message = "Delete Data Failed! Please Contact an Web Administrator!", Data = new UserVM[] { data }, }); } }
public void AddAccount(string nickname, string facebook, BooleanCallback callback) { UserInfo userInfo = new UserInfo(nickname, facebook); UserHistory userHistory = new UserHistory(nickname); UserAccount userAccount = new UserAccount(userInfo, userHistory); var json = JsonUtility.ToJson(userAccount); StartCoroutine(API_POST("newUser/create", json, (connect, response) => { if (connect) { //성공알림 Debug.Log("success create account"); Debug.Log(response); callback(true); } else { Debug.LogError(response); callback(false); //재시도 } })); }
public IList <UserHistory> getHistory() { string connectionString = "Data Source=FORLOGIC357;Initial Catalog=PLANNER;" + "Integrated Security=True"; string sqlQuery = "SELECT * FROM user_history"; UserDAO userDAO = new UserDAO(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(sqlQuery, connection); try { connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { User u = userDAO.getResponsible((int)reader[1]); Boolean statusAux = false; Boolean canCreateAux = false; if (reader[2] != DBNull.Value) { if ((Boolean)reader[2]) { statusAux = true; } } if (reader[3] != DBNull.Value) { if ((Boolean)reader[3]) { canCreateAux = true; } } UserHistory uh = new UserHistory((int)reader[0], u, statusAux, canCreateAux, (DateTime)reader[4]); this.userHistoryList.Add(uh); } reader.Close(); return(this.userHistoryList); } catch (Exception ex) { Console.WriteLine(ex.Message); return(this.userHistoryList); } finally { connection.Close(); } } }
public void ShouldParseErvelanMangaHistory() { UserHistory userHistory = Task.Run(() => jikan.GetUserHistory("Ervelan", UserHistoryExtension.Manga)).Result; Assert.NotNull(userHistory); Assert.True(userHistory.History.Count > 5); Assert.True(userHistory.History.First().Date.Value.Year > 2017); }
public ActionResult History(int id) { var user = UserService.GetByID(id); var model = new UserHistory(); model.InjectFrom<UnflatLoopValueInjection>(user); model.Username = user.Username; model.Logs = _logging.Find(x => x.Username == user.Username && x.Tenant == user.Tenant).OrderByDescending(x=>x.Created).ToList(); return View(model); }
private void UpdateUser(UserHistory user) { try { Cursor = Cursors.WaitCursor; ResultsGrid.Visible = false; var entry = user.Update(parser, DateTime.Now); loader.Save(history); UpdateList(); if (entry.SomethingHappened) new HistoryEntryForm(entry).ShowDialog(); } #if !DEBUG catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endif finally { ResultsGrid.Visible = true; Cursor = Cursors.Default; } }
public static void SaveUserHistory(UserHistory history, bool wait = false) { var result = _db.Table<JsonUserHistory>().Where(x => x.Nick == history.Nick).FirstOrDefaultAsync().Result; var save = history.CopyTo(); if (result == null) { if (wait) _db.InsertAsync(save).Wait(); else _db.InsertAsync(save); } else { //if (wait) { _db.DeleteAsync(result).Wait(); _db.InsertAsync(save).Wait(); //} else // _db.UpdateAsync(save); //todo why does Update/Async not work? } Debug.Assert(_db.Table<JsonUserHistory>().Where(x => x.Nick == history.Nick).CountAsync().Result == 1); }
private HasVictim DeterminesHasVictim(string word, UserHistory userHistory, string key, IDictionary<string, double> externalDictionary, HasVictim hasVictim, bool wait) { if (word == null) return null; var duration = TimeSpan.FromSeconds(externalDictionary[word]); if (!userHistory.History.ContainsKey(key)) userHistory.History.Add(key, new Dictionary<string, int>()); var words = userHistory.History[key]; if (!words.ContainsKey(word)) words.Add(word, 0); words[word]++; Datastore.SaveUserHistory(userHistory, wait); return new HasVictimBuilder(hasVictim, _message.SenderName).IncreaseDuration(duration, words[word], "prohibited phrase").Build(); }
public void AddUserChangeData(UserHistory userHistory) { context.UserHistory.Add(userHistory); }
private Mute MuteAndIncrementHardCoded(UserHistory userHistory, string sectionName, string reason, bool wait) { if (!userHistory.History.ContainsKey(MagicStrings.HardCoded)) userHistory.History.Add(MagicStrings.HardCoded, new Dictionary<string, int>()); var hardcodedLogic = userHistory.History[MagicStrings.HardCoded]; if (!hardcodedLogic.ContainsKey(sectionName)) hardcodedLogic.Add(sectionName, 1); var count = hardcodedLogic[sectionName]; hardcodedLogic[sectionName] = count + 1; Datastore.SaveUserHistory(userHistory, wait); return (Mute) new HasVictimBuilder(new Mute(), _message.SenderName).IncreaseDuration(TimeSpan.FromMinutes(10), count, reason).Build(); }