コード例 #1
0
        private async Task StartOfPauseCommandExecute()
        {
            if (IsRunning)
            {
                if (IsInWork)
                {
                    var result = await Dialogs.ConfirmAsync(new ConfirmConfig
                    {
                        Message    = "¿Seguro quieres detener tu ciclo de trabajo? Esto reiniciará tu temporizador a cero.",
                        OkText     = "Parar",
                        CancelText = "¡Quiero seguir!"
                    });

                    if (result)
                    {
                        Ellapsed = TimeSpan.Zero;
                        StopTimer();
                    }
                }
                else if (IsInBreak)
                {
                    Dialogs.Alert("No puedes detener un ciclo de descanso, aprovéchalo mientras tengas tiempo.");
                }
            }
            else
            {
                if (!IsInWork && !IsInBreak)
                {
                    IsInWork = true;
                }
                StartTimer();
            }
        }
コード例 #2
0
        public async Task <bool> RemoveItem(Contact contact)
        {
            var id = contact?.Id;

            if (string.IsNullOrEmpty(id) && !IsConnected)
            {
                return(false);
            }

            Settings.LastUpdate = DateTime.UtcNow;

#if LOCALWRITES
            contacts.Add(contact);

            await Dialogs.Alert(new AlertInfo
            {
                Cancel  = "OK",
                Title   = "Local Only Mode",
                Message = "Currently running in local write mode. Data will not be sent to the server."
            });

            return(true);
#endif

            var response = await client.DeleteAsync($"api/Contacts/{id}");


            return(response.IsSuccessStatusCode);
        }
コード例 #3
0
        public async Task <bool> AddItem(Contact contact)
        {
            if (contact == null)
            {
                return(false);
            }

            Settings.LastUpdate = DateTime.UtcNow;

            var serializedContact = JsonSerializer.Serialize(contact);

#if LOCALWRITES
            contact.Id = Guid.NewGuid().ToString();
            contacts.Add(contact);

            await Dialogs.Alert(new AlertInfo
            {
                Cancel  = "OK",
                Title   = "Local Only Mode",
                Message = "Currently running in local write mode. Data will not be sent to the server."
            });

            return(true);
#endif

            if (!IsConnected)
            {
                await OfflineAlert();

                return(false);
            }

            var response = await client.PostAsync($"api/Contacts", new StringContent(serializedContact, Encoding.UTF8, "application/json"));

            if (response.IsSuccessStatusCode)
            {
                var json = await response.Content.ReadAsStringAsync();

                var c = JsonSerializer.Deserialize <Contact>(json);
                contact.Id = c.Id;
                return(true);
            }

            return(false);
        }
コード例 #4
0
        private void Search(object SearchCustNo)
        {
            if (!string.IsNullOrEmpty(CustomerSearchCriteria.ClientName) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.Contact) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.CustomerNo) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.Phone) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.PropertyName) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.SalesCode) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.StreetName) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.StreetNo) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.MeterNo) ||
                !string.IsNullOrEmpty(CustomerSearchCriteria.Premise))
            {
                IsBusy = true;
                ServiceAgent.SearchCustomer(CustomerSearchCriteria, (s, e) =>
                {
                    if (e.Error == null)
                    {
                        Customers = e.Result;
                        FillSortDropdown();
                        if (Customers.Count > 0)
                        {
                            SelectedCustomer = Customers[0];
                        }
                        else
                        {
                            Dialogs.Alert(ApplicationResources.GetString(ConstantResources.LTSEARCH), ApplicationResources.GetString(ConstantResources.LTNOCLIENTS), null);
                        }
                    }
                    else
                    {
                        HandleError(e.Error);
                    }

                    IsBusy = false;
                });
            }
            else
            {
                Dialogs.Alert(ApplicationResources.GetString(ConstantResources.LTSEARCHCRITERIA), ApplicationResources.GetString(ConstantResources.LTFILLSEARCHCRITERIA), null);
            }
        }
