Esempio n. 1
0
 private void btnKaydet_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbMarkaAdı.Text))
     {
         var controlname = brandServices.Count(tbMarkaAdı.Text);
         if (controlname > 0)
         {
             MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitOncedenEklenmis))}");
         }
         else
         {
             result = brandServices.Insert(new Brand()
             {
                 Name = tbMarkaAdı.Text.ToUpper(),
             });
             if (result > 0)
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitEklendi))}");
                 dgvMarkaData.DataSource = brandServices.Select();
             }
             else
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitEklenmedi))}");
             }
         }
     }
     else
     {
         MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.BosAlan))}");
     }
 }
        public AppBootstrapper()
        {
            Router = new RoutingState();
            Locator.CurrentMutable.RegisterConstant(this, typeof(IScreen));

            RegisterAkavache();
            RegisterServices();
            RegisterViewModels();

            UserError.RegisterHandler(ue =>
            {
                var notificator = DependencyService.Get <IToastNotificator>();
                notificator.Notify(
                    ToastNotificationType.Error,
                    ue.ErrorMessage,
                    ue.InnerException.ToString(),
                    TimeSpan.FromSeconds(20));

                this.Log().ErrorException(ue.ErrorMessage, ue.InnerException);

                return(Observable.Return(RecoveryOptionResult.CancelOperation));
            });

            Router.Navigate.Execute(new LoadingViewModel());
        }
Esempio n. 3
0
        private void InitExceptionsManagment(CompositionContainer container)
        {
            var exceptionHandler = container.GetExportedValue <IErrorHandlerContext>();

            RxApp.DefaultExceptionHandler = Observer.Create <Exception>(
                exc =>
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                UserError.Throw("Произошла необработанная ошибка", exc);
                Halfblood.Common.Log.LogManager.Log.Debug(exc);
            });

            var messager = container.GetExportedValue <IMessenger>();

            UserError.RegisterHandler(
                exc =>
            {
                if (!exceptionHandler.Handling(exc.InnerException))
                {
                    messager.Add(
                        new UiMessage(exc.ErrorMessage + "\n" + exc.InnerException.ToMessage(), TypeOfMessage.Error));
                }
                return(Observable.Return(RecoveryOptionResult.CancelOperation));
            });
        }
Esempio n. 4
0
        public HttpResponseMessage loadProvince() /// get จังหวัด
        {
            try
            {
                DataSet ds = new DataSet();
                ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "spt_MoblieLoadProvinces");
                DataTable dt = new DataTable();
                dt = ds.Tables[0];
                List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();
                Dictionary <string, object>         row;
                foreach (DataRow dr in dt.Rows)
                {
                    row = new Dictionary <string, object>();
                    foreach (DataColumn col in dt.Columns)
                    {
                        row.Add(col.ColumnName, dr[col]);
                    }
                    rows.Add(row);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, rows));
            }
            catch (Exception ex)
            {                   //Error case เกิดข้อผิดพลาด
                UserError err = new UserError();
                err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ

                err.message = ex.Message;
                //  Return resual
                return(Request.CreateResponse(HttpStatusCode.ExpectationFailed, err));
            }
        }
