public ModelEntity GetModel() { var model = new WorkflowEventModel() { MainEntityType = this.Lane.Pool.Workflow.MainEntityType, Name = this.Name, Type = this.Type, Task = WorkflowEventTaskModel.GetModel(this), Timer = this.Timer, BpmnElementId = this.BpmnElementId, }; model.CopyMixinsFrom(this); return(model); }
public XElement ToXml(IToXmlContext ctx) { return(new XElement("Workflow", new XAttribute("Guid", workflow.Guid), new XAttribute("Name", workflow.Name), new XAttribute("MainEntityType", ctx.TypeToName(workflow.MainEntityType.ToLite())), new XAttribute("MainEntityStrategies", workflow.MainEntityStrategies.ToString(",")), workflow.ExpirationDate == null ? null ! : new XAttribute("ExpirationDate", workflow.ExpirationDate.Value.ToString("o", CultureInfo.InvariantCulture)), this.pools.Values.Select(p => new XElement("Pool", new XAttribute("BpmnElementId", p.BpmnElementId), new XAttribute("Name", p.Name), p.Xml.ToXml())), this.lanes.Values.Select(la => new XElement("Lane", new XAttribute("BpmnElementId", la.BpmnElementId), new XAttribute("Name", la.Name), new XAttribute("Pool", la.Pool.BpmnElementId), la.Actors.IsEmpty() ? null ! : new XElement("Actors", la.Actors.Select(a => new XElement("Actor", a.KeyLong() !))), la.ActorsEval == null ? null ! : new XElement("ActorsEval", new XCData(la.ActorsEval.Script)), la.Xml.ToXml())), this.activities.Values.Select(a => new XElement("Activity", new XAttribute("BpmnElementId", a.BpmnElementId), new XAttribute("Lane", a.Lane.BpmnElementId), new XAttribute("Name", a.Name), new XAttribute("Type", a.Type.ToString()), a.RequiresOpen == false ? null ! : new XAttribute("RequiresOpen", a.RequiresOpen), a.EstimatedDuration == null ? null ! : new XAttribute("EstimatedDuration", a.EstimatedDuration), string.IsNullOrEmpty(a.ViewName) ? null ! : new XAttribute("ViewName", a.ViewName), string.IsNullOrEmpty(a.Comments) ? null ! : new XElement("Comments", a.Comments), !a.ViewNameProps.Any() ? null ! : new XElement("ViewNameProps", a.ViewNameProps.Select(vnp => new XElement("ViewNameProp", new XAttribute("Name", vnp.Name), new XCData(vnp.Expression !))) ), !a.DecisionOptions.Any() ? null ! : new XElement("DecisionOptions", a.DecisionOptions.Select(cdo => cdo.ToXml("DecisionOption"))), a.CustomNextButton?.ToXml("CustomNextButton") !, string.IsNullOrEmpty(a.UserHelp) ? null ! : new XElement("UserHelp", new XCData(a.UserHelp)), a.SubWorkflow == null ? null ! : new XElement("SubWorkflow", new XAttribute("Workflow", ctx.Include(a.SubWorkflow.Workflow)), new XElement("SubEntitiesEval", new XCData(a.SubWorkflow.SubEntitiesEval.Script)) ), a.Script == null ? null ! : new XElement("Script", new XAttribute("Script", ctx.Include(a.Script.Script)), a.Script.RetryStrategy == null ? null ! : new XAttribute("RetryStrategy", ctx.Include(a.Script.RetryStrategy)) ), a.Xml.ToXml() )), this.gateways.Values.Select(g => new XElement("Gateway", new XAttribute("BpmnElementId", g.BpmnElementId), g.Name.HasText() ? new XAttribute("Name", g.Name) : null !, new XAttribute("Lane", g.Lane.BpmnElementId), new XAttribute("Type", g.Type.ToString()), new XAttribute("Direction", g.Direction.ToString()), g.Xml.ToXml())), this.events.Values.Select(e => new { Event = e, WorkflowEventTaskModel = WorkflowEventTaskModel.GetModel(e) }) .Select(e => new XElement("Event", new XAttribute("BpmnElementId", e.Event.BpmnElementId), e.Event.Name.HasText() ? new XAttribute("Name", e.Event.Name) : null !, new XAttribute("Lane", e.Event.Lane.BpmnElementId), new XAttribute("Type", e.Event.Type.ToString()), e.Event.Timer == null ? null ! : new XElement("Timer", e.Event.Timer.Duration?.ToXml("Duration") !, e.Event.Timer.Condition == null ? null ! : new XAttribute("Condition", ctx.Include(e.Event.Timer.Condition))), e.Event.BoundaryOf == null ? null ! : new XAttribute("BoundaryOf", this.activities.Values.SingleEx(a => a.Is(e.Event.BoundaryOf)).BpmnElementId), e.Event.Xml.ToXml(), e.WorkflowEventTaskModel == null ? null ! : new XElement("WorkflowEventTaskModel", new XAttribute("Suspended", e.WorkflowEventTaskModel.Suspended), new XAttribute("TriggeredOn", e.WorkflowEventTaskModel.TriggeredOn.ToString()), e.WorkflowEventTaskModel.Rule == null ? null ! : new XAttribute("Rule", ctx.Include(e.WorkflowEventTaskModel.Rule)), e.WorkflowEventTaskModel.Condition == null ? null ! : new XElement("Condition", new XCData(e.WorkflowEventTaskModel.Condition.Script)), e.WorkflowEventTaskModel.Action == null ? null ! : new XElement("Action", new XCData(e.WorkflowEventTaskModel.Action.Script))) )), this.connections.Values.Select(c => new XElement("Connection", new XAttribute("BpmnElementId", c.BpmnElementId), c.Name.HasText() ? new XAttribute("Name", c.Name) : null !, new XAttribute("Type", c.Type.ToString()), new XAttribute("From", c.From.BpmnElementId), new XAttribute("To", c.To.BpmnElementId), c.DecisionOptionName == null ? null ! : new XAttribute("CustomDecisionName", c.DecisionOptionName !), c.Condition == null ? null ! : new XAttribute("Condition", ctx.Include(c.Condition)), c.Action == null ? null ! : new XAttribute("Action", ctx.Include(c.Action)), c.Order == null ? null ! : new XAttribute("Order", c.Order), c.Xml.ToXml())) )); }