示例#1
0
        // Private methods

        private async Task AttemptRegisterAsync()
        {
            Email.Value     = Email.Value?.Trim();
            FirstName.Value = FirstName.Value?.Trim();
            LastName.Value  = LastName.Value?.Trim();
            Password.Value  = Password.Value?.Trim();

            if (_validationHelper.Validate())
            {
                _userDialogs.ShowLoading("Registration");

                var user = new ApplicationUserModel()
                {
                    Email = Email.Value, FirstName = FirstName.Value, LastName = LastName.Value, Password = Password.Value, BirthDate = BirthDate.Value
                };

                var serviceResult = await _authService.Register(user);

                if (serviceResult.Success)
                {
                    await _navigationService.Navigate <LoginViewModel, ApplicationUserModel>(new ApplicationUserModel()
                    {
                        Email = Email.Value, Password = Password.Value
                    });

                    _userDialogs.HideLoading();
                }
                else
                {
                    _userDialogs.HideLoading();
                    await _userDialogs.AlertAsync(new AlertConfig
                    {
                        Title   = "Registration failed",
                        Message = serviceResult.Error.Description,
                        OkText  = "OK"
                    });

                    InitValidationCommand.Execute(null);
                }
            }
        }
示例#2
0
        public async void OnLogInClicked(object sender, EventArgs e)
        {
            //string targetUrl = "http://50.73.94.149/wsMaterialHouse";

            //await CrossConnectivity.Current.IsReachable(new Uri(targetUrl).Authority);

            try
            {
                if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text) && username.TextColor != Color.Red)
                    {
                        IUserDialogs Dialogs = UserDialogs.Instance;
                        Dialogs.ShowLoading("Loading...");
                        await Task.Delay(2000);

                        Dialogs.HideLoading();
                    if (CrossConnectivity.Current.IsConnected == false)
                    {
                        await DisplayAlert("Log In", "Connection issues", "Ok");
                        Dialogs.HideLoading();
                        return;
                    }

                    Repository repository = new Repository();
                    var usuario = repository.LogIn(password.Text, username.Text);


						await Navigation.PushModalAsync(new AssetsHomePage());
                    else
                    {
                        await DisplayAlert("Log In", "Verify the Information", "OK");
                    }

            }

            catch (Exception ex)
            {
                //await DisplayAlert("Log In", "User not Found", "OK");
                 await DisplayAlert("Log In", ex.Message, "OK");
            }

        } 
        protected override async void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            dialogs.ShowLoading("Cargando...");

            await ChatService.InitAsync(CurrentUser.Username);

            Rooms = await ChatService.GetRooms();

            dialogs.HideLoading();
        }
示例#4
0
        private async Task RefreshOperationExecuted()
        {
            if (IsBusy)
            {
                return;
            }
            LoggingService.Trace("Executing OperationRootTabbedViewModel.RefreshOperationCommand");

            IsBusy = true;
            _userDialogs.ShowLoading();


            var selectedOpId = _preferences.Get(UserSettingsKeys.SelectedOp, string.Empty);

            if (string.IsNullOrWhiteSpace(selectedOpId))
            {
                return;
            }

            var hasUpdated = false;

            try
            {
                var localData = await _operationsDatabase.GetOperationModel(selectedOpId);

                var updatedData = await _wasabeeApiV1Service.Operations_GetOperation(selectedOpId);

                if (localData != null && updatedData != null && !localData.Modified.Equals(updatedData.Modified))
                {
                    await _operationsDatabase.SaveOperationModel(updatedData);

                    hasUpdated = true;
                }
            }
            catch (Exception e)
            {
                LoggingService.Error(e, "Error Executing OperationRootTabbedViewModel.RefreshOperationCommand");
            }
            finally
            {
                IsBusy = false;

                _userDialogs.HideLoading();
                _userDialogs.Toast(hasUpdated ? "Operation data updated" : "You already have latest OP version");

                if (hasUpdated)
                {
                    _messenger.Publish(new MessageFrom <OperationRootTabbedViewModel>(this));
                }

                _messenger.Publish(new RefreshAllAgentsLocationsMessage(this));
            }
        }
