Пример #1
0
        private async void TomarVideoEjecutar()
        {
            try
            {
                await CrossMedia.Current.Initialize();

                if (!CrossMedia.Current.IsTakeVideoSupported)
                {
                    await _userDialogs.AlertAsync("No se tiene acceso a grabar videos, revise su configuración", "VideoS", "OK");

                    return;
                }

                MediaFile file = await CrossMedia.Current.TakeVideoAsync(new StoreVideoOptions
                {
                    Name = "Video.mp4"
                });

                if (file == null)
                {
                    return;
                }

                RutaVideo = file.Path;
                ObtenerVideos();
            }
            catch (Exception error)
            {
                _userDialogs.Toast(error.Message);
            }
        }
        private async Task AddComment()
        {
            try
            {
                IsBusy = true;
                await _commentsService.AddCommentAsync(_commentParam.ParentId, CommentText,
                                                       _commentParam.ParentIsArticle);

                await CoreMethods.PopPageModel();
            }
            catch (ServiceAuthenticationException e)
            {
                await _userDialogs.AlertAsync(title : "Ошибка авторизации",
                                              message : $"{e.Content}", okText : "Ok");
            }
            catch (HttpRequestExceptionEx e)
            {
                await _userDialogs.AlertAsync(title : "Ошибка доступа к серверу",
                                              message : $"HttpCode: {e.HttpCode} Message: {e.Message}", okText : "Ok");
            }
            catch (Exception e)
            {
                await _userDialogs.AlertAsync(title : "Ошибка",
                                              message : $"{e.Message}", okText : "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
        private async Task Login()
        {
            if (!string.IsNullOrWhiteSpace(Username) && !string.IsNullOrWhiteSpace(Password))
            {
                var result = await _loginProvider.LoginAsync();

                if (!result)
                {
                    await
                    _dialogs.AlertAsync(
                        _localizationProvider.LoginFailedMessage,
                        _localizationProvider.LoginFailedTitle,
                        _localizationProvider.LoginFailedCancel);
                }
                else
                {
                    await Navigation.PushAsync((Page)_viewFactory.Get <IHomePageViewModel>());
                }
            }
            else
            {
                await
                _dialogs.AlertAsync(
                    _localizationProvider.ErrorLoginEmpty,
                    _localizationProvider.LoginFailedTitle,
                    _localizationProvider.LoginFailedCancel);
            }
        }
Пример #4
0
        private async Task SearchPropertiesAsync()
        {
            if (string.IsNullOrWhiteSpace(Location))
            {
                await _useDialogs.AlertAsync("Please specify location");

                return;
            }

            try
            {
                IsBusy = true;

                var locationDetails = await _locationPromptService.GetLocationDetails(Location);

                if (locationDetails.Any() == false)
                {
                    await _useDialogs.AlertAsync("No results found. Please try a different location");

                    return;
                }

                await _navigationService.Navigate <PropertiesViewModel, LocationPromptResult>(locationDetails.First());
            }
            catch (Exception exc)
            {
                _log.ErrorException("An error has occurred while trying to get location prompt details", exc);
                await _useDialogs.AlertAsync("An error has occurred. Please try again.");
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #5
0
        public async Task RunSafe(Task task, bool ShowLoading = true, string loadinMessage = null)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                if (ShowLoading)
                {
                    UserDialogs.Instance.ShowLoading(loadinMessage ?? "Loading...");
                }

                await task;
            }
            catch (Exception e)
            {
                IsBusy = false;
                UserDialogs.Instance.HideLoading();
                Debug.WriteLine(e.ToString());
                await Dialog.AlertAsync("Check your internet connection", "Error", "Ok");
            }
            finally
            {
                IsBusy = false;
                if (ShowLoading)
                {
                    UserDialogs.Instance.HideLoading();
                }
            }
        }
        async Task SignUp()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(Email) &&
                    string.IsNullOrWhiteSpace(UserName) &&
                    string.IsNullOrWhiteSpace(Password))
                {
                    await _userDialogs.AlertAsync("All fields are required", "Required fields", "Ok");

                    return;
                }

                await _userRepo.Insert(new User
                {
                    Email     = Email,
                    UserName  = UserName,
                    Password  = Password,
                    DateAdded = DateTime.Now
                });

                await _userDialogs.AlertAsync("User created", "Info", "Ok");

                await _navigationService.GoBackAsync();
            }
            catch (Exception ex)
            {
                ErrorLog.LogError("Save User", ex);
            }
        }
