コード例 #1
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection <ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync();

            var    networkProfiles  = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var    adapter          = networkProfiles.First <Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date    = k.CreatedAt.Date.ToString();
                a.time    = k.CreatedAt.TimeOfDay.ToString();
                a.time    = a.time.Remove(5);
                a.date    = a.date.Remove(10);
                a.Name    = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource         = test;
            test.CollectionChanged += test_CollectionChanged;
        }
コード例 #2
0
 public async Task <IEnumerable <PollResponse> > GetResponsesForPollAsync(string questionId)
 {
     Initialize();
     return(await responseTable
            .OrderByDescending(r => r.UpdatedAt)
            .Take(100).ToEnumerableAsync());
 }
コード例 #3
0
        public List <HighscoreEntry> GetTopTen()
        {
            var task    = _table.OrderByDescending(x => x.Points).Take(10).ToListAsync();
            var awaiter = task.ConfigureAwait(false).GetAwaiter();

            return(awaiter.GetResult());
        }
コード例 #4
0
        public async static Task <Face> GetLatestFace()
        {
            faces = await faceTable
                    .OrderByDescending(faceTable => faceTable.UpdatedAt).ToCollectionAsync();

            return(faces[0]);
        }
コード例 #5
0
        /// <summary>
        /// 進行要顯示資料的初始化
        /// </summary>
        private async Task Init()
        {
            差旅費用項目ViewModel foo差旅費用項目;

            差旅費用項目清單.Clear();

            #region 呼叫 Azure 行動應用後台,取得最新後台資料表的清單
            var fooList = await 差旅費用Table.OrderByDescending(x => x.出差日期).ToListAsync();

            foreach (var item in fooList)
            {
                foo差旅費用項目 = new 差旅費用項目ViewModel
                {
                    ID    = item.Id,
                    出差日期  = item.出差日期,
                    項目名稱  = item.項目名稱,
                    地點    = item.地點,
                    類型    = item.類型,
                    是否有單據 = item.是否有單據,
                    內外    = item.內外,
                    費用    = item.費用,
                    備註    = item.備註,
                };
                差旅費用項目清單.Add(foo差旅費用項目);
            }
            #endregion
        }
コード例 #6
0
        public async Task <AlertItem> GetLatestAlertItemAsync(bool syncItems = false)
        {
            try
            {
#if OFFLINE_SYNC_ENABLED
                if (syncItems)
                {
                    await this.SyncAsync();
                }
#endif
                List <AlertItem> items = await alertTable
                                         .OrderByDescending(i => i.AlertTime)
                                         .Take(1)
                                         .ToListAsync();

                if (items.Count == 1)
                {
                    return(items[0]);
                }
                else
                {
                    return(null);
                }
            }
            catch (MobileServiceInvalidOperationException msioe)
            {
                Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message);
            }
            catch (Exception e)
            {
                Debug.WriteLine(@"Sync error: {0}", e.Message);
            }
            return(null);
        }
コード例 #7
0
        public async Task <ObservableCollection <Yodel> > GetYodelsAsync(bool syncItems = false)
        {
            try
            {
#if OFFLINE_SYNC_ENABLED
                if (syncItems)
                {
                    await this.SyncAsync();
                }
#endif
                IEnumerable <Yodel> items = await yodelTable
                                            //.Where(todoItem => !todoItem.Done)
                                            .OrderByDescending(x => x.CreatedAt)
                                            .Where(yodel => yodel.Deleted != true)
                                            .Take(25)
                                            .ToEnumerableAsync();

                return(new ObservableCollection <Yodel>(items));
            }
            catch (MobileServiceInvalidOperationException msioe)
            {
                Debug.WriteLine(@"Invalid sync operation: {0}", msioe.Message);
            }
            catch (Exception e)
            {
                Debug.WriteLine(@"Sync error: {0}", e.Message);
            }
            return(null);
        }
コード例 #8
0
        public async static Task <Person> GetLatestPerson()
        {
            persons = await personTable
                      .OrderByDescending(personTable => personTable.UpdatedAt).ToCollectionAsync();

            return(persons[0]);
        }
