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;
}