/// <summary> /// Receives client's call and adds a node in the workflow /// </summary> /// <param name="eventArgument">WorkflowId & Node id</param> public void RaiseCallbackEvent(string eventArgument) { try { fieldTypes = new XmlSchema(); //Creating the schema that will contain the field types string[] args = eventArgument.Split('&'); string nodeID = args[0]; string nodeName = args[1]; //Initializing the string to return serialized_field_types += args[0] + '&'; // idnodo & nodeName & basetype | id | label | position x | position y | width | height | rendered_label | constraints & ... /** * EXAMPLE: * workflow_1_node_1&nodeName&StringBox|1|pippo|120|208|100|30|pippo|AddMaxLengthConstraint#30@AddMinLengthConstraint#3@AddRangeLengthConstraint#3$30 **/ for (int i = 2; i < args.Length; i++) { string[] property = args[i].Split('|'); IBaseType f = getField(property[0]); if (f != null) { f.TypeName = property[0] + property[1]; f.Name = XmlConvert.DecodeName(property[2]); //Applying costraints if (!property[8].Equals("")) //apply only if some costraints are defined { //--------------------------- // COSTRAINTS STRING FORMAT: // & CostraintName # CostraintParameter1 | .. | CostraintParameterNN //--------------------------- string[] constraints = property[8].Split('@'); for (int k = 0; k < constraints.Length; k++) { string[] constraintRapresentation = constraints[k].Split('#'); //divide costraint name from parameters string[] tmpParams; if (constraintRapresentation[1].Equals("")) { tmpParams = null; } else { tmpParams = constraintRapresentation[1].Split('$'); //divide each param } List <MethodInfo> constraintList = FieldsManager.GetConstraints(f.GetType()); bool constraint_loaded = false; foreach (MethodInfo c in constraintList) { if (constraintRapresentation[0].Equals(c.Name)) { constraint_loaded = (bool)c.Invoke(f, tmpParams); //apply costraint to field break; } } if (!constraint_loaded) { throw new Exception("No constraint with name \"" + constraintRapresentation[0] + "\" could be applied."); } } } //for the client fieldTypes.Items.Add(f.TypeSchema); } } } catch (Exception e) { Console.Write(e.Message); error = e.Message; } }
public override bool EqualsTo(IBaseType value) { if (value == null) return false; if (value.GetType() != typeof(Struct)) return false; if (!StructuralEquals(value as Struct)) return false; foreach (var item in (value as Struct).Attributes) if (!item.Value.Value.EqualsTo(Attributes[item.Key].Value)) return false; return true; }
/// <summary> /// Receives client's call and gets the predicates /// </summary> /// <param name="eventArgument">The constraints string</param> public void RaiseCallbackEvent(string eventArgument) { string[] property = eventArgument.Split('|'); //property[0] -> field.basType IBaseType f = getField(property[0]); if (f != null) { returnValue = ""; //Applying costraints if (!property[1].Equals("")) //apply only if some costraints are defined { //--------------------------- // COSTRAINTS STRING FORMAT: // & CostraintName # CostraintParameter1 | .. | CostraintParameterNN //--------------------------- string[] constraints = property[1].Split('@'); for (int k = 0; k < constraints.Length; k++) { string[] constraintRapresentation = constraints[k].Split('#'); //divide costraint name from parameters string[] tmpParams; if (constraintRapresentation[1].Equals("")) { tmpParams = null; } else { tmpParams = constraintRapresentation[1].Split('$'); //divide each param } List <MethodInfo> constraintList = FieldsManager.GetConstraints(f.GetType()); bool constraint_loaded = false; foreach (MethodInfo c in constraintList) { if (constraintRapresentation[0].Equals(c.Name)) { constraint_loaded = (bool)c.Invoke(f, tmpParams); //apply costraint to field break; } } if (!constraint_loaded) { List <MethodInfo> constr = FieldsManager.GetConstraints(f.GetType()); string constrName = ""; foreach (MethodInfo mi in constr) { if (mi.Name.Equals(constraintRapresentation[0])) { object[] attributes = mi.GetCustomAttributes(true); Fields.ConstraintAttribute attribute = (Fields.ConstraintAttribute)attributes[0]; constrName += attribute.Name; break; } } returnValue = "Error applying constraint \"" + constrName + "\""; if (tmpParams != null) { returnValue += " with parameter"; if (tmpParams.Length > 1) { returnValue += "s "; for (int i = 0; i < tmpParams.Length; i++) { returnValue += ((i != 0)?", ":"") + tmpParams[i]; } } else { returnValue += " " + tmpParams[0]; } } } } } } }