//--------------------------------------------------------------------------------------------------------------------- protected void GetDefinedProcessingParameters(XmlElement element) { foreach (XmlNode node in element.ChildNodes) { XmlElement subElement = node as XmlElement; if (subElement == null) { continue; } switch (subElement.Name) { case "computingResource": if (ComputingResourceParameter == null) { ComputingResourceParameter = new ServiceComputingResourceParameter(this, subElement); } else { throw new Exception("Multiple computing resources defined"); } break; case "priority": if (PriorityParameter == null) { PriorityParameter = new ServicePriorityParameter(this, subElement); } else { throw new Exception("Multiple priorities defined"); } break; case "parameter": Add(new ServiceParameter(this, subElement)); break; default: // TODO throw exception break; } } }
//--------------------------------------------------------------------------------------------------------------------- public void LoadFromXml(XmlDocument definitionDocument) { XmlElement paramsElement = null, element; foreach (XmlNode node in definitionDocument.DocumentElement.ChildNodes) { if ((element = node as XmlElement) != null && element.Name == "params") { paramsElement = element; break; } } if (paramsElement == null) { return; } if (String.Compare(Service.DefinitionVersion, "2.0") >= 0) // new service.xml format { foreach (XmlNode node in paramsElement.ChildNodes) { element = node as XmlElement; if (element == null) { continue; } switch (element.Name) { case "input": //ProcessingInputSet input = new ProcessingInputSet(this, element); break; case "processing": GetDefinedProcessingParameters(element); break; case "output": //ProcessingOutputSet output = new ProcessingOutputSet(this, element); break; } } } else // old service.xml format { Inputs.Add(new ProcessingInputSet(this)); Outputs.Add(new ProcessingOutputSet(this)); foreach (XmlNode node in paramsElement.ChildNodes) { XmlElement subElement = node as XmlElement; if (subElement == null) { continue; } string source = (subElement.HasAttribute("source") ? subElement.Attributes["source"].Value : null); string type = (subElement.HasAttribute("type") ? subElement.Attributes["type"].Value : null); switch (source) { case "series": case "Task.Series": Inputs[0].CollectionParameter = new ServiceInputCollectionParameter(Inputs[0], subElement); Add(Inputs[0].CollectionParameter); break; case "dataset": case "Task.InputFiles": Inputs[0].ProductParameter = new ServiceInputProductParameter(Inputs[0], subElement); Add(Inputs[0].ProductParameter); break; case "computingResource": case "Task.ComputingResource": case "computingElement": case "Task.ComputingElement": ComputingResourceParameter = new ServiceComputingResourceParameter(this, subElement); Add(ComputingResourceParameter); break; case "priority": case "Task.Priority": PriorityParameter = new ServicePriorityParameter(this, subElement); Add(PriorityParameter); break; case "publishServer": case "Task.PublishServer": Outputs[0].LocationParameter = new ServiceOutputLocationParameter(Outputs[0], subElement); Add(Outputs[0].LocationParameter); break; case "compress": case "Task.Compression": Outputs[0].CompressionParameter = new ServiceOutputCompressionParameter(Outputs[0], subElement); Add(Outputs[0].CompressionParameter); break; /*case "register" : * case "Task.RegisterOutput" : * CheckAutoRegister(param); * break;*/ default: if (type == "caption") { NameParameter = new ServiceProcessNameParameter(this, subElement); Add(NameParameter); } else { ServiceParameter param = new ServiceParameter(this, subElement); Add(param); if (param.SearchExtension != null) { Inputs[0].SearchParameters.Add(param); } } break; } } } }