Пример #1
0
        readonly UserProfile user; // user profile object to host target user information

        public UserSalesRecordsTemplateForm(String username)
        {
            InitializeComponent();

            // fetching target user information
            user = UserInformationManager.ConsultUserInformationByUsername(username);
        }
        private void CreateAndReturnButton_Click(object sender, EventArgs e)
        {
            if (ValidateUserInput())                                                                          // Verifying if user input confirm with all requirements
            {
                String message = UserInformationManager.CreateNewUserProfileInformation(CreateUserProfile()); // Confimring the user creation process

                if (message == "SUCCESS")                                                                     // Creation process has been successful
                {
                    messageLabel.Text = "User has been created succesfully!";
                    ClearTextBoxBuffers(); // cleaning textboxes

                    // Closing form while freeing system resources
                    FormsMenuList.registerNewUserForm.Dispose();

                    // Summon Users Registry Form
                    FormsMenuList.usersRegistryForm = new UsersRegistryForm();
                    FormsMenuList.usersRegistryForm.Show();
                }
                else
                {
                    // Executing correct activity according to given code
                    SystemProtocols.ApplyActivityProtocols("ERR2", null, null);
                    messageLabel.Text = "A Fatal Error has occured!"; // The new user profile has not been created due to en error
                }
            }
            else
            {
                messageLabel.Text = "Please fill in every information correctly"; // user input has not been validated
            }
        }
Пример #3
0
        public UserInformationTemplateForm(String username)
        {
            InitializeComponent();

            user = UserInformationManager.ConsultUserInformationByUsername(username); // fetching information of target user

            userTitleLabel.Text += " " + username;
        }
        readonly UserProfile user; // User profile object to host target user information

        public UserSessionActivitiesReportTemplateForm(String username)
        {
            InitializeComponent();

            // Requesting target user information
            user = UserInformationManager.ConsultUserInformationByUsername(username);

            // Displaying requested information
            usernameLabel.Text = user.Username;
            roleLabel.Text     = user.Role;
        }
Пример #5
0
        private void SuspendUserButton_Click(object sender, EventArgs e)
        {
            // Requesting status change of terget user account
            UserInformationManager.UpdateTargerUserStatusInformation(user.Username, user.Status == "Active" ? 1 : 0, user.Status == "Active" ? "Inactive" : "Active");

            // Updating form information
            user.Status            = user.Status == "Active" ? "1" : "0";
            statusTextBox.Text     = user.Status;
            suspendUserButton.Text = user.Status == "Active" ? "Suspend User" : "Reinstate User";

            // Refreshing and updating information of parent form
            FormsMenuList.usersRegistryForm.RefreshDatagridInformation();
        }
        private void InitiatePasswordChangeProtocols()
        {
            // Validating user input before submitting request for password change
            if (ValidateUserInput())
            {
                // Requesting a password change for a target user
                UserInformationManager.UpdateUserPasswordInformation(username, passwordTextBox.Text);

                MessageBox.Show("Password changed successfully!");

                this.Dispose();
            }
        }
Пример #7
0
 private void RefreshInfo()
 {
     IsStandby = false;
     Task.Factory.StartNew(() =>
     {
         UserInformationManager.ReceiveInidividualInfo(Info);
         DispatcherHelper.BeginInvoke(() =>
         {
             IsStandby = true;
             RefreshUserData();
         });
     }, TaskCreationOptions.LongRunning);
 }
        /// <summary>
        /// Fucntion to populate the user registry data grid
        /// </summary>
        private void PopulateUserResigtryDataGrid()
        {
            // Requestion information to fill data grid
            userList.DataSource = UserInformationManager.ConsultUserListInformation(userSearchBox.Text);

            // Hiding unnecessary fields
            userList.Columns["Password"].Visible         = false;
            userList.Columns["Creator"].Visible          = false;
            userList.Columns["RegistrationDate"].Visible = false;

            // Modifying data grid
            userList.Columns["Status"].Width    = 70;
            userList.Columns["LastLogin"].Width = 130;
        }
Пример #9
0
        private void ShowAccountConfig(AccountInfo parameter)
        {
            string prevId = parameter.ScreenName;
            var    apcvm  = new AccountPropertyConfigViewModel(parameter);
            var    msg    = new TransitionMessage(apcvm, "ShowConfig");

            this.Messenger.Raise(msg);
            if (apcvm.IsModified)
            {
                IsAccountModified = true;
            }
            if (apcvm.AccountInfo != null && apcvm.AccountInfo.ScreenName != prevId)
            {
                // User ID changed
                IsAccountModified = true;
                UserInformationManager.ReceiveInidividualInfo(apcvm.AccountInfo);
            }
        }
