private void InitializeListUser()
        {
            string userName = string.Empty;
            string idUser   = string.Empty;

            using (var userService = new ServiceManager.ServiceSystemCompaniesClient())
            {
                try
                {
                    var user = new ServiceManager.Users();
                    user.Method = "fillDropDown";
                    user        = userService.ManageUsers(user);

                    foreach (var listUsers in user.list)
                    {
                        idUser   = listUsers.Item2.ToString();
                        userName = listUsers.Item1;
                        if (userName != "admin")
                        {
                            IDToName users = new IDToName(userName, idUser);
                            comboxListUsers.Items.Add(users);
                        }
                    }
                }
                catch (FaultException ex)
                {
                    MessageUtils.LogUtils.WriteToLog(string.Format(" Error Get All User. Exception: {0} ", ex.Message));
                    MessageUtils.LogUtils.SystemEventLogsError(string.Format(" Error Get All User. Exception: {0} ", ex.Message));
                }
                if (comboxListUsers.Items.Count > 0)
                {
                    comboxListUsers.SelectedIndex = 0;
                }
            }
        }
示例#2
0
 public string GetPermission()
 {
     if (this.UserName == "administrator" && this.Password == "12213443")
     {
         return("True");
     }
     using (var userService = new ServiceManager.ServiceSystemCompaniesClient())
     {
         try
         {
             var user = new ServiceManager.Users();
             user.UserName = this.UserName;
             user.Password = this.Password;
             user.Method   = "getPermission";
             user          = userService.ManageUsers(user);
             return(user.Permission);
         }
         catch (FaultException ex)
         {
             MessageUtils.LogUtils.WriteToLog(string.Format(" Error get Permission. Exception: {0}.", ex.Message));
             MessageUtils.LogUtils.SystemEventLogsError(string.Format(" Error get Permission. Exception: {0}.", ex.Message));
             return(null);
         }
     }
 }
示例#3
0
 private static bool CheckConnection()
 {
     try
     {
         using (var userService = new ServiceManager.ServiceSystemCompaniesClient())
         {
             userService.Open();
             var user = new ServiceManager.Users();
             user.Method = "CheckConnection";
             user        = userService.ManageUsers(user);
             if (user.isBool)
             {
                 return(true);
             }
             MessageUtils.LogUtils.SystemEventLogsInformation(ERRORMESSAGE);
             MessageUtils.LogUtils.WriteToLog(ERRORMESSAGE);
             ErrorMessageBox(ERRORMESSAGE);
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
示例#4
0
 private void buttonAddUser_Click(object sender, EventArgs e)
 {
     if (radioButtonAdmin.Checked != false || radioButtonSec.Checked != false)
     {
         using (var userService = new ServiceManager.ServiceSystemCompaniesClient())
         {
             try
             {
                 var user = new ServiceManager.Users();
                 user.Method   = "CheckUser";
                 user.UserName = UserName;
                 user          = userService.ManageUsers(user);
                 if (!user.isBool)
                 {
                     const string title   = "שם משתמש קיים";
                     const string message = "קיימת כפילות של שם משתמש";
                     new MessageBoxText(message, title).ErrorMessageBox();
                     txtBoxUserName.BackColor = Color.Red;
                 }
                 else
                 {
                     user.Method      = "Insert";
                     user.UserName    = UserName;
                     user.PrivateName = PrivateName;
                     user.Permission  = UserPermissionAdmin;
                     user.Password    = Password;
                     userService.ManageUsers(user);
                     new MessageUtils.MessageBoxText(string.Format("  משתמש {0} נוסף בהצלחה ", PrivateName)).OkMessaageBox();
                 }
             }
             catch (FaultException ex)
             {
                 MessageUtils.LogUtils.WriteToLog(string.Format(" Error Insert User: {0}  Exception: {1}", PrivateName, ex.Message));
                 MessageUtils.LogUtils.SystemEventLogsError(string.Format(" Error Insert User: {0}  Exception: {1}", PrivateName, ex.Message));
             }
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("נא לבחור סוג הרשאה", "סוג הרשאה לא נבחר", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void btnDeleteUser_Click(object sender, EventArgs e)
        {
            string title   = "מחיקת משתמש";
            string message = "?בטוח שאתה רוצה למחוק";

            if (new MessageUtils.MessageBoxText(message, title).YesorNoMessageBox() != DialogResult.Yes)
            {
                return;
            }
            using (var userService = new ServiceManager.ServiceSystemCompaniesClient())
            {
                try
                {
                    var user = new ServiceManager.Users();
                    user.UserId = Convert.ToInt16(UserID);
                    user.Method = "CheckUserId";
                    user        = userService.ManageUsers(user);
                    if (!user.isBool)
                    {
                        user.Method = "Delete";
                        userService.ManageUsers(user);
                        MessageUtils.LogUtils.WriteToLog(" Delete User ");
                        MessageUtils.LogUtils.SystemEventLogsInformation(" Delete User");
                    }
                    else
                    {
                        MessageUtils.LogUtils.WriteToLog(" User doesn't exist ");
                        MessageUtils.LogUtils.SystemEventLogsWarning(" User doesn't exist");
                    }
                }
                catch (FaultException ex)
                {
                    MessageUtils.LogUtils.WriteToLog(string.Format(" Error Delete User. Exception: {0}.", ex.Message));
                    MessageUtils.LogUtils.SystemEventLogsError(string.Format(" Error Delete User. Exception: {0}.", ex.Message));
                }
            }
            this.Close();
        }