コード例 #5
0
ファイル: EstatesViewModel.cs プロジェクト: 24RMS42/SIDE
        private async Task UpdateMasterData()
        {
            try
            {
                using (var dlg = this.Dialogs.Loading("Progress (No Cancel)"))
                {
                    string res = await _lookupsService.FetchLookups(true);

                    if (res != null && res.Equals("SUCCESS"))
                    {
                        //this.Dialogs.Alert("Master data has been updated.");
                        Dialogs.Alert("Master data has been updated.");
                    }
                    else
                    {
                        //this.Dialogs.ShowError("Sorry, could not receive Master data!");
                        Dialogs.ShowError("Sorry, could not receive Master data!");
                    }

                    if (!string.IsNullOrEmpty(EstateId))
                    {
                        var stat = await _estatesLookupsService.FetchEstateLookups(EstateId, true);

                        if (stat != null && stat.Equals("SUCCESS"))
                        {
                            Dialogs.Alert("Estate background data has been updated");
                        }
                        else
                        {
                            Dialogs.ShowError("Sorry, could not receive data!");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Dialogs.ShowError(e.Message);
            }
        }
コード例 #6
0
        async Task ExecuteEmailCommand(string email)
        {
            if (string.IsNullOrWhiteSpace(email))
            {
                return;
            }

            try
            {
                await Email.ComposeAsync(string.Empty, string.Empty, email);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Dialogs.Alert(new AlertInfo
                {
                    Title   = "Not Supported",
                    Message = "Email is not supported on this device.",
                    Cancel  = "OK"
                });
            }
        }
コード例 #7
0
        async Task ExecuteMessageNumberCommand(string number)
        {
            if (string.IsNullOrWhiteSpace(number))
            {
                return;
            }

            try
            {
                await Sms.ComposeAsync(new SmsMessage(string.Empty, number.SanitizePhoneNumber()));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Dialogs.Alert(new AlertInfo
                {
                    Title   = "Not Supported",
                    Message = "Sms is not supported on this device.",
                    Cancel  = "OK"
                });
            }
        }
コード例 #8
0
        async Task ExecuteDialNumberCommand(string number)
        {
            if (string.IsNullOrWhiteSpace(number))
            {
                return;
            }

            try
            {
                PhoneDialer.Open(number.SanitizePhoneNumber());
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await Dialogs.Alert(new AlertInfo
                {
                    Title   = "Not Supported",
                    Message = "Phone calls are not supported on this device.",
                    Cancel  = "OK"
                });
            }
        }
コード例 #9
0
 async Task ExecuteGetDirectionsCommand(Contact MyContacts)
 {
     try
     {
         await Map.OpenAsync(new Placemark
         {
             AdminArea    = MyContacts.State,
             Locality     = MyContacts.City,
             PostalCode   = MyContacts.PostalCode,
             Thoroughfare = MyContacts.AddressString
         });
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         await Dialogs.Alert(new AlertInfo
         {
             Title   = "Not Supported",
             Message = "Unable to open a map application on the device..",
             Cancel  = "OK"
         });
     }
 }
コード例 #10
0
        async Task ExecuteSaveCommand()
        {
            if (string.IsNullOrWhiteSpace(Contact.LastName) || string.IsNullOrWhiteSpace(Contact.FirstName))
            {
                await Dialogs.Alert(new AlertInfo
                {
                    Title   = "Invalid name!",
                    Message = "An MyContacts must have both a first and last name.",
                    Cancel  = "OK"
                });

                return;
            }

            if (!RequiredAddressFieldCombinationIsFilled)
            {
                await Dialogs.Alert(new AlertInfo
                {
                    Title   = "Invalid address!",
                    Message = "You must enter either a street, city, and state combination, or a postal code.",
                    Cancel  = "OK"
                });

                return;
            }

            if (isNew)
            {
                await DataSource.AddItem(Contact);
            }
            else
            {
                await DataSource.UpdateItem(Contact);
            }
            await PopAsync();
        }
コード例 #11
0
 Task OfflineAlert() => Dialogs.Alert(new AlertInfo
 {
     Cancel  = "OK",
     Title   = "Offline",
     Message = "Currently offline, please check internet connection."
 });
コード例 #12
0
 Task LocalOnlyModeAlert() => Dialogs.Alert(new AlertInfo
 {
     Cancel  = "OK",
     Title   = "Local Only Mode",
     Message = "Currently running in local write mode. Data will not be sent to the server."
 });