Esempio n. 5
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            //TODO: RxSUI - Item 1 - Here we are just setting up bindings to our UI Elements
            //This is a two-way bind
            this.Bind(ViewModel, x => x.SearchQuery, c => c.textEntry.Text)
            .DisposeWith(bindingsDisposable);

            //This is a one-way bind
            this.OneWayBind(ViewModel, x => x.SearchResults, c => c.searchResults.ItemsSource)
            .DisposeWith(bindingsDisposable);

            //This is a command binding
            this.BindCommand(ViewModel, x => x.Search, c => c.search)
            .DisposeWith(bindingsDisposable);

            //TODO: RxSUI - Item 2 - User error allows us to interact with our users and get feedback on how to handle an exception
            UserError
            .RegisterHandler(async(UserError arg) => {
                var result = await this.DisplayAlert("Search Failed", $"{arg.ErrorMessage}{Environment.NewLine}Retry search?", "Yes", "No");
                return(result ? RecoveryOptionResult.RetryOperation : RecoveryOptionResult.CancelOperation);
            })
            .DisposeWith(bindingsDisposable);
        }
        public OpenCacheViewModel(IScreen hostScreen, IAppState appState)
        {
            HostScreen = hostScreen;

            var isCachePathValid = this.WhenAny(
                x => x.CachePath, x => x.OpenAsEncryptedCache, x => x.OpenAsSqlite3Cache,
                (cp, _, sql) => new { Path = cp.Value, Sqlite3 = sql.Value })
                                   .Throttle(TimeSpan.FromMilliseconds(250), RxApp.MainThreadScheduler)
                                   .Select(x => x.Sqlite3 ? File.Exists(x.Path) : Directory.Exists(x.Path));

            OpenCache = new ReactiveCommand(isCachePathValid);

            OpenCache.SelectMany(_ => openAkavacheCache(CachePath, OpenAsEncryptedCache, OpenAsSqlite3Cache))
            .LoggedCatch(this, Observable.Return <IBlobCache>(null))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => {
                if (x == null)
                {
                    UserError.Throw("Couldn't open this cache");
                    return;
                }

                appState.CurrentCache = x;
                hostScreen.Router.Navigate.Execute(new CacheViewModel(hostScreen, appState));
            });

            BrowseForCache = new ReactiveCommand();

            BrowseForCache.Subscribe(_ =>
                                     CachePath = browseForFolder(
                                         Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "Browse for cache"));
        }
        public SearchViewModel()
        {
            SearchResults = new ObservableCollection <SearchResult>();

            // ReactiveCommand has built-in support for background operations and
            // guarantees that this block will only run exactly once at a time, and
            // that the CanExecute will auto-disable and that property IsExecuting will
            // be set according whilst it is running.
            Search = ReactiveCommand.CreateAsyncTask(
                // Here we're describing here, in a *declarative way*, the conditions in
                // which the Search command is enabled.  Now our Command IsEnabled is
                // perfectly efficient, because we're only updating the UI in the scenario
                // when it should change.
                this.WhenAnyValue(vm => vm.SearchQuery, value => !string.IsNullOrWhiteSpace(value)),
                async _ => {
                try
                {
                    var searchService = Locator.CurrentMutable.GetService <IDuckDuckGoApi>();
                    var result        = await searchService.Search(SearchQuery);
                    return(result);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
                return(new DuckDuckGoSearchResult());
            }, RxApp.MainThreadScheduler);

            // ReactiveCommands are themselves IObservables, whose value are the results
            // from the async method, guaranteed to arrive on the given scheduler.
            // We're going to take the list of search results that the background
            // operation loaded, and them into our SearchResults.
            Search.Subscribe(searchResult =>
            {
                SearchResults.Clear();

                foreach (var item in searchResult
                         .RelatedTopics
                         .Select(rt =>
                                 new SearchResult
                {
                    DisplayText = rt.Text,
                    ImageUrl = rt?.Icon?.Url ?? string.Empty
                }))
                {
                    SearchResults.Add(item);
                }
            });

            // ThrownExceptions is any exception thrown from the CreateFromObservable piped
            // to this Observable. Subscribing to this allows you to handle errors on
            // the UI thread.
            Search.ThrownExceptions.Subscribe(ex => {
                UserError.Throw("Potential Network Connectivity Error", ex);
            });

            this.WhenAnyValue(x => x.SearchQuery)
            .Sample(TimeSpan.FromSeconds(1), TaskPoolScheduler.Default)
            .InvokeCommand(Search);
        }
Esempio n. 8
0
        public UserError DeleteUser(UserInfo userInfo)
        {
            UserError error = new UserError();

            UserError whatCheck = UserError.LockedAlready |
                                    UserError.DeletedAlready |
                                    UserError.NoMoreAdminAfterDelete;

            error = CheckUserInfo(userInfo, whatCheck);

            if (error == 0)
            {
                int index = _userStorage.FindIndex(x => x.Name == userInfo.Name);
                //bool removeResult = 
                try
                {
                    _userStorage.RemoveAt(index);
                }
                catch
                {
                    return UserError.NoDeleted;
                }
               _userStorage.SaveStorage(_filePath);
               return UserError.NoError;
            }
            return error;
        }
Esempio n. 9
0
        public HttpResponseMessage GetNews()
        {
            try
            {
                DataSet   ds = SqlHelper.ExecuteDataset(scc, CommandType.StoredProcedure, "Get_A_News");
                DataTable dt = new DataTable();
                dt = ds.Tables[0];

                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

                List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();
                Dictionary <string, object>         row;
                foreach (DataRow dr in dt.Rows)
                {
                    row = new Dictionary <string, object>();
                    foreach (DataColumn col in dt.Columns)
                    {
                        row.Add(col.ColumnName, dr[col]);
                    }
                    rows.Add(row);
                }

                return(Request.CreateResponse(HttpStatusCode.OK, rows));
            }
            catch (Exception ex)
            {
                //Error case เกิดข้อผิดพลาด
                UserError err = new UserError();
                err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ

                err.message = ex.Message;
                //  Return resual
                return(Request.CreateResponse(HttpStatusCode.BadRequest, err));
            }
        }
 public Task<RecoveryOptionResult> Handler(UserError error, Window window = null) {
     if (error is CanceledUserError)
         return Task.FromResult(RecoveryOptionResult.CancelOperation);
     return (error.RecoveryOptions != null) && error.RecoveryOptions.Any()
         ? ErrorDialog(error, window)
         : BasicMessageHandler(error, window);
 }
Esempio n. 11
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            User   u     = new User();
            double phone = 0;

            try
            {
                phone = double.Parse(txtPhone.Text);
            }
            catch { }
            try
            {
                u.Username    = txtUsername.Text;
                u.Name        = txtName.Text;
                u.EmailAdd    = txtEmail.Text;
                u.Twitter     = txtTwitter.Text;
                u.Phonenumber = phone;
                User_List.Add(u);
                SaveUser();
                MessageBox.Show("User " + txtUser.Text + " added");

                txtEmail.Clear();
                txtName.Clear();
                txtPhone.Clear();
                txtTwitter.Clear();
                txtUsername.Clear();
                cvsNewUser.Visibility = Visibility.Hidden;
            }
            catch (Exception UserError)
            {
                MessageBox.Show(UserError.ToString());
            }
        }
        public IObservable <RecoveryOptionResult> Show(UserError userError)
        {
            IsBusy = false;
            var error = userError as TwoFactorRequiredUserError;

            Debug.Assert(error != null,
                         String.Format(CultureInfo.InvariantCulture, "The user error is '{0}' not a TwoFactorRequiredUserError", userError));
            InvalidAuthenticationCode = error.RetryFailed;
            TwoFactorType             = error.TwoFactorType;
            var ok = OkCommand
                     .Do(_ => IsBusy = true)
                     .Select(_ => AuthenticationCode == null
                    ? RecoveryOptionResult.CancelOperation
                    : RecoveryOptionResult.RetryOperation)
                     .Do(_ => error.ChallengeResult = AuthenticationCode != null
                    ? new TwoFactorChallengeResult(AuthenticationCode)
                    : null);
            var resend = ResendCodeCommand.Select(_ => RecoveryOptionResult.RetryOperation)
                         .Do(_ => error.ChallengeResult = TwoFactorChallengeResult.RequestResendCode);
            var cancel = CancelCommand.Select(_ => RecoveryOptionResult.CancelOperation);

            return(Observable.Merge(ok, cancel, resend)
                   .Take(1)
                   .Do(_ => IsAuthenticationCodeSent = error.ChallengeResult == TwoFactorChallengeResult.RequestResendCode));
        }