示例#5
0
        public async void Button_Clicked(object sender, EventArgs e)
        {
            Dialogs.ShowLoading("Espere por favor...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            LoginPage myHomePage = new LoginPage();

            NavigationPage.SetHasNavigationBar(myHomePage, true);
            await Navigation.PushModalAsync(myHomePage);
        }
示例#6
0
        private async void Evaluar_Clicked(object sender, EventArgs e)
        {
            Dialogs.ShowLoading("Espere por favor...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            EvaluarPage myHomePage = new EvaluarPage();

            NavigationPage.SetHasNavigationBar(myHomePage, false);
            await Navigation.PushModalAsync(myHomePage);
        }
示例#7
0
        public async void OnScannerClicked(object sender, EventArgs e)
        {
            IUserDialogs Dialogs = UserDialogs.Instance;

            Dialogs.ShowLoading("Espere...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            Scan();
            //await Navigation.PushAsync(new mobilePMP.Views.QRReaderPage());
        }
示例#8
0
        public async void OnNOClicked(object sender, EventArgs e)
        {
            Dialogs.ShowLoading("Generando Factura...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            FacturacionPage myHomePage = new FacturacionPage();

            NavigationPage.SetHasNavigationBar(myHomePage, false);
            await Navigation.PushModalAsync(myHomePage);
        }
示例#9
0
        public async void OnChatClicked(object sender, EventArgs e)
        {
            Dialogs.ShowLoading("Ingresando...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            var myHomePage = new NavigationPage(new RoomPage());

            NavigationPage.SetHasNavigationBar(myHomePage, true);
            await Navigation.PushModalAsync(myHomePage);
        }
示例#10
0
        private void OnDeviceConnectionLost(object sender, DeviceErrorEventArgs e)
        {
            Devices.FirstOrDefault(d => d.Id == e.Device.Id)?.Update();

            _userDialogs.HideLoading();
            _userDialogs.ErrorToast("Error", $"Connection LOST {e.Device.Name}", TimeSpan.FromMilliseconds(6000));
        }
        private async void LoadCharacteristics()
        {
            _userDialogs.ShowLoading("Loading characteristics...");
            try
            {
                Characteristics = new List <ICharacteristic>(await _service.GetCharacteristicsAsync());
            }
            catch (Exception)
            {
            }

            _userDialogs.HideLoading();
        }
示例#12
0
        // Private methods

        private async Task AttemptLogInAsync()
        {
            Email.Value    = Email.Value?.Trim();
            Password.Value = Password.Value?.Trim();

            if (_validationHelper.Validate())
            {
                _userDialogs.ShowLoading("Login");

                var serviceResult = await _authService.Login(Email.Value, Password.Value);

                if (serviceResult.Success)
                {
                    ClearStack.Execute(null);
                    await _navigationService.Navigate <HomeViewModel>();

                    await _bottomNavigationViewModelService.Show(new BottomNavigationViewModel.PrepareModel()
                    {
                        CheckedItem = Enums.BottomNavigationViewCheckedItemType.Home
                    });

                    _userDialogs.HideLoading();
                }
                else
                {
                    _userDialogs.HideLoading();

                    await _userDialogs.AlertAsync(new AlertConfig
                    {
                        Title   = "Login failed",
                        Message = serviceResult.Error.Description,
                        OkText  = "OK"
                    });

                    InitValidationCommand.Execute(null);
                }
            }
        }
示例#13
0
        public async void Button_Clicked(object sender, EventArgs e)
        {
            IUserDialogs Dialogs = UserDialogs.Instance;



            if (!string.IsNullOrWhiteSpace(usuario.Text) && !string.IsNullOrWhiteSpace(password.Text))
            {
                Login login = repo.ConnectUser(usuario.Text, password.Text).Result;

                if (login.Status == "ok")
                {
                    App.IsUserLoggedIn = true;

                    // REMEMBER LOGIN STATUS!
                    Application.Current.Properties["IsLoggedIn"] = true;
                    Settings.IsLoggedIn = true;

                    App.Current.Properties["token"] = login.Jwt;

                    Dialogs.ShowLoading("Ingresando...");
                    await Task.Delay(2000);

                    Dialogs.HideLoading();

                    InicioPage myHomePage = new InicioPage();
                    NavigationPage.SetHasNavigationBar(myHomePage, false);
                    await Navigation.PushModalAsync(myHomePage);
                }
            }
            else
            {
                Dialogs.ShowLoading("Datos NO válidos...");
                await Task.Delay(1000);

                Dialogs.HideLoading();
            }
        }
示例#14
0
        async void OnAddTokenButtonClicked(object sender, EventArgs e)
        {
            IUserDialogs Dialogs = UserDialogs.Instance;

            Dialogs.ShowLoading("Espere...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            MainPage myHomePage = new MainPage();

            NavigationPage.SetHasNavigationBar(myHomePage, false);
            await Navigation.PushAsync(myHomePage);
        }
示例#15
0
        private async Task LogIn()
        {
            if (string.IsNullOrWhiteSpace(EmailCell.Entry.Text))
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                  AppResources.EmailAddress), AppResources.Ok);

                return;
            }

            if (string.IsNullOrWhiteSpace(PasswordCell.Entry.Text))
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                  AppResources.MasterPassword), AppResources.Ok);

                return;
            }

            _userDialogs.ShowLoading(AppResources.LoggingIn, MaskType.Black);
            var result = await _authService.TokenPostAsync(EmailCell.Entry.Text, PasswordCell.Entry.Text);

            _userDialogs.HideLoading();
            if (!result.Success)
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, result.ErrorMessage, AppResources.Ok);

                return;
            }

            PasswordCell.Entry.Text = string.Empty;

            if (result.TwoFactorRequired)
            {
                _googleAnalyticsService.TrackAppEvent("LoggedIn To Two-step");
                await Navigation.PushAsync(new LoginTwoFactorPage(EmailCell.Entry.Text, result));

                return;
            }

            _googleAnalyticsService.TrackAppEvent("LoggedIn");

            if (Device.RuntimePlatform == Device.Android)
            {
                _pushNotification.Register();
            }

            var task = Task.Run(async() => await _syncService.FullSyncAsync(true));

            Application.Current.MainPage = new MainPage();
        }
