예제 #1
0
        public void SaveChanges() // Edit or Add Order data and save it to DB
        {
            string emailPattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";

            if (!String.IsNullOrEmpty(InputName) ||
                !String.IsNullOrEmpty(InputSurname) ||
                !String.IsNullOrEmpty(InputEmail) ||
                !String.IsNullOrEmpty(InputPhone))
            {
                if (InputPhone.Length < 11 || InputPhone.Any(Char.IsLetter) || !InputPhone.StartsWith("7"))
                {
                    string message         = "Phone must have 11 digits and start with 7.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else if (Regex.IsMatch(InputEmail, emailPattern) == false)
                {
                    string message         = "Incorrect email format.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else if (SelectedGender == Genders[0] || SelectedGender == null)
                {
                    string message         = "You need to select gender.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else
                {
                    if (_currentClient == null)
                    {
                        _currentClient = new Client()
                        {
                            Name      = InputName,
                            Surname   = InputSurname,
                            Phone     = InputPhone,
                            Email     = InputEmail,
                            Gender    = SelectedGender,
                            LastVisit = DateTime.Parse("01/01/01"),
                        };
                        context.Client.Add(_currentClient);
                    }
                    else
                    {
                        _currentClient.Name    = InputName;
                        _currentClient.Surname = InputSurname;
                        _currentClient.Phone   = InputPhone;
                        _currentClient.Email   = InputEmail;
                        _currentClient.Gender  = SelectedGender;
                    }
                    context.SaveChanges();
                }
            }
            else
            {
                string message         = "You need to complete all the fields.";
                var    exceptionWindow = new ExceptionWindow(message);
                exceptionWindow.ShowDialog();
            }
        }
예제 #2
0
        void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            ExceptionWindow exWin = new ExceptionWindow();

            exWin.SetException(e.ExceptionObject as Exception);
            exWin.ShowDialog();
        }
예제 #3
0
 void Button6_Activated(object sender, EventArgs e)
 {
     try
     {
         FileChooserDialog fileChooserDialog = new FileChooserDialog("Select project file", null, FileChooserAction.Open, new object[0]);
         fileChooserDialog.AddButton(Stock.Cancel, ResponseType.Cancel);
         fileChooserDialog.AddButton(Stock.Open, ResponseType.Ok);
         fileChooserDialog.DefaultResponse = ResponseType.Ok;
         fileChooserDialog.SelectMultiple  = false;
         FileFilter fileFilter = new FileFilter();
         fileFilter.AddMimeType("application/json");
         fileFilter.AddPattern("project.json");
         fileFilter.Name = "iCode project file (project.json)";
         fileChooserDialog.AddFilter(fileFilter);
         bool flag = fileChooserDialog.Run() == -5;
         if (flag)
         {
             ProjectManager.LoadProject(fileChooserDialog.Filename);
         }
         fileChooserDialog.Dispose();
     }
     catch (Exception ex)
     {
         ExceptionWindow.Create(ex, this).ShowAll();
     }
 }
예제 #4
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            ExceptionWindow exWin = new ExceptionWindow(e.Exception);

            exWin.ShowDialog();
            e.Handled = true;
        }
예제 #5
0
파일: FuseUI.cs 프로젝트: Earu/Fuse
        internal void ShowException(string msg)
        {
            this.PlayStream(Resources.Error);
            ExceptionWindow ewin = new ExceptionWindow(msg);

            ewin.ShowDialog();
        }
예제 #6
0
        /// <summary>
        /// Throw up an error message for any unhandled exceptions.
        /// </summary>
        /// <param name="sender">The sender</param>
        /// <param name="e">Unhandled Exception EventArgs </param>
        private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                ExceptionWindow window = new ExceptionWindow();

                if (e.ExceptionObject.GetType() == typeof(GeneralApplicationException))
                {
                    GeneralApplicationException applicationException = e.ExceptionObject as GeneralApplicationException;
                    if (applicationException != null)
                    {
                        window.Setup(
                            applicationException.Error + Environment.NewLine + applicationException.Solution,
                            e.ExceptionObject + "\n\n ---- \n\n" + applicationException.ActualException);
                    }
                }
                else
                {
                    window.Setup("An Unknown Error has occured.", e.ExceptionObject.ToString());
                }
                window.ShowDialog();
            }
            catch (Exception)
            {
                MessageBox.Show(
                    "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,
                    "Unhandled Exception",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
예제 #7
0
        private static void ShowUnhandledException(object exceptionObject)
        {
            Logger.logError("Exception: " + exceptionObject.ToString());
            string errorText  = "";
            string stackTrace = "";

            if (exceptionObject is Exception)
            {
                errorText  = (exceptionObject as Exception).Message;
                stackTrace = "\r\n" + (exceptionObject as Exception).GetType().Name + "\r\n" +
                             (exceptionObject as Exception).StackTrace;
            }
            else
            {
                stackTrace = exceptionObject.ToString();
                string[] lines = stackTrace.Split(new char[] { '\n' });
                if (lines != null && lines.Length > 0)
                {
                    errorText = lines[0];
                }
            }
            ExceptionWindow win = new ExceptionWindow(errorText, stackTrace);

            win.ShowDialog();
        }
예제 #8
0
        private void Button_StepClick(object sender, RoutedEventArgs e)
        {
            enableCheckboxes(false, false, false);
            enableButtons(false, false, false);
            lockRecordCreationTools();
            Label_StatusBarLabel.Content = "Busy...";
            try
            {
                Sorter.Merger.Step();
            }
            catch (Exception ex)
            {
                var ExWin = new ExceptionWindow(ex.GetType().ToString(), ex.Message, ex.StackTrace);
                ExWin.ShowDialog();
            }

            string infoText = "Step. ";

            if (Sorter.Merger.FileIsSorted)
            {
                infoText = "Done! ";
                lockRecordCreationTools(false);
                Sorter.RestoreOriginalFileName();
            }
            Label_StatusBarLabel.Content = buildAccessInfoString(infoText);
            tryToDisplayTextIn(TextBlock_SortedFile);
            enableButtons(true, true, true);
        }
예제 #9
0
        private void ShowMessage(Exception exception)
        {
            if (this.prevException?.TargetSite == exception?.TargetSite)
            {
                return;
            }

            this.prevException = exception;
            ThreadPool.QueueUserWorkItem(item =>
            {
                UIDispatcher.Invoke(() =>
                {
                    var exceptionWindow = new ExceptionWindow
                    {
                        AllowsTransparency    = true,
                        WindowStyle           = WindowStyle.None,
                        Exception             = exception,
                        WindowStartupLocation = WindowStartupLocation.CenterOwner
                    };

                    if (Application.Current.MainWindow != exceptionWindow)
                    {
                        exceptionWindow.Owner = Application.Current.MainWindow;
                    }

                    exceptionWindow.ShowDialog();
                });

                this.prevException = null;
            });
        }
예제 #10
0
        /// <summary>
        /// Show the Exception Window
        /// </summary>
        /// <param name="shortError">
        /// The short error.
        /// </param>
        /// <param name="longError">
        /// The long error.
        /// </param>
        public static void ShowExceptiowWindow(string shortError, string longError)
        {
            ExceptionWindow window = new ExceptionWindow();

            window.Setup(shortError, longError);
            window.ShowDialog();
        }
예제 #11
0
        public static void HandleException(Window owner, Exception ex)
        {
            ExceptionWindow win = new ExceptionWindow();

            win.Exception = ex;
            win.Owner     = owner;
            win.ShowDialog();
        }
 /// <summary>
 /// This method opens a new ExceptionWindow with the
 /// passed exception object as datacontext.
 /// </summary>
 public override void OnUnhandledException(Exception e)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         var exceptionWindow         = new ExceptionWindow();
         exceptionWindow.DataContext = new ExceptionWindowVM(e);
         exceptionWindow.Show();
     }));
 }