Esempio n. 13
0
        private static ReactiveCommand FireCommands(
            ICommandPublisher bus,
            IEnumerable <Func <Command> > commands,
            IObservable <bool> canExecute = null,
            IScheduler scheduler          = null,
            string userErrorMsg           = null,
            TimeSpan?responseTimeout      = null,
            TimeSpan?ackTimeout           = null)
        {
            if (scheduler == null)
            {
                scheduler = RxApp.MainThreadScheduler;
            }
            Func <object, Task> task = async _ => await Task.Run(() =>
            {
                foreach (var func in commands)
                {
                    bus.Send(func(), userErrorMsg, responseTimeout, ackTimeout);
                }
            });

            var cmd = ReactiveCommand.CreateFromTask(task, canExecute, scheduler);

            cmd.ThrownExceptions
#pragma warning disable CS0618 // Type or member is obsolete
            .SelectMany(ex => UserError.Throw(userErrorMsg, ex))
#pragma warning restore CS0618 // Type or member is obsolete
            .ObserveOn(MainThreadScheduler).Subscribe(result =>
            {
                //This will return the recovery option returned from the registered user error handler
                //right now this is a simple message box in the view code behind
                /* n.b. this forces evaluation/execution of the select many  */
            });
            return(cmd);
        }
Esempio n. 14
0
        private static ReactiveCommand FromAction(
            Action <object> action,
            IObservable <bool> canExecute = null,
            IScheduler scheduler          = null,
            string userErrorMsg           = null)
        {
            if (scheduler == null)
            {
                scheduler = RxApp.MainThreadScheduler;
            }
            Func <object, Task> task = async _ => await Task.Run(() => action(_));

            var cmd = ReactiveCommand.CreateFromTask(task, canExecute, scheduler);

            cmd.ThrownExceptions
#pragma warning disable CS0618 // Type or member is obsolete
            .ObserveOn(MainThreadScheduler).SelectMany(ex => UserError.Throw(userErrorMsg ?? ex.Message, ex))
#pragma warning restore CS0618 // Type or member is obsolete
            .Subscribe(result =>
            {
                //This will return the recovery option returned from the registered user error handler
                //right now this is a simple message box in the view code behind
                /* n.b. this forces evaluation/execution of the select many  */
            });
            return(cmd);
        }
Esempio n. 15
0
        void downloadUpdates()
        {
            State = "ProgressState";

            var updateManager = getUpdateManager();

            updateManager.DownloadReleases(UpdateInfo.ReleasesToApply, progress)
            // always be disposing
            .Finally(updateManager.Dispose)
            .Catch <Unit, Exception>(ex => {
                UserError.Throw(new UserError("Something unexpected happened", innerException: ex));
                return(Observable.Return(Unit.Default));
            })
            // this next line isn't necessary in The Real World
            // but i'm adding it here to emphasize
            // the progress bar that you get here
            .Delay(TimeSpan.FromSeconds(1.5))
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ =>
            {
                var viewModel        = getApplyViewModel.Value;
                viewModel.UpdateInfo = UpdateInfo;
                HostScreen.Navigate(viewModel);
            });
        }
Esempio n. 16
0
        void HandleError(Exception ex)
        {
            // The Windows ERROR_OPERATION_ABORTED error code.
            const int operationAborted = 995;

            if (ex is HttpListenerException &&
                ((HttpListenerException)ex).ErrorCode == operationAborted)
            {
                // An Oauth listener was aborted, probably because the user closed the login
                // dialog or switched between the GitHub and Enterprise tabs while listening
                // for an Oauth callbacl.
                return;
            }

            if (ex.IsCriticalException())
            {
                return;
            }

            log.Error(ex, "Error logging into '{BaseUri}' as '{UsernameOrEmail}'", BaseUri, UsernameOrEmail);
            if (ex is Octokit.ForbiddenException)
            {
                Error = new UserError(Resources.LoginFailedForbiddenMessage, ex.Message);
            }
            else
            {
                Error = new UserError(ex.Message);
            }
        }
Esempio n. 17
0
        ReleaseEntry readBundledReleasesFile()
        {
            var release = fileSystem.GetFileInfo(Path.Combine(currentAssemblyDir, "RELEASES"));

            if (!release.Exists)
            {
                UserError.Throw("This installer is incorrectly configured, please contact the author",
                                new FileNotFoundException(release.FullName));
                return(null);
            }

            ReleaseEntry ret;

            try {
                var fileText = fileSystem
                               .GetFile(release.FullName)
                               .ReadAllText(release.FullName, Encoding.UTF8);
                ret = ReleaseEntry
                      .ParseReleaseFile(fileText)
                      .Where(x => !x.IsDelta)
                      .OrderByDescending(x => x.Version)
                      .First();
            } catch (Exception ex) {
                this.Log().ErrorException("Couldn't read bundled RELEASES file", ex);
                UserError.Throw("This installer is incorrectly configured, please contact the author", ex);
                return(null);
            }

            return(ret);
        }
Esempio n. 18
0
        private static ReactiveCommand PublishEvents(
            IBus bus,
            IEnumerable <Func <Event> > events,
            IObservable <bool> canExecute = null,
            IScheduler scheduler          = null,
            string userErrorMsg           = null)
        {
            if (scheduler == null)
            {
                scheduler = RxApp.MainThreadScheduler;
            }
            Func <object, Task> task = async _ => await Task.Run(() =>
            {
                foreach (var func in events)
                {
                    bus.Publish(func());
                }
            });

            var cmd = ReactiveCommand.CreateFromTask(task, canExecute, scheduler);

            cmd.ThrownExceptions
            .SelectMany(ex => UserError.Throw(userErrorMsg ?? ex.Message, ex))
            .ObserveOn(MainThreadScheduler).Subscribe(result =>
            {
                //This will return the recovery option returned from the registered user error handler
                //right now this is a simple message box in the view code behind
                /* n.b. this forces evaluation/execution of the select many  */
            });
            return(cmd);
        }
