Ejemplo n.º 1
0
 public StateSites(State mdoState)
 {
     this.name = mdoState.Name;
     this.abbr = mdoState.Abbr;
     SortedList lst = new SortedList();
     foreach (DictionaryEntry de in mdoState.Sites)
     {
         Site s = (Site)de.Value;
         if (s.ChildSites != null)
         {
             for (int i = 0; i < s.ChildSites.Length; i++)
             {
                 lst.Add(s.ChildSites[i].Name, s.ChildSites[i]);
             }
         }
         Site clone = new Site();
         clone.Id = s.Id;
         clone.Name = s.Name;
         clone.State = s.State;
         clone.City = s.City;
         clone.DisplayName = s.DisplayName;
         clone.ParentSiteId = s.ParentSiteId;
         clone.RegionId = s.RegionId;
         lst.Add(clone.Name, clone);
     }
     this.sites = new SiteArray(lst);
 }
Ejemplo n.º 2
0
 public StateArray(State[] mdoStates)
 {
     if (mdoStates == null || mdoStates.Length == 0)
     {
         count = 0;
         return;
     }
     ArrayList al = new ArrayList(mdoStates.Length);
     for (int i = 0; i < mdoStates.Length; i++)
     {
         if (mdoStates[i] != null)
         {
             al.Add(new StateTO(mdoStates[i]));
         }
     }
     states = (StateTO[])al.ToArray(typeof(StateTO));
     count = states.Length;
 }
Ejemplo n.º 3
0
 public StateTO(State mdoState)
 {
     this.name = mdoState.Name;
     this.abbr = mdoState.Abbr;
     this.fips = mdoState.Fips;
     if (mdoState.Sites != null)
     {
         for (int i = 0; i < mdoState.Sites.Count; i++)
         {
             this.sites = new SiteArray(mdoState.Sites);
         }
     }
     if (mdoState.Cities != null)
     {
         for (int i = 0; i < mdoState.Cities.Count; i++)
         {
             this.cities = new CityArray(mdoState.Cities);
         }
     }
 }
Ejemplo n.º 4
0
        public void parseVisnsByState(string filepath)
        {
            if (String.IsNullOrEmpty(filepath))
            {
                throw new ArgumentNullException("No source for state file");
            }

            visnsByState = new SortedList();

            XmlReader reader = null;
            try
            {
                reader = new XmlTextReader(filepath);
                while (reader.Read())
                {
                    switch ((int)reader.NodeType)
                    {
                        case (int)XmlNodeType.Element:
                            String name = reader.Name;
                            if (name == "state")
                            {
                                State state = new State();
                                state.Name = reader.GetAttribute("name");
                                state.Abbr = reader.GetAttribute("abbr");
                                string visns = reader.GetAttribute("visns");
                                state.VisnIds = StringUtils.split(visns, StringUtils.COMMA);
                                visnsByState.Add(state.Abbr, state);
                            }
                            break;
                    }
                }
            }
            catch (Exception) { /* do nothing */ }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 5
0
        public void parseStateFile(string filepath)
        {
            if (String.IsNullOrEmpty(filepath))
            {
                throw new ArgumentNullException("No source for state file");
            }

            states = new SortedList();

            State currentState = null;
            SortedList currentSites = null;
            Site currentSite = null;
            ArrayList currentClinics = null;
            Site currentClinic = null;

            XmlReader reader = null;

            try
            {
                reader = new XmlTextReader(filepath);
                while (reader.Read())
                {
                    switch ((int)reader.NodeType)
                    {
                        case (int)XmlNodeType.Element:
                            String name = reader.Name;
                            if (name == "state")
                            {
                                currentState = new State();
                                currentState.Name = reader.GetAttribute("name");
                                currentState.Abbr = reader.GetAttribute("abbr");
                                currentSites = new SortedList();
                            }
                            else if (name == "vamc")
                            {
                                currentSite = new Site();
                                currentSite.Id = reader.GetAttribute("sitecode");
                                currentSite.Name = reader.GetAttribute("name");
                                currentSite.City = reader.GetAttribute("city");
                                currentSite.SystemName = reader.GetAttribute("system");
                                currentSites.Add(currentSite.Name, currentSite);
                                currentClinics = new ArrayList();
                            }
                            else if (name == "clinic")
                            {
                                currentClinic = new Site();
                                currentClinic.Name = reader.GetAttribute("name");
                                currentClinic.City = reader.GetAttribute("city");
                                currentClinic.State = reader.GetAttribute("state");
                                //if (StringUtils.isEmpty(currentClinic.State))
                                if (String.IsNullOrEmpty(currentClinic.State))
                                {
                                    currentClinic.State = currentState.Abbr;
                                }
                                currentClinic.ParentSiteId = currentSite.Id;
                                currentClinics.Add(currentClinic);
                            }
                            break;
                        case (int)XmlNodeType.EndElement:
                            name = reader.Name;
                            if (name == "state")
                            {
                                currentState.Sites = currentSites;
                                states.Add(currentState.Name, currentState);
                            }
                            else if (name == "vamc")
                            {
                                currentSite.ChildSites = (Site[])currentClinics.ToArray(typeof(Site));
                            }
                            else if (name == "clinic")
                            {
                            }
                            break;
                    }
                }
            }
            catch (Exception) { /* do nothing */ }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Ejemplo n.º 6
0
        public void parseStateCityFile(string filepath)
        {
            if (String.IsNullOrEmpty(filepath))
            {
                throw new ArgumentNullException("No source for state/city file");
            }

            states = new SortedList();

            State currentState = null;
            SortedList currentCities = null;
            City currentCity = null;
            ArrayList currentSites = null;
            Site currentSite = null;

            XmlReader reader = null;
            try
            {
                reader = new XmlTextReader(filepath);
                while (reader.Read())
                {
                    switch ((int)reader.NodeType)
                    {
                        case (int)XmlNodeType.Element:
                            String name = reader.Name;
                            if (name == "state")
                            {
                                currentState = new State();
                                currentState.Name = reader.GetAttribute("name");
                                currentState.Abbr = reader.GetAttribute("abbr");
                                currentCities = new SortedList();
                            }
                            else if (name == "city")
                            {
                                currentCity = new City();
                                currentCity.Name = reader.GetAttribute("name");
                                currentCity.State = currentState.Abbr;
                                currentCities.Add(currentCity.Name, currentCity);
                                currentSites = new ArrayList();
                            }
                            else if (name == "site")
                            {
                                currentSite = new Site();
                                currentSite.Name = reader.GetAttribute("name");
                                currentSite.City = currentCity.Name;
                                currentSite.State = currentState.Abbr;
                                currentSite.Id = reader.GetAttribute("sitecode");
                                currentSite.SiteType = reader.GetAttribute("type");
                                currentSites.Add(currentSite);
                            }
                            break;
                        case (int)XmlNodeType.EndElement:
                            name = reader.Name;
                            if (name == "state")
                            {
                                currentState.Cities = currentCities;
                                states.Add(currentState.Name, currentState);
                            }
                            else if (name == "city")
                            {
                                currentCity.Sites = (Site[])currentSites.ToArray(typeof(Site));
                            }
                            else if (name == "site")
                            {
                            }
                            break;
                    }
                }
            }
            catch (Exception) { /* do nothing */ }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }