Exemplo n.º 1
0
        public ErrorDialog(ErrorDialogViewModel vm)
        {
            DataContext    = vm;
            vm.CloseAction = () => Close();

            InitializeComponent();
        }
        private void ShowError(string messageId, string message)
        {
            messageId = messageId.Replace(Environment.NewLine, string.Empty);// remove newlines to ease persistence

            if (!m_suppressedMessages.Contains(messageId))
            {
                // If this is called from another thread we will not be able to access
                // Application.Current.MainWindow so invoke back to UI thread
                Application.Current.Dispatcher.BeginInvokeIfRequired(() =>
                {
                    if (Application.Current.MainWindow != null &&
                        Application.Current.MainWindow.IsLoaded)
                    {
                        var dlg = new ErrorDialog();

                        var vm          = new ErrorDialogViewModel();
                        vm.Message      = message;
                        dlg.DataContext = vm;
                        dlg.Owner       = Application.Current.MainWindow;
                        dlg.ShowDialog();

                        if (vm.SuppressMessage)
                        {
                            m_suppressedMessages.Add(messageId);
                        }
                    }
                });
            }
        }
        private void QualityControl()
        {
            Project = Application.Current.Properties["SelectedProject"] as Project;

            if (Project == null || !"1".Equals(Project.Type))
            {
                MessageBox.Show("请选择楼盘项目", "提示");
                return;
            }
            var view = new TaskInfoDialog();
            TaskInfoDialogViewModel TaskInfoDialog = TaskInfoDialogViewModel.getInstance();
            var result = DialogHost.Show(view, "RootDialog");

            QualityControlTask task = new QualityControlTask();

            try
            {
                task.Project = Project;
                task.Ongo();
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
        /// <summary>
        /// 修改申请人
        /// </summary>
        private void EditApplicant()
        {
            if (Applicant == null)
            {
                MessageBox.Show("请选择申请人", "提示");
                return;
            }
            if (!canExecute())
            {
                MessageBox.Show("验证失败", "提示");
                return;
            }
            try
            {
                Applicant.UpdateTime = DateTime.Now;
                ApplicantDal.Modify(Applicant);

                // 重新加载页面
                OnNavigatedTo(NavigationContext);
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
        /// <summary>
        /// 新增申请人
        /// </summary>
        private void AddApplicant()
        {
            if (Project == null)
            {
                MessageBox.Show("请选择项目", "提示");
                return;
            }
            if (!canExecute())
            {
                MessageBox.Show("验证失败", "提示");
                return;
            }
            try
            {
                Applicant.ProjectID  = Project.ID;
                Applicant.ID         = Guid.NewGuid();
                Applicant.UpdateTime = DateTime.Now;
                ApplicantDal.Add(Applicant);

                Applicant = null;
                // 重新加载页面
                OnNavigatedTo(NavigationContext);
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="navigationContext"></param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            NavigationContext = navigationContext;
            try
            {
                // 获取选中项目
                Project project = navigationContext.Parameters["Project"] as Project;
                if (project != null)
                {
                    Project = project;
                }
                // 初始化登记项目
                //Project = ProjectDal.InitialRegistrationProject(Project);
                // 获取申请人集合
                Applicants = new ObservableCollection <Applicant>(Project.Applicants);

                // 初始申请人与转移信息
                Applicant = new Applicant();
                Transfer  = Project.Transfer;
                // 按钮为新增状态
                ApplicantButtonContent = "确认新增";
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
Exemplo n.º 7
0
        public bool?ShowDialog(object datacontext)
        {
            ErrorDialogViewModel model = datacontext as ErrorDialogViewModel;

            MessageBox.Show(model.Message, model.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            return(true);
        }
        /// <summary>
        /// 点击按钮,确认/取消
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ConfirSaveServerHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if ("False".Equals(eventArgs.Parameter.ToString()))
            {
                return;
            }
            // cancel the close
            eventArgs.Cancel();

            var    IPTextBox = eventArgs.Parameter as System.Windows.Controls.TextBox;
            String ServerIP  = IPTextBox.Text;

            try
            {
                //string cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;
                //IniFileHelper ini = new IniFileHelper(cfgINI);
                //ini.IniWriteValue("OAUS", "UpdateIP", UpdateIP);
                //ini.IniWriteValue("OAUS", "UpdatePort", "4540");
                ConfigUtil.SaveConfig("ServerIP", ServerIP);

                // 显示加载1s
                eventArgs.Session.UpdateContent(new SampleProgressDialog());
                Task.Delay(TimeSpan.FromSeconds(0.3))
                .ContinueWith((t, _) => eventArgs.Session.Close(false), null,
                              TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().updateShow(ex, eventArgs.Session);
                return;
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Task线程内未捕获异常处理事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     //task线程内未处理捕获
     //MessageBox.Show("捕获线程内未处理异常:" + e.Exception.Message);
     ErrorDialogViewModel.getInstance().show("捕获线程内未处理异常:" + e.Exception.Message, e.Exception.StackTrace);
     e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃)
 }
        public ImportRealEstateDialogViewModel()
        {
            ChooseFileCommand = new DelegateCommand(() => {
                var openFileDialog = new Microsoft.Win32.OpenFileDialog()
                {
                    Filter = "Excel Files (*.xls,*.xlsx)|*.xls;*.xlsx"
                };
                var result = openFileDialog.ShowDialog();
                if (result == true)
                {
                    FilePath = openFileDialog.FileName;
                }
            });

            ImportRealEstateCommand = new DelegateCommand(() => {
                //FinishInteraction?.Invoke();

                ImportRealEstateTask task = new ImportRealEstateTask();
                try
                {
                    task.FullPath = FilePath;
                    task.Ongo();
                }
                catch (Exception ex)
                {
                    ErrorDialogViewModel.getInstance().show(ex);
                    return;
                }
            });
        }
        private void DelBusiness()
        {
            try
            {
                switch (NavigatePath)
                {
                case ERealEstatePage.NaturalBuildingPage:
                    NaturalBuilding    naturalBuilding    = Business.NaturalBuilding;
                    NaturalBuildingDal naturalBuildingDal = new NaturalBuildingDal();
                    naturalBuildingDal.Del(naturalBuilding);
                    break;

                case ERealEstatePage.LogicalBuildingPage:
                    LogicalBuilding    logicalBuilding    = Business.LogicalBuilding;
                    LogicalBuildingDal logicalBuildingDal = new LogicalBuildingDal();
                    logicalBuildingDal.Del(logicalBuilding);
                    break;

                case ERealEstatePage.FloorPage:
                    Floor    floor    = Business.Floor;
                    FloorDal floorDal = new FloorDal();
                    floorDal.Del(floor);
                    break;

                case ERealEstatePage.HouseholdPage:
                    Household    household    = Business.Household;
                    HouseholdDal householdDal = new HouseholdDal();
                    householdDal.Del(household);
                    break;

                case ERealEstatePage.ObligeePage:
                    Obligee    obligee    = Business.Obligee;
                    ObligeeDal obligeeDal = new ObligeeDal();
                    obligeeDal.Del(obligee);
                    break;

                case ERealEstatePage.MortgagePage:
                    Mortgage    mortgage    = Business.Mortgage;
                    MortgageDal mortgageDal = new MortgageDal();
                    mortgageDal.Del(mortgage);
                    break;

                case ERealEstatePage.SequestrationPage:
                    Sequestration    sequestration    = Business.Sequestration;
                    SequestrationDal sequestrationDal = new SequestrationDal();
                    sequestrationDal.Del(sequestration);
                    break;

                default:
                    break;
                }
                BusinessNavCommand.Execute(NavigatePath);
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
Exemplo n.º 12
0
        public void ShowError(Exception ex, string message = null)
        {
            AppHealth.Current.Exception.TrackAsync(ex, message).FireAndForget();

            var vm    = new ErrorDialogViewModel(ex);
            var error = new Views.Common.ErrorDialog(vm);

            GenContext.ToolBox.Shell.UI.ShowModal(error);
        }
Exemplo n.º 13
0
        public void GivenException_WhenInstantiateErrorVm_ThenItFormatsMessageProperly()
        {
            const string exMessage = "@#$%^&111133_7645";
            Exception    ex        = new Exception(exMessage);

            ErrorDialogViewModel erroVmSubject = new ErrorDialogViewModel(ex);

            Assert.Equal(exMessage + "\n\n" + $"StackTrace: {ex.StackTrace}", erroVmSubject.ErrorMessage);
        }
        private void ShowCantDeleteErrorDialog()
        {
            ErrorDialog          errorDialog          = new ErrorDialog();
            ErrorDialogViewModel errorDialogViewModel = (ErrorDialogViewModel)errorDialog.DataContext;

            errorDialog.Title = "Greška";
            errorDialogViewModel.ErrorMessage = "Nije dozvoljeno obrisati radno mesto koje sadrži radnike.";
            errorDialog.ShowDialog();
        }
        private void ShowNotSelectedErrorDialog(bool isDelete)
        {
            ErrorDialog          errorDialog          = new ErrorDialog();
            ErrorDialogViewModel errorDialogViewModel = (ErrorDialogViewModel)errorDialog.DataContext;

            errorDialog.Title = "Greška";
            errorDialogViewModel.ErrorMessage = isDelete ? "Niste selektovali red koji želite da obrišete. Pokušajte ponovo." : "Niste selektovali red koji želite da izmenite. Pokušajte ponovo.";
            errorDialog.ShowDialog();
        }
Exemplo n.º 16
0
        public static bool?ShowErrorDialog(this IDialogService dialogService, BaseViewModel parentViewModel, string errorTitle, string errorInformation, bool canContinue)
        {
            var model = new ErrorDialogModel();

            model.Load(errorTitle, errorInformation, canContinue);
            var loadVm = new ErrorDialogViewModel(parentViewModel, model);

            return(dialogService.ShowDialog <WindowErrorDialog>(parentViewModel, loadVm));
        }
Exemplo n.º 17
0
        internal void ShowError(Exception ex, UserSelection userSelection = null)
        {
            AppHealth.Current.Error.TrackAsync(ex.ToString()).FireAndForget();
            AppHealth.Current.Exception.TrackAsync(ex, userSelection?.ToString()).FireAndForget();

            var vm    = new ErrorDialogViewModel(ex);
            var error = new Views.Common.ErrorDialog(vm);

            GenContext.ToolBox.Shell.ShowModal(error);
        }
Exemplo n.º 18
0
        private void ShowErrorDialog(string message)
        {
            ErrorDialog          errorDialog          = new ErrorDialog();
            ErrorDialogViewModel errorDialogViewModel = (ErrorDialogViewModel)errorDialog.DataContext;

            errorDialog.Title = "Error";
            errorDialogViewModel.ErrorMessage = message;
            errorDialog.ShowDialog();
            Email    = string.Empty;
            Password = string.Empty;
        }
Exemplo n.º 19
0
        private async Task <bool> ShouldPopulate()
        {
            var populate          = true;
            var diagnosticsResult = SubsonicService.Ping();
            await diagnosticsResult.Execute();

            if (diagnosticsResult.Error != null)
            {
                populate = false;
                ErrorDialogViewModel.HandleError(diagnosticsResult.Error);
            }

            return(populate);
        }
Exemplo n.º 20
0
 /// <summary>
 /// UI线程未捕获异常处理事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
 {
     try
     {
         e.Handled = true; //把 Handled 属性设为true,表示此异常已处理,程序可以继续运行,不会强制退出
         //MessageBox.Show("捕获未处理异常:" + e.Exception.Message);
         ErrorDialogViewModel.getInstance().show("捕获未处理异常:" + e.Exception.Message, e.Exception.StackTrace);
     }
     catch (Exception)
     {
         //此时程序出现严重异常,将强制结束退出
         MessageBox.Show("程序发生致命错误,将终止,请联系管理员!");
     }
 }
Exemplo n.º 21
0
 public void Setup()
 {
     _mockWinRTWrapperService       = new MockWinRTWrappersService();
     _mockNavigationService         = new MockNavigationService();
     _mockDialogNotificationService = new MockDialogNotificationService();
     _mockResourceService           = new MockResourceService();
     _mockDialogService             = new MockDialogService();
     _subject = new ErrorDialogViewModel(
         _mockWinRTWrapperService,
         _mockNavigationService,
         _mockDialogNotificationService,
         _mockResourceService,
         _mockDialogService);
 }
 /// <summary>
 /// 打开服务器IP设置框
 /// </summary>
 private async void ExecuteServerDialog()
 {
     try
     {
         var view = new ServerDialog();
         ServerDialogViewModel = new ServerDialogViewModel();
         //show the dialog
         await DialogHost.Show(view, "RootDialog", ConfirSaveServerHandler);
     }
     catch (Exception ex)
     {
         ErrorDialogViewModel.getInstance().show(ex);
         return;
     }
 }
Exemplo n.º 23
0
 private void DelFile(object obj)
 {
     try
     {
         DataGrid dataGrid = obj as DataGrid;
         FileInfo = dataGrid.SelectedItem as FileInfo;
         FileHelper.DelFile(fileInfo);
         FileInfoList.Remove(FileInfo);
     }
     catch (Exception ex)
     {
         ErrorDialogViewModel.getInstance().show(ex);
         return;
     }
 }
        /// <summary>
        /// 编辑用户
        /// </summary>
        private void EditUser()
        {
            try
            {
                user.Password = CEncoder.Encode(user.Password);
                UserInfoDal.Modify(user);
                App.Current.Properties["User"] = user;

                IsPopupOpen = false;
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
            }

        }
        private void ConfirAddOrEditProjectEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if ((bool)eventArgs.Parameter == false)
            {
                return;
            }

            //cancel the close...
            eventArgs.Cancel();

            DialogTitle = AddOrEditProjectDialog.DialogTitle;
            Project     = AddOrEditProjectDialog.Project;

            try
            {
                bool IsSuccess = false;
                switch (DialogTitle)
                {
                case "新增项目":
                    IsSuccess = AddProject();
                    break;

                case "编辑项目":
                    IsSuccess = UpdProject();
                    break;

                default:
                    break;
                }
                if (IsSuccess)
                {
                    // 显示加载1s
                    eventArgs.Session.UpdateContent(new SampleProgressDialog());
                    Task.Delay(TimeSpan.FromSeconds(0.3))
                    .ContinueWith((t, _) => eventArgs.Session.Close(false), null,
                                  TaskScheduler.FromCurrentSynchronizationContext());
                }
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().updateShow(ex, eventArgs.Session);
                return;
            }

            ToggleOwnershipTypeCommand = new DelegateCommand(ToggleOwnershipType);
            ToggleMappingTypeCommand   = new DelegateCommand(ToggleMappingType);
        }
        /// <summary>
        /// 选择申请人列表中的一项
        /// </summary>
        /// <param name="obj"></param>
        private void SelectApplicant(object obj)
        {
            try
            {
                // 加载申请人数据
                ListView listView = obj as ListView;
                Applicant = listView.SelectedItem as Applicant;

                // 按钮为修改状态
                ApplicantButtonContent = "确认修改";
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }
        }
        /// <summary>
        /// 删除项目
        /// </summary>
        private void DelProject()
        {
            if (Project == null)
            {
                MessageBox.Show("请选择一个项目", "提示");
                return;
            }
            try
            {
                if ("1".Equals(Project.Type)) // 楼盘表项目
                {
                    NaturalBuildingDal naturalBuildingDal = new NaturalBuildingDal();
                    LogicalBuildingDal logicalBuildingDal = new LogicalBuildingDal();
                    FloorDal           floorDal           = new FloorDal();
                    HouseholdDal       householdDal       = new HouseholdDal();
                    ObligeeDal         obligeeDal         = new ObligeeDal();
                    MortgageDal        mortgageDal        = new MortgageDal();
                    SequestrationDal   sequestrationDal   = new SequestrationDal();

                    naturalBuildingDal.DelBy(t => t.ProjectID == Project.ID);
                    logicalBuildingDal.DelBy(t => t.ProjectID == Project.ID);
                    floorDal.DelBy(t => t.ProjectID == Project.ID);
                    householdDal.DelBy(t => t.ProjectID == Project.ID);
                    obligeeDal.DelBy(t => t.ProjectID == Project.ID);
                    mortgageDal.DelBy(t => t.ProjectID == Project.ID);
                    sequestrationDal.DelBy(t => t.ProjectID == Project.ID);
                }
                else if ("2".Equals(Project.Type)) // 登记业务项目
                {
                    TransferDal  transferDal  = new TransferDal();
                    ApplicantDal applicantDal = new ApplicantDal();

                    transferDal.DelBy(t => t.ProjectID == Project.ID);
                    applicantDal.DelBy(t => t.ProjectID == Project.ID);
                    FileHelper.DelDir(Project);
                }
                projectDal.Del(Project);
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
                return;
            }

            RefreshProjectList();
        }
Exemplo n.º 28
0
        public override async Task Populate()
        {
            ErrorDialogViewModel.Hide();
            if (SubsonicService.HasValidSubsonicUrl)
            {
                if (await ShouldPopulate())
                {
                    await base.Populate();
                }
            }
            else
            {
                await ShowSettingsNotFoundDialog();

                DialogService.ShowSettings <SettingsViewModel>();
            }
        }
Exemplo n.º 29
0
 public void EditTableAOP()
 {
     if (!canExecute())
     {
         MessageBox.Show("验证失败", "提示");
         return;
     }
     try
     {
         EditTable();
     }
     catch (Exception ex)
     {
         ErrorDialogViewModel.getInstance().show(ex);
         return;
     }
 }
        public UserInfoPageViewModel(IRegionManager regionManager)
        {
            RegionManager = regionManager;

            try
            {
                user = (UserInfo)App.Current.Properties["User"];
                user.Password = CEncoder.Decode(user.Password);
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
            }

            EditUserCommand = new DelegateCommand(EditUser);

            LogoutCommand = new DelegateCommand(Logout);
        }