Esempio n. 19
0
        private static ReactiveCommand FireCommandEx(
            IGeneralBus bus,
            Func <Object, Command> commandFunc,
            IObservable <bool> canExecute = null,
            IScheduler scheduler          = null,
            string userErrorMsg           = null,
            TimeSpan?responseTimeout      = null,
            TimeSpan?ackTimeout           = null)
        {
            if (scheduler == null)
            {
                scheduler = RxApp.MainThreadScheduler;
            }
            Func <object, Task> task = async _ => await Task.Run(() =>
            {
                var c = commandFunc(_);
                if (c != null)
                {
                    bus.Fire(c, userErrorMsg, responseTimeout, ackTimeout);
                }
            });

            var cmd = ReactiveCommand.CreateFromTask(task, canExecute, scheduler);

            cmd.ThrownExceptions
            .SelectMany(ex => UserError.Throw(userErrorMsg ?? ex.Message, ex))
            .ObserveOn(MainThreadScheduler).Subscribe(result =>
            {
                //This will return the recovery option returned from the registered user error handler
                //right now this is a simple message box in the view code behind
                /* n.b. this forces evaluation/execution of the select many  */
            });
            return(cmd);
        }
Esempio n. 20
0
        private UserErrorDialog(UserError error) : base(null, DialogFlags.Modal, MessageType.Error, ButtonsType.None, null)
        {
            _userError     = error;
            Icon           = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
            WindowPosition = WindowPosition.Center;
            Response      += UserErrorDialog_Response;

            SetSizeRequest(120, 50);

            AddButton("OK", OkResponseId);

            bool isInSetupGuide = IsCoveredBySetupGuide(error);

            if (isInSetupGuide)
            {
                AddButton("Open the Setup Guide", SetupGuideResponseId);
            }

            string errorCode = GetErrorCode(error);

            SecondaryUseMarkup = true;

            Title         = $"Ryujinx error ({errorCode})";
            Text          = $"{errorCode}: {GetErrorTitle(error)}";
            SecondaryText = GetErrorDescription(error);

            if (isInSetupGuide)
            {
                SecondaryText += "\n<b>For more information on how to fix this error, follow our Setup Guide.</b>";
            }
        }
Esempio n. 21
0
        private IObservable <RecoveryOptionResult> ErrorHandler(UserError arg)
        {
            if (arg.RecoveryOptions.Count != 2)
            {
                throw new InvalidDataException("Expecting two recovery options, one affirmative, one negative");
            }
            var aff = arg.RecoveryOptions.OfType <RecoveryCommand>().FirstOrDefault(x => x.IsDefault);
            var neg = arg.RecoveryOptions.OfType <RecoveryCommand>().FirstOrDefault(x => x.IsCancel);
            MessageDialogStyle  style   = MessageDialogStyle.AffirmativeAndNegative;
            MetroDialogSettings options = new MetroDialogSettings
            {
                AffirmativeButtonText = aff.CommandName,
                NegativeButtonText    = neg.CommandName,
            };

            return(this.ShowMessageAsync("", arg.ErrorMessage, style, options).ToObservable().Select(r =>
            {
                switch (r)
                {
                case MessageDialogResult.Negative:
                    return RecoveryOptionResult.FailOperation;

                case MessageDialogResult.Affirmative:
                    return RecoveryOptionResult.RetryOperation;

                case MessageDialogResult.FirstAuxiliary:
                    return RecoveryOptionResult.CancelOperation;

                default:
                    throw new ArgumentOutOfRangeException(nameof(r), r, null);
                }
            }));
        }
Esempio n. 22
0
        public UserViewModel(IScreen screen, User user) : base(SegmentName, screen)
        {
            this.WhenAnyValue(e => e.User).Where(e => e != null).Subscribe(u => { Name = u.Name; });
            User = user;

            this.WhenAnyValue(e => e.Name).Subscribe(name => User.Name = name);

            UserError.RegisterHandler(async error =>
            {
                // Don't block app
                await Task.Delay(1);
                var message            = new StringBuilder();
                var hasRecoveryOptions = error.ErrorCauseOrResolution.IsValid();
                if (hasRecoveryOptions)
                {
                    message.AppendLine(error.ErrorCauseOrResolution);
                }
                message.AppendLine(error.ErrorMessage);
                var result = MessageBox.Show(message.ToString(), "Alert!",
                                             hasRecoveryOptions ? MessageBoxButton.YesNo : MessageBoxButton.OK);

                return(hasRecoveryOptions && result == MessageBoxResult.Yes
                    ? RecoveryOptionResult.RetryOperation
                    : RecoveryOptionResult.CancelOperation);
            });
        }
        public HttpResponseMessage get_Gender()
        {
            try
            {
                XpoTypesInfoHelper.GetXpoTypeInfoSource();
                XafTypesInfo.Instance.RegisterEntity(typeof(Gender));
                List <Gender_Model>   list           = new List <Gender_Model>();
                XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null);
                IObjectSpace          ObjectSpace    = directProvider.CreateObjectSpace();
                IList <Gender>        collection     = ObjectSpace.GetObjects <Gender>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1", null));
                foreach (Gender row in collection)
                {
                    Gender_Model model = new Gender_Model();
                    model.Oid        = row.Oid.ToString();
                    model.GenderName = row.GenderName;
                    model.IsActive   = row.IsActive;
                    list.Add(model);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, list));
            }
            catch (Exception ex)
            {                   //Error case เกิดข้อผิดพลาด
                UserError err = new UserError();
                err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ

                err.message = ex.Message;
                //  Return resual
                return(Request.CreateResponse(HttpStatusCode.BadRequest, err));
            }
        }
        public void ShowsHelpfulTooltipWhenForbiddenResponseReceived()
        {
            var response = Substitute.For <IResponse>();

            response.StatusCode.Returns(HttpStatusCode.Forbidden);
            var repositoryHosts = Substitute.For <IRepositoryHosts>();

            repositoryHosts.LogIn(HostAddress.GitHubDotComHostAddress, Args.String, Args.String)
            .Returns(_ => Observable.Throw <AuthenticationResult>(new ForbiddenException(response)));
            var browser        = Substitute.For <IVisualStudioBrowser>();
            var loginViewModel = new LoginToGitHubViewModel(repositoryHosts, browser);
            var message        = "";

            using (UserError.RegisterHandler <UserError>(x =>
            {
                message = x.ErrorMessage;
                return(Observable.Return(RecoveryOptionResult.RetryOperation));
            }))
            {
                loginViewModel.Login.Execute(null);
            }

            Assert.Equal("Make sure to use your password and not a Personal Access token to log in.",
                         message);
        }
        public async Task <IActionResult> checkadminuname(string txtAdminUName, int id)
        {
            bool      exists = false;
            UserError e      = new UserError();

            //validate request
            if (!ModelState.IsValid)
            {
                var modelErrors = new List <UserError>();
                var eD          = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        eD.Add(modelError.ErrorMessage);
                    }
                }
                e.error        = ((int)HttpStatusCode.BadRequest).ToString();
                e.errorDetails = eD;

                return(BadRequest(e));
            }

            try
            {
                exists = await userSqlRepo.checkAdminUname(txtAdminUName, id);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(CreatedAtAction("checkAdminUname", exists));
        }
