示例#1
0
        private async Task <JobAmounts> GetAmounts(Connection cnx)
        {
            string key     = string.Format("/api/api/5?id=id$~{0}~cmd$~getjobnums", cnx.ID);
            var    jsonRaw = await Client.GET(cnx.Token, key);

            if (jsonRaw == "errorerrorerror")
            {
                await DisplayAlert("Http Request Error", "Please try again.\n\nIf this keeps happening, please contact us.", "Ok");

                //Make sure that if you return null here it doesnt break the app.
                return(null);
            }

            JobAmounts jobAmounts = JobAmounts.FromJson(jsonRaw);

            return(jobAmounts);
        }
示例#2
0
        async Task updateList(Connection cnx, List <JobCell> JOBCELLS)
        {
            this.BarBackgroundColor         = Color.FromHex("#B80000");
            settingsButton.BackgroundColor  = Color.FromHex("#B80000");
            materialsButton.BackgroundColor = Color.FromHex("#B80000");
            contactButton.BackgroundColor   = Color.FromHex("#B80000");
            passwordButton.BackgroundColor  = Color.FromHex("#B80000");

            List <Job>     Jobs  = new List <Job>();;
            List <JobCell> Cells = new List <JobCell>();


            if (JOBCELLS == null)
            {
                JobAmounts jobamounts = await GetAmounts(cnx);

                if (!string.IsNullOrEmpty(jobamounts.jobs))
                {
                    int endNumber = Int32.Parse(jobamounts.jobs);
                    Jobs = await GetContent(0, endNumber, cnx);

                    if (Jobs == null)
                    {
                        await DisplayAlert("Error", "There has been an issue retreiving your jobs. Please try again.\n\nIf this keeps happening please restart the app.", "Ok");

                        return;
                    }
                }
                else
                {
                    await DisplayAlert("Error", "There has been an issue retreiving your job count. Please try again.\n\nIf this keeps happening please restart the app.", "Ok");
                }

                foreach (Job job in Jobs)
                {
                    JobCell cell = new JobCell
                    {
                        JobNumber   = job.job.ToString(),
                        Add1        = job.add1,
                        JobColor    = StatusSorter.JobNumberColor(job),
                        Status      = StatusSorter.StatusText(job),
                        StatusColor = StatusSorter.StatusColor(job),
                        CellColor   = StatusSorter.CellColor(job),
                        job         = job
                    };
                    Cells.Add(cell);

                    _Cells = Cells;
                }
            }
            else
            {
                Cells = JOBCELLS;
            }



            Label jobHeader = new Label
            {
                Text                    = Maincnx.Name,
                TextColor               = Color.Black,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                FontAttributes          = FontAttributes.Bold,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center
            };

            searchbar = new SearchBar()
            {
                Placeholder       = "Search:",
                Text              = searchBarText,
                CancelButtonColor = Color.Red
            };

            searchbar.SearchButtonPressed += SearchBarButtonPressedChanged;
            searchbar.TextChanged         += Searchbar_TextChanged;

            listView = new ListView()
            {
                HasUnevenRows   = true,
                BackgroundColor = Color.White,
                ItemsSource     = Cells,

                ItemTemplate = new DataTemplate(() =>
                {
                    //create views with bindings for displaying each property.
                    Label JobNumber = new Label()
                    {
                        FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                        FontAttributes = FontAttributes.Bold
                    };
                    JobNumber.SetBinding(Label.TextProperty, "JobNumber");
                    JobNumber.SetBinding(Label.TextColorProperty, "JobColor");



                    Label JobAddress = new Label()
                    {
                        FontSize       = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                        FontAttributes = FontAttributes.Italic
                    };
                    JobAddress.SetBinding(Label.TextProperty, "Add1");
                    JobAddress.TextColor = Color.Black;

                    Label Status = new Label();
                    Status.SetBinding(Label.TextProperty, "Status");
                    Status.SetBinding(Label.TextColorProperty, "StatusColor");

                    return(new ViewCell
                    {
                        View = new StackLayout
                        {
                            Padding = new Thickness(0, 5),
                            Orientation = StackOrientation.Horizontal,
                            Children =
                            {
                                JobNumber,
                                //stick in an image here for whatever you want.
                                new StackLayout
                                {
                                    VerticalOptions = LayoutOptions.CenterAndExpand,
                                    Spacing = 0,
                                    Children =
                                    {
                                        JobAddress,
                                        Status
                                    }
                                }
                            }
                        }
                    });
                })
            };

            listView.ItemSelected += ListView_ItemSelected;

            this.Padding = new Thickness(10, 20, 10, 5);


            Tab1.Content = new StackLayout
            {
                Children =
                {
                    jobHeader,
                    searchbar,
                    listView,
                }
            };
        }