コード例 #1
0
        public void MobileServiceCollectionCanCopyToAndNotNotifies()
        {
            // Get the Books table
            MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>();

            query.EnumerableAsyncThrowsException = true;

            MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query);

            List <string> properties         = new List <string>();
            List <string> expectedProperties = new List <string>()
            {
            };
            List <NotifyCollectionChangedAction> actions         = new List <NotifyCollectionChangedAction>();
            List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>()
            {
            };

            Book book = new Book();

            collection.Add(book);
            Book[] books = new Book[1];

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.CopyTo(books, 0);

            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(1, books.Count());
            Assert.AreEqual(collection[0], books[0]);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }
コード例 #2
0
        public async Task AddVehicleAsync(Vehicle vehicle)
        {
            try
            {
                Debug.WriteLine("Inserting vehicle...");
                await vehicles.InsertAsync(vehicle);

                Debug.WriteLine("Adding vehicle to offline database...");
                Items.Add(vehicle);
                Debug.WriteLine("Syncing offline database...");
                await SyncAsync();
            }
            catch
            {
            }
        }
        public void MobileServiceCollectionCanContainsAndNotNotifies()
        {
            // Get the Books table
            MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>();

            query.EnumerableAsyncThrowsException = true;

            MobileServiceCollection <Book, Book> collection = new MobileServiceCollection <Book, Book>(query);

            List <string> properties         = new List <string>();
            List <string> expectedProperties = new List <string>()
            {
            };
            List <NotifyCollectionChangedAction> actions         = new List <NotifyCollectionChangedAction>();
            List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>()
            {
            };

            Book book = new Book();

            collection.Add(book);

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);

            Assert.Contains(book, collection);
            Assert.Equal(expectedProperties, properties);
            Assert.Equal(expectedActions, actions);
        }
コード例 #4
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. After the operation completes
            // and the mobile app backend has assigned an id, the item is added to the CollectionView.
            try
            {
                await todoTable.InsertAsync(todoItem);

                items.Add(todoItem);
            }
            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));
            }


#if OFFLINE_SYNC_ENABLED
            await App.MobileService.SyncContext.PushAsync(); // offline sync
#endif
        }
コード例 #5
0
        public void MobileServiceCollectionCanClearAndNotifies()
        {
            // Get the Books table
            MobileServiceTableQueryMock <Book> query = new MobileServiceTableQueryMock <Book>();

            query.EnumerableAsyncThrowsException = true;

            MobileServiceCollection <Book> collection = new MobileServiceCollection <Book>(query);

            List <string> properties         = new List <string>();
            List <string> expectedProperties = new List <string>()
            {
                "Count", "Item[]"
            };
            List <NotifyCollectionChangedAction> actions         = new List <NotifyCollectionChangedAction>();
            List <NotifyCollectionChangedAction> expectedActions = new List <NotifyCollectionChangedAction>()
            {
                NotifyCollectionChangedAction.Reset
            };

            Book book = new Book();

            collection.Add(book);

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.Clear();

            Assert.AreEqual(0, collection.Count);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }
コード例 #6
0
        private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            e.Cancel = true;

            switch (e.NotificationType)
            {
            // Badges are not yet supported and will be added in a future version
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            // Tiles are not yet supported and will be added in a future version
            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            // The current version of AzureChatr only works via toast notifications
            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                XmlDocument toastXml = e.ToastNotification.Content;

                // Extract the relevant chat item data from the toast notification payload
                XmlNodeList toastTextAttributes = toastXml.GetElementsByTagName("text");
                string      username            = toastTextAttributes[0].InnerText;
                string      chatline            = toastTextAttributes[1].InnerText;
                string      chatdatetime        = toastTextAttributes[2].InnerText;

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    var chatItem = new ChatItem {
                        Text = chatline, UserName = username
                    };
                    // Post the new chat item received in the chat window.
                    // IMPORTANT: If you updated the code above to post new chat lines from
                    //            the current user immediately in the chat window, you will
                    //            end up with duplicates here. You need to filter-out the
                    //            current user's chat entries to avoid these duplicates.
                    items.Add(chatItem);
                    ScrollDown();
                });

                // This is a quick and dirty way to make sure that we don't use speech synthesis
                // to read the current user's chat lines out loud
                if (chatline != lastChatline)
                {
                    ReadText(username + " says: " + chatline);
                }

                break;

            // Raw notifications are not used in this version
            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
            }
            //e.Cancel = true;
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: phaufe/ZumoContrib
        private async void InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile Services has assigned an Id, the item is added to the CollectionView
            await todoTable.InsertAsync(todoItem);

            items.Add(todoItem);
        }
