Exemplo n.º 1
0
        public static void OnThreadException(object sender, ThreadExceptionEventArgs e)
        {
            Debug.Assert(e != null);
            Debug.Assert(e.Exception != null);
            Debug.Assert(e.Exception.Message != null);

            Exception ex = e.Exception;

            if (Global.Instance.ExitSignal && ex is ObjectDisposedException)
            {
                return;
            }

#if DEBUGGER
            Trace.WriteLine(ex, Strings.VRPINT);
#endif
            new Action <Exception>((ee) => ServiceDataAccess.Instance.LogOperation(OperationHistory.Error, Program.SessionId, Program.currentUser.CountryID, 0, 0, 0, 0, ee.ToString())).FireAndForgetSafe(ex);
            Speeker.SpeakAsynchSf(ex.Message);
#if !USE_LOGGER
            FileLogger.LogError(ex, Strings.VRPINT);
#endif

            FileInfoApplicationException ex2 = e.Exception as FileInfoApplicationException;
            if (ex2 != null)
            {
                MainForm.Default.InvokeSf(() => { FileMsgForm.show(MainForm.Default, "Error", ex2.Message, ex2.Info); });
            }
            else
            {
                MainForm.Default.InvokeSf(() => ex.ShowDialog(MainForm.Default));
            }
        }
Exemplo n.º 2
0
        private void TryLogin()
        {
            CountryDetail country = (CountryDetail)cbCountryID.SelectedItem;

            if (country == null)
            {
                this.ShowExclamation("Please select country first.");
            }
            else
            {
                Program.IsAdmin = (string.Compare(textBoxUsername.Text, "rosen") == 0) &&
                                  (string.Compare(textBoxPassword.Text, "rosen") == 0);
                int countryId = country.Number;

                if (Program.IsAdmin)
                {
                    SaveCurrentUser(0, countryId, false);
                }
                else
                {
                    var auth = new Authentication.Authentication();

                    string result = auth.AuthenticateUser(countryId, textBoxUsername.Text, textBoxPassword.Text);

                    if (!string.IsNullOrEmpty(result))
                    {
                        var userId = auth.RetrieveUser(countryId, textBoxUsername.Text);
                        SaveCurrentUser(userId, countryId, false);
                    }
                    else
                    {
                        var  security = new Security();
                        bool result2  = security.DomainValidate("fintrax", textBoxUsername.Text, textBoxPassword.Text);
                        if (result2)
                        {
                            SaveCurrentUser(-100, countryId, true);
                        }
                        else
                        {
                            Speeker.SpeakAsynchSf("Invalid user id or password, please try again.");
                            this.ShowExclamation("Invalid user id or password, please try again.");
                            textBoxPassword.Text = "";
                            textBoxPassword.Focus();
                        }
                    }
                }
            }
        }