Example #1
0
        /// <summary>
        /// Parse Xml data obtained
        /// </summary>
        /// <param name="xmlFeed"></param>
        private void ParseSubMenuList(XElement xmlFeed)
        {
            try
            {
                XNamespace s = "http://syndication.nhschoices.nhs.uk/services";
                foreach (XElement curElement in xmlFeed.Descendants("entry").Descendants("content").Descendants(s + "organisationSummary"))
                {
                    lstSurgenSearch.ItemsSource = null;
                    try
                    {
                        SelectSurgenFeedData SelectSurgen = new SelectSurgenFeedData();
                        var newData = new organisationSummaryAddress();

                        SelectSurgen.Name    = (curElement.Element(s + "name")).Value.ToString();
                        SelectSurgen.OdsCode = (curElement.Element(s + "odsCode")).Value.ToString();
                        string[] addresslines = new string[6];
                        int      i            = 0;
                        foreach (XElement curElementCoordinates in curElement.Descendants(s + "address"))
                        {
                            foreach (XElement SubcurElementCoordinates in curElementCoordinates.Descendants(s + "addressLine"))
                            {
                                addresslines[i] = SubcurElementCoordinates.Value;
                                i++;
                            }
                            addresslines[5] = curElementCoordinates.Element(s + "postcode").Value.ToString();
                        }
                        if ((!string.IsNullOrEmpty(addresslines[0])) && (!string.IsNullOrWhiteSpace(addresslines[0])))
                        {
                            SelectSurgen.AddressLine1 = addresslines[0];
                        }
                        else
                        {
                            SelectSurgen.AddressLine1 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[1])) && (!string.IsNullOrWhiteSpace(addresslines[1])))
                        {
                            SelectSurgen.AddressLine2 = addresslines[1];
                        }
                        else
                        {
                            SelectSurgen.AddressLine2 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[2])) && (!string.IsNullOrWhiteSpace(addresslines[2])))
                        {
                            SelectSurgen.AddressLine3 = addresslines[2];
                        }
                        else
                        {
                            SelectSurgen.AddressLine3 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[3])) && (!string.IsNullOrWhiteSpace(addresslines[3])))
                        {
                            SelectSurgen.AddressLine4 = addresslines[3];
                        }
                        else
                        {
                            SelectSurgen.AddressLine4 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[4])) && (!string.IsNullOrWhiteSpace(addresslines[4])))
                        {
                            SelectSurgen.AddressLine4 = string.Concat(SelectSurgen.AddressLine4, ", ", addresslines[4]);
                        }
                        if ((!string.IsNullOrEmpty(addresslines[5])) && (!string.IsNullOrWhiteSpace(addresslines[5])))
                        {
                            SelectSurgen.AddressLine4 = string.Concat(SelectSurgen.AddressLine4, ", ", addresslines[5]);
                        }
                        selectSurgenCollection.Add(SelectSurgen);
                        App.SelectSurgenCollectionGlobalvar = selectSurgenCollection;
                    }
                    catch (FormatException fe)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(fe);
#endif
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(e);
#endif
                    }
                }

                lstSurgenSearch.Items.Clear();
                if (!IsPostCodeSearch)
                {
                    selectSurgenCollection.Sort();
                }
                lstSurgenSearch.ItemsSource = selectSurgenCollection;
                progressBar.Visibility      = Visibility.Collapsed;
                LayoutRoot.IsHitTestVisible = true;
            }
            catch (Exception ex)
            {
                LayoutRoot.IsHitTestVisible = true;
                tbxSurgenSearch.Focus();
#if DEBUG
                System.Diagnostics.Debug.WriteLine(ex);
#endif
            }
        }
        /// <summary>
        /// Parse Xml data obtained
        /// </summary>
        /// <param name="xmlFeed"></param>
        private void ParseSubMenuList(XElement xmlFeed)
        {
            try
            {
                XNamespace s = "http://syndication.nhschoices.nhs.uk/services";
                foreach (XElement curElement in xmlFeed.Descendants("entry").Descendants("content").Descendants(s + "organisationSummary"))
                {
                    lstSurgenSearch.ItemsSource = null;
                    try
                    {
                        SelectSurgenFeedData SelectSurgen = new SelectSurgenFeedData();
                        var newData = new organisationSummaryAddress();

                        SelectSurgen.Name = (curElement.Element(s + "name")).Value.ToString();
                        SelectSurgen.OdsCode = (curElement.Element(s + "odsCode")).Value.ToString();
                        string[] addresslines = new string[6];
                        int i = 0;
                        foreach (XElement curElementCoordinates in curElement.Descendants(s + "address"))
                        {
                            foreach (XElement SubcurElementCoordinates in curElementCoordinates.Descendants(s + "addressLine"))
                            {
                                addresslines[i] = SubcurElementCoordinates.Value;
                                i++;
                            }
                            addresslines[5] = curElementCoordinates.Element(s + "postcode").Value.ToString();
                        }
                        if ((!string.IsNullOrEmpty(addresslines[0])) && (!string.IsNullOrWhiteSpace(addresslines[0])))
                        {
                            SelectSurgen.AddressLine1 = addresslines[0];
                        }
                        else
                        {
                            SelectSurgen.AddressLine1 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[1])) && (!string.IsNullOrWhiteSpace(addresslines[1])))
                        {
                            SelectSurgen.AddressLine2 = addresslines[1];
                        }
                        else
                        {
                            SelectSurgen.AddressLine2 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[2])) && (!string.IsNullOrWhiteSpace(addresslines[2])))
                        {
                            SelectSurgen.AddressLine3 = addresslines[2];
                        }
                        else
                        {
                            SelectSurgen.AddressLine3 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[3])) && (!string.IsNullOrWhiteSpace(addresslines[3])))
                        {
                            SelectSurgen.AddressLine4 = addresslines[3];
                        }
                        else
                        {
                            SelectSurgen.AddressLine4 = "-";
                        }
                        if ((!string.IsNullOrEmpty(addresslines[4])) && (!string.IsNullOrWhiteSpace(addresslines[4])))
                        {
                            SelectSurgen.AddressLine4 = string.Concat(SelectSurgen.AddressLine4, ", ", addresslines[4]);
                        }
                        if ((!string.IsNullOrEmpty(addresslines[5])) && (!string.IsNullOrWhiteSpace(addresslines[5])))
                        {
                            SelectSurgen.AddressLine4 = string.Concat(SelectSurgen.AddressLine4, ", ", addresslines[5]);
                        }
                        selectSurgenCollection.Add(SelectSurgen);
                        App.SelectSurgenCollectionGlobalvar = selectSurgenCollection;

                    }
                    catch (FormatException fe)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(fe);
#endif
                    }
                    catch (Exception e)
                    {
#if DEBUG
                        System.Diagnostics.Debug.WriteLine(e);
#endif
                    }

                }

                lstSurgenSearch.Items.Clear();
                if (!IsPostCodeSearch)
                selectSurgenCollection.Sort();
                lstSurgenSearch.ItemsSource = selectSurgenCollection;
                progressBar.Visibility = Visibility.Collapsed;
                LayoutRoot.IsHitTestVisible = true;
               
            }
            catch (Exception ex)
            {
                LayoutRoot.IsHitTestVisible = true;
                tbxSurgenSearch.Focus();
#if DEBUG
                System.Diagnostics.Debug.WriteLine(ex);
#endif
            }
        }