/// <summary> /// Считать пользователей из базы конфигурации /// </summary> private bool ReadUsers() { try { lock (users) { users.Clear(); DataTable tblUser = new DataTable(); BaseAdapter adapter = new BaseAdapter(); adapter.FileName = Settings.BaseDATDir + "user.dat"; adapter.Fill(tblUser, false); foreach (DataRow dataRow in tblUser.Rows) { User user = new User(); user.Name = (string)dataRow["Name"]; user.Password = (string)dataRow["Password"]; user.RoleID = (int)dataRow["RoleID"]; users[user.Name.Trim().ToLowerInvariant()] = user; } } AppLog.WriteAction(Localization.UseRussian ? "Пользователи считаны из базы конфигурации" : "Users are read from the configuration database", Log.ActTypes.Action); return true; } catch (Exception ex) { AppLog.WriteAction((Localization.UseRussian ? "Ошибка при считывании пользователей из базы конфигурации: " : "Error reading users from the configuration database: ") + ex.Message, Log.ActTypes.Exception); return false; } }
/// <summary> /// Initializes a new instance of the FormMainWindow class. /// </summary> /// <param name="i_UserData">The user facebook data</param> public FormMainWindow(LoginResult i_UserData) { InitializeComponent(); r_LoggedInUser = i_UserData.LoggedInUser; m_MyPosts = new List<MyPost>(); loadPosts(); FacebookService.s_CollectionLimit = 1000; s_Bdate = r_LoggedInUser.Birthday; r_FeatureReceiver = new FeatureReceiver(r_FeaturesFactory); setCommandsInUi(); }
/// <summary> /// Determines whether the input information was valid, clears fields that contain invalid information, /// and highlights that field's label. Called by OKButton_Click and by NameBox_KeyPress, EmailBox_KeyPress, /// and PhoneNumber_KeyPress when the enter key is pressed and any of these controls have the focus. /// </summary> private void FormAccept() { int InvalidFieldCount = 0; UserName = new Name(NameBox.Text); UserEmail = new EmailAddress(EmailBox.Text); UserPhoneNumber = new PhoneNumber(PhoneNumberBox.Text); NewUser = new User(UserName, UserEmail, UserPhoneNumber); if (NewUser.IsValid) { this.Close(); } else { if (UserName.IsValid == false) { UserNameLabel.ForeColor = Color.Red; NameBox.Text = String.Empty; InvalidFieldCount++; } else { UserNameLabel.ForeColor = Color.Black; } if (UserEmail.IsValid == false) { EmailLabel.ForeColor = Color.Red; EmailBox.Text = String.Empty; InvalidFieldCount++; } else { EmailLabel.ForeColor = Color.Black; } if (UserPhoneNumber.IsValid == false) { PhoneNumberLabel.ForeColor = Color.Red; PhoneNumberBox.Text = String.Empty; InvalidFieldCount++; } else { PhoneNumberLabel.ForeColor = Color.Black; } if (InvalidFieldCount > 1) { InstructionBox.Text = "Highlighted fields were invalid. Please enter valid values"; } else { InstructionBox.Text = "Highlighted field was invalid. Please enter a valid value"; } } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> /// <param name="i_UserData">The user facebook data</param> public MainWindow(LoginResult i_UserData) { InitializeComponent(); r_LoggedInUser = i_UserData.LoggedInUser; FacebookService.s_CollectionLimit = 1000; r_Util = Utils.Utils.Instance; fetchUserInfo(); }