Esempio n. 26
0
 private void btnKaydet_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbModelAdi.Text))
     {
         var controlname = modelServices.Count(tbModelAdi.Text.ToUpper(), (cmbMarkaAdi.SelectedValue as Brand).ID);
         if (controlname > 0)
         {
             MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitOncedenEklenmis))}");
         }
         else
         {
             result = modelServices.Insert(new Model()
             {
                 Name     = tbModelAdi.Text.ToUpper(),
                 Brand_ID = cmbMarkaAdi.SelectedIndex
             });
             if (result > 0)
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitEklendi))}");
                 dgvModelData.DataSource = modelServices.Select();
             }
             else
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitEklenmedi))}");
             }
         }
     }
     else
     {
         MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.BosAlan))}");
     }
 }
        public async Task <IActionResult> activateuser([FromBody] Login login)
        {
            User      _user = null;
            UserError e     = new UserError();

            //validate request
            if (!ModelState.IsValid)
            {
                var modelErrors = new List <UserError>();
                var eD          = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        eD.Add(modelError.ErrorMessage);
                    }
                }
                e.error        = ((int)HttpStatusCode.BadRequest).ToString();
                e.errorDetails = eD;

                return(BadRequest(e));
            }

            try
            {
                _user = await userSqlRepo.UpdateUser(login);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(CreatedAtAction("activateuser", _user));
        }
        public async Task <IActionResult> getallusers()
        {
            List <User> _users = null;
            UserError   e      = new UserError();

            //validate request
            if (!ModelState.IsValid)
            {
                var modelErrors = new List <UserError>();
                var eD          = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        eD.Add(modelError.ErrorMessage);
                    }
                }
                e.error        = ((int)HttpStatusCode.BadRequest).ToString();
                e.errorDetails = eD;

                return(BadRequest(e));
            }

            try
            {
                _users = await userSqlRepo.GetAllUsers();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(CreatedAtAction("getallusers", _users));
        }
        /// ประเภทเมล็ด
        public HttpResponseMessage loadSeedType()
        {
            try
            {
                XpoTypesInfoHelper.GetXpoTypeInfoSource();
                XafTypesInfo.Instance.RegisterEntity(typeof(SeedType));
                List <SeedType_Model> list           = new List <SeedType_Model>();
                XPObjectSpaceProvider directProvider = new XPObjectSpaceProvider(scc, null);
                IObjectSpace          ObjectSpace    = directProvider.CreateObjectSpace();
                //   Activity ActivityOid = ObjectSpace.FindObject<Activity>(CriteriaOperator.Parse("GCRecord is null and IsActive = 1 and ActivityName ='เพื่อช่วยเหลือภัยพิบัติ'  ", null));
                ForageType       objseedtype = ObjectSpace.FindObject <ForageType>(CriteriaOperator.Parse("IsActive = 1 and  ForageTypeName = 'เสบียงสัตว์ ' ", null));
                IList <SeedType> collection  = ObjectSpace.GetObjects <SeedType>(CriteriaOperator.Parse(" GCRecord is null and IsActive = 1  and [ForageTypeOid] ='" + objseedtype.Oid + "'  ", null));
                foreach (SeedType row in collection)
                {
                    SeedType_Model model = new SeedType_Model();
                    model.SeedTypeOid  = row.Oid.ToString();
                    model.SeedTypeName = row.SeedTypeName;
                    model.IsActive     = row.IsActive;
                    list.Add(model);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, list));
            }
            catch (Exception ex)
            {                   //Error case เกิดข้อผิดพลาด
                UserError err = new UserError();
                err.code = "6"; // error จากสาเหตุอื่นๆ จะมีรายละเอียดจาก system แจ้งกลับ

                err.message = ex.Message;
                //  Return resual
                return(Request.CreateResponse(HttpStatusCode.BadRequest, err));
            }
        }