示例#16
0
        public async void ClickedRegistrarse(object sender, EventArgs e)
        {
            IUserDialogs Dialogs = UserDialogs.Instance;

            Dialogs.ShowLoading("Espere por favor...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            RegisterPage myHomePage = new RegisterPage();

            NavigationPage.SetHasNavigationBar(myHomePage, true);
            await Navigation.PushModalAsync(myHomePage);
        }
        // Private methods

        private async Task AttemptLogOutAsync()
        {
            _userDialogs.ShowLoading("Logout");
            var serviceResult = await _authService.Logout();

            await _topNavigationViewModelService.Close();

            await _bottomNavigationViewModelService.Close();

            ClearStack.Execute(null);
            await _navigationService.Navigate <LoginViewModel>();

            _userDialogs.HideLoading();
        }
示例#18
0
        public async void OnSignInClicked(object sender, EventArgs e)
        {
            IUserDialogs Dialogs = UserDialogs.Instance;
            Dialogs.ShowLoading("Loading...");
            await Task.Delay(1000);
            Dialogs.HideLoading();

            Device.BeginInvokeOnMainThread(async () =>
            {
                await Navigation.PushModalAsync(new PreSigninPage());
            });
            

            
        }
示例#19
0
        async Task LoadLocalOrders()
        {
            Xamarin.Forms.Device.BeginInvokeOnMainThread(() => _userDialogs.ShowLoading("Carregando seus pedidos"));
            var orders = await _orderService.GetAllAsync();

            if (orders != null && orders.Any())
            {
                Orders = new ObservableCollection <Order>(orders);
            }
            else
            {
                Orders = new ObservableCollection <Order>(OrderHelper.Orders);
            }
            Xamarin.Forms.Device.BeginInvokeOnMainThread(() => _userDialogs.HideLoading());
        }
示例#20
0
        public async Task SaveQuote()
        {
            _userDialogs.ShowLoading("Saving Quote");

            try
            {
                await _databaseService.UpdateQuote(Quote);
            }
            finally
            {
                _userDialogs.HideLoading();
            }

            await CoreMethods.PopPageModel(Quote);
        }
        private async void Connect()
        {
            _userDialogs.ShowLoading("Trying to connect");

            try
            {
                if (!await HasLocationPermissionAsync())
                {
                    return;
                }

                await _example.InitHostAndDiscoverAsync(false).ConfigureAwait(true);

                if (_example.SelectedHub != null)
                {
                    _userDialogs.HideLoading();
                    _userDialogs.Toast($"Connected to {_example.SelectedHub.AdvertisingName }", TimeSpan.FromSeconds(3));
                    _userDialogs.ShowLoading($"Connected to {_example.SelectedHub.AdvertisingName } - Executing action");
                    await _example.ExecuteAsync();

                    _userDialogs.Toast($"Executed action successfully", TimeSpan.FromSeconds(3));
                }
                else
                {
                    _userDialogs.Toast($"Could not connect", TimeSpan.FromSeconds(3));
                }
            }
            catch (Exception e)
            {
                _userDialogs.Toast($"Error: {e.Message}", TimeSpan.FromSeconds(3));
            }
            finally
            {
                _userDialogs.HideLoading();
            }
        }
示例#22
0
        private async Task LogIn()
        {
            if (string.IsNullOrWhiteSpace(CodeCell.Entry.Text))
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                  AppResources.VerificationCode), AppResources.Ok);

                return;
            }

            var request = new TokenRequest
            {
                Email = _email,
                MasterPasswordHash = _masterPasswordHash,
                Token    = CodeCell.Entry.Text.Replace(" ", ""),
                Provider = 0, // Authenticator app (only 1 provider for now, so hard coded)
                Device   = new DeviceRequest(_appIdService, _deviceInfoService)
            };

            _userDialogs.ShowLoading(AppResources.ValidatingCode, MaskType.Black);
            var response = await _authService.TokenPostAsync(request);

            _userDialogs.HideLoading();
            if (!response.Succeeded)
            {
                await DisplayAlert(AppResources.AnErrorHasOccurred, response.Errors.FirstOrDefault()?.Message, AppResources.Ok);

                return;
            }

            _cryptoService.Key         = _key;
            _tokenService.Token        = response.Result.AccessToken;
            _tokenService.RefreshToken = response.Result.RefreshToken;
            _authService.UserId        = _tokenService.TokenUserId;
            _authService.Email         = _tokenService.TokenEmail;
            _settings.AddOrUpdateValue(Constants.LastLoginEmail, _authService.Email);
            _googleAnalyticsService.RefreshUserId();
            _googleAnalyticsService.TrackAppEvent("LoggedIn From Two-step");

            if (Device.OS == TargetPlatform.Android)
            {
                _pushNotification.Register();
            }

            var task = Task.Run(async() => await _syncService.FullSyncAsync(true));

            Application.Current.MainPage = new MainPage();
        }
