示例#1
0
        async void RefreshUsersList()
        {
            progressBar.Visibility = Visibility.Visible;
            try
            {
                accessRights.Clear();
                dataGrid.ItemsSource = null;
                dataGrid.ItemsSource = accessRights;

                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allAccessRights = await client.GetAllAccessRightsAsync();

                foreach (var accessRight in allAccessRights)
                {
                    accessRights.Add(new AccessRightView(accessRight));
                }

                dataGrid.ItemsSource = null;
                dataGrid.ItemsSource = accessRights;
            }
            catch (Exception)
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        async void SaveWorkRequest()
        {
            progressBar.Visibility = Visibility.Visible;
            cancelButton.IsEnabled = false;
            saveButton.IsEnabled   = false;

            WorkRequest = new WorkRequest {
                WorkRequestId = Guid.NewGuid(), CreatedByUser = AppGlobals.UserThatIsLoggedin, RequestDate = RequestDate.Value, Description = RequestDescription, WorkStatus = WorkStatus, WorkType = WorkType, SoftwareType = SoftwareType, UsersAssigned = AssignedToUsers, Customer = Customer
            };

            var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();


            try
            {
                // Add workRequest
                WorkRequest = await client.AddWorkRequestAsync(WorkRequest);

                WorkRequestWasAdded = true;
                Close();
                MessageBox.Show("Work request was added.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        async void Save()
        {
            if (Validate())
            {
                progressBar.Visibility = Visibility.Visible;
                cancelButton.IsEnabled = false;
                saveButton.IsEnabled   = false;

                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                try
                {
                    var updatedCustomer = await client.GetCustomerAsync(Customer.CustomerId);

                    updatedCustomer.Name = CustomerName;

                    updatedCustomer = await client.UpdateCustomerAsync(updatedCustomer);

                    Customer           = updatedCustomer;
                    CustomerWasUpdated = true;
                    Close();
                    MessageBox.Show("Customer was updated.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                progressBar.Visibility = Visibility.Collapsed;
            }
            else
            {
                MessageBox.Show("One or more fields are empty.");
            }
        }
        async void RefreshUsersList()
        {
            progressBar.Visibility = Visibility.Visible;
            try
            {
                users.Clear();
                dataGrid.ItemsSource = null;
                dataGrid.ItemsSource = users;

                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allUsers = await client.GetAllUsersAsync();

                foreach (var user in allUsers)
                {
                    users.Add(new WorkRequestUserView(user));
                }

                dataGrid.ItemsSource = null;
                dataGrid.ItemsSource = users;
            }
            catch (Exception)
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
示例#5
0
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (accessRightNameTextBox.Text.Length > 0)
            {
                progressBar.Visibility = Visibility.Visible;
                cancelButton.IsEnabled = false;
                saveButton.IsEnabled   = false;

                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                AccessRight = new AccessRight {
                    AccessRightId = Guid.NewGuid(), Name = accessRightNameTextBox.Text
                };

                try
                {
                    AccessRight = await client.AddAccessRightAsync(AccessRight);

                    AccessRightWasAdded = true;
                    Close();
                    MessageBox.Show("Access Right was added.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                progressBar.Visibility = Visibility.Collapsed;
            }
            else
            {
                MessageBox.Show("One or more fields are empty.");
            }
        }
示例#6
0
        private async void loginButton_Click(object sender, RoutedEventArgs e)
        {
            if (userIdTextBox.Text.Length > 0 && passwordTextBox.Password.Length > 0)
            {
                progressBar.Visibility    = Visibility.Visible;
                cancelButton.IsEnabled    = false;
                loginButton.IsEnabled     = false;
                userIdTextBox.IsEnabled   = false;
                passwordTextBox.IsEnabled = false;


                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();


                try
                {
                    var userLogin = await client.FindUserLoginAsync(userIdTextBox.Text.Trim(), passwordTextBox.Password);

                    if (userLogin != null)
                    {
                        var userAccessRights = await client.GetActiveUserAccessRightsAsync(userLogin.User.UserId);

                        // Check to see if user is allowed to login
                        var userIsAllowedToLoginAccessRight = userAccessRights.FirstOrDefault(userAccessRight => userAccessRight.AccessRight.Name.Equals("Can Login"));

                        if (userIsAllowedToLoginAccessRight != null)
                        {
                            LoginWasSuccessfull           = true;
                            AppGlobals.UserThatIsLoggedin = userLogin.User;
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("You don't have the Access Right to log in.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The User Id and Password you entered did not match any records in the system.");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                progressBar.Visibility    = Visibility.Collapsed;
                cancelButton.IsEnabled    = true;
                loginButton.IsEnabled     = true;
                userIdTextBox.IsEnabled   = true;
                passwordTextBox.IsEnabled = true;
                passwordTextBox.Clear();
                passwordTextBox.Focus();
            }
            else
            {
                MessageBox.Show("One or more fields are empty.");
            }
        }
示例#7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // This going to wake up the database, so that login takes little time.
            Task.Run(async() => {
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();
                var result = client.FindUserLoginAsync(".", ".");
            });

            progressBar.Visibility = Visibility.Collapsed;
            userIdTextBox.Focus();
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            selectUsersControl = new SelectUsersControl(this);
            assignedToUserGrid.Children.Add(selectUsersControl);

            progressBar.Visibility = Visibility.Visible;

            try
            {
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                // Status
                var allStatuses = await client.GetAllWorkStatusesAsync();

                foreach (var status in allStatuses)
                {
                    statusComboBox.Items.Add(new WorkRequestWorkStatusView(status));
                }

                // Customer
                var allCustomers = await client.GetAllActiveCustomersAsync();

                foreach (var customer in allCustomers)
                {
                    customerComboBox.Items.Add(new WorkRequestCustomerView(customer));
                }


                // Work type
                var allWorktypes = await client.GetAllWorkTypesAsync();

                foreach (var workType in allWorktypes)
                {
                    workTypeComboBox.Items.Add(new WorkRequestWorkTypeView(workType));
                }



                // Software type
                var allSoftwareTypes = await client.GetAllSoftwareTypesAsync();

                foreach (var softwareType in allSoftwareTypes)
                {
                    softwareComboBox.Items.Add(new WorkRequestSoftwareTypeView(softwareType));
                }
            }
            catch (Exception)
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
 public void OnUserWasAddedPushNotification(Guid userId)
 {
     Dispatcher.Invoke(new Action(async() => {
         try
         {
             var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();
             var user   = await client.GetUserAsync(userId);
             Add(user);
             dataGrid.RefreshData();
         }
         catch
         {
         }
     }));
 }
 public void OnWorkRequestWasAddedPushNotification(Guid workRequestId)
 {
     Dispatcher.Invoke(new Action(async() => {
         try
         {
             var client      = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();
             var workRequest = await client.GetWorkRequestAsync(workRequestId);
             Add(workRequest);
             dataGrid.RefreshData();
         }
         catch
         {
         }
     }));
 }
示例#11
0
        public void OnCustomerWasUpdatedPushNotification(Guid customerId)
        {
            Dispatcher.Invoke(new Action(async() => {
                try
                {
                    var client   = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();
                    var customer = await client.GetCustomerAsync(customerId);

                    Update(customer);
                    dataGrid.RefreshData();
                }
                catch
                {
                }
            }));
        }
        private async void removeButton_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItems.Count > 0)
            {
                MessageBoxResult result = MessageBox.Show("Remove selected items?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);

                if (result == MessageBoxResult.Yes)
                {
                    try
                    {
                        var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                        foreach (var selectedItem in dataGrid.SelectedItems)
                        {
                            var selectedWorkRequestUserView = selectedItem as WorkRequestUserView;

                            if (selectedWorkRequestUserView != null)
                            {
                                var user = selectedWorkRequestUserView.user;

                                var removedUser = new RemovedUser {
                                    RemovedUserId = Guid.NewGuid(), DateRemoved = DateTime.Now, RemovedByUser = AppGlobals.UserThatIsLoggedin, User = user
                                };

                                await client.RemoveUserAsync(removedUser);
                            }
                        }

                        RefreshUsersList();
                        MessageBox.Show("Done.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            else
            {
                MessageBox.Show("You have not selected any items.");
            }
        }
示例#13
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            selectAccessRightsControl = new SelectAccessRightsControl(this);
            accessRightsGrid.Children.Add(selectAccessRightsControl);

            progressBar.Visibility = Visibility.Visible;

            try
            {
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allGenders = await client.GetAllGendersAsync();

                foreach (var gender in allGenders)
                {
                    genderComboBox.Items.Add(new GenderView(gender));
                }


                var userLogins = await client.GetActiveUserLoginsAsync(User.UserId);

                userLogin = userLogins.FirstOrDefault();
                User      = userLogin.User;


                userAccessRights = await client.GetActiveUserAccessRightsAsync(User.UserId);

                // Populate the UI
                FirstName    = User.FirstName;
                LastName     = User.LastName;
                Gender       = User.Gender;
                UserId       = userLogin.UserId;
                AccessRights = (from userAccessRight in userAccessRights
                                select userAccessRight.AccessRight)
                               .ToList();
            }
            catch
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        async void SaveWorkRequest()
        {
            if (Validate())
            {
                progressBar.Visibility = Visibility.Visible;
                cancelButton.IsEnabled = false;
                saveButton.IsEnabled   = false;


                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var updatedWorkRequest = await client.GetWorkRequestAsync(WorkRequest.WorkRequestId);

                updatedWorkRequest.RequestDate   = RequestDate.Value;
                updatedWorkRequest.Description   = RequestDescription;
                updatedWorkRequest.Customer      = Customer;
                updatedWorkRequest.SoftwareType  = SoftwareType;
                updatedWorkRequest.UsersAssigned = AssignedToUsers;
                updatedWorkRequest.WorkStatus    = WorkStatus;
                updatedWorkRequest.WorkType      = WorkType;

                try
                {
                    // Add workRequest
                    updatedWorkRequest = await client.UpdateWorkRequestAsync(updatedWorkRequest);

                    WorkRequest           = updatedWorkRequest;
                    WorkRequestWasUpdated = true;

                    Close();
                    MessageBox.Show("Work request was updated.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                progressBar.Visibility = Visibility.Collapsed;
            }
        }
        async void RefreshWorkRequestsList()
        {
            progressBar.Visibility = Visibility.Visible;
            try
            {
                WorkRequests.Clear();
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allWorkRequests = await client.GetAllActiveWorkRequestsAsync();

                foreach (var workRequest in allWorkRequests)
                {
                    Add(workRequest);
                }

                dataGrid.RefreshData();
            }
            catch
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        async void Save()
        {
            if (Validate())
            {
                if (AccessRightName.Length > 0)
                {
                    progressBar.Visibility = Visibility.Visible;
                    cancelButton.IsEnabled = false;
                    saveButton.IsEnabled   = false;

                    var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                    var updatedAccessRight = client.GetAccessRight(AccessRight.AccessRightId);
                    updatedAccessRight.Name = AccessRightName;

                    try
                    {
                        updatedAccessRight = await client.UpdateAccessRightAsync(updatedAccessRight);

                        AccessRight           = updatedAccessRight;
                        AccessRightWasUpdated = true;
                        Close();
                        MessageBox.Show("Access Right was updated.");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    progressBar.Visibility = Visibility.Collapsed;
                }
                else
                {
                    MessageBox.Show("One or more fields are empty.");
                }
            }
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            selectAccessRightsControl = new SelectAccessRightsControl(this);
            accessRightsGrid.Children.Add(selectAccessRightsControl);

            progressBar.Visibility = Visibility.Visible;

            try
            {
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allGenders = await client.GetAllGendersAsync();

                foreach (var gender in allGenders)
                {
                    genderComboBox.Items.Add(new GenderView(gender));
                }
            }
            catch (Exception)
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        async void RefreshUsersList()
        {
            progressBar.Visibility = Visibility.Visible;

            try
            {
                Users.Clear();
                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                var allUsers = await client.GetAllActiveUsersAsync();

                foreach (var user in allUsers)
                {
                    Add(user);
                }

                dataGrid.RefreshData();
            }
            catch
            {
            }

            progressBar.Visibility = Visibility.Collapsed;
        }
        private async void saveButton_Click(object sender, RoutedEventArgs e)
        {
            if (firstNameTextBox.Text.Length > 0 && lastNameTextBox.Text.Length > 0 && genderComboBox.SelectedIndex >= 0)
            {
                if (userIdTextBox.Text.Length > 0 && passwordTextBox.Password.Length > 0 && confirmPasswordTextBox.Password.Length > 0)
                {
                    if (passwordTextBox.Password == confirmPasswordTextBox.Password)
                    {
                        if (selectAccessRightsControl.SelectedAccessRights.Count > 0)
                        {
                            progressBar.Visibility = Visibility.Visible;
                            cancelButton.IsEnabled = false;
                            saveButton.IsEnabled   = false;

                            var selectedGenderView = genderComboBox.SelectedValue as GenderView;
                            var selectedGender     = selectedGenderView.gender;

                            var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                            User = new User {
                                FirstName = firstNameTextBox.Text, LastName = lastNameTextBox.Text, Gender = selectedGender, UserId = Guid.NewGuid()
                            };

                            try
                            {
                                // Add user
                                User = await client.AddUserAsync(User);

                                // Add Login
                                var userLogin = new UserLogin {
                                    UserLoginId = Guid.NewGuid(), UserId = userIdTextBox.Text, PasswordHash = passwordTextBox.Password, User = User
                                };
                                userLogin = await client.AddUserLoginAsync(userLogin);

                                // Add Access Rights
                                foreach (var selectedAccessRight in selectAccessRightsControl.SelectedAccessRights)
                                {
                                    var userAccessRight = new UserAccessRight {
                                        UserAccessRightId = Guid.NewGuid(), AccessRight = selectedAccessRight, User = User
                                    };
                                    userAccessRight = await client.AddUserAccessRightAsync(userAccessRight);
                                }


                                UserWasAdded = true;
                                Close();
                                MessageBox.Show("User was added.");
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                            }

                            progressBar.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            MessageBox.Show("You have not selected any Access Rights for this user.");
                        }
                    }
                    else
                    {
                        MessageBox.Show("The Password and Confirm Password fields do not match.");
                    }
                }
                else
                {
                    MessageBox.Show("One or more fields in Login Info section are empty.");
                }
            }
            else
            {
                MessageBox.Show("One or more fields in Personal Info section are empty.");
            }
        }
示例#20
0
        async void Save()
        {
            if (Validate())
            {
                progressBar.Visibility = Visibility.Visible;
                cancelButton.IsEnabled = false;
                saveButton.IsEnabled   = false;

                var client = await BacklogAPIClientBuilder.GetBackLogAPIClientAsync();

                try
                {
                    // Update User
                    var updatedUser = await client.GetUserAsync(User.UserId);

                    updatedUser.FirstName = FirstName;
                    updatedUser.LastName  = LastName;
                    updatedUser.Gender    = Gender;
                    updatedUser           = await client.UpdateUserAsync(updatedUser);

                    // Update Login
                    var updatedUserLogin = await client.GetUserLoginAsync(userLogin.UserLoginId);

                    updatedUserLogin.UserId = UserId;

                    if (Password.Length > 0)
                    {
                        updatedUserLogin.PasswordHash = Password;
                    }

                    updatedUserLogin = await client.UpdateUserLoginAsync(updatedUserLogin);


                    // Remove User Access Rights
                    var userAccessRightsToRemove = userAccessRights
                                                   .Where(userAccessRight => !AccessRights
                                                          .Select(accessRight => accessRight.AccessRightId)
                                                          .Contains(userAccessRight.AccessRight.AccessRightId))
                                                   .ToList();

                    // Remove User Access Rights
                    foreach (var userAccessRightToRemove in userAccessRightsToRemove)
                    {
                        var removedUserAccessRight = await client.RemoveUserAccessRightAsync(new RemovedUserAccessRight { DateRemoved = DateTime.Now, RemovedByUser = AppGlobals.UserThatIsLoggedin, RemovedUserAccessRightId = Guid.NewGuid(), UserAccessRight = userAccessRightToRemove });
                    }


                    // Remove User Access Rights
                    var userAccessRightsToAdd = AccessRights
                                                .Where(accessRight => !userAccessRights
                                                       .Select(userAccessRight => userAccessRight.AccessRight.AccessRightId)
                                                       .Contains(accessRight.AccessRightId))
                                                .ToList();

                    // Add User Access Rights
                    foreach (var userAccessRightToAdd in userAccessRightsToAdd)
                    {
                        var addedUserAccessRight = await client.AddUserAccessRightAsync(new UserAccessRight { UserAccessRightId = Guid.NewGuid(), User = updatedUser, AccessRight = userAccessRightToAdd });
                    }

                    User = updatedUser;

                    UserWasUpdated = true;
                    Close();
                    MessageBox.Show("User was updated.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                progressBar.Visibility = Visibility.Collapsed;
            }
        }