Пример #7
0
        private async Task OnLoginCommandAsync()
        {
            if (string.IsNullOrWhiteSpace(Email))
            {
                await _userDialogsService.AlertAsync(Strings.EnterEmailMessage);

                return;
            }

            if (string.IsNullOrWhiteSpace(Password))
            {
                await _userDialogsService.AlertAsync(Strings.EnterPasswordMessage);

                return;
            }

            AOResult result;

            using (_userDialogsService.Loading())
            {
                result = await _authorizationService.LoginAsync(Email, Password);
            }

            if (result.IsSuccess)
            {
                await _navigationService.NavigateAsync('/' + nameof(NavigationPage) + '/' + nameof(RootView), useModalNavigation : false);
            }
            else
            {
                await _userDialogsService.AlertAsync(Strings.IncorrectLoginDataMessage);
            }
        }
Пример #8
0
        private async Task SynchronizeDataAsync(bool byPassCurrentAction = false)
        {
            try
            {
                if (_muscularGroups == null)
                {
                    var muscularGroupService = new MuscularGroupService(_dbContext);
                    _muscularGroups = muscularGroupService.FindMuscularGroups();
                }

                if (_muscles == null)
                {
                    var muscleService = new MuscleService(_dbContext);
                    _muscles = muscleService.FindMuscles();
                }

                if (_bodyExercises == null)
                {
                    var bodyExerciseService = new BodyExerciseService(_dbContext);
                    _bodyExercises = bodyExerciseService.FindBodyExercises();
                }

                /*
                 * if(onShow && _muscularGroups != null && _muscularGroups.Count > 0 && _muscles != null)
                 * {
                 *  MuscularGroup = _muscularGroups[0];
                 *  Muscle = _muscles.Where(m => m.MuscularGroupId == MuscularGroup.Id).FirstOrDefault();
                 * }*/

                //Refresh BodyExercise
                BindingBodyExercises.Clear();
                if (MuscularGroup != null && Muscle != null && _bodyExercises != null && _bodyExercises.Count > 0)
                {
                    BindingBodyExercise bindingBodyExercise;
                    var bodyexerciseList = _bodyExercises.Where(be => be.MuscleId == Muscle.Id);
                    foreach (var bodyexercise in bodyexerciseList)
                    {
                        bindingBodyExercise = new BindingBodyExercise()
                        {
                            BodyExercise = bodyexercise,
                            Name         = bodyexercise.Name
                        };
                        BindingBodyExercises.Add(bindingBodyExercise);
                    }

                    if (BindingBodyExercises.Count > 0)
                    {
                        List <BindingBodyExercise> bindingList = new List <BindingBodyExercise>();
                        bindingList.AddRange(BindingBodyExercises);
                        Task t = CachingImagesAsync(bindingList);
                    }
                }
                OnPropertyChanged("BindingBodyExercises");
            }
            catch (Exception except)
            {
                await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK));
            }
        }
        public async void CreateForum()
        {
            await ForumDatabase.getForumDB.SaveForum(Forum);

            await _dialog.AlertAsync("O fórum foi criado com sucesso. Os coordenadores serão notificados em breve."
                                     , "Fórum Criado"
                                     , "OK");
        }
