protected void btnConfirm_Click(object sender, EventArgs e) { CartableEmploymentEntities context = new CartableEmploymentEntities(); MasterPage master = this.Master as MasterPage; string nextState = master.workflowManager.GoNext(""); if (!string.IsNullOrEmpty(nextState)) { Guid cartableId = new Guid(Session["CartableId"].ToString()); wfCartable OldCart = (from cart in context.wfCartable where cart.CartableId == cartableId select cart).First(); OldCart.wfWorkflowStatusReference.Load(); OldCart.wfWorkflowStatus = context.wfWorkflowStatus.First(id => id.Status == "Completed"); OldCart.ActionDate = DateTime.Now; wfCartable cartable = new wfCartable(); cartable.CartableId = Guid.NewGuid(); cartable.ItemId = Convert.ToInt32(Request.QueryString["ItemId"].ToString()); cartable.WorkflowId = master.workflowManager.CurrentWorkflowInstanceId; cartable.CreateDate = DateTime.Now; cartable.ParentWorkflowId = master.workflowManager.ParentWorkflowId; cartable.wfWorkflowStatus = context.wfWorkflowStatus.First(id => id.Status == "Run") as wfWorkflowStatus; cartable.wfActivityStates = context.wfActivityStates.First(id => id.ActivityStateName == nextState) as wfActivityStates; context.AddTowfCartable(cartable); context.SaveChanges(); btnConfirm.Enabled = false; } }
void manager_SubWorkflowStarted(object sender, HA.Workflow.Services.Interfaces.SubWorkflowArgs e) { MasterPage master = this.Master as MasterPage; WorkflowManager manager = master.workflowManager; Guid cartableId = new Guid(Session["CartableId"].ToString()); wfCartable OldCart = (from cart in context.wfCartable where cart.CartableId == cartableId select cart).First(); OldCart.wfWorkflowStatusReference.Load(); OldCart.wfWorkflowStatus = context.wfWorkflowStatus.First(id => id.Status == "Wait"); wfCartable cartable = new wfCartable(); cartable.CartableId = Guid.NewGuid(); cartable.ItemId = Convert.ToInt32(Request.QueryString["ItemId"].ToString()); cartable.WorkflowId = e.InstanceId; cartable.CreateDate = DateTime.Now; cartable.ParentWorkflowId = e.ParentWorkflowId; cartable.wfWorkflowStatus = context.wfWorkflowStatus.First(id => id.Status == "Run") as wfWorkflowStatus; cartable.wfActivityStates = context.wfActivityStates.First(id => id.ActivityStateName == manager._PageToGoTO) as wfActivityStates; context.AddTowfCartable(cartable); }
protected void StartWorkflow() { //string pageTogo = this.Page.Master.woe MasterPage master = this.Master as MasterPage; string state = master.workflowManager.StartNewWorkflow(); Session["EventWaiting"] = master.workflowManager.EventWatingDataSet; wfCartable cartable = new wfCartable(); Session["CartableId"] = cartable.CartableId = Guid.NewGuid(); cartable.ItemId = Convert.ToInt32(txtId.Text); cartable.WorkflowId = master.workflowManager.CurrentWorkflowInstanceId; cartable.CreateDate = DateTime.Now; cartable.wfWorkflowStatus = context.wfWorkflowStatus.First(id => id.Status == "Run") as wfWorkflowStatus; cartable.wfActivityStates = context.wfActivityStates.First(id => id.ActivityStateName == "RegisterApplicant") as wfActivityStates; context.AddTowfCartable(cartable); context.SaveChanges(); BindDropDownTask(); }