コード例 #8
0
        private async Task InsertTodoItem(Message todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile Services has assigned an Id, the item is added to the CollectionView
            await messageTable.InsertAsync(todoItem);

            messages.Add(todoItem);

            //await SyncAsync(); // offline sync
        }
コード例 #9
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile Apps has assigned an Id, the item is added to the CollectionView
            await todoTable.InsertAsync(todoItem);

            items.Add(todoItem);

            //await App.MobileService.SyncContext.PushAsync(); // offline sync
        }
コード例 #10
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile App backend has assigned an Id, the item is added to the CollectionView.
            await todoTable.InsertAsync(todoItem);

            items.Add(todoItem);

            await SyncAsync(); // offline sync
        }
コード例 #11
0
        private async Task InsertWeatherDataItem(WeatherDataItem weatherDataItem)
        {
            // This code inserts a new WeatherDataItem into the database. When the operation completes
            // and Mobile App backend has assigned an Id, the item is added to the CollectionView.
            await weatherTable.InsertAsync(weatherDataItem);

            data.Add(weatherDataItem);

            await SyncAsync(); // offline sync
        }
コード例 #12
0
        private async Task InsertUser(User user)
        {
            // This code inserts a new User into the database. When the operation completes
            // and Mobile Services has assigned an Id, the item is added to the CollectionView
            await usersTable.InsertAsync(user);

            users.Add(user);

            //await SyncAsync(); // offline sync
        }
コード例 #13
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            await todoTable.InsertAsync(todoItem);

            items.Add(todoItem);

#if OFFLINE_SYNC_ENABLED
            await App.MobileService.SyncContext.PushAsync(); // offline sync
#endif
        }
コード例 #14
0
ファイル: MainPage.cs プロジェクト: jackhwl/azure
        private async Task InsertDemoColor(DemoColor demoColor)
        {
            if (!string.IsNullOrWhiteSpace(demoColor.Name))
            {
                // This code inserts a new DemoColor into the database. When the operation completes
                // and Mobile App backend has assigned an Id, the item is added to the CollectionView.
                await demoTable.InsertAsync(demoColor);

                items.Add(demoColor);
            }
        }
コード例 #15
0
        // Add drill to database
        public async Task AddDrill(DrillItem drillItem, String n, int s, int t, string sty, string use)
        {
            drillItem.Name    = n;
            drillItem.Sets    = s;
            drillItem.SetTime = t;
            drillItem.Style   = sty;
            drillItem.Use     = use;
            await App.MobileService.GetTable <DrillItem>().InsertAsync(drillItem);

            drills.Add(drillItem);
        }
コード例 #16
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. After the operation completes
            // and the mobile app backend has assigned an id, the item is added to the CollectionView.
            await todoTable.InsertAsync(todoItem);
            items.Add(todoItem);

#if OFFLINE_SYNC_ENABLED
            await App.MobileService.SyncContext.PushAsync(); // offline sync
#endif
        }
コード例 #17
0
ファイル: Domain.cs プロジェクト: valeryjacobs/PlenMe
        public Content AddContent()
        {
            Content instance = new Content
            {
                Id = Guid.NewGuid().ToString()
            };

            _contentTable.InsertAsync(instance);
            _items.Add(instance);
            return(instance);
        }
コード例 #18
0
        private async void SendInfo(problem prob)
        {
            try
            {
                await prob_tb.InsertAsync(prob);

                probl.Add(prob);
            }
            catch (Exception ex)
            {
            }
        }
コード例 #19
0
        private async void SendInfo(newQ que)
        {
            try
            {
                await quest_tb.InsertAsync(que);

                quest.Add(que);
            }
            catch (Exception ex)
            {
            }
        }