Пример #10
0
        void VoltageEvent(object sender, CSLibrary.Notification.VoltageEventArgs e)
        {
            if (e.Voltage == 0xffff)
            {
                _labelVoltage = "CS108 Bat. ERROR"; //			3.98v
            }
            else
            {
                // to fix CS108 voltage bug
                if (_cancelVoltageValue)
                {
                    _cancelVoltageValue = false;
                    return;
                }

                double voltage = (double)e.Voltage / 1000;

                {
                    var batlow = ClassBattery.BatteryLow(voltage);

                    if (BleMvxApplication._batteryLow && batlow == ClassBattery.BATTERYLEVELSTATUS.NORMAL)
                    {
                        BleMvxApplication._batteryLow = false;
                        RaisePropertyChanged(() => labelVoltageTextColor);
                    }
                    else
                    if (!BleMvxApplication._batteryLow && batlow != ClassBattery.BATTERYLEVELSTATUS.NORMAL)
                    {
                        BleMvxApplication._batteryLow = true;

                        if (batlow == ClassBattery.BATTERYLEVELSTATUS.LOW)
                        {
                            _userDialogs.AlertAsync("14% Battery Life Left, Please Recharge CS108 or Replace Freshly Charged CS108B");
                        }
                        else if (batlow == ClassBattery.BATTERYLEVELSTATUS.LOW_17)
                        {
                            _userDialogs.AlertAsync("8% Battery Life Left, Please Recharge CS108 or Replace with Freshly Charged CS108B");
                        }

                        RaisePropertyChanged(() => labelVoltageTextColor);
                    }
                }

                switch (BleMvxApplication._config.BatteryLevelIndicatorFormat)
                {
                case 0:
                    _labelVoltage = "CS108 Bat. " + voltage.ToString("0.000") + "v";     //			v
                    break;

                default:
                    _labelVoltage = "CS108 Bat. " + ClassBattery.Voltage2Percent(voltage).ToString("0") + "%";     //			%
                    //_labelVoltage = ClassBattery.Voltage2Percent((double)e.Voltage / 1000).ToString("0") + "% " + ((double)e.Voltage / 1000).ToString("0.000") + "v"; //			%
                    break;
                }
            }

            RaisePropertyChanged(() => labelVoltage);
        }
Пример #11
0
        public async Task OpenPhotoTaker()
        {
            ActivateSpinner();

            var rnd       = new Random();
            var rndEnding = rnd.Next(100, 9999);

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await _userDialoags.AlertAsync("It appears that no camera is available", "No Camera", "OK");

                return;
            }
            var myfile = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
            {
                PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Small,        //resizes the photo to 50% of the original
                CompressionQuality = 92,                                               // Int from 0 to 100 to determine image compression level
                DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Front,     // determine which camera to default to
                Directory          = "CC Directors",
                Name        = $"myprofilepic{rndEnding}",
                SaveToAlbum = true,                                                     // this saves the photo to the camera roll
                //if we need the public album path --> var aPpath = file.AlbumPath;
                //if we need a private path --> var path = file.Path;
                AllowCropping = false,
            });

            file = myfile;
            if (file == null)
            {
                DeactivateSpinner();
                return;
            }

            Debug.WriteLine("File Location: " + file.Path + "     <--- here");


            // imageChanged = true;
            setImage = ImageSource.FromStream(() =>
            {
                var stream      = file.GetStream();
                var path        = file.Path;
                var pathprivate = file.AlbumPath;
                Debug.WriteLine(path.ToString());
                Debug.WriteLine(pathprivate.ToString());
                profileimage = file.GetStream();


                //file.Dispose();
                return(stream);
            });

            await DetermineEmotion();



            DeactivateSpinner();
        }
Пример #12
0
        void StateChangedEvent(object sender, CSLibrary.Events.OnStateChangedEventArgs e)
        {
            if (e.state == CSLibrary.Constants.RFState.INITIALIZATION_COMPLETE)
            {
                BleMvxApplication._batteryLow = false;
                RaisePropertyChanged(() => labelVoltageTextColor);

                // for cloud server
                //BleMvxApplication._reader.siliconlabIC.GetSerialNumber();

                // Set Country and Region information
                if (BleMvxApplication._config.RFID_Region == CSLibrary.Constants.RegionCode.UNKNOWN)
                {
                    BleMvxApplication._config.RFID_Region = BleMvxApplication._reader.rfid.SelectedRegionCode;

                    if (BleMvxApplication._reader.rfid.IsFixedChannel)
                    {
                        BleMvxApplication._config.RFID_FrequenceSwitch = 1;
                        BleMvxApplication._config.RFID_FixedChannel    = BleMvxApplication._reader.rfid.SelectedChannel;
                    }
                    else
                    {
                        BleMvxApplication._config.RFID_FrequenceSwitch = 0; // Hopping
                    }
                }

                // the library auto cancel the task if the setting no change
                switch (BleMvxApplication._config.RFID_FrequenceSwitch)
                {
                case 0:
                    BleMvxApplication._reader.rfid.SetHoppingChannels(BleMvxApplication._config.RFID_Region);
                    break;

                case 1:
                    BleMvxApplication._reader.rfid.SetFixedChannel(BleMvxApplication._config.RFID_Region, BleMvxApplication._config.RFID_FixedChannel);
                    break;

                case 2:
                    BleMvxApplication._reader.rfid.SetAgileChannels(BleMvxApplication._config.RFID_Region);
                    break;
                }

                if (BleMvxApplication._reader.rfid.GetFirmwareVersion() < 0x00020614 || BleMvxApplication._reader.siliconlabIC.GetFirmwareVersion() < 0x00010009 || BleMvxApplication._reader.bluetoothIC.GetFirmwareVersion() < 0x0001000E)
                {
                    _userDialogs.AlertAsync("Firmware too old" + Environment.NewLine +
                                            "Please upgrade firmware to at least :" + Environment.NewLine +
                                            "RFID Processor firmware: V2.6.20" + Environment.NewLine +
                                            "SiliconLab Firmware: V1.0.9" + Environment.NewLine +
                                            "Bluetooth Firmware: V1.0.14");
                }

                ClassBattery.SetBatteryMode(ClassBattery.BATTERYMODE.IDLE);
            }
        }
