Beispiel #1
0
        public InviteUserViewModel(MainViewModel mainViewModelParent, IMobileServiceTable<Profile> mobileServiceProfileTable)
        {
            profileTable = mobileServiceProfileTable;
            parent = mainViewModelParent;

            SearchCommand = new DelegateCommand(() =>
            {
                currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount();
                }
                else
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount().Where
                        (p => p.Name.IndexOf(SearchText) >= 0);
                }
                RefreshQueryAsync();
            });

            NextCommand = new DelegateCommand(() =>
            {
                currentPage++;
                RefreshQueryAsync();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                currentPage--;
                RefreshQueryAsync();
            }, false);
        }
        public InviteUserViewModel(MainViewModel parent, IMobileServiceTable<Profile> profileTable, Action dismiss)
        {
            _profileTable = profileTable;
            _parent = parent;
            _dismiss = dismiss;

            SearchCommand = new DelegateCommand(() =>
            {
                _currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount();
                }
                else
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount().Where(p => p.Name.IndexOf(SearchText) > -1);
                }
                RefreshQuery();
            });

            NextCommand = new DelegateCommand(() =>
            {
                _currentPage++;
                RefreshQuery();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                _currentPage--;
                RefreshQuery();
            }, false);
        }
        public InviteUserViewModel(MainViewModel parent, IMobileServiceTable <Profile> profileTable, Action dismiss)
        {
            _profileTable = profileTable;
            _parent       = parent;
            _dismiss      = dismiss;

            SearchCommand = new DelegateCommand(() =>
            {
                _currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount();
                }
                else
                {
                    _query = profileTable.Take(_pageCount).IncludeTotalCount().Where(p => p.Name.IndexOf(SearchText) > -1);
                }
                RefreshQuery();
            });

            NextCommand = new DelegateCommand(() =>
            {
                _currentPage++;
                RefreshQuery();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                _currentPage--;
                RefreshQuery();
            }, false);
        }
Beispiel #4
0
        public InviteUserViewModel(MainViewModel mainViewModelParent, IMobileServiceTable <Profile> mobileServiceProfileTable)
        {
            profileTable = mobileServiceProfileTable;
            parent       = mainViewModelParent;

            SearchCommand = new DelegateCommand(() =>
            {
                currentPage = 0;
                if (String.IsNullOrWhiteSpace(SearchText))
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount();
                }
                else
                {
                    query = profileTable.Take(profileCountPerPage).IncludeTotalCount().Where
                                (p => p.Name.IndexOf(SearchText) >= 0);
                }
                RefreshQueryAsync();
            });

            NextCommand = new DelegateCommand(() =>
            {
                currentPage++;
                RefreshQueryAsync();
            }, false);

            PrevCommand = new DelegateCommand(() =>
            {
                currentPage--;
                RefreshQueryAsync();
            }, false);
        }
        public async static Task <List <StockPriceHistory> > GetAllStockPriceHistorys()
        {
            var prices = stockPriceHistoryTable.Take(10).ToListAsync().Result;

            return(prices);
            //return stockPriceHistoryTable.ToListAsync().Result;
        }
Beispiel #6
0
        public async Task <List <Item> > GetItems()
        {
            try
            {
                Items = await itemsTable.Take(1000).ToListAsync();

                //Fix issue #27 - Search unable to handle NULL Azure database table value
                foreach (var item in Items)
                {
                    Type type       = item.GetType();
                    var  properties = type.GetRuntimeProperties();
                    foreach (PropertyInfo property in properties)
                    {
                        if (property.GetValue(item, null) == null)
                        {
                            property.SetValue(item, string.Empty);
                        }
                    }
                }

                return(Items);
            }
            catch (Exception e)
            {
                ServiceLocator.MessageService.ShowErrorAsync("Error when retrieving items from AzureMobileService", "Application Error");
                return(Items);
            }
        }
