public ProcessDescription GetDescription() { ProcessDescription process = new ProcessDescription("Calculator", "Calculator", "Basic operations through WPS", "1.1"); LiteralInput oper = new LiteralInput("operator", "operator", "abstract operator", "string", "add"); oper.AllowedValues.AddRange(new string[] { "add", "sub", "mult", "div" }); process.inputs.Add(oper); process.inputs.Add(new ComplexInput("a", "operand a", "abstract a", new ComplexFormat("text/xml", "uf8", "myschema.xsd"))); process.inputs.Add(new ComplexInput("b", "operand b", "abstract b", new ComplexFormat("text/xml", "uf8", "myschema.xsd"))); process.outputs.Add(new ComplexOutput("result", "result of operation as file", "raw abstract result of operation as file", new ComplexFormat("text/xml", "utf8", "myschema.xsd"))); return(process); }
public ProcessDescription GetDescription() { ProcessDescription process = new ProcessDescription("Add", "Add", "(a + b) through WPS", "1.1"); LiteralInput a = new LiteralInput("a", "operand a", "abstract a", "integer", "88"); a.MinOccurs = 0; a.MaxOccurs = 3; //a.AllowedValues.Add("88"); //a.AllowedValues.Add("6"); process.inputs.Add(a); process.inputs.Add(new LiteralInput("b", "operand b", "abstract b", "integer", "22")); process.outputs.Add(new LiteralOutput("sum", "sum of a + b", "abstract sum a + b", "integer")); ComplexOutput sumFile = new ComplexOutput("sumFile", "sum of a + b as file", "raw abstract sum a + b", new ComplexFormat("text/xml", "utf8", "")); sumFile.Formats.Add(new ComplexFormat("plain/text", "utf8", "")); process.outputs.Add(sumFile); return(process); }
/// <summary> /// This method is called by the DescribeProcess part of WPS.NET, it must be implemented. /// </summary> /// <returns>The process description</returns> public override ProcessDescription GetDescription() { ///This is where we create the process description ProcessDescription process = new ProcessDescription("AsyncClock", "Async Clock", "Counts a user-defined number of seconds asynchronously (This is an example of async process for developpers)", "1.1"); ///This check is meant to make sure everything is in it's place so that the process ///can be called asynchronously without failing miserably. if (this is IAsyncProcess && this.MainAppDomain != null) { ///Is this process implements IAsyncProcess and if the Main Application Domain is provided, ///we can assume that status will be supported (provided status updates are properly coded). process.statusSupported = true; if (this.BaseUrlToResultPath != String.Empty && this.StoredResultPath != string.Empty) { ///If the necessary informations for responses and results storage are provided ///we can enable storage support. process.storeSupported = true; } } ///This is the declaration of the numberOfSeconds parameter ///It has 1 minoccurs and 1 maxoccurs, it is mandatory. LiteralInput numberOfSeconds = new LiteralInput("numberOfSeconds", "Number of seconds", "The number of seconds this process will count", "integer", "100"); numberOfSeconds.MinOccurs = 1; numberOfSeconds.MaxOccurs = 1; ///Dont forget to add the previously created parameter in the inputs collection of the process. process.inputs.Add(numberOfSeconds); ///A start date should be also specified process.processStartDate = this.startDate; ///Specify the output of the process LiteralOutput output = new LiteralOutput("AsyncClockResult", "Async Clock Result", "A string containing the start datetime and the end datetime", "string"); output.Value = String.Empty; process.outputs.Add(output); ///Return the description of the process. return(process); }
public ProcessReturnValue Execute(ProcessInputParams args, ProcessReturnValue ret) { float fresult = 0; float fa = 0, fb = 0; ComplexInput a = args.GetData("a", 0).asComplexInput(); ComplexInput b = args.GetData("b", 0).asComplexInput(); XmlDocument doc = new XmlDocument(); try { doc.LoadXml(a.ToString()); fa = float.Parse(doc.InnerText); } catch { } try { doc.LoadXml(b.ToString()); fb = float.Parse(doc.InnerText); } catch { } LiteralInput oper = args.GetData("operator", 0).asLiteralInput(); string myOperator = oper.ToString(); if (ret.IsOutputIdentifierRequested("result")) { switch (myOperator) { case "sub": fresult = fa - fb; break; case "mult": fresult = fa * fb; break; case "div": if (fb != 0) { fresult = fa / fb; } else { fresult = fa; } break; case "add": default: fresult = fa + fb; break; } ComplexOutput result = null; List <OutputData> outputs = ret.GetOutputsForIdentifier("result"); if (ret.IsRawDataOutput()) { ret.fileName = "result.xml"; result = outputs[0].asComplexOutput(); result.SetValue(String.Format("<?xml version='1.0' encoding='{0}'?>\n<number>{1}</number>", result.Format.encoding, fresult)); ret.AddData(result); } else { foreach (OutputData output in outputs) { result = output.asComplexOutput(); result.SetValue("<number>" + fresult + "</number>"); ret.AddData(result); } } } ret.status = ProcessState.Succeeded; return(ret); }
public ProcessReturnValue Execute(ProcessInputParams args, ProcessReturnValue ret) { int sum = 0; int i = 0; while (true) { LiteralInput a = args.GetData("a", i++).asLiteralInput(); if (a == null) { break; } sum += Int32.Parse(a.ToString()); } LiteralInput b = args.GetData("b", 0).asLiteralInput(); int ib = Int32.Parse(b.ToString()); sum += ib; if (ret.IsOutputIdentifierRequested("sum")) { List <OutputData> outputs = ret.GetOutputsForIdentifier("sum"); // Output 1: a literal containing the raw sum LiteralOutput sumOutput = null; foreach (OutputData output in outputs) { sumOutput = output.asLiteralOutput(); sumOutput.Value = sum.ToString(); ret.AddData(sumOutput); } } if (ret.IsOutputIdentifierRequested("sumFile")) { List <OutputData> outputs = ret.GetOutputsForIdentifier("sumFile"); // Output 2: a complex data type - plain text by default if (ret.IsRawDataOutput()) { ComplexOutput sumOutput = outputs[0].asComplexOutput(); if (Utils.StrICmp(sumOutput.Format.mimeType, "text/xml")) { sumOutput.SetValue("<number>" + sum + "</number>"); ret.fileName = "result.xml"; } else if (Utils.StrICmp(sumOutput.Format.mimeType, "plain/text")) { sumOutput.SetValue("sum is " + sum); ret.fileName = "result.txt"; } ret.AddData(sumOutput); } else { ComplexOutput sumOutput = null; foreach (OutputData output in outputs) { sumOutput = output.asComplexOutput(); if (Utils.StrICmp(sumOutput.Format.mimeType, "text/xml")) { sumOutput.SetValue("<number>" + sum + "</number>"); } else { sumOutput.SetValue("sum is " + sum); } ret.AddData(sumOutput); } } } ret.status = ProcessState.Succeeded; return(ret); }