public ActionResult ActivityForm(string aa) { IDictionary userInputFields = new Hashtable(); IActivityForm activityForm = (IActivityForm)HttpContext.Session["activityForm"]; IList fields = activityForm.Fields; IEnumerator fildEnumer = fields.GetEnumerator(); while (fildEnumer.MoveNext()) { IField field = (IField)fildEnumer.Current; // Construct a meaningfull name that is http-compliant String attributeName = field.Attribute.Name; String parameterName = convertToHttpCompliant(attributeName); String parameterValue = HttpContext.Request.Params[parameterName]; if (FieldAccessHelper.IsRequired(field.Access) && (parameterValue == null || "".Equals(parameterValue))) { //AddMessage("Field "+field.Name+" is required. Please, provide a value"); } else { try { Object parsedParameter = null; IHtmlFormatter htmlFormatter = field.GetHtmlFormatter(); if (htmlFormatter != null) { // TODO: Test if there is the possibility to simplify the interface, see null parsedParameter = htmlFormatter.ParseHttpParameter(parameterValue, null); if (parsedParameter != null) { userInputFields.Add(attributeName, parsedParameter); } } else { //log.Warn("No htmlformatter defined for field:"+field.Name); } } catch (Exception ex) { //log.Debug( "error parsing user-input-field " + field.Name + " : " + parameterValue,ex); //AddMessage("error parsing user-input-field " + field.Name + " with value: " + parameterValue); } } } if (false) { //log.Debug( "submitted activity-form has messages, redirecting to activityFormPage..." ); HttpContext.Session.Add("userInputFields", userInputFields); if (activityForm.Flow == null) { return(RedirectToAction("ActivityForm", "Form", new RouteValueDictionary() { { "flowId", activityForm.ProcessDefinition.Id } })); //StartProcessInstance(activityForm.ProcessDefinition.Id); } else { return(RedirectToAction("ActivityForm", "Form", new RouteValueDictionary())); //ShowActivityForm(activityForm.Flow.Id); } } else { // remove the old inputvalues HttpContext.Session.Remove("userInputFields"); //log.Debug( "submitting the form..." ); IList activatedFlows = null; IFlow flow = activityForm.Flow; // if there is no flow in the activityForm IExecutionSessionLocal executionComponent = null; try { executionComponent = ServiceLocator.Instance.GetService(typeof(IExecutionSessionLocal)) as IExecutionSessionLocal; if (flow == null) { // this means that it is a start-activity being performed so we have to // start a new process instance IProcessDefinition processDefinition = activityForm.ProcessDefinition; IProcessInstance processInstance = executionComponent.StartProcessInstance(processDefinition.Id, userInputFields); activatedFlows = new ArrayList(); //AddAllActiveFlows(processInstance.RootFlow,activatedFlows); //activatedFlows.Add(processInstance.RootFlow); } else { activatedFlows = executionComponent.PerformActivity(flow.Id, userInputFields); } } finally { ServiceLocator.Instance.Release(executionComponent); } if (activatedFlows.Count > 0) { System.Text.StringBuilder feedbackBuffer = new System.Text.StringBuilder(); for (int i = 0; i < activatedFlows.Count; ++i) { IFlow activatedFlow = (IFlow)activatedFlows[i]; if (activatedFlow.GetActor() != null) { feedbackBuffer.Append(activatedFlow.GetActor().Name); } else { // when flow's node is start-state no actor is assigned to it, this is to handle the NPE thrown feedbackBuffer.Append("Nobody"); } if (i + 1 < activatedFlows.Count) { feedbackBuffer.Append(", "); } } if (activatedFlows.Count > 1) { //AddMessage("Now, following people are handling this process :"+feedbackBuffer.ToString()); } else { //AddMessage("Now, "+ feedbackBuffer.ToString() +" is handling this process"); } return(Redirect("/User/ShowHome")); } else { //AddMessage("This flow in the process finished"); return(Redirect("/User/ShowHome")); } } }
public void CheckAccess(IDictionary attributeValues, StateImpl state) { IDictionary fields = new Hashtable(); // first we check if a value is supplied for all required fields IEnumerator iter = state.Fields.GetEnumerator(); log.Debug(iter); while (iter.MoveNext()) { FieldImpl field = (FieldImpl)iter.Current; String attributeName = field.Attribute.Name; fields[attributeName] = field; // if a field is found required and no attribute value is supplied throw // RequiredFieldException log.Debug(field); log.Debug(field.Access); if ((FieldAccessHelper.IsRequired(field.Access)) && (attributeValues == null)) { throw new RequiredFieldException(field); } // OR // if field is found required and attribute value of it is not available // throw RequiredFieldException if ((FieldAccessHelper.IsRequired(field.Access)) && (attributeValues != null) && (!attributeValues.Contains(attributeName))) { throw new RequiredFieldException(field); } } // then we check if the access of all supplied values is writable IList attributeNamesToBeRemoved = new ArrayList(); // store attribute name of attribute to be removed if (attributeValues != null) { iter = attributeValues.GetEnumerator(); while (iter.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)iter.Current; String attributeName = (String)entry.Key; FieldImpl field = (FieldImpl)fields[attributeName]; if ((field != null) && (!FieldAccessHelper.IsWritable(field.Access))) { log.Warn("ignoring attributeValue for unwritable attribute '" + attributeName + "'"); // commented out cause will result in ConcurrentModificationException // instead copy its attribute name and remove later OR do a deep copy of the // attributeValues so there is one set that gets iterated and another that //gets deleted??? //attributeValues.remove( attributeName ); attributeNamesToBeRemoved.Add(attributeName); } } // now removed collected to be removed attribute IEnumerator itr = attributeNamesToBeRemoved.GetEnumerator(); while (itr.MoveNext()) { String an = (String)itr.Current; attributeValues.Remove(an); } } }
public bool IsRequired() { return(FieldAccessHelper.IsRequired(_field.Access)); }