Beispiel #7
0
        public async void RefreshSets()
        {
            if (App.SelectedTeam == null)
            {
                return;
            }

            MobileServiceInvalidOperationException exception = null;

            SetsCollection = null;
            try
            {
                SetsCollection = await setsTable.Take(1000)
                                 .ToCollectionAsync();
            }
            catch (MobileServiceInvalidOperationException e)
            {
                exception = e;
            }

            if (exception != null)
            {
                await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
            }
            else
            {
                OnCollectionLoaded();
            }
        }
Beispiel #8
0
        public async static Task <List <FundPriceHistory> > GetAllFundPriceHistorys()
        {
            var prices = fundPriceHistoryTable.Take(10).ToListAsync().Result;

            return(prices);
            //return fundPriceHistoryTable.ToListAsync().Result;
        }
Beispiel #9
0
        public async Task <IList <Team> > GetTeams()
        {
            IMobileServiceTable <Team> teams = m_MobileService.GetTable <Team>();

            IList <Team> listTeams = await teams.Take(100).ToListAsync();

            return(listTeams);
        }
        public async Task SimpleDataSourceWithTotalCount()
        {
            // Get the Movie table
            IMobileServiceTable <Movie> table = GetClient().GetTable <Movie>();

            // Create a new CollectionView
            MobileServiceCollection <Movie, Movie> dataSource = await table.Take(5).IncludeTotalCount().ToCollectionAsync();

            Assert.Equal(5, dataSource.Count);
            Assert.Equal((long)248, dataSource.TotalCount);
        }
        public async Task SimpleDataSource()
        {
            // This test is known to fail in Xamarin -- see https://bugzilla.xamarin.com/show_bug.cgi?id=22955
            // Get the Movie table
            IMobileServiceTable <Movie> table = GetClient().GetTable <Movie>();

            // Create a new CollectionView
            MobileServiceCollection <Movie, Movie> dataSource = await table.Take(1000).OrderByDescending(m => m.Title).ToCollectionAsync();

            Assert.Equal(248, dataSource.Count);
            Assert.Equal((long)-1, dataSource.TotalCount);
            Assert.Equal("Yojimbo", dataSource[0].Title);
        }
        public async Task SimpleDataSourceWithTotalCount()
        {
            // Get the Books table
            IMobileServiceTable <Book> table = GetClient().GetTable <Book>();

            // Create a new CollectionView
            Log("Creating DataSource");
            MobileServiceCollection <Book, Book> dataSource =
                await table.Take(5).IncludeTotalCount().ToCollectionAsync();

            Log("Verifying loaded");
            Assert.AreEqual(5, dataSource.Count);
            Assert.AreEqual((long)18, ((ITotalCountProvider)dataSource).TotalCount);
        }
Beispiel #13
0
        public async Task <List <Item> > GetItems()
        {
            try
            {
                Items = await itemsTable.Take(1000).ToListAsync();

                return(Items);
            }
            catch (Exception e)
            {
                ServiceLocator.MessageService.ShowErrorAsync("Error when retrieving items from AzureMobileService", "Application Error");
                return(Items);
            }
        }
        public static async Task <List <Station> > GetAllStations()
        {
            IMobileServiceTable <Station> itemsTable = App.AzureClient.GetTable <Station>();

            List <Station> itemsList =
                await itemsTable.Take(100).ToListAsync();

            if (itemsList.Count != 0)
            {
                return(itemsList);
            }
            else
            {
                return(null);
            }
        }