Esempio n. 30
0
 private void btnSil_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbModelAdi.Text))
     {
         var delete = modelServices.Find(Convert.ToInt32(dgvModelData.CurrentRow.Cells[0].Value.ToString()));
         if (delete != null)
         {
             result = modelServices.Delete(delete);
             if (result > 0)
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitSilindi))}");
                 dgvModelData.DataSource = modelServices.Select();
             }
             else
             {
                 MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitSilinmedi))}");
             }
         }
         else
         {
             MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.KayitBulunamadı))}");
         }
     }
     else
     {
         MessageBox.Show($"{UserError.ErrorMessage(Convert.ToInt32(UserError.ErrorCode.BosAlan))}");
     }
 }
        public IObservable <TwoFactorChallengeResult> Show(UserError userError)
        {
            Guard.ArgumentNotNull(userError, nameof(userError));

            IsBusy = false;
            var error = userError as TwoFactorRequiredUserError;

            if (error == null)
            {
                throw new GitHubLogicException(
                          String.Format(
                              CultureInfo.InvariantCulture,
                              "The user error is '{0}' not a TwoFactorRequiredUserError",
                              userError));
            }

            InvalidAuthenticationCode = error.RetryFailed;
            IsAuthenticationCodeSent  = false;
            TwoFactorType             = error.TwoFactorType;
            var ok = OkCommand
                     .Do(_ => IsBusy = true)
                     .Select(_ => AuthenticationCode == null
                    ? null
                    : new TwoFactorChallengeResult(AuthenticationCode));
            var resend = ResendCodeCommand.Select(_ => RecoveryOptionResult.RetryOperation)
                         .Select(_ => TwoFactorChallengeResult.RequestResendCode)
                         .Do(_ => IsAuthenticationCodeSent = true);
            var cancel = this.WhenAnyValue(x => x.TwoFactorType)
                         .Skip(1)
                         .Where(x => x == TwoFactorType.None)
                         .Select(_ => default(TwoFactorChallengeResult));

            return(Observable.Merge(ok, cancel, resend).Take(1));
        }
        public void BadPasswordMeansErrorMessage()
        {
            var mock = new MoqMockingKernel();

            mock.Bind <ILoginViewModel>().To(typeof(LoginViewModel));

            mock.Bind <Func <IObservable <Unit> > >()
            .ToConstant <Func <IObservable <Unit> > >(() => Observable.Throw <Unit>(new Exception("Bad Stuff")))
            .Named("confirmUserPass");

            var fixture = mock.Get <ILoginViewModel>();

            fixture.User     = "******";
            fixture.Password = "******";

            fixture.Confirm.CanExecute(null).Should().BeTrue();

            UserError error = null;

            using (UserError.OverrideHandlersForTesting(x => { error = x; return(Observable.Return(RecoveryOptionResult.CancelOperation)); })) {
                fixture.Confirm.Execute(null);
            }

            error.Should().NotBeNull();
            this.Log().Info("Error Message: {0}", error.ErrorMessage);
            error.ErrorMessage.Should().NotBeNullOrEmpty();
        }
Esempio n. 33
0
        public UserErrorViewModel(UserError userError) {
            UserError = userError;

            this.WhenActivated(d => {
                foreach (var a in userError.RecoveryOptions.OfType<RecoveryCommand>().Where(x => !(x is IDontRecover)))
                    d(a.Subscribe(x => TryClose()));
            });
        }
Esempio n. 34
0
        public Task<RecoveryOptionResult> Handler(UserError error, Window window = null) {
            return error.RecoveryOptions != null && error.RecoveryOptions.Any()
                ? UiRoot.Main.ErrorDialog(error, window)
                :
#if DEBUG
                UnhandledError(error, window);
#else
            BasicHandler(error, window);
#endif
        }
 private async Task<RecoveryOptionResult> ErrorDialog(UserError error, Window window = null) {
     MainLog.Logger.FormattedWarnException(error.InnerException, "UserError");
     if (Common.Flags.IgnoreErrorDialogs)
         return RecoveryOptionResult.FailOperation;
     var settings = new Dictionary<string, object>();
     if (window != null)
         settings["Owner"] = window;
     var t2 = error.RecoveryOptions.GetTask();
     await _specialDialogManager.ShowDialog(new UserErrorViewModel(error), settings).ConfigureAwait(false);
     return await t2.ConfigureAwait(false);
 }
 public Task<RecoveryOptionResult> Handler(UserError error) {
     if (error is CanceledUserError)
         return Task.FromResult(RecoveryOptionResult.CancelOperation);
     return (error.RecoveryOptions != null) && error.RecoveryOptions.Any()
         ? ErrorDialog(error)
         : /*#if DEBUG
                         UnhandledError(error);
         #else
                     BasicMessageHandler(error);
         #endif*/
         BasicMessageHandler(error);
 }
 async Task<RecoveryOptionResult> HandleUserError(UserError error) {
     var t2 = error.RecoveryOptions.GetTask();
     await _api.AddUserError(new UserErrorModel2(error,
         error.RecoveryOptions.Select(
             x =>
                 new RecoveryOptionModel {
                     CommandName = x.CommandName
                 }).ToList())).ConfigureAwait(false);
     //error.RecoveryOptions.First(x => x.CommandName == r).Execute(null);
     return await t2;
     //return error.RecoveryOptions.First(x => x.RecoveryResult.HasValue).RecoveryResult.Value;
 }
Esempio n. 38
0
 async Task<RecoveryOptionResult> UnhandledError(UserError error, Window window = null) {
     var message = error.ErrorCauseOrResolution;
     var title = error.ErrorMessage;
     var result = await _dialogManager.ExceptionDialogAsync(error.InnerException.UnwrapExceptionIfNeeded(),
         message, title, window).ConfigureAwait(false);
     //await _dialogManager.ExceptionDialogAsync(x.InnerException, x.ErrorCauseOrResolution,
     //x.ErrorMessage);
     //var result = await Dispatcher.InvokeAsync(() => _exceptionHandler.HandleException(arg.InnerException));
     // TODO: Should actually fail and rethrow as an exception to then be catched by unhandled exception handler?
     // TODO: Add proper retry options. e.g for Connect - dont just show a connect dialog, but make it part of the retry flow;
     // pressing Connect, and succesfully connect, should then retry the action?
     return result ? RecoveryOptionResult.CancelOperation : RecoveryOptionResult.FailOperation;
 }
 Task<RecoveryOptionResult> BasicMessageHandler(UserError userError) {
     MainLog.Logger.Error(userError.InnerException.Format());
     //var id = Guid.Empty;
     Report(userError.InnerException);
     // NOTE: this code really shouldn't throw away the MessageBoxResult
     var message = userError.ErrorCauseOrResolution +
                   "\n\nWe've been notified about the problem." +
                   "\n\nPlease make sure you are running the latest version of the software.\n\nIf the problem persists, please contact Support: http://community.withsix.com";
     var title = userError.ErrorMessage ?? "An error has occured while trying to process the action";
     return
         _api.HandleUserError(new UserError(title, message,
             new[] {new RecoveryCommandImmediate("OK", x => RecoveryOptionResult.CancelOperation)},
             userError.ContextInfo, userError.InnerException));
 }
        async Task<RecoveryOptionResult> BasicMessageHandler(UserError userError, Window window) {
            MainLog.Logger.Error(userError.InnerException.Format());
            //var id = Guid.Empty;

            Report(userError.InnerException);
            // NOTE: this code really shouldn't throw away the MessageBoxResult
            var message = userError.ErrorCauseOrResolution +
                          "\n\nWe've been notified about the problem." +
                          "\n\nPlease make sure you are running the latest version of the software.\n\nIf the problem persists, please contact Support: http://community.withsix.com";
            var title = userError.ErrorMessage ?? "An error has occured while trying to process the action";
            var result =
                await
                    _dialogManager.MessageBox(new MessageBoxDialogParams(message, title) {Owner = window})
                        .ConfigureAwait(false);
            return RecoveryOptionResult.CancelOperation;
        }
