private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            IContainerProvider   myContainer          = (App.Current as PrismApplication).Container;
            AppExceptionsService appExceptionsService = myContainer
                                                        .Resolve <AppExceptionsService>();
            AppStatus appStatus = myContainer
                                  .Resolve <AppStatus>();

            Task.Run(async() =>
            {
                await appExceptionsService.ReadFromFileAsync();
                ExceptionRecordDto fooObject = new ExceptionRecordDto()
                {
                    CallStack     = (e.ExceptionObject as Exception).StackTrace,
                    ExceptionTime = DateTime.Now,
                    Message       = (e.ExceptionObject as Exception).Message,
                    DeviceModel   = DeviceInfo.Model,
                    DeviceName    = DeviceInfo.Name,
                    OSType        = DeviceInfo.Platform.ToString(),
                    OSVersion     = DeviceInfo.Version.ToString(),
                };
                if (appStatus.SystemStatus.UserID <= 0)
                {
                    fooObject.MyUserId = null;
                }
                else
                {
                    fooObject.MyUserId = appStatus.SystemStatus.UserID;
                }
                appExceptionsService.Items.Add(fooObject);
                await appExceptionsService.WriteToFileAsync();
            }).Wait();
        }
Esempio n. 2
0
 public LogoutCleanHelper(IPageDialogService dialogService,
                          SystemEnvironmentsService systemEnvironmentsService,
                          SystemStatusService systemStatusService, AppStatus appStatus, RefreshTokenService refreshTokenService,
                          ExceptionRecordsService exceptionRecordsService, AppExceptionsService appExceptionsService)
 {
     this.dialogService             = dialogService;
     this.systemEnvironmentsService = systemEnvironmentsService;
     this.systemStatusService       = systemStatusService;
     this.appStatus               = appStatus;
     this.refreshTokenService     = refreshTokenService;
     this.exceptionRecordsService = exceptionRecordsService;
     this.appExceptionsService    = appExceptionsService;
 }
 public SplashPageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                            SystemStatusService systemStatusService, SystemEnvironmentsService systemEnvironmentsService,
                            ProjectService projectService, MyUserService myUserService,
                            RecordCacheHelper recordCacheHelper, AppStatus appStatus,
                            ExceptionRecordsService exceptionRecordsService, AppExceptionsService appExceptionsService,
                            LeaveCategoryService leaveCategoryService, OnCallPhoneService onCallPhoneService)
 {
     this.navigationService         = navigationService;
     this.dialogService             = dialogService;
     this.systemStatusService       = systemStatusService;
     this.systemEnvironmentsService = systemEnvironmentsService;
     this.projectService            = projectService;
     this.myUserService             = myUserService;
     this.recordCacheHelper         = recordCacheHelper;
     this.appStatus = appStatus;
     this.exceptionRecordsService = exceptionRecordsService;
     this.appExceptionsService    = appExceptionsService;
     this.leaveCategoryService    = leaveCategoryService;
     this.onCallPhoneService      = onCallPhoneService;
 }
        public HomePageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                                 OnlyAdministratorService OnlyAdministratorService, OnlyUserService OnlyUserService,
                                 RefreshTokenService refreshTokenService,
                                 SystemStatusService systemStatusService, AppStatus appStatus,
                                 AppExceptionsService appExceptionsService, ExceptionRecordsService exceptionRecordsService)
        {
            this.navigationService       = navigationService;
            this.dialogService           = dialogService;
            onlyAdministratorService     = OnlyAdministratorService;
            onlyUserService              = OnlyUserService;
            this.refreshTokenService     = refreshTokenService;
            this.systemStatusService     = systemStatusService;
            this.appStatus               = appStatus;
            this.appExceptionsService    = appExceptionsService;
            this.exceptionRecordsService = exceptionRecordsService;

            #region OnlyAdministratorCommand
            OnlyAdministratorCommand = new DelegateCommand(async() =>
            {
                using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,執行中...", null, null, true, MaskType.Black))
                {
                    bool fooRefreshTokenResult = await RefreshTokenHelper
                                                 .CheckAndRefreshToken(dialogService, refreshTokenService,
                                                                       systemStatusService, appStatus);
                    if (fooRefreshTokenResult == false)
                    {
                        return;
                    }
                    var fooResult = await OnlyAdministratorService.GetAsync();
                    if (fooResult.Status == false)
                    {
                        Message = fooResult.Message;
                    }
                    else
                    {
                        Message = fooResult.Payload.ToString();
                    }
                }
            });
            #endregion
            #region OnlyUserCommand
            OnlyUserCommand = new DelegateCommand(async() =>
            {
                using (IProgressDialog fooIProgressDialog = UserDialogs.Instance.Loading($"請稍後,執行中...", null, null, true, MaskType.Black))
                {
                    bool fooRefreshTokenResult = await RefreshTokenHelper
                                                 .CheckAndRefreshToken(dialogService, refreshTokenService,
                                                                       systemStatusService, appStatus);
                    if (fooRefreshTokenResult == false)
                    {
                        return;
                    }
                    var fooResult = await OnlyUserService.GetAsync();
                    if (fooResult.Status == false)
                    {
                        Message = fooResult.Message;
                    }
                    else
                    {
                        Message = fooResult.Payload.ToString();
                    }
                }
            });
            #endregion
            #region 故意拋出例外
            ThrowExceptionrCommand = new DelegateCommand(async() =>
            {
                throw new Exception("魔鬼藏在細節中");
            });
            #endregion
        }