Пример #13
0
 private async Task SynchronizeDataAsync()
 {
     try
     {
         FillWeekOfYearDescription(TrainingWeek);
         FillWeekDays(TrainingWeek);
     }
     catch (Exception except)
     {
         await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK));
     }
 }
        // MUST be geant location permission
        private async void GetLocationPermission()
        {
            if (await _permissions.CheckPermissionStatusAsync(Permission.Location) != PermissionStatus.Granted)
            {
                if (Device.RuntimePlatform == Device.Android)
                {
                    await _userDialogs.AlertAsync("This app collects location data in the background.  In terms of the features using this location data in the background, this App collects location data when it is reading temperature RFID tag in the “Magnus S3 with GPS for Advantech” page.  The purpose of this is to correlate the RFID tag with the actual GNSS location of the tag.  In other words, this is to track the physical location of the logistics item tagged with the RFID tag.");
                }
//                await _userDialogs.AlertAsync("This app collects location data to enable temperature RFID tag inventory with GNSS location mapped to each tag data when the app is open and in the foreground.  This location data collection is not carried out when the app is closed or not in use.   Specifically, this App collects location data when it is reading temperature RFID tag in the “Magnus S3 with GPS for Advantech” page.");

                await _permissions.RequestPermissionsAsync(Permission.Location);
            }
        }
Пример #15
0
        public async Task SyncTransaction()
        {
            try
            {
                await transactionTable.PullAsync("allTransactions", transactionTable.CreateQuery());

                await MobileService.SyncContext.PushAsync();
            }
            catch (Exception ex)
            {
                await userDialog.AlertAsync(string.Format("Failed synchronising. Error : {0}", ex.Message));
            }
        }
Пример #16
0
        private async Task SynchronizeDataAsync()
        {
            try
            {
                if (_bodyExerciseList == null)
                {
                    var bodyExerciseService = new BodyExerciseService(_dbContext);
                    _bodyExerciseList = bodyExerciseService.FindBodyExercises();
                }

                //Create BindingCollection
                GroupedTrainingExercises.Clear();

                if (_trainingDays != null)
                {
                    foreach (var trainingDay in _trainingDays)
                    {
                        CreateOrReplaceBindingTrainingDay(trainingDay);
                    }
                }
            }
            catch (Exception except)
            {
                await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK));
            }
        }
Пример #17
0
        private Task DisplayNotification(string titleKey, string messageKey)
        {
            var title   = LocalizationService.GetLocalizedString(titleKey);
            var message = LocalizationService.GetLocalizedString(messageKey);

            return(DialogsService.AlertAsync(message, title));
        }
Пример #18
0
        private void getApiPosts()
        {
            dialogService.ShowLoading();

            apiService.GetPosts((List <Post> data, Exception error) =>
            {
                dialogService.HideLoading();

                if (error == null)
                {
                    this.ItemsPosts.Clear();
                    foreach (Post p in data)
                    {
                        this.ItemsPosts.Add(p);
                    }
                }
                else
                {
                    if (error.GetType() == typeof(ApiException))
                    {
                        // TODO
                        dialogService.AlertAsync("API Error!", "Warning", "OK");
                    }
                    else if (error.GetType() == typeof(NetworkException))
                    {
                        // TODO
                    }
                    else if (error.GetType() == typeof(ArgumentNullException))
                    {
                        // TODO
                    }
                }
            });
        }