コード例 #9
0
        // Fetches the last chat conversation items from the cloud to be displayed on screen
        private async void RefreshChatItems()
        {
            prgBusy.IsActive = true;

            if (isLoggedin)
            {
                MobileServiceInvalidOperationException exception = null;
                try
                {
                    // The max number of items to retrieve from Azure Mobile Services
                    // Note that N CANNOT be greater than 50, we'd have to use paging for more
                    int n = 20;

                    // This code refreshes the entries in the list view by querying the ChatItems table.
                    // We only want the last N members, so we have to sort by descending order and request the first N
                    items = await chatTable.OrderByDescending(chatitem => chatitem.TimeStamp).Take(n).ToCollectionAsync();

                    // But now we need to reverse the order again so the last item is always at the bottom of the list, not the top
                    // Unfortunately, both of these methods are unsupported on a Mobile Service Collection
                    // items.Reverse<ChatItem>();
                    // items.OrderBy(chatitem => chatitem.TimeStamp);

                    // Let's get creative and manually invert the order of the items by moving them one by one
                    // Since there cannot be more than 50 items, this is not an unreasonable technique to use
                    if (items.Count > 0)
                    {
                        if (items.Count < n)
                        {
                            n = items.Count;
                        }

                        for (int i = 0; i < (n - 1); i++)
                        {
                            items.Move(0, n - i - 1);
                        }
                    }

                    items.CollectionChanged += (s, args) => ScrollDown();

                    ScrollDown();
                }
                catch (MobileServiceInvalidOperationException e)
                {
                    exception = e;
                }

                if (exception != null)
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        new MessageDialog(exception.Message, "Error loading items").ShowAsync();
                    });
                }
                else
                {
                    ListItems.ItemsSource = items;
                }
            }
            prgBusy.IsActive = false;
        }
コード例 #10
0
ファイル: MainPage.xaml.cs プロジェクト: yavorg/samples
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.  The Parameter
 /// property is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     updates = updatesTable
               .OrderByDescending(u => u.Date)
               .Take(10)
               .ToCollectionView();
     items.ItemsSource = updates;
 }
コード例 #11
0
ファイル: Repository.cs プロジェクト: creasewp/GamePool
        /// <summary>
        /// For now, this returns all users
        /// </summary>
        /// <param name="poolId">The pool identifier.</param>
        /// <returns></returns>
        /// <author>Wayne Creasey</author>
        /// <datetime>10/8/2014</datetime>
        public async Task <IList <User> > GetPoolUsers(string poolId)
        {
            IMobileServiceTable <User> users = m_MobileService.GetTable <User>();

            IList <User> listUsers = await users.OrderByDescending(item => item.PoolScore).ToListAsync();

            return(listUsers);
        }
コード例 #12
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //PushNotificationChannel channel;
            //channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            //try
            //{
            //    await App.Mugd_appClient.GetPush().RegisterNativeAsync(channel.Uri);
            //    //await App.Mugd_appClient.InvokeApiAsync("notifyAllUsers",
            //    //    new JObject(new JProperty("toast", "Sample Toast")));
            //}
            //catch (Exception exception)
            //{
            //    HandleRegisterException(exception);
            //}
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection <ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync();

            var    networkProfiles  = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var    adapter          = networkProfiles.First <Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date    = k.CreatedAt.Date.ToString();
                a.time    = k.CreatedAt.TimeOfDay.ToString();
                a.time    = a.time.Remove(5);
                a.date    = a.date.Remove(10);
                a.Name    = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource         = test;
            test.CollectionChanged += test_CollectionChanged;
        }
        /// <summary>
        /// 進行要顯示資料的初始化
        /// </summary>
        private async Task Init()
        {
            工作日報表項目ViewModel fooHeader工作日報表項目 = null;

            工作日報表項目清單.Clear();

            #region 呼叫 Azure 行動應用後台,取得最新後台資料表的清單
            List <WorkLog> fooList = new List <WorkLog>();
            try
            {
                fooList = await WorkLogTable.OrderByDescending(x => x.日期).ToListAsync();
            }
            catch (MobileServiceInvalidOperationException ex)
            {
                // 判斷是否使用者尚未登入,否則,不能夠使用這個功能
                if (ex.Response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    await _dialogService.DisplayAlertAsync("警告", "這個頁面需要先登入系統,才能夠使用", "確定");
                }
            }
            catch (Exception ex)
            {
                await _dialogService.DisplayAlertAsync("警告", $"發生錯誤:{ex.Message}", "確定");
            }
            foreach (var item in fooList)
            {
                var foo工作日報表項目 = new 工作日報表項目ViewModel
                {
                    ID       = item.Id,
                    專案名稱     = item.專案名稱,
                    日期       = item.日期,
                    處理時間     = item.處理時間,
                    工作內容     = item.工作內容,
                    當日累計工時   = 0,
                    是否顯示日期區塊 = false,
                };
                if (fooHeader工作日報表項目 == null)
                {
                    fooHeader工作日報表項目          = foo工作日報表項目;
                    fooHeader工作日報表項目.當日累計工時   = foo工作日報表項目.處理時間;
                    fooHeader工作日報表項目.是否顯示日期區塊 = true;
                }
                else if (fooHeader工作日報表項目.日期.Date == foo工作日報表項目.日期.Date)
                {
                    fooHeader工作日報表項目.當日累計工時 += foo工作日報表項目.處理時間;
                }
                else
                {
                    fooHeader工作日報表項目          = foo工作日報表項目;
                    fooHeader工作日報表項目.當日累計工時   = foo工作日報表項目.處理時間;
                    fooHeader工作日報表項目.是否顯示日期區塊 = true;
                }
                工作日報表項目清單.Add(foo工作日報表項目);
            }
            #endregion
        }
