Interaction logic for BatchPage.xaml
Inheritance: System.Windows.Controls.Page
Exemplo n.º 1
0
        /// <summary>
        /// Handles the Closing event of the mainWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
        private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            //var rockConfig = RockConfig.Load();
            //var window = sender as NavigationWindow;
            //rockConfig.WindowCurrentHeight = window.ActualHeight;
            //rockConfig.WindowCurrentWidth = window.ActualWidth;
            //rockConfig.Save();
            try
            {
                ImageSafeHelper.CloseDevice();
            }
            catch
            {
                // if image safe is not loaded then just ignore driver exception.
            }

            BatchPage batchPage = null;

            if (mainWindow.Content is BatchPage)
            {
                batchPage = mainWindow.Content as BatchPage;
            }
            else if (mainWindow.Content is ScanningPage)
            {
                batchPage = (mainWindow.Content as ScanningPage)._batchPage;
            }

            if (batchPage != null && batchPage.rangerScanner != null)
            {
                batchPage.rangerScanner.ShutDown();
            }

            Application.Current.Shutdown();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Closing event of the mainWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
        private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            BatchPage batchPage = null;

            if (mainWindow.Content is BatchPage)
            {
                batchPage = mainWindow.Content as BatchPage;
            }
            else if (mainWindow.Content is ScanningPage)
            {
                batchPage = (mainWindow.Content as ScanningPage).batchPage;
            }

            if (batchPage != null)
            {
                if (batchPage.ScannedCheckList.Where(a => !a.Uploaded).Count() > 0)
                {
                    e.Cancel = true;
                    return;
                }

                batchPage.rangerScanner.ShutDown();
            }

            Application.Current.Shutdown();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Closing event of the mainWindow control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param>
        private void mainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            BatchPage batchPage = null;

            if (mainWindow.Content is BatchPage)
            {
                batchPage = mainWindow.Content as BatchPage;
            }
            else if (mainWindow.Content is ScanningPage)
            {
                batchPage = (mainWindow.Content as ScanningPage).batchPage;
            }

            if (batchPage != null && batchPage.rangerScanner != null)
            {
                batchPage.rangerScanner.ShutDown();
            }

            Application.Current.Shutdown();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScanningPage"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public ScanningPage(BatchPage value)
        {
            InitializeComponent();
            this.batchPage = value;

            try
            {
                var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
                DebugLogFilePath = config.AppSettings.Settings["DebugLogFilePath"].Value;
                bool isDirectory = !string.IsNullOrWhiteSpace(DebugLogFilePath) && Directory.Exists(this.DebugLogFilePath);
                if (isDirectory)
                {
                    DebugLogFilePath = Path.Combine(DebugLogFilePath, "CheckScanner.log");
                }
            }
            catch
            {
                // ignore any exceptions
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ScanningPage"/> class.
        /// </summary>
        /// <param name="value">The value.</param>
        public ScanningPage( BatchPage value )
        {
            InitializeComponent();
            this.batchPage = value;

            try
            {
                var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None);
                DebugLogFilePath = config.AppSettings.Settings["DebugLogFilePath"].Value;
                bool isDirectory = !string.IsNullOrWhiteSpace(DebugLogFilePath) && Directory.Exists( this.DebugLogFilePath );
                if (isDirectory)
                {
                    DebugLogFilePath = Path.Combine( DebugLogFilePath, "CheckScanner.log" );
                }
            }
            catch
            {
                // ignore any exceptions
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionsPage"/> class.
 /// </summary>
 public OptionsPage(BatchPage batchPage)
 {
     InitializeComponent();
     this.BatchPage   = batchPage;
     this._rockConfig = RockConfig.Load();
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionsPage"/> class.
 /// </summary>
 public OptionsPage( BatchPage batchPage )
 {
     InitializeComponent();
     this.BatchPage = batchPage;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptionsPage"/> class.
 /// </summary>
 public OptionsPage(BatchPage batchPage)
 {
     InitializeComponent();
     this.BatchPage = batchPage;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPage"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 public ScanningPage(BatchPage value)
 {
     InitializeComponent();
     this.batchPage = value;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPage"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 public ScanningPage( BatchPage value )
 {
     InitializeComponent();
     this.ScannedDocInfoHistory = new List<ScannedDocInfo>();
     this.batchPage = value;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click( object sender, RoutedEventArgs e )
        {
            lblLoginWarning.Visibility = Visibility.Hidden;
            txtUsername.Text = txtUsername.Text.Trim();
            txtRockUrl.Text = txtRockUrl.Text.Trim();
            Uri rockUrl = new Uri( txtRockUrl.Text );
            var validSchemes = new string[] { Uri.UriSchemeHttp, Uri.UriSchemeHttps };
            if ( !validSchemes.Contains( rockUrl.Scheme ) )
            {
                txtRockUrl.Text = "http://" + rockUrl.AbsoluteUri;
            }

            RockRestClient rockRestClient = new RockRestClient( txtRockUrl.Text );

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            if ( string.IsNullOrWhiteSpace( userName ) )
            {
                lblLoginWarning.Content = "Username cannot be blank";
                lblLoginWarning.Visibility = Visibility.Visible;
                return;
            }

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += delegate( object s, DoWorkEventArgs ee )
            {
                ee.Result = null;
                rockRestClient.Login( userName, password );
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate( object s, RunWorkerCompletedEventArgs ee )
            {
                this.Cursor = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if ( ee.Error != null )
                    {
                        throw ee.Error;
                    }

                    Person person = rockRestClient.GetData<Person>( string.Format( "api/People/GetByUserName/{0}", userName ) );
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username = txtUsername.Text;
                    rockConfig.Password = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage( person );

                    if ( this.NavigationService.CanGoBack )
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        try
                        {
                            batchPage.LoadLookups();
                            batchPage.LoadFinancialBatchesGrid();
                        }
                        catch ( HttpErrorException ex )
                        {
                            if ( ex.Response != null && ex.Response.StatusCode.Equals( HttpStatusCode.Unauthorized ) )
                            {
                                lblLoginWarning.Content = "Not Authorized for Financial Batches";
                                lblLoginWarning.Visibility = Visibility.Visible;
                                return;
                            }
                            else
                            {
                                throw ex;
                            }
                        }

                        this.NavigationService.Navigate( batchPage );
                    }
                }
                catch ( WebException wex )
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if ( response != null )
                    {
                        if ( response.StatusCode.Equals( HttpStatusCode.Unauthorized ) )
                        {
                            lblLoginWarning.Content = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if ( wex.InnerException != null )
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility = Visibility.Visible;
                    txtRockUrl.Visibility = Visibility.Visible;
                    lblLoginWarning.Content = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click( object sender, RoutedEventArgs e )
        {
            txtUsername.Text = txtUsername.Text.Trim();
            txtRockUrl.Text = txtRockUrl.Text.Trim();
            RockRestClient rockRestClient = new RockRestClient( txtRockUrl.Text );

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += delegate( object s, DoWorkEventArgs ee )
            {
                ee.Result = null;
                rockRestClient.Login( userName, password );
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate( object s, RunWorkerCompletedEventArgs ee )
            {
                this.Cursor = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if ( ee.Error != null )
                    {
                        throw ee.Error;
                    }

                    Person person = rockRestClient.GetData<Person>( string.Format( "api/People/GetByUserName/{0}", userName ) );
                    person.Aliases = rockRestClient.GetData<List<PersonAlias>>( "api/PersonAlias/", "PersonId eq " + person.Id );
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username = txtUsername.Text;
                    rockConfig.Password = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage();
                    batchPage.LoggedInPerson = person;

                    if ( this.NavigationService.CanGoBack )
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        this.NavigationService.Navigate( batchPage );
                    }
                }
                catch ( WebException wex )
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if ( response != null )
                    {
                        if ( response.StatusCode.Equals( HttpStatusCode.Unauthorized ) )
                        {
                            lblLoginWarning.Content = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if ( wex.InnerException != null )
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility = Visibility.Visible;
                    txtRockUrl.Visibility = Visibility.Visible;
                    lblLoginWarning.Content = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPage"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 public ScanningPage( BatchPage value )
 {
     InitializeComponent();
     this.batchPage = value;
 }
Exemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPromptPage"/> class.
 /// </summary>
 /// <param name="scanningPage">The scanning page.</param>
 public ScanningPromptPage( BatchPage batchPage )
 {
     InitializeComponent();
     this.BatchPage = batchPage;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPromptPage"/> class.
 /// </summary>
 /// <param name="scanningPage">The scanning page.</param>
 public ScanningPromptPage(BatchPage batchPage)
 {
     InitializeComponent();
     this.BatchPage = batchPage;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Handles the Click event of the btnLogin control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            lblLoginWarning.Visibility = Visibility.Hidden;
            txtUsername.Text           = txtUsername.Text.Trim();
            txtRockUrl.Text            = txtRockUrl.Text.Trim();
            RockRestClient rockRestClient = new RockRestClient(txtRockUrl.Text);

            string userName = txtUsername.Text;
            string password = txtPassword.Password;

            // start a background thread to Login since this could take a little while and we want a Wait cursor
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += delegate(object s, DoWorkEventArgs ee)
            {
                ee.Result = null;
                rockRestClient.Login(userName, password);
            };

            // when the Background Worker is done with the Login, run this
            bw.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ee)
            {
                this.Cursor        = null;
                btnLogin.IsEnabled = true;
                try
                {
                    if (ee.Error != null)
                    {
                        throw ee.Error;
                    }

                    Person person = rockRestClient.GetData <Person>(string.Format("api/People/GetByUserName/{0}", userName));
                    person.Aliases = rockRestClient.GetData <List <PersonAlias> >("api/PersonAlias/", "PersonId eq " + person.Id);
                    RockConfig rockConfig = RockConfig.Load();
                    rockConfig.RockBaseUrl = txtRockUrl.Text;
                    rockConfig.Username    = txtUsername.Text;
                    rockConfig.Password    = txtPassword.Password;
                    rockConfig.Save();

                    BatchPage batchPage = new BatchPage(person);

                    if (this.NavigationService.CanGoBack)
                    {
                        // if we got here from some other Page, go back
                        this.NavigationService.GoBack();
                    }
                    else
                    {
                        this.NavigationService.Navigate(batchPage);
                    }
                }
                catch (WebException wex)
                {
                    // show WebException on the form, but any others should end up in the ExceptionDialog
                    HttpWebResponse response = wex.Response as HttpWebResponse;
                    if (response != null)
                    {
                        if (response.StatusCode.Equals(HttpStatusCode.Unauthorized))
                        {
                            lblLoginWarning.Content    = "Invalid Login";
                            lblLoginWarning.Visibility = Visibility.Visible;
                            return;
                        }
                    }

                    string message = wex.Message;
                    if (wex.InnerException != null)
                    {
                        message += "\n" + wex.InnerException.Message;
                    }

                    lblRockUrl.Visibility      = Visibility.Visible;
                    txtRockUrl.Visibility      = Visibility.Visible;
                    lblLoginWarning.Content    = message;
                    lblLoginWarning.Visibility = Visibility.Visible;
                    return;
                }
            };

            // set the cursor to Wait, disable the login button, and start the login background process
            this.Cursor        = Cursors.Wait;
            btnLogin.IsEnabled = false;
            bw.RunWorkerAsync();
        }
Exemplo n.º 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanningPage"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 public ScanningPage(BatchPage value)
 {
     InitializeComponent();
     this.ScannedDocInfoHistory = new List <ScannedDocInfo>();
     this.batchPage             = value;
 }