private FilterFeatureData ApplyFilter()
        {
            // Build filter
            // Get filter data from IBOutlets

            // Try to get Number of Event
            string numberEvent = "";

            if (NumberEventTextField.Text.Length > 0)
            {
                numberEvent = NumberEventTextField.Text;
            }

            string title = TitleTextField.Text;



            // Build filter objects
            FilterFeatureData filter = new FilterFeatureData();

            filter.Username = numberEvent;
            filter.Detail   = title;
            filter.Sector   = SectionSelected;
            filter.FromDate = DateTime.ParseExact(FromDateTextField.Text, AysaConstants.FormatDate, null);
            filter.ToDate   = DateTime.ParseExact(ToDateTextField.Text, AysaConstants.FormatDate, null);

            return(filter);
        }
Exemple #2
0
        // This delegate will be called when the user apply new filters
        public void LoadFeaturesByFilter(FilterFeatureData filter)
        {
            // Save filter
            this.FilterApplied = filter;

            // When the controller will appear, it will get the events with filters
        }
Exemple #3
0
        // This delegate will be called when the user remove the filters
        public void ClearAppliedFilter()
        {
            // Remove filters applied
            this.FilterApplied = null;

            // When the controller will appear, it will get the events without filters
        }
        private FilterFeatureData ApplyFilter()
        {
            // Build filter
            // Get filter data from IBOutlets

            // Try to get Number of Feature


            UsernameText = FindViewById <EditText>(Resource.Id.nro_event_text_field);
            string userName = UsernameText.Text;

            DetailText = FindViewById <EditText>(Resource.Id.title_text_field);
            string title = DetailText.Text;


            // Build filter objects
            Section           auxSector = ActiveSectionsList[spinnerSectors.SelectedItemPosition];
            FilterFeatureData filter    = new FilterFeatureData();

            filter.Username = userName;
            filter.Detail   = title;
            filter.FromDate = DateTime.ParseExact(fromDateText.Text, AysaConstants.FormatDate, null);
            filter.ToDate   = DateTime.ParseExact(toDateText.Text, AysaConstants.FormatDate, null);
            filter.Sector   = auxSector;

            return(filter);
        }
        private void SetUpView()
        {
            // Set toolbar and title
            global::Android.Support.V7.Widget.Toolbar toolbar = (global::Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.toolbar);
            toolbar.Title = GetString(Resource.String.event_filter);


            // Add back button
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            UsernameText = FindViewById <EditText>(Resource.Id.nro_event_text_field);
            DetailText   = FindViewById <EditText>(Resource.Id.title_text_field);
            // Sector field
            spinnerSectors = FindViewById <Spinner>(Resource.Id.spinnerSectors);


            Button btnAplicar = FindViewById <Button>(Resource.Id.btn_aplicar);

            btnAplicar.Click += BtnAplicar_Click;

            SetUpDateFields();

            // Get filter applied
            if (Intent.GetStringExtra(FILTER_APPLIED) != null)
            {
                this.FilterApplied = JsonConvert.DeserializeObject <FilterFeatureData>(Intent.GetStringExtra(FILTER_APPLIED));
                LoadFilterSavedInView();
            }

            LoadActiveSectionsInView();
        }
        private void FinishWithResult(FilterFeatureData filter)
        {
            Intent data = new Intent();

            data.PutExtra(FILTER_RESULT, JsonConvert.SerializeObject(filter));

            SetResult(Result.Ok, data);
            Finish();
        }
