protected void ButtonStart_Click(object sender, EventArgs e) { if (Session["currentInstance"] == null) { Server.Transfer("Error.aspx"); } dbHelper helper = new dbHelper(); FlowInstances currentFlow = (FlowInstances)Session["currentInstance"]; Actions next = helper.GetNextAction(currentFlow.Flows.FlowId, currentFlow.CurrentPosition); if (next == null) { Server.Transfer("End.aspx"); } else { FlowInstances flowInstance = helper.GetFlowInstanceById(currentFlow.FlowInstanceId); flowInstance.CurrentPosition++; flowInstance.Actions = next; helper.UpdateChanges(); Session["currentInstance"] = flowInstance; Server.Transfer(flowInstance.Actions.ActionPage); } }
protected void ButtonPlay_Click(object sender, EventArgs e) { if (Page.IsValid) { if (dt.Rows.Count > 0) { Flows playflow = SaveFlow(); if (playflow != null) { FlowInstances currentFlow = new FlowInstances(); dbHelper helper = new dbHelper(); DataRow firstRow = dt.Rows[0]; Actions startAction = helper.GetActionById(firstRow["Id"].ToString()); currentFlow.Actions = startAction; currentFlow.CurrentPosition = 1; currentFlow.Users = playflow.Users; currentFlow.Flows = playflow; helper.AddToModel(currentFlow); Session["currentInstance"] = currentFlow; Server.Transfer(currentFlow.Actions.ActionPage); } } } }
public FlowInstances GetFlowInstanceById(int instanceId) { EntityKey key = new EntityKey("SimpleFlowEntities.FlowInstances", "FlowInstanceId", instanceId); FlowInstances instance = model.GetObjectByKey(key) as FlowInstances; instance = model.FlowInstances.Include("Flows").Where <FlowInstances>(f => f.FlowInstanceId == instance.FlowInstanceId).FirstOrDefault <FlowInstances>(); return(instance); }