public static parseSiteList ( |
||
siteTable | ||
siteList | String | |
return | gov.va.medora.mdo.Site[] |
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));
}
/// <summary> /// Visit multiple data sources after a login. /// </summary> /// <remarks> /// Requires a previous login so the credentials are already in mySession and are /// not altered. Can visit a single source or multiple sources. Sources may be /// VAMCs, VISNs, some combination of VAMCs and VISNs, or the entire VHA. See the /// sourceList parameter. /// </remarks> /// <param name="pwd">Client app's BSE security phrase</param> /// <param name="sourceList"> /// A comma-delimited list of station numbers and/or VISN IDs, as in /// "402,550" or "V12,V22" or "V1,V2,456". To visit all VistA systems set the param /// to "*". Duplicate station #'s are ignored. /// </param> /// <param name="permissionString">If blank defaults to CPRS context</param> /// <returns>TaggedTextArray: each site with user DUZ or an error message</returns> public TaggedTextArray visitSites(string pwd, string sourceList, string permissionString) { TaggedTextArray result = new TaggedTextArray(); //Say the magic word // TBD - needed????? //if (pwd != mySession.AppPwd) //{ // result.fault = new FaultTO("Invalid application password"); //} if (mySession == null || mySession.SiteTable == null) { result.fault = new FaultTO("No site table"); } else if (sourceList == "") { result.fault = new FaultTO("Missing sitelist"); } //else if (mySession.user == null) //{ // result.fault = new FaultTO("No logged in user"); //} else if (mySession.Credentials == null) { result.fault = new FaultTO("Cannot use this method without previous login"); } if (result.fault != null) { return(result); } Site[] sites = MdwsUtils.parseSiteList(mySession.SiteTable, sourceList); List <DataSource> sources = new List <DataSource>(sites.Length); for (int i = 0; i < sites.Length; i++) { for (int j = 0; j < sites[i].Sources.Length; j++) { if (sites[i].Sources[j].Protocol == "VISTA" || sites[i].Sources[j].Protocol == "FHIE" || sites[i].Sources[j].Protocol == "XVISTA") { sources.Add(sites[i].Sources[j]); } } } return(setupMultiSourceQuery(pwd, sources, permissionString)); }