Beispiel #15
0
        public async Task <IList <Game> > GetGames()
        {
            IMobileServiceTable <Game> games = m_MobileService.GetTable <Game>();

            List <Game> listGames = await games.Take(100).ToListAsync();

            IList <Team> teams = await GetTeams();


            foreach (Game game in listGames)
            {
                game.HomeTeam = teams.Single(item => item.Id == game.HomeTeamId);
                game.AwayTeam = teams.Single(item => item.Id == game.AwayTeamId);
            }

            listGames.Sort(new GameByDateTimeComparerASC());


            return(listGames);
        }
        private async Task fetchSpeedTraps()
        {
            SpeedTrapMap.Children.Clear(); //Clear all current entries from the map

            //TODO: Replace .Take(1000) with something that handles paging
            var items = await speedTrapLocationTable.Take(1000).ToListAsync();

            foreach (var item in items)
            {
                var pushpin = new Bing.Maps.Pushpin();

                Flyout f = new Flyout();

                pushpin.PointerEntered += ((pinControl, ev) =>
                {
                    // Flyout is a ContentControl so set your content within it.
                    f.Content = new SpeedTrap(item);

                    f.Placement = PlacementMode.Top;
                    f.PlacementTarget = (UIElement)pinControl; //Make it appear near the push pin element

                    layoutRoot.Children.Add(f.HostPopup);

                    f.Closed += (b, c) =>
                    {
                        layoutRoot.Children.Remove(f.HostPopup);
                    };

                    f.IsOpen = true;
                });

                pushpin.PointerExited += ((s, ev) =>
                {
                    f.IsOpen = false;
                });

                //This function orients the pushpin on the map before we add it to the map
                MapLayer.SetPosition(pushpin, new Location(item.Latitude, item.Longitude));
                SpeedTrapMap.Children.Add((UIElement)pushpin);
            }
        }
        private static async Task <IEnumerable <T> > GetAll <T>(this IMobileServiceTable <T> mobileServiceTable, Int32 count)
        {
            var list  = new List <T>();
            var items = await mobileServiceTable.Take(count).IncludeTotalCount().ToEnumerableAsync();

            list.AddRange(items);
            var countProvider = items as ITotalCountProvider;

            if (countProvider != null)
            {
                var current = count;
                while (current < countProvider.TotalCount)
                {
                    items = await mobileServiceTable.Skip(current).ToEnumerableAsync();

                    list.AddRange(items);
                    current += count;
                }
            }
            return(list);
        }
        public async Task SimpleDataSourceWithTotalCount()
        {
            // Get the Books table
            IMobileServiceTable <Book> table = GetClient().GetTable <Book>();

            // Create a new CollectionView
            Log("Creating DataSource");
            MobileServiceCollectionView <Book> dataSource =
                table.Take(5).IncludeTotalCount().ToCollectionView();

            // Spin until the data finishes loading on another thread
            Log("Waiting for population");
            while (dataSource.Count <= 0)
            {
                await Task.Delay(500);
            }

            Log("Verifying loaded");
            Assert.AreEqual(5, dataSource.Count);
            Assert.AreEqual((long)18, ((ITotalCountProvider)dataSource).TotalCount);
        }
Beispiel #19
0
        private async Task InitContentItems()
        {
            MobileServiceInvalidOperationException exception = null;

            try
            {
                _items = await _contentTable.Take(500).ToCollectionAsync();
            }
            catch (MobileServiceInvalidOperationException e)
            {
                exception = e;
            }

            if (exception != null)
            {
                await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
            }
            else
            {
                WebContentTemplate.HTML = _items.Where(x => x.Id == "13").Single().Data;
            }
        }
Beispiel #20
0
        private async Task EnsureEmptyTableAsync <T>()
        {
            // Make sure the table is empty
            IMobileServiceTable <T> table = GetClient().GetTable <T>();

            while (true)
            {
                IEnumerable <T> results = await table.Take(1000).ToListAsync();

                T[] items = results.ToArray();

                if (!items.Any())
                {
                    break;
                }

                foreach (T item in items)
                {
                    await table.DeleteAsync(item);
                }
            }
        }
 public IMobileServiceTableQuery <T> Take(int count)
 {
     return(_table.Take(count));
 }
        private async void Button_Click_1Async(object sender, RoutedEventArgs e)
        {
            recipes = await recipesTable.Take(5).ToCollectionAsync();

            this.Frame.Navigate(typeof(Display));
        }
