Пример #1
0
        public static Site[] parseSiteList(SiteTable siteTable, String siteList)
        {
            if (siteList == null || siteList == "")
            {
                throw new ArgumentException("Invalid sitelist: no sites specified");
            }
            ArrayList lst = new ArrayList();

            if (siteList == "*")
            {
                IEnumerator e = siteTable.Sites.Values.GetEnumerator();
                while (e.MoveNext())
                {
                    lst.Add((Site)e.Current);
                }
                return((Site[])lst.ToArray(typeof(Site)));
            }

            siteList = siteList.ToUpper();
            String[]  items   = StringUtils.split(siteList, StringUtils.COMMA);
            Hashtable siteIds = new Hashtable();

            for (int i = 0; i < items.Length; i++)
            {
                items[i] = items[i].Trim();
                if (items[i] == "*")
                {
                    throw new ArgumentException("Invalid sitelist: * must be only arg");
                }
                else if (items[i][0] == 'V')
                {
                    Region visn = siteTable.getRegion(items[i].Substring(1));
                    if (visn == null)
                    {
                        throw new ArgumentException("Invalid sitelist: invalid VISN: " + visn);
                    }
                    ArrayList sites = visn.Sites;
                    for (int j = 0; j < sites.Count; j++)
                    {
                        lst.Add((Site)sites[j]);
                    }
                }
                else
                {
                    Site site = siteTable.getSite(items[i]);
                    if (site == null)
                    {
                        throw new ArgumentException("Invalid sitelist: nonexistent sitecode: " + items[i]);
                    }
                    if (siteIds.ContainsKey(items[i]))   // duplicate sitecode - skip it
                    {
                        throw new ArgumentException("Invalid sitelist: duplicate sitecode: " + items[i]);
                    }
                    lst.Add(siteTable.getSite(items[i]));
                    siteIds.Add(items[i], "");
                }
            }
            return((Site[])lst.ToArray(typeof(Site)));
        }
Пример #2
0
        public static String getSiteName(String sitecode)
        {
            if (_table == null)
            {
                _table = new SiteTable("C:\\inetpub\\wwwroot\\dashboard2\\resources\\xml\\VhaSites.xml");
            }

            return(_table.getSite(sitecode).Name);
        }
Пример #3
0
 internal static DataSource getSrc(SiteTable t, string id)
 {
     // Need to clone a new source for test suites that might change the
     // properties.
     DataSource theSource = t.getSite(id).getDataSourceByModality("HIS");
     DataSource result = new DataSource();
     result.Modality = "HIS";
     result.Port = theSource.Port;
     result.Protocol = theSource.Protocol;
     result.SiteId = theSource.SiteId;
     result.Provider = theSource.Provider;
     return result;
 }
Пример #4
0
        internal static DataSource getSrc(SiteTable t, string id)
        {
            // Need to clone a new source for test suites that might change the
            // properties.
            DataSource theSource = t.getSite(id).getDataSourceByModality("HIS");
            DataSource result    = new DataSource();

            result.Modality = "HIS";
            result.Port     = theSource.Port;
            result.Protocol = theSource.Protocol;
            result.SiteId   = theSource.SiteId;
            result.Provider = theSource.Provider;
            return(result);
        }
Пример #5
0
 /// <summary>
 /// Disconnect old connection and try reconnecting to same site. Set old connection to new connection
 /// if the reconnent is successful
 /// </summary>
 /// <param name="cxn"></param>
 void reconnect(AbstractConnection cxn)
 {
     try
     {
         cxn.disconnect();
         AbstractConnection newCxn = connectWithReturn(_siteTable.getSite(cxn.DataSource.SiteId.Id), false);
         if (newCxn != null)
         {
             cxn = newCxn;
         }
     }
     catch (Exception)
     {
         // what to do? let heartbeat clean up for now
     }
 }
Пример #6
0
 public void addConnections(string sitelist, SiteTable siteTbl)
 {
     string[] siteIds = StringUtils.split(sitelist, StringUtils.COMMA);
     for (int i = 0; i < siteIds.Length; i++)
     {
         Site site = siteTbl.getSite(siteIds[i]);
         if (site == null)
         {
             throw new Exception("No such site: " + siteIds[i]);
         }
         DataSource src = site.getDataSourceByModality(this.modality);
         if (src == null)
         {
             throw new Exception("No " + modality + " data source at site " + siteIds[i]);
         }
         int        protocol   = DaoFactory.getConstant(src.Protocol);
         DaoFactory daoFactory = DaoFactory.getDaoFactory(protocol);
         addConnection(daoFactory.getConnection(src));
     }
 }
Пример #7
0
 public void addConnections(string sitelist, SiteTable siteTbl)
 {
     string[] siteIds = StringUtils.split(sitelist, StringUtils.COMMA);
     for (int i = 0; i < siteIds.Length; i++)
     {
         Site site = siteTbl.getSite(siteIds[i]);
         if (site == null)
         {
             throw new Exception("No such site: " + siteIds[i]);
         }
         DataSource src = site.getDataSourceByModality(this.modality);
         if (src == null)
         {
             throw new Exception("No " + modality + " data source at site " + siteIds[i]);
         }
         int protocol = DaoFactory.getConstant(src.Protocol);
         DaoFactory daoFactory = DaoFactory.getDaoFactory(protocol);
         addConnection(daoFactory.getConnection(src));
     }
 }