示例#23
0
        protected override async void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            dialogs.ShowLoading("Cargando...");

            var liscontacts = await contactAgent.GetAll(CurrentUser.Username);

            await ChatService.InitAsync(CurrentUser.Username);

            Contacts = new ObservableCollection <Contact>(liscontacts.objectResult);

            //Rooms = await ChatService.GetRooms();

            dialogs.HideLoading();
        }
示例#24
0
        public async void OnClickedFinalizar(object sender, EventArgs args)
        {
            if (nombre.Text != null && password.Text != null && correo.Text != null && password.Text != null && telefono.Text != null && password.Text.Equals(passwordconf.Text))
            {
                MD5HashX2 pwtohash = new MD5HashX2();

                User usuario = new User();
                usuario.name               = nombre.Text;
                usuario.Lastname           = apellido.Text;
                usuario.Id                 = userid.Text;
                usuario.Emal               = correo.Text;
                usuario.Password           = pwtohash.MD5Hash(password.Text);
                usuario.City               = ciudad.SelectedIndex.ToString();
                usuario.Address            = address.Text;
                usuario.Cellnumber         = telefono.Text;
                usuario.Gender             = lstViewGeneros.SelectedIndex.ToString();
                usuario.Birdhdate          = fechaNacimiento.Date;
                usuario.Datapolicy         = true;
                usuario.Termsandconditions = true;


                Repository repository = new Repository();

                try
                {
                    userCreate user = repository.postUserCreate(usuario).Result;
                    Dialogs.ShowLoading(user.Message.ToString());;
                    await Task.Delay(2000);

                    Dialogs.HideLoading();
                    InicioPage myHomePage = new InicioPage();
                    NavigationPage.SetHasNavigationBar(myHomePage, false);
                    await Navigation.PushModalAsync(myHomePage);
                }

                catch (Exception ex)
                {
                    await DisplayAlert("Registrarse Error", ex.Message, "Gracias");
                }
            }


            else
            {
                await DisplayAlert("Registrarse", "Verifique la Información", "Gracias");
            }
        }