예제 #13
0
 /// <summary>
 /// This method opens a new ExceptionWindow with the
 /// passed exception object as datacontext.
 /// </summary>
 public override void OnUnhandledException(Exception e, bool terminate)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         var exceptionWindow         = new ExceptionWindow();
         exceptionWindow.DataContext = new ExceptionWindowViewModel(e, terminate);
         exceptionWindow.ShowDialog();
     }));
 }
예제 #14
0
 public void Launch()
 {
     var exception = GetException();
     var model = new ExceptionWindowModel
         {
             ExceptionText = exception.ExceptionHierarchyToString(),
         };
     var window = new ExceptionWindow(model);
     window.ShowDialog();
 }
예제 #15
0
        public static void DefaultErrHandling(Exception exc)
        {
#if DEBUG
            throw exc;
#else
            ExceptionWindow wnd = new ExceptionWindow();
            wnd.excText.Text = exc.ToString();
            wnd.ShowDialog();
#endif
        }
예제 #16
0
        /// <summary>
        /// Shows exception and exit application
        /// </summary>
        /// <param name="exception">The exception.</param>
        public static void ShowAndExitApplication(this Exception exception)
        {
            ExceptionWindow showExceptionWindow = new ExceptionWindow
            {
                DataContext = new ExceptionViewModel(Resources.UnhandledException, Resources.UnhandledExceptionOccurredApplicationWillBeClosed, exception)
            };

            showExceptionWindow.ShowDialog();
            Environment.Exit(-1);
        }