Пример #10
0
        private void InitializieCombo()
        {
            try
            {
                UserInformationManager uIManager = new UserInformationManager();

                ddlUser.DataSource     = uIManager.GetAllUsers();
                ddlUser.DataTextField  = "Name";
                ddlUser.DataValueField = "UserCode";
                ddlUser.DataBind();
                ddlUser.Items.Insert(0, new ListItem(String.Empty, String.Empty));
                ddlUser.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #11
0
        private void ChangeAccessLevelButtom_Click(object sender, EventArgs e)
        {
            // Requesting a access level change for a target user
            UserInformationManager.UpdateTargetUserAccessLevelInformation(user.Username, user.Role == "Admin" ? "User" : "Admin");

            // Updating information of the form
            user.Role                    = user.Role == "Admin" ? "User" : "Admin";
            roleTextBox.Text             = user.Role;
            changeAccessLevelButtom.Text = user.Role == "Admin" ? "Demote to User Level" : "Promote to Admin Level";

            // Disabling features according to target user's access level compared to current user in session's access level
            if (SystemProtocols.ApplySessionsProtocols(2, user.Username, user.Role))
            {
                changeAccessLevelButtom.Visible = false;
                changeAccessLevelButtom.Enabled = false;
                changePasswordButton.Visible    = false;
                changePasswordButton.Enabled    = false;
            }

            // Refreshing and updating information of parent form
            FormsMenuList.usersRegistryForm.RefreshDatagridInformation();
        }
        private void UsernameTextBox_TextChanged(object sender, EventArgs e)
        {
            usernameTextBox.BackColor = Color.White;

            // Requesting an availability check for the new username
            if (usernameTextBox.Text.ToLower() == "admin" || usernameTextBox.Text.ToLower() == "super" || usernameTextBox.Text.ToLower() == "superadmin" || usernameTextBox.Text.ToLower() == "adminsuper")
            {
                usernameErrorLable.Visible = true; // username is invalid regardless if it isn't registered
            }
            else if (usernameTextBox.Text.Count() < 3)
            {
                usernameErrorLable.Visible = true; // username is invalid due to legnth
            }
            else if (UsernameHasEmptySpace())
            {
                usernameErrorLable.Visible = true; // username is invalid due to empty space
            }
            else if (UserInformationManager.ConsultUsernameAvailability(usernameTextBox.Text))
            {
                usernameErrorLable.Visible = false; // username is available and validated so error message is hidden
            }
        }
Пример #13
0
        private void AddAccount()
        {
            var auth = new AuthenticateViewModel();
            var msg  = new TransitionMessage(auth, "ShowAuth");

            this.Messenger.Raise(msg);
            var ainfo = auth.GetAccountInfo();

            if (auth.Success && ainfo != null)
            {
                if (AccountStorage.Contains(ainfo.ScreenName))
                {
                    this.Messenger.Raise(new InformationMessage("アカウント @" + ainfo.ScreenName + " は既に存在します。", "アカウント追加エラー", System.Windows.MessageBoxImage.Error, "Information"));
                }
                else
                {
                    IsAccountModified = true;
                    ShowAccountConfig(ainfo);
                    AccountStorage.RegisterAccount(ainfo);
                    UserInformationManager.ReceiveInidividualInfo(ainfo);
                }
            }
        }
        private void CreateNewUserButton_Click(object sender, EventArgs e)
        {
            if (ValidateUserInput())                                                                          // Verifying if user input confirm with all requirements
            {
                String message = UserInformationManager.CreateNewUserProfileInformation(CreateUserProfile()); // Confimring the user creation process

                if (message == "SUCCESS")                                                                     // Creation process has been successful
                {
                    messageLabel.Text = "User " + usernameTextBox.Text + " has been created succesfully!";
                    ClearTextBoxBuffers(); // cleaning textboxes
                }
                else
                {
                    // Executing correct activity according to given code
                    SystemProtocols.ApplyActivityProtocols("ERR2", null, null);
                    messageLabel.Text = "A Fatal Error has occured!"; // The new user profile has not been created due to en error
                }
            }
            else
            {
                messageLabel.Text = "Please fill in every information correctly"; // user input has not been validated
            }
        }
Пример #15
0
 /// <summary>
 /// 明示的な変更があった場合に接続を更新します。
 /// </summary>
 public static void RefreshReceivers()
 {
     lock (_cmLocker)
     {
         var exists = connections.Keys;
         var infos  = AccountStorage.Accounts
                      .Where(i => i.AccountProperty.UseUserStreams)
                      .ToArray();
         var addeds  = infos.Except(exists).ToArray();
         var removes = exists.Except(infos).ToArray();
         var keeps   = exists.Except(removes).ToArray();
         var nones   = AccountStorage.Accounts.Where(i => !i.AccountProperty.UseUserStreams);
         Parallel.ForEach(addeds, i =>
         {
             // 新規接続
             UserInformationManager.ReceiveInidividualInfo(i);
             RefreshConnection(i);
         });
         foreach (var i in removes)
         {
             // 登録削除
             UserStreamsConnection ccon;
             if (connections.TryGetValue(i, out ccon))
             {
                 connections.Remove(i);
                 if (ccon != null)
                 {
                     ccon.Dispose();
                 }
             }
         }
         Parallel.ForEach(keeps, i =>
         {
             RefreshConnection(i);
         });
     }
 }