示例#25
0
        public override async void Init(object initData)
        {
            base.Init(initData);

            try
            {
                _userDialogs.ShowLoading("Loading contacts...", MaskType.Gradient);
                Contacts = await _dataService.GetContacts();
            }
            catch
            {
            }
            finally
            {
                _userDialogs.HideLoading();
            }
        }
示例#26
0
 public override async void Init(object initData)
 {
     base.Init(initData);
     _userDialogs.ShowLoading();
     try
     {
         QuoteList = await _dataService.GetQuotes();
     }
     catch (Exception Ex)
     {
         _userDialogs.ShowError($"Error getting data: {Ex.Message}", 3000);
     }
     finally
     {
         _userDialogs.HideLoading();
     }
 }
        void RandomList(int position)
        {
            _userDialogs.ShowLoading("Carregando mais registros");
            var max = LastPosition + position;

            for (int i = LastPosition; i < max; i++)
            {
                Numbers.Add(new Number
                {
                    Id          = Guid.NewGuid(),
                    Description = i.ToString()
                });
            }

            LastPosition = max;
            _userDialogs.HideLoading();
        }
        public async void OnSaveHVAC(object sender, EventArgs e)
        {
            try

            {
                //var path = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
                //var filename = Path.Combine(path.ToString(), "myfile.txt");

                IUserDialogs Dialogs = UserDialogs.Instance;
                Dialogs.ShowLoading("Saving...");
                await Task.Delay(2000);

                Repository repository = new Repository();
                Dialogs.HideLoading();


                HVAC hvac = new HVAC();
                hvac.PropertyAsset = new PropertyAsset();



                var a = int.Parse(App.Current.Properties["PropertyId"].ToString());



                hvac.IDPropertyAsset = a;


                hvac.Brand       = brandplug.Text;
                hvac.Warranty    = warrantyplug.Text;
                hvac.Description = descripctionplug.Text;
                hvac.Comments    = commentsplug.Text;
                hvac.FFile       = fileNameplug;

                hvac.IDUSERPropertyAsset = int.Parse(App.Current.Properties["UsersId"].ToString());
                repository.PostHVAC(hvac);

                await DisplayAlert("HVAC", "The HVAC:  " + brandplug.Text + "  is saved ", "OK");

                GoToPage();
            }
            catch (Exception ex)
            {
                await DisplayAlert("HVAC", ex.Message, "OK");
            }
        }
示例#29
0
        async void  OnGeneratePing(object sender, EventArgs e)
        {
            Application.Current.Properties["PingCreado"] = true;

            IUserDialogs Dialogs = UserDialogs.Instance;

            Dialogs.ShowLoading("Creando Ping...");
            await Task.Delay(2000);

            Dialogs.HideLoading();

            MainPage myHomePage = new MainPage();


            NavigationPage.SetHasNavigationBar(myHomePage, false);

            await Navigation.PushAsync(myHomePage);
        }
        private async void LoadServices()
        {
            try
            {
                _userDialogs.ShowLoading("Discovering services...");

                Services = await _device.GetServicesAsync();
                await RaisePropertyChanged(() => Services);
            }
            catch (Exception ex)
            {
                await _userDialogs.AlertAsync(ex.Message, "Error while discovering services");

                Trace.Message(ex.Message);
            }
            finally
            {
                _userDialogs.HideLoading();
            }
        }