Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(filePathTextBox.Text))
            {
                errorMessageLabel.Text = "Please select a valid file";
            }
            else if (String.IsNullOrWhiteSpace(usernameTextBox.Text))
            {
                errorMessageLabel.Text = "Please enter a valid username";
            }
            else if (String.IsNullOrWhiteSpace(passwordTextBox.Password))
            {
                errorMessageLabel.Text = "Please enter a valid password";
            }
            else if (String.IsNullOrWhiteSpace(accountCodeTextBox.Text))
            {
                errorMessageLabel.Text = "Please enter a valid account code";
            }
            else
            {
                string sessionTicket = apiHelper.GetSessionTicket(accountCodeTextBox.Text, usernameTextBox.Text, passwordTextBox.Password);
                if (sessionTicket == null)
                {
                    errorMessageLabel.Text = "Authentication Unsuccessful: Please check login details.";
                }
                else
                {
                    errorMessageLabel.Text = String.Empty;
                    //Process the CSV File
                    NavigationService.Navigate(new ProcessingPage());
                    var  people = csvHelper.ParseReportToObjects(filePath);
                    bool timecardsAddedSuccessfuly = apiHelper.AddTimeCards(people, sessionTicket);

                    if (timecardsAddedSuccessfuly)
                    {
                        NavigationService.Navigate(new CompletedPage(BatchState.CompletedSuccesfully));
                    }
                    else
                    {
                        var errors = apiHelper.GetErrors();
                        foreach (var error in errors)
                        {
                            //Type 1
                            //Scenario: Job not in MIPAC - Comment field incorrect format
                            //Action: Reject perosons's timecard and ask for manual entry at end

                            //Type 2
                            //Scenario: Job not in MIPAC - Comment field correct format - Job doesn't exist in Projector
                            //Action: Reject perosons's timecard and ask for manual entry at end


                            //Type 3
                            //Scenario: Job in MIPAC - Job in lookup table - Projector code no longer working
                            //Action: Reject perosons's timecard and ask for manual entry at end

                            //Type 4:
                            //Scenario: Job in MIPAC - Job not in lookup table
                            //Action: Verify from user if job is in projector
                            //YES: Show mipac code+name and ask user to enter projector code+name. Save project to db. Proceed with adding timecard.
                            //NO: Reject perosons's timecard and ask for manual entry at end
                        }
                    }
                }
            }
        }