Exemple #7
0
        private void GetOpenFeaturesFromServer()
        {
            // If the controller is making a request, don't allow make another request until the first request finishes
            if (IsNetworkWorking)
            {
                return;
            }

            // Display an Activity Indicator in the status bar
            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            IsNetworkWorking = true;

            Task.Run(async() =>
            {
                try
                {
                    if (FilterApplied == null)
                    {
                        FilterApplied = BuildDefaultFilter();
                    }

                    List <Feature> features = await AysaClient.Instance.GetFeaturesByFilter(FilterApplied);
                    this.FeaturesFromServer = features.OrderByDescending(m => m.Date).ToList();


                    InvokeOnMainThread(() =>
                    {
                        // Load data and reload TableView
                        TableView.Source             = new FeaturesTableDataSource(FeaturesFromServer, this);
                        TableView.RowHeight          = UITableView.AutomaticDimension;
                        TableView.EstimatedRowHeight = 280f;
                        TableView.ReloadData();
                    });
                }
                catch (HttpUnauthorized)
                {
                    InvokeOnMainThread(() =>
                    {
                        ShowSessionExpiredError();
                    });
                }
                catch (Exception ex)
                {
                    InvokeOnMainThread(() =>
                    {
                        ShowErrorAlert(ex.Message);
                    });
                }
                finally
                {
                    // Dismiss an Activity Indicator in the status bar
                    UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                    IsNetworkWorking = false;
                }
            });
        }
        partial void SaveChangesButton_TouchUpInside(UIButton sender)
        {
            // Build filter form IBOutlets
            FilterFeatureData filter = ApplyFilter();

            if (filter != null)
            {
                // Send filter to EventsViewController to get events by filter
                if (_delegate != null)
                {
                    Delegate?.LoadFeaturesByFilter(filter);
                }

                DismissViewController(true, null);
            }
        }
Exemple #9
0
        public async Task <List <Feature> > GetFeaturesByFilter(FilterFeatureData filter)
        {
            // Refresh token if it needed
            await RefreshTokenIfNeeded();


            string userName = filter.Username != "" ? filter.Username : "";
            string detail   = filter.Detail;
            string fromDate = filter.FromDate.ToString(FormatDateToServer);
            string toDate   = filter.ToDate.ToString(FormatDateToServer);
            string sectorId = filter.Sector.Id != "000000000" ? filter.Sector.Id : "";

            string parameters = string.Format(GET_FEATURES_BY_FILTER_URL, userName, detail, fromDate, toDate, sectorId);

            // Get people in guard from server
            return(await AysaClientServices.Instance.Get <List <Feature> >(parameters));
        }
Exemple #10
0
        private void GetFeaturesFromServer()
        {
            ShowProgressDialog(true);
            clearListData();

            Task.Run(async() =>
            {
                try
                {
                    if (FilterApplied == null)
                    {
                        FilterApplied = BuildDefaultFilter();
                    }

                    List <Feature> features = await AysaClient.Instance.GetFeaturesByFilter(FilterApplied);
                    this.FeatureFromServer  = features.OrderByDescending(m => m.Date).ToList();

                    Activity.RunOnUiThread(() =>
                    {
                        SetAdapterWithFilterText("");
                    });
                }
                catch (HttpUnauthorized)
                {
                    this.Activity.RunOnUiThread(() =>
                    {
                        ShowSessionExpiredError();
                    });
                }
                catch (Exception ex)
                {
                    this.Activity.RunOnUiThread(() =>
                    {
                        ShowErrorAlert(ex.Message);
                    });
                }
                finally
                {
                    this.Activity.RunOnUiThread(() =>
                    {
                        ShowProgressDialog(false);
                    });
                }
            });
        }
Exemple #11
0
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (requestCode == FILTERS_SCREEN)
            {
                //Result.ok = -1
                if (resultCode == -1)
                {
                    String result = data.GetStringExtra(FilterFeaturesActivity.FILTER_RESULT);
                    FilterApplied = JsonConvert.DeserializeObject <FilterFeatureData>(result);

                    GetFeaturesFromServer();
                }
            }
            else if (requestCode == ADD_FEATURE_CODE || requestCode == FEATURE_DETAIL_CODE)
            {
                if (resultCode == 0 || resultCode == -1)
                {
                    GetFeaturesFromServer();
                }
            }
        }
Exemple #12
0
        private FilterFeatureData BuildDefaultFilter()
        {
            DateTime fromDate = DateTime.Now.AddDays(-30);
            DateTime toDate   = DateTime.Now;
            // Build filter objects
            Section dummySector = new Section();

            dummySector.Nombre = "Todas";
            dummySector.Id     = "000000000";
            dummySector.Nivel  = 0;
            dummySector.ResponsablesGuardia = null;

            FilterFeatureData filter = new FilterFeatureData();

            filter.FromDate = fromDate;
            filter.ToDate   = toDate;
            filter.Sector   = dummySector;
            filter.Username = "";
            filter.Detail   = "";

            return(filter);
        }
        void BtnAplicar_Click(object sender, System.EventArgs e)
        {
            FilterFeatureData filter = ApplyFilter();

            FinishWithResult(filter);
        }