Пример #1
0
        void DoShellAuthentication(object sender, CHBaseResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            App.HealthVaultService.SaveSettings(SettingsFilename);

            string url;

            if (_addingRecord)
            {
                url = App.HealthVaultService.GetUserAuthorizationUrl();
            }
            else
            {
                url = App.HealthVaultService.GetApplicationCreationUrl();
            }

            App.HealthVaultShellUrl = url;

#if !UseHostedBrowser
            Uri pageUri = new Uri("/HealthVaultIntroPage.xaml", UriKind.RelativeOrAbsolute);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                NavigationService.Navigate(pageUri);
            });
#else
            WebBrowserTask task = new WebBrowserTask();
            task.URL = HttpUtility.UrlEncode(url);
            task.Show();
#endif
        }
Пример #2
0
        void GetThingsCompleted(object sender, CHBaseResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            if (e.ErrorText == null)
            {
                _currentThingIds.Clear();

                List <XElement> thingNodes = GetThingsFromResponse(e);

                List <string> values = new List <string>();
                int           count  = 0;
                foreach (XElement thingNode in thingNodes)
                {
                    XElement thingIdNode = thingNode.Element("thing-id");
                    _currentThingIds.Add(thingIdNode.ToString());

                    XElement dateNode = thingNode.Element("eff-date");
                    DateTime dateTime = DateTime.Parse(dateNode.Value);
                    string   value, units = "kg";
                    try
                    {
                        XElement displayValueNode = thingNode.Descendants("display").Single();
                        value = displayValueNode.Value;
                        units = displayValueNode.Attribute("units").Value;
                    }
                    catch
                    {
                        XElement displayValueNode = thingNode.Descendants("value").Single();
                        value = displayValueNode.Descendants("kg").Single().Value;
                    }

                    string displayValue = dateTime.ToString() + "      " + value + " " + units;

                    values.Add(displayValue);

                    count++;
                    if (count == 10)
                    {
                        break;
                    }
                }

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    string text = "Results\r\n";

                    foreach (string value in values)
                    {
                        text += value + "\r\n";
                    }

                    c_Response.Text = text;
                });
            }
        }
Пример #3
0
        List <XElement> GetThingsFromResponse(CHBaseResponseEventArgs eventArgs)
        {
            XElement responseNode = XElement.Parse(eventArgs.ResponseXml);

            XElement infoNode = responseNode.Element(XName.Get("info", "urn:com.microsoft.wc.methods.response.GetThings3"));

            List <XElement> thingNodes = new List <XElement>(infoNode.Element("group").Elements("thing"));

            return(thingNodes);
        }
Пример #4
0
        void PutThingsCompleted(object sender, CHBaseResponseEventArgs e)
        {
            if (e.ErrorText != null)
            {
                // handle error...
            }

            SetProgressBarVisibility(false);

            XElement response = XElement.Parse(e.ResponseXml);

            XElement thingIdNode = response.Descendants("thing-id").Single();

            Guid thingId = new Guid(thingIdNode.Value);

            Guid versionStamp = new Guid(thingIdNode.Attribute("version-stamp").Value);

            GetThingsStart();
        }
Пример #5
0
        void GetPersonalImageCompleted(object sender, CHBaseResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            if (e.ErrorText == null)
            {
                _currentThingIds.Clear();

                List <XElement> thingNodes = GetThingsFromResponse(e);
                try
                {
                    if (thingNodes.Count != 0)
                    {
                        string url = thingNodes[0].Descendants("blob-ref-url").Single().Value;

                        HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
                        request.BeginGetResponse((ar) =>
                        {
                            var response = request.EndGetResponse(ar);
                            Dispatcher.BeginInvoke(() =>
                            {
                                using (var stream = response.GetResponseStream())
                                {
                                    var image = new BitmapImage();
                                    image.SetSource(stream);
                                    c_RecordImage.Source = image;
                                }
                            });
                        }, null);
                    }
                }
                catch (Exception) { }
            }

            AnimateObjectOpacity(c_RecordPanel);

            GetThingsStart();
        }
Пример #6
0
        void AuthenticationCompleted(object sender, CHBaseResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            if (e != null && e.ErrorText != null)
            {
                SetRecordName(e.ErrorText);
                return;
            }

            if (App.HealthVaultService.CurrentRecord == null)
            {
                App.HealthVaultService.CurrentRecord = App.HealthVaultService.Records[0];
            }

            App.HealthVaultService.SaveSettings(SettingsFilename);
            if (App.HealthVaultService.CurrentRecord != null)
            {
                SetRecordName(App.HealthVaultService.CurrentRecord.RecordName);

                //GetThingsStart();
                GetPersonalImageStart();
            }
        }
Пример #7
0
        void RemoveThingsCompleted(object sender, CHBaseResponseEventArgs e)
        {
            SetProgressBarVisibility(false);

            GetThingsStart();
        }