コード例 #20
0
        private async Task InsertTournamentTeam(string teamId)
        {
            string         tournamentId   = TournamentIdTextBlock.Text;
            TournamentTeam tournamentTeam = new TournamentTeam {
                TournamentId = tournamentId, TeamId = teamId, TeamWins = 0
            };
            await tournamentTeamsTable.InsertAsync(tournamentTeam);

            tournamentTeams.Add(tournamentTeam);

            //await App.MobileService.SyncContext.PushAsync(); // offline sync
        }
コード例 #21
0
        private async void InsertTodoItem(StudentTable todoItem)
        {
            await todoTable.InsertAsync(todoItem);

            items.Add(todoItem);

            // TODO: Delete or comment the following statement; Mobile Services auto-generates the ID.
            // todoItem.Id = Guid.NewGuid().ToString();

            //// This code inserts a new TodoItem into the database. When the operation completes
            //// and Mobile Services has assigned an Id, the item is added to the CollectionView
            //// TODO: Mark this method as "async" and uncomment the following statement.
        }
コード例 #22
0
        public async Task InsertSessionItem(session sessionItem)
        {
            try
            {
                await sessionTable.InsertAsync(sessionItem);

                items.Add(sessionItem);

                //await SyncAsync(); // offline sync
            }
            catch
            {
            }
        }
コード例 #23
0
        public async Task <bool> InsertProduct(Product newProduct)
        {
            try
            {
                await productTable.InsertAsync(newProduct);

                _products.Add(newProduct);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #24
0
        public async Task InsertEventItem(dxevent eventItem)
        {
            try
            {
                await eventTable.InsertAsync(eventItem);

                items.Add(eventItem);

                //await SyncAsync(); // offline sync
            }
            catch
            {
            }
        }
        private async Task InsertTodoItem(ToDoItemDocDb todoItem)
        {
            // This code inserts a new TodoItem into the database. After the operation completes
            // and the mobile app backend has assigned an id, the item is added to the CollectionView.
            await todoTable.InsertAsync(todoItem);

            todoItems.Add(todoItem);

            try
            {
                await App.MobileService.SyncContext.PushAsync();
            }
            catch { }
        }
コード例 #26
0
        private async void InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. When the operation completes
            // and Mobile Services has assigned an Id, the item is added to the CollectionView
            try
            {
                await todoTable.InsertAsync(todoItem);

                items.Add(todoItem);
            }
            catch (HttpRequestException)
            {
                ShowError();
            }
        }
コード例 #27
0
        private async Task InsertIntentItem(IntentItem IntentItem)
        {
            try
            {
                // This code inserts a new IntentItem into the database. After the operation completes
                // and the mobile app backend has assigned an id, the item is added to the CollectionView.
                await intentTable.InsertAsync(IntentItem);

                items.Add(IntentItem);

                await MobileService.SyncContext.PushAsync(); // offline sync
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
コード例 #28
0
        private async void OnPushNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs e)
        {
            String notificationContent = String.Empty;

            e.Cancel = true;

            switch (e.NotificationType)
            {
            // Los Badges aún no funcionan, pueden hacer eso en proximas versiones
            case PushNotificationType.Badge:
                notificationContent = e.BadgeNotification.Content.GetXml();
                break;

            // Los Tiles aún no funcionan, pueden hacer eso en proximas versiones
            case PushNotificationType.Tile:
                notificationContent = e.TileNotification.Content.GetXml();
                break;

            // La versión actual de esta aplicación sólo soporta notificaciones Toast
            case PushNotificationType.Toast:
                notificationContent = e.ToastNotification.Content.GetXml();
                XmlDocument toastXml = e.ToastNotification.Content;

                //Extrae los datos relevantes del chat para la carga de la notificación Toast
                XmlNodeList toastTextAttributes = toastXml.GetElementsByTagName("text");
                string      username            = toastTextAttributes[0].InnerText;
                string      chatline            = toastTextAttributes[1].InnerText;
                string      chatdatetime        = toastTextAttributes[2].InnerText;

                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    var chatItem = new Chat {
                        Mensaje = chatline, NombreUsuario = username
                    };
                    items.Add(chatItem);
                });

                break;

            // Las notificaciones Raw tampoco se utilizan en esta versión
            case PushNotificationType.Raw:
                notificationContent = e.RawNotification.Content;
                break;
            }
        }