Beispiel #23
0
        /// <summary>
        /// Gets at least a week back for displaying on the chart. Keeps searching back week by week if there is still data to find
        /// </summary>
        /// <returns></returns>
        private async Task UpdateExpenseChart()
        {
            // Update if the chart is scrolled all the way back
            if (ChartScroll.HorizontalOffset == ChartScroll.ScrollableWidth)
            {
                // Display the progress wheel when getting data
                ProgressRing LoginProgress = new ProgressRing();
                LoginProgress.HorizontalAlignment = HorizontalAlignment.Center;
                LoginProgress.VerticalAlignment   = VerticalAlignment.Center;
                ContentRoot.Children.Add(LoginProgress);
                LoginProgress.IsActive = true;

                List <Expense> TempExpenses = new List <Expense>();

                // Query the database to see how many expenses there are in the database
                IMobileServiceTable <Expense> ExpenseTable = App.alltheairgeadClient.GetTable <Expense>();
                var TotalCount = (await ExpenseTable.Take(0).IncludeTotalCount().ToListAsync() as IQueryResultEnumerable <Expense>).TotalCount;
                // If all the expense  have been found, don't searchfor more
                if (Expenses.Count >= TotalCount)
                {
                    // Disable the progress wheel and exit
                    LoginProgress.IsActive = false;
                    ContentRoot.Children.Remove(LoginProgress);
                    return;
                }

                // Keep track of how many weeks have been checked in this update
                int weekssearched = 0;
                do
                {
                    // Query for the next week back of expenses
                    MinExpenseDate = MinExpenseDate.AddDays(-7);
                    TempExpenses   = await ExpenseTable.Where(a => (a.Date > MinExpenseDate)& (a.Date <= MinExpenseDate.AddDays(7))).OrderByDescending(a => a.Date).ToListAsync();

                    weekssearched++;
                } while (TempExpenses.Count == 0);

                // If some are found, add them to the list of expenses
                if (TempExpenses.Count != 0)
                {
                    // Add the found expenses to the list of total expenses
                    Expenses.AddRange(TempExpenses);

                    // Expand the chart by a fixed amount for every week
                    ExpenseChart.Width += 750 * ChartXScale * weekssearched;

                    // Go through each series of data and update them with the latest data
                    foreach (LineSeries i in ExpenseChart.Series)
                    {
                        // Create temporary series to hold new data for series
                        List <Expense>       SeriesExpenses = new List <Expense>();
                        List <DateValueItem> TempItems      = new List <DateValueItem>();
                        // Take only the data relevent to the current series
                        if (i.Name == "TotalExpenses")
                        {
                            SeriesExpenses = TempExpenses;
                        }
                        else
                        {
                            SeriesExpenses = TempExpenses.FindAll(a => a.Category == (string)i.Title);
                        }

                        // Get the current list of items in the series
                        TempItems = (List <DateValueItem>)i.ItemsSource;
                        if (TempItems == null)
                        {
                            TempItems = new List <DateValueItem>();
                        }

                        // Add the expenses to the current list
                        foreach (Expense j in SeriesExpenses)
                        {
                            TempItems.Add(new DateValueItem {
                                Date = (j.Date + j.Time.TimeOfDay), Value = (int)j.Price, Id = j.Id
                            });
                        }

                        // Set the source of the series to the updated list
                        i.ItemsSource = TempItems;

                        // If the series is the total expenses series, update the axis
                        if (ExpenseChart.Series.IndexOf(i) == 0)
                        {
                            i.IndependentAxis =
                                new DateTimeAxis
                            {
                                Minimum      = MinExpenseDate,
                                Maximum      = DateTime.Now.AddHours(6),
                                Location     = AxisLocation.Bottom,
                                Orientation  = AxisOrientation.X,
                                IntervalType = (ChartXScale > ChartXScaleIntervalThresh ? DateTimeIntervalType.Hours : DateTimeIntervalType.Days),
                            };
                            i.DependentRangeAxis =
                                new LinearAxis
                            {
                                Orientation   = AxisOrientation.Y,
                                ShowGridLines = true,
                                Location      = AxisLocation.Right,
                                Minimum       = 0,
                            };
                        }
                        // Otherwise update the others to the match the total expenses one
                        else
                        {
                            i.IndependentAxis    = ((ExpenseChart.Series[0] as LineSeries).IndependentAxis as DateTimeAxis);
                            i.DependentRangeAxis = ((ExpenseChart.Series[0] as LineSeries).DependentRangeAxis as LinearAxis);
                        }
                        i.Refresh();
                    }
                }
                // Disable the progress wheel
                LoginProgress.IsActive = false;
                ContentRoot.Children.Remove(LoginProgress);
            }
        }
        public async Task LoadAsync()
        {
            int count = 0;

            do
            {
                items = await azureTable.Take(1).ToCollectionAsync();

                for (int i = 0; i < items.Count; i++)
                {
                    items = await azureTable.Take((items.Count + 1)).ToCollectionAsync();

                    count++;
                }
            } while (items.Count != count);

            var itemsCP = items;

            List <string> elementsMonday = new List <string>();

            elementsMonday = items.Where(x => x.Monday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Monday).ToList();
            int sizeMonday = elementsMonday.Count();

            for (int i = 0; i < sizeMonday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsMonday.ElementAt(i));
                b  = GenerateNewBorder(tb);

                mondayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsTuesday = new List <string>();

            elementsTuesday = items.Where(x => x.Tuesday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Tuesday).ToList();
            int sizeTuesday = elementsTuesday.Count();

            for (int i = 0; i < sizeTuesday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsTuesday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                tuesdayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsWednesday = new List <string>();

            elementsWednesday = items.Where(x => x.Wednesday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Wednesday).ToList();
            int sizeWednesday = elementsWednesday.Count();

            for (int i = 0; i < sizeWednesday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsWednesday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                wednesdayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsThursday = new List <string>();

            elementsThursday = items.Where(x => x.Thursday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Thursday).ToList();
            int sizeThursday = elementsThursday.Count();

            for (int i = 0; i < sizeThursday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsThursday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                thursdayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsFriday = new List <string>();

            elementsFriday = items.Where(x => x.Friday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Friday).ToList();
            int sizeFriday = elementsFriday.Count();

            for (int i = 0; i < sizeFriday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsFriday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                fridayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsSaturday = new List <string>();

            elementsSaturday = items.Where(x => x.Saturday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Saturday).ToList();
            int sizeSaturday = elementsSaturday.Count();

            for (int i = 0; i < sizeSaturday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsSaturday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                saturdayStack.Children.Add(b);
            }
            items = itemsCP;

            List <string> elementsSunday = new List <string>();

            elementsSunday = items.Where(x => x.Sunday != null && x.UserID.Equals(UniqueUser.UniqueID)).Select(x => x.Sunday).ToList();
            int sizeSunday = elementsSunday.Count();

            for (int i = 0; i < sizeSunday; i++)
            {
                var tb = new TextBlock();
                var b  = new Border();
                tb = GenerateNewTextBox(elementsSunday.ElementAt(i));
                b  = GenerateNewBorder(tb);
                sundayStack.Children.Add(b);
            }
            items = itemsCP;
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            var passParameters = Intent.Extras.GetStringArrayList("passParameters") ?? new string[0];

            timePeriod        = passParameters.ElementAt(0);
            timePeriodDesired = extractTimePeriod();
            displayFormat     = passParameters.ElementAt(1);
            PlotView   view      = null;
            PlotModel  plotModel = null;
            LineSeries series1   = null;

            if (displayFormat == "Graph")
            {
                SetContentView(Resource.Layout.Graphs);
                view = FindViewById <PlotView>(Resource.Id.plot_view);
                var startDate = DateTime.Now.AddDays(timePeriodDesired);
                var endDate   = DateTime.Now;

                var minValue = DateTimeAxis.ToDouble(startDate);
                var maxValue = DateTimeAxis.ToDouble(endDate);

                plotModel = new PlotModel {
                    Title = "Weigh History"
                };
                plotModel.Axes.Add(new DateTimeAxis
                {
                    Position     = AxisPosition.Bottom,
                    Minimum      = minValue,
                    Maximum      = maxValue,
                    StringFormat = "M/d",
                    //MinorIntervalType = DateTimeIntervalType.Days,
                    IntervalType   = DateTimeIntervalType.Days,
                    IntervalLength = 30,
                    Title          = "Day of Weighing",
                });
                series1 = new LineSeries
                {
                    MarkerType   = MarkerType.Circle,
                    MarkerSize   = 4,
                    MarkerStroke = OxyColors.White
                };
            }

            else
            {
                SetContentView(Resource.Layout.multipleColumnsLayout);
            }


            string ourUserId = ToDoActivity.CurrentActivity.Currentuserid;
            //Console.WriteLine("sid is: {0}", ourUserId);
            //Bar's sid:    sid:f5ccac253e6e9ce70bd96a3b9a0b59d2
            //string BarSID = "sid:f5ccac253e6e9ce70bd96a3b9a0b59d2";
            //ourUserId = BarSID;


            MobileServiceClient client = ToDoActivity.CurrentActivity.CurrentClient;

            weighTableRef = client.GetTable <weighTable>();
            UsersTableRef = client.GetTable <UsersTable>();

            try
            {
                DateTime today        = DateTime.Now;
                DateTime earliestDate = today.AddDays(timePeriodDesired);

                //weighTable :      username               weigh       createdAt
                //UsersTable:       UniqueUsername         height       gender      age


                //var list9 = await weighTableRef.Where(item => (item.username == ourUserId) && (item.createdAt >= earliestDate)).ToListAsync();
                var list9 = await weighTableRef.Take(500).Where(item => (item.username == ourUserId) && (item.createdAt >= earliestDate)).ToListAsync();


                if (list9.Count == 0)
                {
                    CreateAndShowDialog("Please Weigh yourself and try again", "No Previous Weighs Found in the requested time period");
                }

                int      i = 1;   int q = 0;   int z = 0;
                DateTime debuggDate;
                string   dateSring;
                foreach (weighTable weight in list9)
                {
                    float  currW = weight.weigh;
                    string weighInStringFormat = Convert.ToString(currW);
                    lastWeights.Add(currW);
                    //Console.WriteLine("weight = : {0}", currW);
                    DateTime date1 = weight.createdAt;
                    debuggDate = date1;
                    //string dateSring = Convert.ToString(date1);
                    //Console.WriteLine(date1.ToString());
                    //dateSring = Convert.ToString(debuggDate);

                    dateSring = Convert.ToString(date1);
                    if (displayFormat == "List")
                    {
                        weighDateList.Add(new WeighDatePair
                        {
                            myWeight    = weighInStringFormat,
                            dateOfWeigh = dateSring
                        });
                    }
                    else
                    {
                        //shift dates to debugg graph
                        debuggDate = date1.AddDays(-i);
                        //z = z + 1;
                        //q = q + 2;
                        //i = i + q -z;
                        i = i + 2;

                        series1.Points.Add(new DataPoint(DateTimeAxis.ToDouble(debuggDate), currW));
                    }
                }

                float minWeigh = 0;
                float maxWeigh = 0;
                if (displayFormat == "Graph" && list9.Count > 0)
                {
                    //find the min and max weigh of the Time Period checked:
                    minWeigh = lastWeights.Min();
                    minWeigh = minWeigh - 2;
                    maxWeigh = lastWeights.Max();
                    maxWeigh = maxWeigh + 2;
                }


                if (displayFormat == "List")
                {
                    var listView = FindViewById <ListView>(Resource.Id.listView);
                    listView.Adapter = new WeighDatePairAdapter(this, weighDateList);
                }
                else
                {
                    if (list9.Count > 0)
                    {
                        plotModel.Axes.Add(new LinearAxis
                        {
                            Position = AxisPosition.Left,
                            Title    = "Weigh",
                            Minimum  = minWeigh,
                            Maximum  = maxWeigh
                        });
                        plotModel.Series.Add(series1);
                        view.Model = plotModel;
                    }
                }

                //DateTime date2 = new DateTime(2017, 6, 28, 16, 5, 0);
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }

            //this.ListAdapter = new ArrayAdapter<float>(this, Android.Resource.Layout.SimpleListItem1, lastWeights);
        }
Beispiel #26
0
        private async Task GetSampleDataFromAzure()
        {
            try{
                var items = await Result.Take(88).ToListAsync();

                //  var items = await Result.ToCollectionAsync();
                SQLiteAsyncConnection conn = new SQLiteAsyncConnection("ATMOS.db");
                list.Clear();
                foreach (Events i in items)
                {
                    list.Add(i);
                }
                await conn.DropTableAsync <Events>();

                await conn.CreateTableAsync <Events>();

                list.Sort((ev1, ev2) => DateTime.Compare(ev1.startTime, ev2.startTime));
                await conn.InsertAllAsync(list);

                EventsGroupByDate group1 = new EventsGroupByDate("1", "10th October");
                EventsGroupByDate group2 = new EventsGroupByDate("2", "11th October");
                EventsGroupByDate group3 = new EventsGroupByDate("3", "12th October");
                EventsGroupByDate group4 = new EventsGroupByDate("1", "Current Events");
                EventsGroupByDate group5 = new EventsGroupByDate("2", "Future Events");
                this.Groupsh.Clear();
                int uid = 1;
                foreach (Events i in list)
                {
                    if (TimeLine.stb == 1)
                    {
                        string d = i.startTime.Date.ToString("dd/MM/yyyy");
                        if (d.Equals("12/10/2014"))
                        {
                            group3.Items.Add(i);
                        }
                        else if (d.Equals("11/10/2014"))
                        {
                            group2.Items.Add(i);
                        }
                        else
                        {
                            group1.Items.Add(i);
                        }
                    }
                    else if (TimeLine.stb == 3)
                    {
                        if (DateTime.Compare(i.startTime, DateTime.Now) > 0)
                        {
                            group5.Items.Add(i);
                        }
                        else if (DateTime.Compare(i.endTime, DateTime.Now) > 0 && DateTime.Compare(i.startTime, DateTime.Now) <= 0)
                        {
                            group4.Items.Add(i);
                        }
                    }
                    else
                    {
                        if (this._groupsh.Count == 0)
                        {
                            EventsGroupByHour group = new EventsGroupByHour();
                            group.UniqueId = "1";
                            group.Time     = i.startTime.ToString("hh:mm tt dd/MM/yyyy");
                            group.Items.Add(i);
                            this.Groupsh.Add(group);
                        }
                        else if (this.Groupsh[_groupsh.Count - 1].Time.Equals(i.startTime.ToString("hh:mm tt dd/MM/yyyy")))
                        {
                            EventsGroupByHour group = this._groupsh[_groupsh.Count - 1];
                            group.Items.Add(i);
                        }
                        else
                        {
                            uid++;
                            EventsGroupByHour group = new EventsGroupByHour();
                            group.UniqueId = uid.ToString();
                            group.Time     = i.startTime.ToString("hh:mm tt dd/MM/yyyy");
                            group.Items.Add(i);

                            this.Groupsh.Add(group);
                        }
                    }
                }
                if (TimeLine.stb == 1)
                {
                    this.Groupsd.Clear();
                    this.Groupsd.Add(group1); this.Groupsd.Add(group2); this.Groupsd.Add(group3);
                }
                else if (TimeLine.stb == 3)
                {
                    this.Groupsw.Clear(); this.Groupsw.Add(group4); this.Groupsw.Add(group5);
                }
            }
            catch (Exception e1)
            {
                MessageDialog ob = new MessageDialog("Please connect to internet to download the schedule.");
                ob.ShowAsync();
            }
        }
Beispiel #27
0
        public async void pull()
        {
            taxRates = await myTable.Take(5).ToCollectionAsync();

            assign();
        }
Beispiel #28
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.PickDateViewVer2);

            MobileServiceClient client = ToDoActivity.CurrentActivity.CurrentClient;

            weighTableRef = client.GetTable <weighTable>();

            _dateDisplay = FindViewById <TextView>(Resource.Id.date_display);

            _dateSelectButton = FindViewById <Button>(Resource.Id.date_select_button);
            _remSingleButton  = FindViewById <Button>(Resource.Id.remove_single_button);
            _remAllButton     = FindViewById <Button>(Resource.Id.remove_all_button);

            _dateSelectButton.Click += DateSelect_OnClick;
            _remSingleButton.Click  += _remSingleButton_Click;
            _remAllButton.Click     += _remAllButton_Click;

            Button OkButton = FindViewById <Button>(Resource.Id.OKbutton);

            OkButton.Visibility = ViewStates.Gone;
            Button CancelButton = FindViewById <Button>(Resource.Id.CancelButton);

            CancelButton.Visibility = ViewStates.Gone;

            OkButton.Click += async(sender, e) =>
            {
                FindViewById <TextView>(Resource.Id.date_display).Text = "Deleting from database. Please Wait...";
                OkButton.Visibility     = ViewStates.Gone;
                CancelButton.Visibility = ViewStates.Gone;
                List <weighTable> queryResult;
                try
                {
                    switch (job)
                    {
                    case DeleteJob.Single:
                        queryResult = await weighTableRef.Take(500).Where(item => (item.username == ourUserId) && (item.createdAt <= datePicked) && (item.createdAt >= datePicked.AddDays(-1))).ToListAsync();

                        //var list9 = await weighTableRef.Take(500).Where(item => (item.username == ourUserId) && (item.createdAt >= earliestDate)).ToListAsync();
                        Console.WriteLine("datePicked = " + datePicked + ", datePicked-1 = " + datePicked.AddDays(-1), "");
                        break;

                    case DeleteJob.All:
                        queryResult = await weighTableRef.Take(500).Where(item => (item.username == ourUserId)).ToListAsync();

                        break;

                    case DeleteJob.PriorToDate:
                        queryResult = await weighTableRef.Take(500).Where(item => (item.username == ourUserId) && (item.createdAt <= datePicked)).ToListAsync();

                        break;

                    default:
                        queryResult = new List <weighTable>();
                        break;
                    }
                    await deleteWeighs(queryResult);

                    //FindViewById<TextView>(Resource.Id.date_display).Text = "Deleted Successfully";
                }
                catch (Exception ex)
                {
                    CreateAndShowDialog(ex, "Error");
                }
            };

            CancelButton.Click += (sender, e) =>
            {
                //OkButton.Visibility = ViewStates.Gone;
                //CancelButton.Visibility = ViewStates.Gone;
                //var intent = new Intent(this, typeof(UpdateProfile))
                //.SetFlags(ActivityFlags.ReorderToFront);
                //StartActivity(intent);
                Finish();
            };
        }
        async void updateUsers()
        {
            var onlineUsers = await usersTable.Take(100).ToCollectionAsync();

            ListUsers.ItemsSource = onlineUsers;
        }