Esempio n. 41
0
 public UserError AddUser(UserInfo userInfo)
 {
     UserError error = new UserError();
     UserError whatCheck = UserError.NoLogin | 
                           UserError.NoPassword |
                           UserError.NoFIO | 
                           UserError.LoginAlreadyExist|
                           UserError.FIOAlreadyExist |
                           UserError.NoRole;
     
     error = CheckUserInfo(userInfo, whatCheck);
     if (error== 0)
     {
         userInfo.Id = NextUserInfoId;
         _userStorage.Add(userInfo);
         _userStorage.SaveStorage(_filePath);
         return UserError.NoError;
     }
     return error;
 }
 public IObservable<RecoveryOptionResult> Show(UserError userError)
 {
     IsBusy = false;
     var error = userError as TwoFactorRequiredUserError;
     Debug.Assert(error != null,
         String.Format(CultureInfo.InvariantCulture, "The user error is '{0}' not a TwoFactorRequiredUserError", userError));
     InvalidAuthenticationCode = error.RetryFailed;
     TwoFactorType = error.TwoFactorType;
     var ok = OkCommand
         .Do(_ => IsBusy = true)
         .Select(_ => AuthenticationCode == null
             ? RecoveryOptionResult.CancelOperation
             : RecoveryOptionResult.RetryOperation)
         .Do(_ => error.ChallengeResult = AuthenticationCode != null
             ? new TwoFactorChallengeResult(AuthenticationCode)
             : null);
     var resend = ResendCodeCommand.Select(_ => RecoveryOptionResult.RetryOperation)
         .Do(_ => error.ChallengeResult = TwoFactorChallengeResult.RequestResendCode);
     var cancel = CancelCommand.Select(_ => RecoveryOptionResult.CancelOperation);
     return Observable.Merge(ok, cancel, resend)
         .Take(1)
         .Do(_ => IsAuthenticationCodeSent = error.ChallengeResult == TwoFactorChallengeResult.RequestResendCode);
 }
Esempio n. 43
0
        public string GetErrorMessage(UserError error, UserInfo userInfo)
        {
            string errorMessage = "";

            if ((error & UserError.LockedAlready) == UserError.LockedAlready)
                errorMessage += "- Пользователь с логином \"" + userInfo.Name + "\" заблокирован\n";

            if ((error & UserError.NoLogin) == UserError.NoLogin)
                errorMessage += "- У пользователя отсутствует логин\n";

            if ((error & UserError.NoPassword) == UserError.NoPassword)
                errorMessage += "- Не заполнено поле Пароль\n";

            if ((error & UserError.DeletedAlready) == UserError.DeletedAlready)
                errorMessage += "- Пользователь " + (userInfo == null ? "" : "\"" + userInfo.Name + "\" ") +
                                "уже удален\n";

            if ((error & UserError.LoginAlreadyExist) == UserError.LoginAlreadyExist)
                errorMessage += "- Пользователь с логином " + (userInfo == null ? "" : "\"" + userInfo.Name + "\" ") +
                                "уже учтен в Системе\n";

            if ((error & UserError.FIOAlreadyExist) == UserError.FIOAlreadyExist)
                errorMessage += "- Пользователь с таким ФИО " +
                                (userInfo == null ? "" : "\"" + userInfo.FullName + "\" ") + "уже учтен в Системе\n";

            if ((error & UserError.NoRole) == UserError.NoRole)
                errorMessage += "- Пользователю не назначена ни одна роль\n";

            if ((error & UserError.NoFIO) == UserError.NoFIO)
                errorMessage += "- У пользователя отсутствует ФИО\n";

            if ((error & UserError.NoDeleted) == UserError.NoDeleted)
                errorMessage += "- Пользователь не удален\n";

            if ((error & UserError.UnlockedAlready) == UserError.UnlockedAlready)
                errorMessage += "- Пользователь уже разблокирован\n";

            if ((error & UserError.NoMoreAdminAfterDelete) == UserError.NoMoreAdminAfterDelete)
                errorMessage += "- В Системе должен остаться хотя бы один пользователь с ролью Администратор\n";

            if ((error & UserError.WorkInSystem) == UserError.WorkInSystem)
                errorMessage += "- Запись недоступна для изменения: пользователь работает в Системе\n";

            if ((error & UserError.LastUserWithAdminRole) == UserError.LastUserWithAdminRole)
                errorMessage += "- В Системе должен остаться хотя бы один пользователь с ролью Администратор\n";


            return errorMessage;
        }
Esempio n. 44
0
 public UserException(string message, UserError error)
     : base(message)
 {
     _error = error;
 }
Esempio n. 45
0
 Task<RecoveryOptionResult> BasicHandler(UserError error, Window window) {
     return BasicMessageHandler(error, window);
 }