コード例 #14
0
        public async Task OrderingReadAsyncWithValidStringIdAgainstStringIdTable()
        {
            await EnsureEmptyTableAsync <ToDoWithStringId>();

            string[] testIdData = new string[] { "a", "b", "C", "_A", "_B", "_C", "1", "2", "3" };
            IMobileServiceTable <ToDoWithStringId> table = GetClient().GetTable <ToDoWithStringId>();

            foreach (string testId in testIdData)
            {
                ToDoWithStringId item = new ToDoWithStringId()
                {
                    Id = testId, String = "Hey"
                };
                await table.InsertAsync(item);
            }

            IEnumerable <ToDoWithStringId> results = await table.OrderBy(p => p.Id).ToEnumerableAsync();

            ToDoWithStringId[] items = results.ToArray();

            Assert.AreEqual(9, items.Count());
            Assert.AreEqual("_A", items[0].Id);
            Assert.AreEqual("_B", items[1].Id);
            Assert.AreEqual("_C", items[2].Id);
            Assert.AreEqual("1", items[3].Id);
            Assert.AreEqual("2", items[4].Id);
            Assert.AreEqual("3", items[5].Id);
            Assert.AreEqual("a", items[6].Id);
            Assert.AreEqual("b", items[7].Id);
            Assert.AreEqual("C", items[8].Id);

            results = await table.OrderByDescending(p => p.Id).ToEnumerableAsync();

            items = results.ToArray();

            Assert.AreEqual(9, items.Count());
            Assert.AreEqual("_A", items[8].Id);
            Assert.AreEqual("_B", items[7].Id);
            Assert.AreEqual("_C", items[6].Id);
            Assert.AreEqual("1", items[5].Id);
            Assert.AreEqual("2", items[4].Id);
            Assert.AreEqual("3", items[3].Id);
            Assert.AreEqual("a", items[2].Id);
            Assert.AreEqual("b", items[1].Id);
            Assert.AreEqual("C", items[0].Id);

            foreach (string testId in testIdData)
            {
                ToDoWithStringId item = new ToDoWithStringId()
                {
                    Id = testId
                };
                await table.DeleteAsync(item);
            }
        }
コード例 #15
0
ファイル: AzureMobileService.cs プロジェクト: steamypassion/X
        public async Task <List <Favourite> > RetrieveFavoritesFromCloudAsync(int pageSize = 20)
        {
            if (!AppService.IsConnected())
            {
                return(null);
            }

            var result = await mstFavourite.OrderByDescending(x => x.TimeStamp).Take(pageSize).ToListAsync();

            return(result);
        }
コード例 #16
0
        public async Task <List <Promote> > RetrievePromotedFromCloudAsync()
        {
            if (!AppService.IsConnected())
            {
                return(null);
            }

            return(await mstPromote.OrderByDescending(x => x.TimeStamp).Take(50).ToListAsync());

            //return await mstFavourite.Take(10).ToListAsync();
        }
