示例#1
0
 public RegionArray(Region[] mdoRegions)
 {
     if (mdoRegions == null || mdoRegions.Length == 0)
     {
         count = 0;
         return;
     }
     regions = new RegionTO[mdoRegions.Length];
     for (int i = 0; i < mdoRegions.Length; i++)
     {
         regions[i] = new RegionTO(mdoRegions[i]);
     }
     count = mdoRegions.Length;
 }
示例#2
0
文件: SitesLib.cs 项目: OSEHRA/mdws
        public SiteTO addSite(string id, string name, string datasource, string port, string modality, string protocol, string region)
        {
            SiteTO result = new SiteTO();
            Site site = new Site();
            DataSource source = new DataSource();
            int iPort = 0;
            int iRegion = 0;

            if (!mySession.MdwsConfiguration.IsProduction)
            {
                result.fault = new FaultTO("You may not add data sources to non-production MDWS installations");
            }
            else if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(name) || String.IsNullOrEmpty(datasource) ||
                String.IsNullOrEmpty(port) || String.IsNullOrEmpty(modality) || String.IsNullOrEmpty(protocol) ||
                String.IsNullOrEmpty(region))
            {
                result.fault = new FaultTO("Must supply all parameters");
            }
            else if (mySession.SiteTable.Sites.ContainsKey(id))
            {
                result.fault = new FaultTO("That site id is in use", "Choose a different site id");
            }
            else if (!Int32.TryParse(port, out iPort))
            {
                result.fault = new FaultTO("Non-numeric port", "Provide a numeric value for the port");
            }
            else if (!Int32.TryParse(region, out iRegion))
            {
                result.fault = new FaultTO("Non-numeric region", "Provide a numeric value for the region");
            }
            else if (modality != "HIS")
            {
                result.fault = new FaultTO("Only HIS modality currently supported", "Use 'HIS' as your modality");
            }
            else if (protocol != "VISTA")
            {
                result.fault = new FaultTO("Only VISTA protocol currently supported", "Use 'VISTA' as your protocol");
            }

            if(result.fault != null)
            {
                return result;
            }

            source.Port = iPort;
            source.Modality = modality;
            source.Protocol = protocol;
            source.Provider = datasource;
            source.SiteId = new SiteId(id, name);

            site.Sources = new DataSource[1];
            site.Sources[0] = source;
            site.RegionId = region;
            site.Name = name;
            site.Id = id;

            if(!mySession.SiteTable.Regions.ContainsKey(iRegion))
            {
                Region r = new Region();
                r.Id = iRegion;
                r.Name = "Region " + region;
                r.Sites = new ArrayList();
                mySession.SiteTable.Regions.Add(iRegion, r);
            }
            ((Region)mySession.SiteTable.Regions[iRegion]).Sites.Add(site);
            mySession.SiteTable.Sites.Add(id, site);
            mySession.SiteTable.Sources.Add(site.Sources[0]);
            result = new SiteTO(site);
            return result;
        }
示例#3
0
文件: SiteTable.cs 项目: OSEHRA/mdo
        private void parse(String filepath)
        {
            if (String.IsNullOrEmpty(filepath))
            {
                throw new ArgumentNullException("No source for site table");
            }

            Region currentRegion = null;
            ArrayList currentSites = null;
            Site currentSite = null;
            DataSource dataSource = null;
            ArrayList currentSources = null;
            #if DEBUG
            string currentDirStr = Directory.GetCurrentDirectory();
            #endif

            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 == "VhaVisn")
                            {
                                currentRegion = new Region();
                                currentRegion.Id = Convert.ToInt32(reader.GetAttribute("ID"));
                                currentRegion.Name = reader.GetAttribute("name");
                                currentSites = new ArrayList();
                            }
                            else if (name == "VhaSite")
                            {
                                currentSite = new Site();
                                currentSite.Id = reader.GetAttribute("ID");
                                currentSite.Name = reader.GetAttribute("name");
                                String displayName = reader.GetAttribute("displayname");
                                if (displayName == null)
                                {
                                    displayName = currentSite.Name;
                                }
                                currentSite.DisplayName = displayName;
                                currentSite.Moniker = reader.GetAttribute("moniker");
                                currentSite.RegionId = Convert.ToString(currentRegion.Id);
                                currentSources = new ArrayList();
                                currentSites.Add(currentSite);
                            }
                            else if (name == "DataSource")
                            {
                                dataSource = new DataSource();
                                KeyValuePair<string, string> kvp =
                                    new KeyValuePair<string, string>(currentSite.Id, currentSite.Name);
                                dataSource.SiteId = new SiteId(kvp.Key, kvp.Value);
                                dataSource.Modality = reader.GetAttribute("modality");
                                dataSource.Protocol = reader.GetAttribute("protocol");
                                dataSource.Provider = reader.GetAttribute("source");
                                dataSource.Status = reader.GetAttribute("status");
                                String sTmp = reader.GetAttribute("port");
                                if (String.IsNullOrEmpty(sTmp)) // StringUtils.isEmpty(sTmp))
                                {
                                    if (String.Equals(dataSource.Protocol, "VISTA", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        dataSource.Port = 9200;
                                    }
                                    else if (String.Equals(dataSource.Protocol, "HL7", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        dataSource.Port = 5000;
                                    }
                                }
                                else
                                {
                                    dataSource.Port = Convert.ToInt32(sTmp);
                                }
                                sTmp = reader.GetAttribute("provider");
                                if (sTmp != null)
                                {
                                    dataSource.Provider = sTmp;
                                }
                                sTmp = reader.GetAttribute("description");
                                if (sTmp != null)
                                {
                                    dataSource.Description = sTmp;
                                }
                                sTmp = reader.GetAttribute("vendor");
                                if (sTmp != null)
                                {
                                    dataSource.Vendor = sTmp;
                                }
                                sTmp = reader.GetAttribute("version");
                                if (sTmp != null)
                                {
                                    dataSource.Version = sTmp;
                                }
                                sTmp = reader.GetAttribute("context");
                                if (sTmp != null)
                                {
                                    dataSource.Context = sTmp;
                                }
                                sTmp = reader.GetAttribute("connectionString");
                                if (!String.IsNullOrEmpty(sTmp))
                                {
                                    dataSource.ConnectionString = sTmp;
                                }

                                currentSources.Add(dataSource);
                                sources.Add(dataSource);
                            }
                            break;
                        case (int)XmlNodeType.EndElement:
                            name = reader.Name;
                            if (name == "VhaVisn")
                            {
                                currentRegion.Sites = currentSites;
                                regions.Add(currentRegion.Id, currentRegion);
                            }
                            else if (name == "VhaSite")
                            {
                                currentSite.Sources = (DataSource[])currentSources.ToArray(typeof(DataSource));
                                sites.Add(currentSite.Id, currentSite);
                            }
                            break;
                    }
                }
            }
            catch (Exception) { /* do nothing */ }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
示例#4
0
文件: RegionTO.cs 项目: OSEHRA/mdws
 public RegionTO(Region mdoRegion)
 {
     this.name = mdoRegion.Name;
     this.id = Convert.ToString(mdoRegion.Id);
     this.sites = new SiteArray(mdoRegion.Sites);
 }