protected void WriteCustomIdentities(UserTask userTask, string identityType, ISet <string> users, ISet <string> groups, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_CUSTOM_RESOURCE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, identityType, xtw); IList <string> identityList = new List <string>(); if (users != null) { foreach (string userId in users) { identityList.Add("user(" + userId + ")"); } } if (groups != null) { foreach (string groupId in groups) { identityList.Add("group(" + groupId + ")"); } } string delimitedString = ConvertToDelimitedString(identityList); xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_RESOURCE_ASSIGNMENT, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FORMAL_EXPRESSION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(delimitedString); xtw.WriteEndElement(); // End ELEMENT_FORMAL_EXPRESSION xtw.WriteEndElement(); // End ELEMENT_RESOURCE_ASSIGNMENT xtw.WriteEndElement(); // End ELEMENT_CUSTOM_RESOURCE }
protected internal virtual void WriteCancelDefinition(Event parentEvent, CancelEventDefinition cancelEventDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_CANCELDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(cancelEventDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal virtual void WriteCompensateDefinition(Event parentEvent, CompensateEventDefinition compensateEventDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_COMPENSATEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_COMPENSATE_ACTIVITYREF, compensateEventDefinition.ActivityRef, xtw); bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(compensateEventDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal virtual void WriteErrorDefinition(Event parentEvent, ErrorEventDefinition errorDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_ERRORDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ERROR_REF, errorDefinition.ErrorCode, xtw); bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(errorDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
private bool WriteIOParameters(string elementName, IList <IOParameter> parameterList, bool didWriteExtensionStartElement, XMLStreamWriter xtw) { if (parameterList.Count == 0) { return(didWriteExtensionStartElement); } foreach (IOParameter ioParameter in parameterList) { if (!didWriteExtensionStartElement) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE); didWriteExtensionStartElement = true; } xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, elementName, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); if (!string.IsNullOrWhiteSpace(ioParameter.Source)) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE, ioParameter.Source, xtw); } if (!string.IsNullOrWhiteSpace(ioParameter.SourceExpression)) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_SOURCE_EXPRESSION, ioParameter.SourceExpression, xtw); } if (!string.IsNullOrWhiteSpace(ioParameter.Target)) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_IOPARAMETER_TARGET, ioParameter.Target, xtw); } xtw.WriteEndElement(); } return(didWriteExtensionStartElement); }
protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw) { UserTask userTask = (UserTask)element; didWriteExtensionStartElement = WriteFormProperties(userTask, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = WriteCustomIdentities(element, didWriteExtensionStartElement, xtw); if (userTask.CustomProperties.Count() > 0) { foreach (CustomProperty customProperty in userTask.CustomProperties) { if (string.IsNullOrWhiteSpace(customProperty.SimpleValue)) { continue; } if (!didWriteExtensionStartElement) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE); didWriteExtensionStartElement = true; } xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, customProperty.Name, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); xtw.WriteCharacters(customProperty.SimpleValue); xtw.WriteEndElement(); } } return(didWriteExtensionStartElement); }
protected internal virtual void WriteSignalDefinition(Event parentEvent, SignalEventDefinition signalDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_SIGNALDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_SIGNAL_REF, signalDefinition.SignalRef, xtw); if (parentEvent is ThrowEvent && signalDefinition.Async) { BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, "true", xtw); } bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(signalDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { ScriptTask scriptTask = (ScriptTask)element; if (!string.IsNullOrWhiteSpace(scriptTask.Script)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TASK_SCRIPT_TEXT, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(scriptTask.Script); xtw.WriteEndElement(); } }
protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { TextAnnotation textAnnotation = (TextAnnotation)element; if (!string.IsNullOrWhiteSpace(textAnnotation.Text)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_TEXT_ANNOTATION_TEXT, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(textAnnotation.Text); xtw.WriteEndElement(); } }
protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { DataStoreReference dataStoreRef = (DataStoreReference)element; if (!string.IsNullOrWhiteSpace(dataStoreRef.DataState)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DATA_STATE, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(dataStoreRef.DataState); xtw.WriteEndElement(); } }
protected internal override void WriteAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) { SequenceFlow sequenceFlow = (SequenceFlow)element; if (!string.IsNullOrWhiteSpace(sequenceFlow.ConditionExpression)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_FLOW_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteAttribute(BpmnXMLConstants.XSI_PREFIX, BpmnXMLConstants.XSI_NAMESPACE, "type", "bpmn2:tFormalExpression"); xtw.WriteCharacters(sequenceFlow.ConditionExpression); xtw.WriteEndElement(); } }
protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw) { ServiceTask serviceTask = (ServiceTask)element; if (serviceTask.CustomProperties.Count > 0) { foreach (CustomProperty customProperty in serviceTask.CustomProperties) { if (string.IsNullOrWhiteSpace(customProperty.SimpleValue)) { continue; } if (!didWriteExtensionStartElement) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE); didWriteExtensionStartElement = true; } xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_FIELD_NAME, customProperty.Name); if ((customProperty.SimpleValue.Contains("${") || customProperty.SimpleValue.Contains("#{")) && customProperty.SimpleValue.Contains("}")) { xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ATTRIBUTE_FIELD_EXPRESSION, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); } else { xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FIELD_STRING, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); } xtw.WriteCharacters(customProperty.SimpleValue); xtw.WriteEndElement(); xtw.WriteEndElement(); } } else { didWriteExtensionStartElement = FieldExtensionExport.WriteFieldExtensions(serviceTask.FieldExtensions, didWriteExtensionStartElement, xtw); } return(didWriteExtensionStartElement); }
protected internal virtual void WriteTimerDefinition(Event parentEvent, TimerEventDefinition timerDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_TIMERDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); if (!string.IsNullOrWhiteSpace(timerDefinition.CalendarName)) { WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_CALENDAR_NAME, timerDefinition.CalendarName, xtw); } bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(timerDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } if (!string.IsNullOrWhiteSpace(timerDefinition.TimeDate)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_DATE, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(timerDefinition.TimeDate); xtw.WriteEndElement(); } else if (!string.IsNullOrWhiteSpace(timerDefinition.TimeCycle)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_CYCLE, BpmnXMLConstants.BPMN2_NAMESPACE); if (!string.IsNullOrWhiteSpace(timerDefinition.EndDate)) { xtw.WriteAttribute(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE, BpmnXMLConstants.ATTRIBUTE_END_DATE, timerDefinition.EndDate); } xtw.WriteCharacters(timerDefinition.TimeCycle); xtw.WriteEndElement(); } else if (!string.IsNullOrWhiteSpace(timerDefinition.TimeDuration)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ATTRIBUTE_TIMER_DURATION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(timerDefinition.TimeDuration); xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal virtual void WriteTerminateDefinition(Event parentEvent, TerminateEventDefinition terminateDefinition, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_TERMINATEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); if (terminateDefinition.TerminateAll) { WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TERMINATE_ALL, "true", xtw); } if (terminateDefinition.TerminateMultiInstance) { WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_TERMINATE_MULTI_INSTANCE, "true", xtw); } bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(terminateDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal virtual void WriteMessageDefinition(Event parentEvent, MessageEventDefinition messageDefinition, BpmnModel model, XMLStreamWriter xtw) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EVENT_MESSAGEDEFINITION, BpmnXMLConstants.BPMN2_NAMESPACE); string messageRef = messageDefinition.MessageRef; if (!string.IsNullOrWhiteSpace(messageRef)) { // remove the namespace from the message id if set if (messageRef.StartsWith(model.TargetNamespace, StringComparison.Ordinal)) { messageRef = messageRef.Replace(model.TargetNamespace, ""); messageRef = messageRef.ReplaceFirst(":", ""); } else { foreach (string prefix in model.Namespaces.Keys) { string @namespace = model.GetNamespace(prefix); if (messageRef.StartsWith(@namespace, StringComparison.Ordinal)) { messageRef = messageRef.Replace(model.TargetNamespace, ""); messageRef = prefix + messageRef; } } } } WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_MESSAGE_REF, messageRef, xtw); bool didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(messageDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } xtw.WriteEndElement(); }
protected internal override bool WriteExtensionChildElements(BaseElement element, bool didWriteExtensionStartElement, XMLStreamWriter xtw) { ValuedDataObject dataObject = (ValuedDataObject)element; if (!string.IsNullOrWhiteSpace(dataObject.Id) && dataObject.Value != null) { if (!didWriteExtensionStartElement) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE); didWriteExtensionStartElement = true; } xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_DATA_VALUE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); if (dataObject.Value != null) { string value; if (dataObject is DateDataObject) { value = ((DateTime)dataObject.Value).ToString(sdf); } else { value = dataObject.Value.ToString(); } if (dataObject is StringDataObject && xmlChars.IsMatch(value)) { xtw.WriteCData(value); } else { xtw.WriteCharacters(value); } } xtw.WriteEndElement(); } return(didWriteExtensionStartElement); }
public virtual void ConvertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, XMLElementName, BpmnXMLConstants.BPMN2_NAMESPACE); bool didWriteExtensionStartElement = false; WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ID, baseElement.Id, xtw); if (baseElement is FlowElement) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, ((FlowElement)baseElement).Name, xtw); } if (baseElement is FlowNode flowNode) { if (flowNode.Asynchronous) { WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw); if (flowNode.NotExclusive) { WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw); } } if (baseElement is Activity activity) { if (activity.ForCompensation) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw); } if (!string.IsNullOrWhiteSpace(activity.DefaultFlow)) { FlowElement defaultFlowElement = model.GetFlowElement(activity.DefaultFlow); if (defaultFlowElement is SequenceFlow) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_DEFAULT, activity.DefaultFlow, xtw); } } } if (baseElement is Gateway gateway) { if (!string.IsNullOrWhiteSpace(gateway.DefaultFlow)) { FlowElement defaultFlowElement = model.GetFlowElement(gateway.DefaultFlow); if (defaultFlowElement is SequenceFlow) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_DEFAULT, gateway.DefaultFlow, xtw); } } } } WriteAdditionalAttributes(baseElement, model, xtw); if (baseElement is FlowElement flowElement) { if (!string.IsNullOrWhiteSpace(flowElement.Documentation)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DOCUMENTATION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(flowElement.Documentation); xtw.WriteEndElement(); } } didWriteExtensionStartElement = WriteExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = WriteListeners(baseElement, didWriteExtensionStartElement, xtw); didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(baseElement, didWriteExtensionStartElement, model.Namespaces, xtw); if (baseElement is Activity) { FailedJobRetryCountExport.WriteFailedJobRetryCount(baseElement as Activity, xtw); } if (didWriteExtensionStartElement) { xtw.WriteEndElement(); } if (baseElement is Activity) { MultiInstanceExport.WriteMultiInstance(baseElement as Activity, xtw); } WriteAdditionalChildElements(baseElement, model, xtw); xtw.WriteEndElement(); }
public virtual byte[] ConvertToXML(BpmnModel model, string encoding) { try { using (MemoryStream ms = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings { //要求缩进 Indent = true, //注意如果不设置encoding默认将输出utf-16 //注意这儿不能直接用Encoding.UTF8如果用Encoding.UTF8将在输出文本的最前面添加4个字节的非xml内容 Encoding = new UTF8Encoding(false), //设置换行符 NewLineChars = Environment.NewLine, NamespaceHandling = NamespaceHandling.OmitDuplicates, OmitXmlDeclaration = true }; using (XmlWriter xmlWriter = XmlWriter.Create(ms, settings)) { XMLStreamWriter writer = new XMLStreamWriter(xmlWriter); DefinitionsRootExport.WriteRootElement(model, writer, encoding); CollaborationExport.WritePools(model, writer); DataStoreExport.WriteDataStores(model, writer); SignalAndMessageDefinitionExport.WriteSignalsAndMessages(model, writer); foreach (Process process in model.Processes) { if (process.FlowElements?.Count == 0 && process.Lanes?.Count == 0) { // empty process, ignore it continue; } ProcessExport.WriteProcess(process, writer); foreach (FlowElement flowElement in process.FlowElements) { CreateXML(flowElement, model, writer); } foreach (Artifact artifact in process.Artifacts) { CreateXML(artifact, model, writer); } // end process element writer.WriteEndElement(); } try { BPMNDIExport.WriteBPMNDI(model, writer); } catch (Exception ex) { ///TODO: 不支持仅模型没有坐标位置的流程图 } writer.WriteEndElement(); } return(ms.ToArray()); } } catch (Exception e) { log.LogError("Error writing BPMN XML", e); throw new XMLException("Error writing BPMN XML", e); } }
public virtual void CreateXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) { if (flowElement is SubProcess subProcess) { if (flowElement is Transaction) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_TRANSACTION, BpmnXMLConstants.BPMN2_NAMESPACE); } else if (flowElement is AdhocSubProcess) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_ADHOC_SUBPROCESS, BpmnXMLConstants.BPMN2_NAMESPACE); } else { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_SUBPROCESS, BpmnXMLConstants.BPMN2_NAMESPACE); } xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, subProcess.Id); if (!string.IsNullOrWhiteSpace(subProcess.Name)) { xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, subProcess.Name); } else { xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, "subProcess"); } if (subProcess is EventSubProcess) { xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_TRIGGERED_BY, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE); } else if (!(subProcess is Transaction)) { if (subProcess.Asynchronous) { BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw); if (subProcess.NotExclusive) { BpmnXMLUtil.WriteQualifiedAttribute(BpmnXMLConstants.ATTRIBUTE_ACTIVITY_EXCLUSIVE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw); } } } else if (subProcess is AdhocSubProcess hocSubProcess) { BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_CANCEL_REMAINING_INSTANCES, hocSubProcess.CancelRemainingInstances.ToString(), xtw); if (!string.IsNullOrWhiteSpace(hocSubProcess.Ordering)) { BpmnXMLUtil.WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_ORDERING, hocSubProcess.Ordering, xtw); } } if (!string.IsNullOrWhiteSpace(subProcess.Documentation)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_DOCUMENTATION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCharacters(subProcess.Documentation); xtw.WriteEndElement(); } bool didWriteExtensionStartElement = ActivitiListenerExport.WriteListeners(subProcess, false, xtw); didWriteExtensionStartElement = BpmnXMLUtil.WriteExtensionElements(subProcess, didWriteExtensionStartElement, model.Namespaces, xtw); if (didWriteExtensionStartElement) { // closing extensions element xtw.WriteEndElement(); } MultiInstanceExport.WriteMultiInstance(subProcess, xtw); if (subProcess is AdhocSubProcess adhocSubProcess) { if (!string.IsNullOrWhiteSpace(adhocSubProcess.CompletionCondition)) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_COMPLETION_CONDITION, BpmnXMLConstants.BPMN2_NAMESPACE); xtw.WriteCData(adhocSubProcess.CompletionCondition); xtw.WriteEndElement(); } } foreach (FlowElement subElement in subProcess.FlowElements) { CreateXML(subElement, model, xtw); } foreach (Artifact artifact in subProcess.Artifacts) { CreateXML(artifact, model, xtw); } xtw.WriteEndElement(); } else { BaseBpmnXMLConverter converter = convertersToXMLMap[flowElement.GetType()]; if (converter == null) { throw new XMLException("No converter for " + flowElement.GetType() + " found"); } converter.ConvertToXML(xtw, flowElement, model); } }
protected internal virtual bool WriteFormProperties(FlowElement flowElement, bool didWriteExtensionStartElement, XMLStreamWriter xtw) { IList <FormProperty> propertyList = null; if (flowElement is UserTask) { propertyList = ((UserTask)flowElement).FormProperties; } else if (flowElement is StartEvent) { propertyList = ((StartEvent)flowElement).FormProperties; } if (propertyList != null) { foreach (FormProperty property in propertyList) { if (!string.IsNullOrWhiteSpace(property.Id)) { if (!didWriteExtensionStartElement) { xtw.WriteStartElement(BpmnXMLConstants.BPMN_PREFIX, BpmnXMLConstants.ELEMENT_EXTENSIONS, BpmnXMLConstants.BPMN2_NAMESPACE); didWriteExtensionStartElement = true; } xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_FORMPROPERTY, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_ID, property.Id, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_NAME, property.Name, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_TYPE, property.Type, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_EXPRESSION, property.Expression, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_VARIABLE, property.Variable, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_DEFAULT, property.DefaultExpression, xtw); WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_DATEPATTERN, property.DatePattern, xtw); if (!property.Readable) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_READABLE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw); } if (!property.Writeable) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_WRITABLE, BpmnXMLConstants.ATTRIBUTE_VALUE_FALSE, xtw); } if (property.Required) { WriteDefaultAttribute(BpmnXMLConstants.ATTRIBUTE_FORM_REQUIRED, BpmnXMLConstants.ATTRIBUTE_VALUE_TRUE, xtw); } foreach (FormValue formValue in property.FormValues) { if (!string.IsNullOrWhiteSpace(formValue.Id)) { xtw.WriteStartElement(BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX, BpmnXMLConstants.ELEMENT_VALUE, BpmnXMLConstants.ACTIVITI_EXTENSIONS_NAMESPACE); xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_ID, formValue.Id); xtw.WriteAttribute(BpmnXMLConstants.ATTRIBUTE_NAME, formValue.Name); xtw.WriteEndElement(); } } xtw.WriteEndElement(); } } } return(didWriteExtensionStartElement); }