コード例 #17
0
ファイル: AzureMobileService.cs プロジェクト: steamypassion/X
        public async Task <List <Comment> > RetrieveCommentFromCloudAsync(int pageSize = 30)
        {
            if (!AppService.IsConnected())
            {
                return(null);
            }

            var result = await mstComment.OrderByDescending(x => x.TimeStamp).Take(pageSize).ToListAsync();

            return(result);
        }
コード例 #18
0
        private async Task RefreshTodoItems()
        {
            MobileServiceInvalidOperationException exception = null;

            try
            {
                // This code refreshes the entries in the list view by querying the TodoItems table.
                // The query excludes completed TodoItems.

                /*
                 * items = await todoTable
                 *  .Where(todoItem => todoItem.Complete == false)
                 *  .ToCollectionAsync();
                 *
                 * natanItems = await natanTable
                 *  .Where(natanItem => natanItem.Complete == false)
                 *  .ToCollectionAsync();
                 */
                try
                {
                    playerItems = await playerTable
                                  .OrderByDescending(playerItem => playerItem.Score)
                                  .ToCollectionAsync();
                } catch (System.Net.Http.HttpRequestException ex)
                {
                    ContentDialog deleteFileDialog = new ContentDialog
                    {
                        FontSize          = 10,
                        Title             = "Network Error",
                        PrimaryButtonText = "Home"
                    };

                    ContentDialogResult result = await deleteFileDialog.ShowAsync();

                    this.Frame.Navigate(typeof(ServerMenuPage));
                }
            }
            catch (MobileServiceInvalidOperationException e)
            {
                exception = e;
            }

            if (exception != null)
            {
                await new MessageDialog(exception.Message, "Error loading items").ShowAsync();
            }
            else
            {
                //ListItems.ItemsSource = items;
                ListItems.ItemsSource = playerItems;
                //this.ButtonSave.IsEnabled = true;
            }
        }
コード例 #19
0
        public async Task OrderByDescAsyncGeneric()
        {
            TestHttpHandler hijack = new TestHttpHandler();

            hijack.SetResponseContent("[]");
            IMobileServiceClient service = new MobileServiceClient("http://www.test.com", "secret...", hijack);

            IMobileServiceTable <StringType> table = service.GetTable <StringType>();
            List <StringType> people = await table.OrderByDescending(p => p.Id).ThenByDescending(p => p.String).ToListAsync();

            Assert.Contains(hijack.Request.RequestUri.ToString(), "StringType");
            Assert.Contains(hijack.Request.RequestUri.ToString(), "orderby=id desc,String desc");
        }
コード例 #20
0
        // Fetches the last chat conversation items from the cloud to be displayed on screen
        private async void RefreshChatItems()
        {
            prgBusy.IsActive = true;

            if (isLoggedin)
            {
                MobileServiceInvalidOperationException exception = null;
                try
                {
                    // The max number of items to retrieve from Azure Mobile Services
                    int n = 30;
                    // refreshes the entries in the list view by querying the ChatItems table.
                    items = await chatTable.OrderByDescending(chatitem => chatitem.TimeStamp).Take(n).ToCollectionAsync();

                    // reverse the order again so the last item is always at the bottom of the list, not the top
                    if (items.Count > 0)
                    {
                        if (items.Count < n)
                        {
                            n = items.Count;
                        }

                        for (int i = 0; i < (n - 1); i++)
                        {
                            items.Move(0, n - i - 1);
                        }
                    }

                    ScrollDown();
                }
                catch (MobileServiceInvalidOperationException e)
                {
                    exception = e;
                }

                if (exception != null)
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        new MessageDialog(exception.Message, "Error loading items").ShowAsync();
                    });
                }
                else
                {
                    ListItems.ItemsSource = items;
                    //lastCount = items.Count;
                    ScrollDown();
                }
            }
            prgBusy.IsActive = false;
        }
コード例 #21
0
        public async Task <List <Dog> > GetTopThreeDogsByTotalWalk()
        {
            var items = await dogTable
                        .OrderByDescending(dog => dog.Walk)
                        .Take(3)
                        .ToListAsync();

            if (items == null || items.Count == 0)
            {
                return(null);
            }

            return(items);
        }