Esempio n. 46
0
        public UserError UpdateUser(UserInfo userInfo)
        {
            UserError error = new UserError();

            UserError whatCheck = UserError.NoLogin |
                                  UserError.NoPassword |
                                  UserError.NoFIO |
                                  UserError.LastUserWithAdminRole|
                                  UserError.LoginAlreadyExist |
                                  UserError.FIOAlreadyExist |
                                  UserError.DeletedAlready |
                                  UserError.NoRole |
                                  UserError.UnlockedAlready;
            //TODO проверять если логин или FIO поменялись

            error = CheckUserInfo(userInfo, whatCheck);

            if (error == 0)
            {
                UserInfo userInfoPrev = _userStorage.Find(x => x.Id == userInfo.Id);
                userInfoPrev.Name = userInfo.Name;
                userInfoPrev.Hash = userInfo.Hash;
                userInfoPrev.IsAdmin = userInfo.IsAdmin;
                userInfoPrev.IsOperator = userInfo.IsOperator;
                userInfoPrev.Comment = userInfo.Comment;
                userInfoPrev.FullName = userInfo.FullName;

                _userStorage.SaveStorage(_filePath);
                return UserError.NoError;
            }
            return error;
        }
Esempio n. 47
0
        public UserError UnlockUser(UserInfo userInfo)
        {
            UserError error = new UserError();

            UserError whatCheck =   UserError.DeletedAlready | 
                                    UserError.UnlockedAlready;

            error = CheckUserInfo(userInfo, whatCheck);

            if (error == 0)
            {
                
                 LockUserListDelete(userInfo);
                return UserError.NoError;
            }
            return error;
        }
Esempio n. 48
0
 public IObservable<RecoveryOptionResult> HandleError(UserError error)
 {
     var result = MessageBox.Show(error.ErrorMessage, "Error");
     return Observable.Return(result == MessageBoxResult.Yes ? RecoveryOptionResult.RetryOperation : RecoveryOptionResult.CancelOperation);
 }
Esempio n. 49
0
        public UserError CheckUserInfo(UserInfo userInfo,UserError forCheck)
        {
            UserError error = new UserError();


            
            //Проверка на залнение логина
            if((forCheck&UserError.NoLogin)==UserError.NoLogin)
            {
                if (userInfo== null || userInfo.Name.Trim().Length == 0)
                {
                    error |= UserError.NoLogin;
                }
            }

            //В системе останется после удаления хотя бы одни пользователь с ролью Администратор  
            if ((forCheck & UserError.NoMoreAdminAfterDelete) == UserError.NoMoreAdminAfterDelete)
            {
                UserInfo systemUserInfo = FindSystemUser();
                if (userInfo != null) 
                {
                    if (!_userStorage.Exists(x => x.Id != userInfo.Id && x.IsAdmin && x.Id!= systemUserInfo.Id))
                    {
                        error |= UserError.NoMoreAdminAfterDelete;
                    }
                }
            }

            if ((forCheck & UserError.LastUserWithAdminRole) == UserError.LastUserWithAdminRole)
            {
                UserInfo systemUserInfo = FindSystemUser();
                if (userInfo != null)
                {
                    if (!_userStorage.Exists(x => x.Id != userInfo.Id && x.IsAdmin && x.Id != systemUserInfo.Id) && !userInfo.IsAdmin)
                    {
                        error |= UserError.LastUserWithAdminRole;
                    }
                }
            }


            //Проверка на залнение FIO
            if ((forCheck & UserError.NoFIO) == UserError.NoFIO)
            {
                if (userInfo == null || userInfo.FullName.Trim().Length == 0)
                {
                    error |= UserError.NoFIO;
                }
            }

            //Проверка на заполнение пароля
            if ((forCheck & UserError.NoPassword) == UserError.NoPassword)
            {
                if (userInfo == null || userInfo.Hash.Length == 0)
                {
                    error |= UserError.NoPassword;
                }
            }

            //Проверка на залнение хотя бы одной роли
            if ((forCheck & UserError.NoRole) == UserError.NoRole)
            {
                if ((userInfo == null) ||(!userInfo.IsAdmin && !userInfo.IsOperator))
                {
                    error |= UserError.NoRole;
                }
            }
            
            //Проверка на то, что пользователь уже удален
            if ((forCheck & UserError.DeletedAlready) == UserError.DeletedAlready)
            {
                int userInfoIndex = -1;
                if(userInfo!= null)
                    userInfoIndex = _userStorage.FindIndex(x => x.Id == userInfo.Id);

                if (userInfoIndex == -1)
                {
                    error |= UserError.DeletedAlready;
                }
            }

            //Проверка на, то что такой Login уже есть в системе
            if ((forCheck & UserError.LoginAlreadyExist) == UserError.LoginAlreadyExist)
            {
                //_userStorage.Find(value => value.Name.Equals(userInfo.Name, StringComparison.InvariantCultureIgnoreCase)&& value.Id!=userInfo.Id);
                if (userInfo != null && _userStorage.Exists(x => x.Id != userInfo.Id && x.Name != null && x.Name.ToLower().Trim() == userInfo.Name.ToLower().Trim() ))
                {
                    error |= UserError.LoginAlreadyExist;
                }
            }

            //Проверка на, то что такое FIO уже есть в системе
            if ((forCheck & UserError.FIOAlreadyExist) == UserError.FIOAlreadyExist)
            {
                if (userInfo != null && _userStorage.Exists(x => x.FullName!=null && x.FullName.ToLower().Trim() == userInfo.FullName.ToLower().Trim() && x.Id != userInfo.Id))
                {
                    error |= UserError.FIOAlreadyExist;
                }
            }

            //Проверка на, то что пользователь с таким Id заблокрован 
            if ((forCheck & UserError.LockedAlready) == UserError.LockedAlready)
            {
                
                if (userInfo != null && lockedUsers.Exists(x => x.Id == userInfo.Id))
                {
                    error |= UserError.LockedAlready;
                }
            }

            //Проверка на, то что пользователь с таким Id уже не заблоктрована
            if ((forCheck & UserError.UnlockedAlready) == UserError.UnlockedAlready)
            {
                if (userInfo != null && !lockedUsers.Exists(x => x.Id == userInfo.Id))
                {
                    error |= UserError.UnlockedAlready;
                }
            }

            return error;
        }
 private async Task<RecoveryOptionResult> ErrorDialog(UserError userError) {
     if (Common.Flags.IgnoreErrorDialogs)
         return RecoveryOptionResult.FailOperation;
     return await _api.HandleUserError(userError).ConfigureAwait(false);
 }