private async void AppBarButtonPersonGroupRefresh_Click(object sender, RoutedEventArgs e)
        {
            this.IsEnabled = false;
            personGroupProgressRing.IsActive = true;

            appbarEditPersonGroupButton.IsEnabled   = false;
            appbarPersonGroupNextButton.IsEnabled   = false;
            appbarDeletePersonGroupButton.IsEnabled = false;

            List <PersonGroups> personGroups = await PersonGroupCmds.ListPersonGroups();

            personGroupListView.ItemsSource       = personGroups;
            personGroupListView.DisplayMemberPath = "name";
            globals.gPersonGroupList = personGroups;

            personGroupProgressRing.IsActive = false;
            this.IsEnabled = true;
        }
Beispiel #2
0
        private async void FaceQuery(StorageFile file)
        {
            CloudBlockBlob blob         = null;
            string         blobFileName = null;

            if (null != file)
            {
                txtResponse.Text = "";
                progressRingMainPage.IsActive = true;
                BitmapImage         bitmapImage = new BitmapImage();
                IRandomAccessStream fileStream  = await file.OpenAsync(FileAccessMode.Read);

                bitmapImage.SetSource(fileStream);
                CapturedPhoto.Source = bitmapImage;
                CapturedPhoto.Tag    = file.Path;

                blobFileName = System.Guid.NewGuid() + "." + file.Name.Split('.').Last <string>();

                await HttpHandler.tempContainer.CreateIfNotExistsAsync();

                BlobContainerPermissions permissions = new BlobContainerPermissions();
                permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
                await HttpHandler.tempContainer.SetPermissionsAsync(permissions);

                blob = HttpHandler.tempContainer.GetBlockBlobReference(blobFileName);
                await blob.DeleteIfExistsAsync();

                await blob.UploadFromFileAsync(file);

                string              uri        = "https://api.projectoxford.ai/face/v1.0/detect?returnFaceId=true";
                string              jsonString = "{\"url\":\"" + HttpHandler.storagePath + "visitors/" + blobFileName + "\"}";
                HttpContent         content    = new StringContent(jsonString, Encoding.UTF8, "application/json");
                HttpResponseMessage response   = await HttpHandler.client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    if (null == globals.gPersonGroupList)
                    {
                        globals.gPersonGroupList = await PersonGroupCmds.ListPersonGroups();
                    }

                    List <string> names = await VisitorCmds.CheckVisitorFace(responseBody, globals.gPersonGroupList);

                    if (0 == names.Count)
                    {
                        txtResponse.Text = "Sorry, I don't know.";
                    }
                    else
                    {
                        txtResponse.Text = string.Join(", ", names.ToArray());
                    }
                }
                else
                {
                    string responseBody = await response.Content.ReadAsStringAsync();

                    globals.ShowJsonErrorPopup(responseBody);
                }

                await blob.DeleteAsync();

                progressRingMainPage.IsActive = false;
            }
        }