コード例 #1
0
 private void Login()
 {
     try
     {
         IPMACommunicationContract proxy = configManager.CreateConnectionChannel(textBox_Server.Text, decimal.ToInt32(numericUpDown_port.Value));
         string md5Password = OperationUtils.EncodePasswordToMD5(textBox_Password.Text);
         configManager.clientRuntimeInfo.sessionID = proxy.GetSessionID(textBox_User.Text, md5Password);
         if (configManager.clientRuntimeInfo.sessionID != string.Empty)
         {
             configManager.clientRuntimeInfo.UserInfo = proxy.GetUserInfo(configManager.clientRuntimeInfo.sessionID);
             configManager.clientInfo.Server          = textBox_Server.Text;
             configManager.clientInfo.Port            = numericUpDown_port.Value.ToString();
             configManager.SaveConfiguration();
             this.Close();
         }
         else
         {
             MessageBox.Show("User Information does not matched");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
     finally
     {
         configManager.CloseConnectionChannel();
     }
 }
コード例 #2
0
 //---------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Handles the Click event of the button_ChangePassword control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void button_ChangePassword_Click(object sender, EventArgs e)
 {
     dataGridView_users.Rows[rowIndex].Cells["PasswordString"].Value = OperationUtils.EncodePasswordToMD5(textBox_NewPassword.Text);
     PasswordResetForm.Close();
     PasswordResetForm.Dispose();
     MessageBox.Show("Password is changed for user " + dataGridView_users.Rows[rowIndex].Cells["User"].Value.ToString());
 }
コード例 #3
0
        //---------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the Click event of the button_Add control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void button_Add_Click(object sender, EventArgs e)
        {
            bool isCheckedBox = false;

            foreach (Control ctrl in this.Controls)
            {
                if ((ctrl is CheckBox) && (ctrl as CheckBox).Checked)
                {
                    isCheckedBox = true;
                    break;
                }
            }
            if (textBox_User.Text != string.Empty && textBox_Password.Text != string.Empty && isCheckedBox && !IsUserAlreadyExist(textBox_User.Text))
            {
                DataGridViewRow row = dataGridView_users.Rows[dataGridView_users.Rows.Add()];
                row.Cells["User"].Value             = textBox_User.Text;
                row.Cells["PasswordString"].Value   = OperationUtils.EncodePasswordToMD5(textBox_Password.Text);
                row.Cells["SQL"].Value              = checkBox_SQL.Checked;
                row.Cells["Action"].Value           = checkBox_Action.Checked;
                row.Cells["Services"].Value         = checkBox_Services.Checked;
                row.Cells["TaskManagerAdmin"].Value = checkBox_TaskManagerAdmin.Checked;
                row.Cells["Password"].Value         = "Reset";
                row.Cells["RemoveUser"].Value       = "Remove";
                UpdateConfig();
            }
            else
            {
                StringBuilder message = new StringBuilder();
                if (!isCheckedBox)
                {
                    message.AppendLine("Please select one feature for admin");
                }
                else if (IsUserAlreadyExist(textBox_User.Text))
                {
                    message.AppendLine("User Already exist");
                }
                else
                {
                    message.AppendLine("Please provide valid credentials");
                }

                MessageBox.Show(this, message.ToString());
            }
        }