コード例 #22
0
        public async Task SimpleDataSource()
        {
            // Get the Books table
            IMobileServiceTable <Book> table = GetClient().GetTable <Book>();

            // Create a new CollectionView
            Log("Creating DataSource");
            MobileServiceCollection <Book, Book> dataSource =
                await table.OrderByDescending(b => b.Price).ToCollectionAsync();

            Log("Verifying loaded");
            Assert.AreEqual(18, dataSource.Count);
            Assert.AreEqual((long)-1, ((ITotalCountProvider)dataSource).TotalCount);
            Assert.AreEqual(22.95, dataSource[0].Price);
        }
コード例 #23
0
        public async Task OrderingReadAsyncWithStringIdAgainstIntegerIdTable()
        {
            await EnsureEmptyTableAsync <ToDoWithIntId>();

            IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>();
            List <ToDoWithIntId> integerIdItems       = new List <ToDoWithIntId>();

            for (var i = 0; i < 10; i++)
            {
                ToDoWithIntId item = new ToDoWithIntId()
                {
                    String = i.ToString()
                };
                await table.InsertAsync(item);

                integerIdItems.Add(item);
            }

            IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>();

            IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.OrderBy(p => p.Id).ToEnumerableAsync();

            ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray();

            Assert.AreEqual(10, items.Count());
            for (var i = 0; i < 8; i++)
            {
                Assert.AreEqual((int.Parse(items[i].Id) + 1).ToString(), items[i + 1].Id);
            }

            results = await stringIdTable.OrderByDescending(p => p.Id).ToEnumerableAsync();

            items = results.ToArray();

            Assert.AreEqual(10, items.Count());
            for (var i = 8; i >= 0; i--)
            {
                Assert.AreEqual((int.Parse(items[i].Id) - 1).ToString(), items[i + 1].Id);
            }

            foreach (ToDoWithIntId integerIdItem in integerIdItems)
            {
                await table.DeleteAsync(integerIdItem);
            }
        }
コード例 #24
0
        // Obtiene los últimos mensajes de la conversación desde la nube para mostrarlos en la pantalla
        private async void RefreshChatItems()
        {
            prgBusy.IsActive = true;

            if (isLoggedin)
            {
                MobileServiceInvalidOperationException exception = null;
                try
                {
                    int n = 20;
                    items = await chatTable.OrderByDescending(chatitem => chatitem.TimeStamp).Take(n).ToCollectionAsync();

                    if (items.Count > 0)
                    {
                        if (items.Count < n)
                        {
                            n = items.Count;
                        }

                        for (int i = 0; i < (n - 1); i++)
                        {
                            items.Move(0, n - i - 1);
                        }
                    }
                }
                catch (MobileServiceInvalidOperationException e)
                {
                    exception = e;
                }

                if (exception != null)
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        new MessageDialog(exception.Message, "Error cargando los mensajes").ShowAsync();
                    });
                }
                else
                {
                    ListItems.ItemsSource = items;
                }
            }
            prgBusy.IsActive = false;
        }
コード例 #25
0
        public async Task SimpleDataSource()
        {
            // Get the Books table
            IMobileServiceTable <Book> table = GetClient().GetTable <Book>();

            // Create a new CollectionView
            Log("Creating DataSource");
            MobileServiceCollectionView <Book> dataSource =
                table.OrderByDescending(b => b.Price).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(18, dataSource.Count);
            Assert.AreEqual(22.95, dataSource[0].Price);
        }
コード例 #26
0
 public IMobileServiceTableQuery <T> OrderByDescending <TKey>(Expression <Func <T, TKey> > keySelector)
 {
     return(_table.OrderByDescending(keySelector));
 }
コード例 #27
0
ファイル: TodoRepository.cs プロジェクト: John-Emmett/TodoApp
 //Filter Descending Method
 public async void FilterByDescendingOrder(TodoItem todo)
 {
     IMobileServiceTableQuery <TodoItem> query = todoTable.OrderByDescending(todoItem => todoItem.Text);
     List <TodoItem> items = await query.ToListAsync();
 }