private void UpdatePercistancyData(UserStruct user) { if (ConnectionString == null) { return; } persitancyData[ConnectionString.ConnectionString] = new SavedUserData(checkBoxSaveUsername.Checked, checkBoxSavePassword.Checked, checkBoxAutoLogin.Checked, checkBoxSaveUsername.Checked ? comboBoxUserSelection.Text : string.Empty, checkBoxSavePassword.Checked ? user.AuthenticationType == UserAuthenticationTyp.ListAuthentication || textBoxPassword.Text.Length <= 0 ? string.Empty : (PasswordType)textBoxPassword.Tag == PasswordType.Hashed ? textBoxPassword.Text : Methods.GetHashedPassword(textBoxPassword.Text) : string.Empty); Stream outputStream = null; try { BinaryFormatter binary = new BinaryFormatter(); IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForAssembly(); outputStream = new IsolatedStorageFileStream(Settings.Default.AuthDataFile, FileMode.Create, storageFile); outputStream = new CryptoStream(outputStream, Rijndael.Create().CreateEncryptor(Encoding.Unicode.GetBytes("mlifter"), Encoding.Unicode.GetBytes("omicron")), CryptoStreamMode.Write); binary.Serialize(outputStream, persitancyData); } catch (Exception e) { Trace.WriteLine(e.ToString()); } finally { if (outputStream != null) { outputStream.Close(); } } }
public IList <UserStruct> GetUserList() { IList <UserStruct> users = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.UserList, 0)] as IList <UserStruct>; if (users != null) { return(users); } using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT * FROM \"GetUserList\"()"; NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser, false); users = new List <UserStruct>(); while (reader.Read()) { UserStruct user = new UserStruct(reader["username"].ToString(), (UserAuthenticationTyp)Enum.Parse(typeof(UserAuthenticationTyp), reader["typ"].ToString())); users.Add(user); } reader.Close(); Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.UserList, 0, new TimeSpan(0, 0, 30))] = users; return(users); } } }
/// <summary> /// Gets the testuser. /// </summary> /// <param name="userStr">The user struct.</param> /// <param name="con">The connectionStringStruct.</param> /// <returns></returns> /// <remarks>Documented by Dev08</remarks> public static UserStruct?GetTestUser(UserStruct userStr, ConnectionStringStruct con) { UserStruct userStruct = new UserStruct("testuser", UserAuthenticationTyp.ListAuthentication); userStruct.CloseOpenSessions = true; return(userStruct); }
public FileProperties(int fileId, int userId) { try { _fileStruct = DataMethod.GetFile(fileId); _userStruct = DataMethod.GetUser(_fileStruct.userId); _userActive = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } InitializeComponent(); FillForm(); buttonUpdate.Text = "Изменить"; richTextBoxComment.Enabled = false; textBoxName.Enabled = false; EnabledForm(true); textBoxName.Validated += textBoxName_Validated; richTextBoxComment.Validated += richTextBoxComment_Validated; textBoxName.MaxLength = 50; richTextBoxComment.MaxLength = 250; Icon = Properties.Resources.info; }
internal DbUser(UserStruct? user, ParentClass parent, ConnectionStringStruct connection, DataAccessErrorDelegate errorMessageDelegate, bool standAlone) { this.parent = parent; connectionString = connection; ErrorMessageDelegate = errorMessageDelegate; cache = new Cache(true); if (!user.HasValue) throw new NoValidUserException(); this.authenticationStruct = user.Value; this.username = user.Value.UserName; this.hashedPassword = user.Value.Password; this.standAlone = standAlone; this.user = user; securityFramework = MLifter.DAL.Security.SecurityFramework.GetDataAdapter(this); if (username != null && securityFramework != null) { try { securityToken = securityFramework.CreateSecurityToken(this.username); securityToken.IsCaching = cachePermissions; } catch (Exception ex) { Debug.WriteLine("Failed to create security token! (" + ex.Message + ")"); } } Login(); }
/// <summary> /// Gets the admin user. /// </summary> /// <param name="userStr">The user struct.</param> /// <param name="con">The connectionStringStruct.</param> /// <returns>The user struct.</returns> /// <remarks>Documented by Dev08</remarks> public static UserStruct?GetAdminUser(UserStruct userStr, ConnectionStringStruct con) { UserStruct userStruct = new UserStruct("admin", "admin", UserAuthenticationTyp.FormsAuthentication, false); userStruct.CloseOpenSessions = true; return(userStruct); }
public ActionResult <VerificationStruct> SetVerifyEmail(string login, string verifcode) { var user = new UserStruct(context, login); var dbcode = user.GetVerifCode(context); if (dbcode.Equals(verifcode)) { user.Email.SetVerified(context); return(new VerificationStruct() { Answer = true, Message = new Dictionary <string, string>() { ["Message"] = "Code is right." } }); } else { return new VerificationStruct() { Answer = false, Message = new Dictionary <string, string>() { ["Message"] = "Code is invalid" } } }; }
//Query5:Получить следующую структуру (передать Id пользователя в параметры) // User // Последний пост пользователя(по дате) // Количество комментов под последним постом // Количество невыполненных тасков для пользователя // Самый популярный пост пользователя(там где больше всего комментов с длиной текста больше 80 символов) // Самый популярный пост пользователя(там где больше всего лайков) public static UserStruct Query5(int userId) { UserStruct user = new UserStruct(); try { SomeEntity usr = GetEntities().Where(u => u.Id == userId).FirstOrDefault(); List <FullPost> posts = usr?.Posts.ToList(); user.LastPost = posts?.OrderByDescending(p => p.CreatedAt).FirstOrDefault(); user.LastPostCommentsCount = posts?.OrderByDescending(p => p.CreatedAt).FirstOrDefault()?.Comments.Count() ?? 0; user.MostPopularByComms = posts?.Where(p => p.Comments.Count() > 0) .Select(a => new { CurrentPost = a, CommentsCount = a.Comments.Where(c => c.Body.Length > 80).Count() }) .OrderByDescending(i => i.CommentsCount) .Where(i => i.CommentsCount > 0) .FirstOrDefault()?.CurrentPost; user.MostPopularByLikes = posts?.OrderByDescending(p => p.Likes).FirstOrDefault(); user.UnCompletedTasksCount = usr.Todos.Where(t => t.IsComplete == false).Count(); } catch (Exception ex) { Console.Clear(); Console.WriteLine(ex.Message); Console.ReadKey(); } return(user); }
public static UserDatabase Parse(string filename) { XmlDocument xml = new XmlDocument(); xml.Load(filename); List <User> parsedUsers = new List <User>(); foreach (XmlNode node in xml.SelectSingleNode("//users").ChildNodes) { UserStruct user = new UserStruct(); user.username = node["username"].InnerText; user.password = node["password"].InnerText; user.deleted = bool.Parse(node["deleted"].InnerText); user.id = int.Parse(node["id"].InnerText); List <UserThread> userThreads = new List <UserThread>(); foreach (XmlNode usrthreds in node["userThreads"]) { userThreads.Add(new UserThread(int.Parse(usrthreds["threadId"].InnerText), DateTime.Parse(usrthreds["lastSeen"].InnerText))); } user.userThreads = userThreads; parsedUsers.Add(new User(user.username, user.password, user.id, user.userThreads, user.deleted)); } return(new UserDatabase(parsedUsers)); }
static void printStructAndClass() { var userStruct = new UserStruct("Ann", 18); Console.WriteLine("Структура"); userStruct.DisplayInfo(); // Name: Ann Age: 18 changeStruct(userStruct); userStruct.DisplayInfo(); // Name: Ann Age: 18 changeStruct(ref userStruct); userStruct.DisplayInfo(); //Name: Jane Age: 34 var userStruct2 = new UserStruct { name = "Sam", age = 31 }; userStruct2.DisplayInfo(); var userStruct3 = new UserStruct(); userStruct3.DisplayInfo(); //Name: Age: 0 userStruct3.name = "Tom"; userStruct3.age = 68; userStruct3.DisplayInfo(); //Name: Tom Age: 68 var userClass = new UserClass("Ann", 18); Console.WriteLine("Класс"); userClass.DisplayInfo(); // Name: Ann Age: 18 changeClass(userClass); userClass.DisplayInfo(); // Name: Tarja Age: 41 changeClassRef(ref userClass); userClass.DisplayInfo(); // Name: Andrew Age: 42 }
/// <summary> /// Gets the user list. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev05, 2009-01-16</remarks> public IList <UserStruct> GetUserList() { IList <UserStruct> users = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.UserList, 0)] as IList <UserStruct>; if (users != null) { return(users); } SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT * FROM \"UserProfiles\";"; SqlCeDataReader reader = MSSQLCEConn.ExecuteReader(cmd); users = new List <UserStruct>(); users.Add(new UserStruct(Resources.CREATE_NEW_USER, UserAuthenticationTyp.ListAuthentication)); while (reader.Read()) { UserStruct user = new UserStruct(reader["username"].ToString(), reader["local_directory_id"].ToString(), UserAuthenticationTyp.ListAuthentication); users.Add(user); } reader.Close(); Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.UserList, 0, new TimeSpan(0, 0, 30))] = users; return(users); }
private void UpdateFile() { if (_statusUpdate == true) { if (MessageBox.Show("Вы действительно желаете изменить информацию о файле?", "Изменение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _statusUpdate = false; _userStruct = DataMethod.GetUser(_userStruct.userId); _fileStruct = DataMethod.GetFile(_fileStruct.fileId); _changeStruct = DataMethod.GetChange(_fileStruct.fileId); DataMethod.UpdateFile(_userActive.userId, _fileStruct.fileId, textBoxName.Text, richTextBoxComment.Text, comboBoxStatusFile.Text); this.textBoxName.Enabled = false; this.richTextBoxComment.Enabled = false; this.comboBoxStatusFile.Enabled = false; this.buttonUpdate.Text = "Изменить"; } } else { _statusUpdate = true; this.textBoxName.Enabled = true; this.richTextBoxComment.Enabled = true; this.comboBoxStatusFile.Enabled = true; this.buttonUpdate.Text = "Сохранить"; } this.FillForm(); }
public FileForm(int fileId, int userId) { _fileStruct = DataMethod.GetFile(fileId); _changeStruct = DataMethod.GetChange(fileId); _userStruct = DataMethod.GetUser(_fileStruct.userId); _userActive = DataMethod.GetUser(userId); this.InitializeComponent(); }
public static void GetUsers(Context context) { var user = new UserStruct() { Login = "******", Password = new PasswordStruct() { Password = "******", Temporary = false }, Email = new EmailStruct() { Email = "AnnEmail", Verified = true } }; user.Register(context); user = new UserStruct() { Login = "******", Password = new PasswordStruct() { Password = "******", Temporary = false }, Email = new EmailStruct() { Email = "JoeEmail", Verified = true } }; user.Register(context); user.SaveNewPassword(context, new PasswordStruct() { Password = "******", Temporary = false }); user = new UserStruct() { Login = "******", Password = new PasswordStruct() { Password = "******", Temporary = false }, Email = new EmailStruct() { Email = "LizEmail", Verified = true } }; user.Register(context); }
static void changeStruct(ref UserStruct user) { user.name = "Jane"; user.age = 34; Console.WriteLine("\tPrint from method"); Console.Write("\t"); user.DisplayInfo(); Console.WriteLine("\tEnd print from method"); }
public Dashboard() { string json = File.ReadAllText("User.McdM"); UserStruct StaticUserStruct = JsonConvert.DeserializeObject <UserStruct>(json); InitializeComponent(); txt_UserNotes.Text = $"Name: {StaticUserStruct.UserFirstname}\nLastName: {StaticUserStruct.UserLastName}\nMoneyRemaining: {StaticUserStruct.MoneyRemains} Tooman\nRegDate: {StaticUserStruct.UserRegDate}"; }
public ActionResult <VerificationStruct> Login(string login, string password) { var user = new UserStruct() { Login = login, Password = new PasswordStruct() { Password = password } }; var answer = user.Enter(context); if (!answer.Answer && answer.Message["Invalid"].Equals("Password")) { var wrongenters = user.GetWrongEnters(context); var permanentersleft = AppConfigurations.PermanentBanErrors - wrongenters; var constentersleft = AppConfigurations.ConstantBanErrors - wrongenters; if (AppConfigurations.PermanentBanErrors - wrongenters == 0) { answer.Message.Add("EntersLeft", permanentersleft.ToString()); answer.Message["Message"] = answer.Message["Message"] + " User was permanently banned."; user.SetBan(context, true); user.SendPermanentBanEmail(context); } else if (constentersleft <= 0) { answer.Message.Add("EntersLeft", constentersleft.ToString()); answer.Message["Message"] = answer.Message["Message"] + " Password was reset."; user.SetBan(context, true); user.SendConstantBanEmail(context); } } if (!answer.Answer && answer.Message["Invalid"].Equals("Locked")) { user.SendPermanentBanEmail(context); } if (answer.Answer) { var session = new SessionStruct() { User = user, }; session.SessionNo = session.GetSession(Sessions); if (session.SessionNo != 0) { Sessions.Remove(session); } session.SessionNo = session.GenSessionNo(); Sessions.Add(session); answer.Message.Add("SessionNo", session.SessionNo.ToString()); } return(answer); }
private UserStruct GetActualUser() { UpdateSelection(true); UserStruct user = comboBoxUserSelection.SelectedItem is UserStruct ? (UserStruct)comboBoxUserSelection.SelectedItem : new UserStruct(comboBoxUserSelection.Text, UserAuthenticationTyp.FormsAuthentication); user.Password = user.AuthenticationType == UserAuthenticationTyp.ListAuthentication || textBoxPassword.Text.Length <= 0 ? string.Empty : (PasswordType)textBoxPassword.Tag == PasswordType.Hashed ? textBoxPassword.Text : Methods.GetHashedPassword(textBoxPassword.Text); UpdatePercistancyData(user); return(user); }
public GridStruct(int width, int height) { this.height = height; this.width = width; user = new UserStruct() { score = 0, steps = 0, time = 0 }; grid = new TileStruct[width, height]; }
// ---------------------- methods ---------------------- public override void Registration(String email, String password) { email = email.Split('@')[0]; // turn email to user name this.Email = email; this.Password = password; Hashtable userTemp = new Hashtable(); userTemp[email] = password; // save to struct object UserStruct usersave = new UserStruct(userTemp, this.MyBoard); UserDAL.saveUser(usersave); //save to DB }
private void GameRoom_OnConnectionAddOtherData(UserStruct user, string connection) { var others = GetOthersConnections(user); GameHub.HubContext.Clients.Clients(others).SendAsync("AddUser", new { Id = GetId(user), Name = user.Name }); RoomsHub.HubContext.Clients.All.SendAsync("UpdateLobby", GetVueLobbyInfo()); if (Admin.Value.IsNull()) { Admin = this.Where(x => x.Value.IsNotNull()).FirstOrDefault(); GameHub.HubContext.Clients.Client(Admin.Value).SendAsync("InstallAsAnAdmin"); } }
public UserProperties(int userId) { try { _userStruct = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } InitializeComponent(); Icon = Properties.Resources.info; }
internal UserModifier(System.IntPtr nativePointer, MTA context) : base(nativePointer) { _nativePointer = nativePointer; _handleWrapper = context; _data = (UserStruct)System.Runtime.InteropServices.Marshal.PtrToStructure(nativePointer, typeof(UserStruct)); _username = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.username); _password = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.password); _firstname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.firstname); _lastname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.lastname); _companyname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.companyname); _role = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.role); _imagehash = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.imagehash); _nickname = MylapsSDK.Utilities.SDKHelperFunctions.UTF8ByteArrayToString(_data.nickname); }
public Loading(string wtd, string username = "", string password = "") { WTD = wtd; int i = 0; dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); Console.WriteLine("========================MyWindow_Loaded==========================="); Console.WriteLine($"{ii} = " + KJG); Console.WriteLine("========================MyWindow_Loaded==========================="); if (WTD == "Login") { Console.WriteLine("========================MyWindow_Loaded==========================="); Console.WriteLine($"{ii} = " + KJG); Console.WriteLine("========================MyWindow_Loaded==========================="); WebClient wc = new WebClient(); string urls = $"{ProjectProp.MasterUrl}/CustomerSideUserApp/userAuth?_u={username}&_p={password}"; KJG = wc.DownloadString(urls); EncDec endc = new EncDec(); Requests re = JsonConvert.DeserializeObject <Requests>(KJG); if (re.RequestEnc == "-1") { MessageBox.Show("User Not Found!"); Hide = 1; HasAccess = 3; } else if (re.RequestEnc == "-2") { MessageBox.Show("Cannot Connect To The Server"); Hide = 1; HasAccess = 2; } else if (re.Requestname == "OK") { UserStruct us = JsonConvert.DeserializeObject <UserStruct>(endc.DecryptText(re.RequestEnc)); File.WriteAllText("User.McdM", JsonConvert.SerializeObject(us)); HasAccess = 1; Hide = 1; } ii++; Console.WriteLine("========================MyWindow_Loaded==========================="); Console.WriteLine($"{ii} = " + KJG); Console.WriteLine("========================MyWindow_Loaded==========================="); } InitializeComponent(); }
public UserList(int userId) { InitializeComponent(); try { _userActive = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } _userStruct = new UserStruct(); Icon = Properties.Resources.list; }
public UserEdit(int userId) { try { _userStruct = DataMethod.GetUser(userId); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } _statusUpdate = true; InitializeComponent(); buttonAction.Text = "Изменить"; }
public static UserStruct?GetUser(UserStruct user, ConnectionStringStruct connection) { if (authenticationUsers.ContainsKey(connection.ConnectionString) && user.LastLoginError == LoginError.NoError) { return(authenticationUsers[connection.ConnectionString]); } else { UserStruct?newUser = MLifter.Controls.LoginForm.OpenLoginForm(user, connection); if (newUser.HasValue) { authenticationUsers[connection.ConnectionString] = newUser.Value; } return(newUser); } }
internal UserStruct?GetUser(UserStruct user, ConnectionStringStruct connection) { if (authenticationUsers.ContainsKey(connection.ConnectionString) && (!defaultUserSubmitted.ContainsKey(connection) || !defaultUserSubmitted[connection])) { defaultUserSubmitted[connection] = true; return(authenticationUsers[connection.ConnectionString]); } else { UserStruct?newUser = LoginForm.OpenLoginForm(user, connection); if (newUser.HasValue) { authenticationUsers[connection.ConnectionString] = newUser.Value; } return(newUser); } }
private void UpdateSelection(bool searchItem) { if (searchItem && comboBoxUserSelection.SelectedItem == null) { int sel = comboBoxUserSelection.SelectionStart; int index = comboBoxUserSelection.FindStringExact(comboBoxUserSelection.Text); comboBoxUserSelection.SelectedIndex = index; comboBoxUserSelection.SelectionStart = sel; } UserStruct userStruct = comboBoxUserSelection.SelectedItem is UserStruct ? (UserStruct)comboBoxUserSelection.SelectedItem : new UserStruct(comboBoxUserSelection.Text, UserAuthenticationTyp.FormsAuthentication); if (userStruct.AuthenticationType.HasValue) { ChangeUserAuthType(userStruct.AuthenticationType.Value); } }
static void printCopiedStructAndClass() { Console.WriteLine("Структура"); var userStruct1 = new UserStruct(); var userStruct2 = new UserStruct("Kate", 14); userStruct1 = userStruct2; userStruct2.age = 16; userStruct1.DisplayInfo(); userStruct2.DisplayInfo(); Console.WriteLine("Класс"); var userClass1 = new UserClass(); var userClass2 = new UserClass("Kate", 14); userClass1 = userClass2; userClass2.age = 16; userClass1.DisplayInfo(); userClass2.DisplayInfo(); }
private UserStruct?GetInvalidLdUser(UserStruct userStr, ConnectionStringStruct con) { if (!invalidLdUserReceived) { invalidLdUserReceived = true; } else { LoginError err = userStr.LastLoginError; if (err == LoginError.ForbiddenAuthentication) { throw new NoValidUserException(); } else { throw new Exception("Invalide authentication not recognised"); } } return(new UserStruct("invalid", UserAuthenticationTyp.LocalDirectoryAuthentication)); }
public IList<UserStruct> GetUserList() { IList<UserStruct> users = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.UserList, 0)] as IList<UserStruct>; if (users != null) return users; using (NpgsqlConnection con = PostgreSQLConn.CreateConnection(Parent.CurrentUser)) { using (NpgsqlCommand cmd = con.CreateCommand()) { cmd.CommandText = "SELECT * FROM \"GetUserList\"()"; NpgsqlDataReader reader = PostgreSQLConn.ExecuteReader(cmd, Parent.CurrentUser, false); users = new List<UserStruct>(); while (reader.Read()) { UserStruct user = new UserStruct(reader["username"].ToString(), (UserAuthenticationTyp)Enum.Parse(typeof(UserAuthenticationTyp), reader["typ"].ToString())); users.Add(user); } reader.Close(); Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.UserList, 0, new TimeSpan(0, 0, 30))] = users; return users; } } }
/// <summary> /// Gets the user list. /// </summary> /// <returns></returns> /// <remarks>Documented by Dev05, 2009-01-16</remarks> public IList<UserStruct> GetUserList() { IList<UserStruct> users = Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.GetIdentifier(CacheObject.UserList, 0)] as IList<UserStruct>; if (users != null) return users; SqlCeCommand cmd = MSSQLCEConn.CreateCommand(Parent.CurrentUser); cmd.CommandText = "SELECT * FROM \"UserProfiles\";"; SqlCeDataReader reader = MSSQLCEConn.ExecuteReader(cmd); users = new List<UserStruct>(); users.Add(new UserStruct(Resources.CREATE_NEW_USER, UserAuthenticationTyp.ListAuthentication)); while (reader.Read()) { UserStruct user = new UserStruct(reader["username"].ToString(), reader["local_directory_id"].ToString(), UserAuthenticationTyp.ListAuthentication); users.Add(user); } reader.Close(); Parent.CurrentUser.Cache[ObjectLifetimeIdentifier.Create(CacheObject.UserList, 0, new TimeSpan(0, 0, 30))] = users; return users; }