コード例 #1
0
        public ErrorDialog(ErrorDialogViewModel vm)
        {
            DataContext    = vm;
            vm.CloseAction = () => Close();

            InitializeComponent();
        }
コード例 #2
0
        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);
                        }
                    }
                });
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        /// <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;
            }
        }
コード例 #5
0
        /// <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;
            }
        }
コード例 #6
0
        /// <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;
            }
        }
コード例 #7
0
        public bool?ShowDialog(object datacontext)
        {
            ErrorDialogViewModel model = datacontext as ErrorDialogViewModel;

            MessageBox.Show(model.Message, model.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            return(true);
        }
コード例 #8
0
        /// <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;
            }
        }
コード例 #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();//设置该异常已察觉(这样处理后就不会引起程序崩溃)
 }
コード例 #10
0
        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;
                }
            });
        }
コード例 #11
0
        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;
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        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();
        }
コード例 #16
0
ファイル: DialogExtensions.cs プロジェクト: wriley/SEToolbox
        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));
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #19
0
ファイル: MainViewModel.cs プロジェクト: mavenius/SubSonic8
        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);
        }
コード例 #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("程序发生致命错误,将终止,请联系管理员!");
     }
 }
コード例 #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);
 }
コード例 #22
0
 /// <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;
     }
 }
コード例 #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;
     }
 }
コード例 #24
0
        /// <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);
            }

        }
コード例 #25
0
        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);
        }
コード例 #26
0
        /// <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;
            }
        }
コード例 #27
0
        /// <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();
        }
コード例 #28
0
ファイル: MainViewModel.cs プロジェクト: mavenius/SubSonic8
        public override async Task Populate()
        {
            ErrorDialogViewModel.Hide();
            if (SubsonicService.HasValidSubsonicUrl)
            {
                if (await ShouldPopulate())
                {
                    await base.Populate();
                }
            }
            else
            {
                await ShowSettingsNotFoundDialog();

                DialogService.ShowSettings <SettingsViewModel>();
            }
        }
コード例 #29
0
 public void EditTableAOP()
 {
     if (!canExecute())
     {
         MessageBox.Show("验证失败", "提示");
         return;
     }
     try
     {
         EditTable();
     }
     catch (Exception ex)
     {
         ErrorDialogViewModel.getInstance().show(ex);
         return;
     }
 }
コード例 #30
0
        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);
        }