예제 #17
0
        public bool ShowException(Exception exception)
        {
            LastException = exception;
            WriteLog();
            ExceptionWindow = new ExceptionWindow();
            ExceptionWindow.SetException(LastException);
            var showDialog = ExceptionWindow.ShowDialog();

            return(showDialog != null && (bool)showDialog);
        }
예제 #18
0
        private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            var errorWindow = new ExceptionWindow
            {
                Owner      = Current.MainWindow,
                Message    = e.Exception.Message,
                StackTrace = e.Exception.StackTrace
            };

            errorWindow.ShowDialog();
        }
예제 #19
0
 private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     if (!ShowingException)  //In case an exception causes a cascade of accompanying exceptions in other threads (shouldn't happen), only allow the first one to show
     {
         ShowingException = true;
         ExceptionWindow exceptionWindow = new ExceptionWindow(e);
         exceptionWindow.ShowDialog();
         wnd.Close();
         Current.Shutdown();
     }
 }
예제 #20
0
    public void Launch()
    {
        var exception = GetException();
        var model     = new ExceptionWindowModel
        {
            ExceptionText = exception.ExceptionHierarchyToString(),
        };
        var window = new ExceptionWindow(model);

        window.ShowDialog();
    }
예제 #21
0
 /// <summary>
 /// This method opens a new ExceptionWindow with the
 /// passed exception object as datacontext.
 /// </summary>
 public override void OnUnhandledException(Exception ex, bool terminate)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         var exceptionWindow = new ExceptionWindow();
         var logService      = ((App)App.Current).GetLogService();
         var vm                      = new ExceptionWindowViewModel(logService, ex, terminate);
         vm.OnRequestClose          += (s, e) => exceptionWindow.Close();
         exceptionWindow.DataContext = vm;
         exceptionWindow.ShowDialog(App.Current.MainWindow);
     }));
 }
 public void HandleException(Exception exception)
 {
     var model = new ExceptionWindowModel
                     {
                         ExceptionText = exception.ExceptionHierarchyToString(),
                     };
     var window = new ExceptionWindow(model);
     new WindowInteropHelper(window)
         {
             Owner = GetActiveWindow()
         };
     window.ShowDialog();
 }
예제 #23
0
파일: App.xaml.cs 프로젝트: teize001/Crema
        private void SendMail(Exception e)
        {
            var window = new ExceptionWindow(e)
            {
                Title       = "Crema Server App",
                MailAddress = "*****@*****.**",
                UserName    = "******",
                Password    = "******",
            };

            window.ShowDialog();
            Environment.Exit(-1);
        }
예제 #24
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
#if !DEBUG
            SentrySdk.CaptureException(e.Exception);
#endif
            var exceptionWindow = new ExceptionWindow(e.Exception, true);
            var val             = exceptionWindow.ShowDialog();
            e.Handled = val != true;
            if (val == true)
            {
                Environment.Exit(1);
            }
        }
    public void HandleException(Exception exception)
    {
        var model = new ExceptionWindowModel
        {
            ExceptionText = exception.ExceptionHierarchyToString(),
        };
        var window = new ExceptionWindow(model);

        new WindowInteropHelper(window)
        {
            Owner = GetActiveWindow()
        };
        window.ShowDialog();
    }
 public void Launch()
 {
     var exception = GetException();
     var model = new ExceptionWindowModel
                                    {
                                        ExceptionText = exception.ExceptionHierarchyToString(),
                                    };
     var runner = new CrossThreadRunner();
     runner.RunInSta(() =>
                         {
                             var window = new ExceptionWindow(model);
                             window.ShowDialog();
                         });
 }
예제 #27
0
        public static void HandleException(Exception e)
        {
            if (e is SQLiteException)
            {
                if (e.Message.Contains("constraint"))
                {
                    return;
                }
            }

            ExceptionWindow window = new ExceptionWindow(e);

            window.ShowDialog();
        }