コード例 #29
0
        private async void InsertTodoItem(TodoItem todoItem)
        {
            string errorString = string.Empty;

            if (imageStream != null)
            {
                // Set blob properties of TodoItem.
                todoItem.ContainerName = "todoitemimages";
                todoItem.ResourceName  = Guid.NewGuid().ToString() + ".jpg";
            }

            // Send the item to be inserted. When blob properties are set this
            // generates an SAS in the response.
            await todoTable.InsertAsync(todoItem);

            // If we have a returned SAS, then upload the blob.
            if (!string.IsNullOrEmpty(todoItem.SasQueryString))
            {
                // Get the URI generated that contains the SAS
                // and extract the storage credentials.
                StorageCredentials cred = new StorageCredentials(todoItem.SasQueryString);
                var imageUri            = new Uri(todoItem.ImageUri);

                // Instantiate a Blob store container based on the info in the returned item.
                CloudBlobContainer container = new CloudBlobContainer(
                    new Uri(string.Format("https://{0}/{1}",
                                          imageUri.Host, todoItem.ContainerName)), cred);

                // Upload the new image as a BLOB from the stream.
                CloudBlockBlob blobFromSASCredential =
                    container.GetBlockBlobReference(todoItem.ResourceName);
                await blobFromSASCredential.UploadFromStreamAsync(imageStream);

                // When you request an SAS at the container-level instead of the blob-level,
                // you are able to upload multiple streams using the same container credentials.

                imageStream = null;
            }

            // Add the new item to the collection.
            items.Add(todoItem);
            TodoInput.Text = "";
        }
コード例 #30
0
        private async Task InsertTodoItem(TodoItem todoItem)
        {
            // This code inserts a new TodoItem into the database. After the operation completes
            // and the mobile app backend has assigned an id, the item is added to the CollectionView.
            try
            {
                await todoTable.InsertAsync(todoItem);

                items.Add(todoItem);

#if OFFLINE_SYNC_ENABLED
                await App.MobileService.SyncContext.PushAsync(); // offline sync
#endif
            }
            catch (Exception e)
            {
                await new MessageDialog(e.Message, "Error syncing items").ShowAsync();
            }
        }
コード例 #31
0
        public void MobileServiceCollectionCanClearAndNotifies()
        {
            // Get the Books table
            MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>();
            query.EnumerableAsyncThrowsException = true;

            MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query);

            List<string> properties = new List<string>();
            List<string> expectedProperties = new List<string>() { "Count", "Item[]" };
            List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>();
            List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() { NotifyCollectionChangedAction.Reset };

            Book book = new Book();
            collection.Add(book);

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.Clear();

            Assert.AreEqual(0, collection.Count);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }
コード例 #32
0
        public void MobileServiceCollectionCanCopyToAndNotNotifies()
        {
            // Get the Books table
            MobileServiceTableQueryMock<Book> query = new MobileServiceTableQueryMock<Book>();
            query.EnumerableAsyncThrowsException = true;

            MobileServiceCollection<Book, Book> collection = new MobileServiceCollection<Book, Book>(query);

            List<string> properties = new List<string>();
            List<string> expectedProperties = new List<string>() {  };
            List<NotifyCollectionChangedAction> actions = new List<NotifyCollectionChangedAction>();
            List<NotifyCollectionChangedAction> expectedActions = new List<NotifyCollectionChangedAction>() {  };

            Book book = new Book();
            collection.Add(book);
            Book[] books = new Book[1];

            ((INotifyPropertyChanged)collection).PropertyChanged += (s, e) => properties.Add(e.PropertyName);
            collection.CollectionChanged += (s, e) => actions.Add(e.Action);
            collection.CopyTo(books, 0);

            Assert.AreEqual(1, collection.Count);
            Assert.AreEqual(1, books.Count());
            Assert.AreEqual(collection[0], books[0]);
            Assert.IsTrue(properties.SequenceEqual(expectedProperties));
            Assert.IsTrue(actions.SequenceEqual(expectedActions));
        }