LogException() 공개 정적인 메소드

Silently tries to log the exception to the server's exception log service
public static LogException ( Exception ex ) : void
ex System.Exception The ex.
리턴 void
예제 #1
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click(object sender, RoutedEventArgs e)
        {
            _rockConfig.CaptureAmountOnScan = chkCaptureAmountOnScan.IsChecked == true;

            _rockConfig.RequireControlAmount    = chkRequireControlAmount.IsChecked == true;
            _rockConfig.RequireControlItemCount = chkRequireControlItemCount.IsChecked == true;
            AddAccountsForAmountsToSave();
            if (_rockConfig.CaptureAmountOnScan && _rockConfig.SelectedAccountForAmountsIds.Count() == 0)
            {
                MessageBox.Show("Please select at least one account", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            try
            {
                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 client = new RockRestClient(txtRockUrl.Text);
                client.Login(_rockConfig.Username, _rockConfig.Password);
                BatchPage.LoggedInPerson = client.GetData <Person>(string.Format("api/People/GetByUserName/{0}", _rockConfig.Username));
            }
            catch (WebException wex)
            {
                HttpWebResponse response = wex.Response as HttpWebResponse;
                if (response != null)
                {
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // valid URL but invalid login, so navigate back to the LoginPage
                        _rockConfig.RockBaseUrl = txtRockUrl.Text;
                        _rockConfig.Save();
                        LoginPage loginPage = new LoginPage(true);
                        this.NavigationService.Navigate(loginPage);
                        return;
                    }
                }

                lblAlert.Content    = wex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }
            catch (Exception ex)
            {
                App.LogException(ex);
                lblAlert.Content    = ex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }

            _rockConfig.RockBaseUrl = txtRockUrl.Text;

            switch (cboScannerInterfaceType.SelectedItem as string)
            {
            case "MagTek COM":
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MICRImageRS232;
                break;

            case "MagTek Image Safe":
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MagTekImageSafe;
                break;

            default:
                _rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.RangerApi;
                break;
            }

            string imageOption = cboImageOption.SelectedValue as string;

            _rockConfig.Sensitivity = txtSensitivity.Text.Trim().AsInteger().ToString();
            _rockConfig.Plurality   = txtPlurality.Text.Trim().AsInteger().ToString();

            switch (imageOption)
            {
            case "Grayscale":
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeGrayscale;
                break;

            case "Color":
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeColor;
                break;

            default:
                _rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeBitonal;
                break;
            }

            string comPortName = cboMagTekCommPort.SelectedItem as string;

            if (!string.IsNullOrWhiteSpace(comPortName))
            {
                _rockConfig.MICRImageComPort = short.Parse(comPortName.Replace("COM", string.Empty));
            }

            var campusFilter = cboCampusFilter.SelectedItem as Campus;

            _rockConfig.CampusIdFilter = campusFilter?.Id;

            _rockConfig.Save();
            BatchPage.LoadLookups();

            // shutdown the scanner so that options will be reloaded when the batch page loads
            if (BatchPage.rangerScanner != null)
            {
                BatchPage.rangerScanner.ShutDown();
            }

            BatchPage.UnbindAllEvents();
            BatchPage.BindDeviceToPage();
            BatchPage.ConnectToScanner();
            BatchPage.LoadFinancialBatchesGrid();
            BatchPage.UpdateBatchUI(BatchPage.SelectedFinancialBatch);

            this.NavigationService.Navigate(BatchPage);
        }
예제 #2
0
 /// <summary>
 /// Shows the exception.
 /// </summary>
 /// <param name="ex">The ex.</param>
 private static void ShowException(Exception ex)
 {
     App.LogException(ex);
     MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
 }
예제 #3
0
        /// <summary>
        /// Handles the Click event of the btnSave 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 btnSave_Click(object sender, RoutedEventArgs e)
        {
            RockConfig rockConfig = RockConfig.Load();

            try
            {
                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 client = new RockRestClient(txtRockUrl.Text);
                client.Login(rockConfig.Username, rockConfig.Password);
                BatchPage.LoggedInPerson = client.GetData <Person>(string.Format("api/People/GetByUserName/{0}", rockConfig.Username));
            }
            catch (WebException wex)
            {
                HttpWebResponse response = wex.Response as HttpWebResponse;
                if (response != null)
                {
                    if (response.StatusCode == HttpStatusCode.Unauthorized)
                    {
                        // valid URL but invalid login, so navigate back to the LoginPage
                        rockConfig.RockBaseUrl = txtRockUrl.Text;
                        rockConfig.Save();
                        LoginPage loginPage = new LoginPage(true);
                        this.NavigationService.Navigate(loginPage);
                        return;
                    }
                }

                lblAlert.Content    = wex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }
            catch (Exception ex)
            {
                App.LogException(ex);
                lblAlert.Content    = ex.Message;
                lblAlert.Visibility = Visibility.Visible;
                return;
            }

            rockConfig.RockBaseUrl = txtRockUrl.Text;

            if (cboScannerInterfaceType.SelectedItem.Equals("MagTek"))
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.MICRImageRS232;
            }
            else
            {
                rockConfig.ScannerInterfaceType = RockConfig.InterfaceType.RangerApi;
            }

            string imageOption = cboImageOption.SelectedValue as string;

            rockConfig.Sensitivity = txtSensitivity.Text.Trim().AsInteger().ToString();
            rockConfig.Plurality   = txtPlurality.Text.Trim().AsInteger().ToString();

            switch (imageOption)
            {
            case "Grayscale":
                rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeGrayscale;
                break;

            case "Color":
                rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeColor;
                break;

            default:
                rockConfig.ImageColorType = RangerImageColorTypes.ImageColorTypeBitonal;
                break;
            }

            string comPortName = cboMagTekCommPort.SelectedItem as string;

            if (!string.IsNullOrWhiteSpace(comPortName))
            {
                rockConfig.MICRImageComPort = short.Parse(comPortName.Replace("COM", string.Empty));
            }

            rockConfig.Save();

            // shutdown the scanner so that options will be reloaded when the batch page loads
            if (BatchPage.rangerScanner != null)
            {
                BatchPage.rangerScanner.ShutDown();
            }

            BatchPage.ConnectToScanner();

            this.NavigationService.GoBack();
        }
예제 #4
0
 /// <summary>
 /// Shows the exception.
 /// </summary>
 /// <param name="ex">The ex.</param>
 public static void ShowException(Exception ex, Label lblExceptions)
 {
     App.LogException(ex);
     lblExceptions.Content    = "ERROR: " + ex.Message;
     lblExceptions.Visibility = Visibility.Visible;
 }