예제 #28
0
 public void SaveChanges()
 {
     if (!String.IsNullOrEmpty(InputName) ||
         !String.IsNullOrEmpty(InputSurname) ||
         !String.IsNullOrEmpty(SelectedDate.ToString()))
     {
         if (SelectedGender == Genders[0] || SelectedGender == null)
         {
             string message         = "You need to select gender.";
             var    exceptionWindow = new ExceptionWindow(message);
             exceptionWindow.ShowDialog();
         }
         else if (SelectedRole == Roles[0] || SelectedRole == null)
         {
             string message         = "You need to select role.";
             var    exceptionWindow = new ExceptionWindow(message);
             exceptionWindow.ShowDialog();
         }
         else
         {
             if (_currentEmployee == null)
             {
                 _currentEmployee = new Employee()
                 {
                     Name             = InputName,
                     Surname          = InputSurname,
                     Gender           = SelectedGender,
                     Role             = SelectedRole,
                     DateOfEmployment = SelectedDate
                 };
             }
             else
             {
                 _currentEmployee.Name             = InputName;
                 _currentEmployee.Surname          = InputSurname;
                 _currentEmployee.Gender           = SelectedGender;
                 _currentEmployee.Role             = SelectedRole;
                 _currentEmployee.DateOfEmployment = SelectedDate;
             }
             context.SaveChanges();
         }
     }
     else
     {
         string message         = "You need to complete all the fields.";
         var    exceptionWindow = new ExceptionWindow(message);
         exceptionWindow.ShowDialog();
     }
 }
예제 #29
0
    public void Launch()
    {
        var exception = GetException();
        var model     = new ExceptionWindowModel
        {
            ExceptionText = exception.ExceptionHierarchyToString(),
        };
        var runner = new CrossThreadRunner();

        runner.RunInSta(() =>
        {
            var window = new ExceptionWindow(model);
            window.ShowDialog();
        });
    }
예제 #30
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            var logger = LogManager.GetCurrentClassLogger();

            logger.Error(e.Exception, "DispatcherUnhandledException");

            var exceptionWindow = new ExceptionWindow(e.Exception, true);
            var val             = exceptionWindow.ShowDialog();

            e.Handled = val != true;
            if (val == true)
            {
                Environment.Exit(1);
            }
        }
예제 #31
0
        public static void Add(this Notebook notebook, Widget widget, string str, bool isVolatile)
        {
            try
            {
                widget.Name = str;
                Extensions.Tabs.Add(str, widget);

                ScrolledWindow scrolledWindow = new ScrolledWindow();
                scrolledWindow.Add(widget);
                scrolledWindow.Name = str;
                if (widget is CodeTabWidget tabWidget)
                {
                    notebook.AppendPage(scrolledWindow, (tabWidget.GetLabel()));

                    tabWidget.GetLabel().ShowAll();
                    tabWidget.GetLabel().CloseClicked += delegate
                    {
                        notebook.RemovePage(notebook.PageNum(notebook.Children.First(x => x == scrolledWindow)));
                        Extensions.Tabs.Remove(str);
                    };
                }
                else
                {
                    NotebookTabLabel notebookTabLabel = new NotebookTabLabel(str, widget);

                    notebookTabLabel.CloseClicked += delegate(object obj, EventArgs eventArgs)
                    {
                        notebook.RemovePage(notebook.PageNum(notebook.Children.First(x => x == scrolledWindow)));
                        Extensions.Tabs.Remove(str);
                    };
                    notebook.AppendPage(scrolledWindow, notebookTabLabel);
                    notebookTabLabel.ShowAll();
                }

                notebook.SetTabDetachable(scrolledWindow, isVolatile);
                notebook.SetTabReorderable(scrolledWindow, isVolatile);

                widget.ShowAll();
            }
            catch (ArgumentException)
            {
                notebook.Page = notebook.PageNum(Tabs.First(x => x.Key == str).Value);
            }
            catch (Exception e)
            {
                ExceptionWindow.Create(e, notebook).ShowAll();
            }
        }
예제 #32
0
 public bool Open()
 {
     if (SelectedEmployee != null && SelectedEmployee != Employees[0])
     {
         StartWindow startWindow = new StartWindow(SelectedEmployee);
         startWindow.Show();
         return(true);
     }
     else
     {
         string message         = "You need to select employee account.";
         var    exceptionWindow = new ExceptionWindow(message);
         exceptionWindow.ShowDialog();
         return(false);
     }
 }
예제 #33
0
        public void ShowException(Exception Exception, string Message, bool Blocking = false)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                var win = new ExceptionWindow(Exception, Message);

                if (Blocking)
                {
                    win.ShowDialog();
                }
                else
                {
                    win.ShowAndFocus();
                }
            });
        }
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     ExceptionWindow exWin = new ExceptionWindow();
     exWin.SetException(e.ExceptionObject as Exception);
     exWin.ShowDialog();
 }