//提交 protected void Submit_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(id); bool isSuccess = WorkflowHelper.BackToPreApprover(sn.Value, "founder\\" + _BPMContext.CurrentUser.LoginId); string Opinion = GetApproveOpinion(nodeName.Value); if (string.IsNullOrEmpty(Opinion)) { Opinion = "同意"; } string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "2";//会签步骤 string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; if (bfApproval.AddApprovalRecord(appRecord)) { wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); //if (jc.UpdateStatus(id, "03")) //{} ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } }
//创建转移日志 public static void CreateInstanceChangeLog(this MyDbContext Db, WorkFlowInstance instance, string typeId, string operatorId, string reason, string nextNodeId = "") { /* * WorkFlowInstanceType * 1 开始 * 2 结束 * 3 正常流转 * 4 终止 * 5 回退 */ Db.InstanceChangeLog.Add(new InstanceChangeLog() { InstanceChangeLogID = instance.WorkFlowInstanceID + "-" + instance.CurrentNodeID.Replace(instance.WorkFlow.WorkFlowID, "") + nextNodeId.CheckValue().Replace(instance.WorkFlow.WorkFlowID, "") + DateTime.Now.Random(), WorkFlowInstanceID = instance.WorkFlowInstanceID, FromNodeID = typeId == "1" ? null:instance.CurrentNodeID, ToNodeID = typeId == "1"? instance.CurrentNodeID : nextNodeId, Operator = operatorId, ChangeTime = DateTime.Now, Reason = reason, InstanceChangeLogTypeID = typeId, Note = DateTime.Now + operatorId + "将" + instance.WorkFlow.Name + "(" + instance.WorkFlowInstanceID + ")从" + //instance.Node.Name+ "(" + instance.CurrentNodeID + ")设置为" + nextNodeId.CheckValue() + "理由为:" + reason }); }
public IActionResult WorkFlowProcessing(WorkFlowProcessingModel model) { if (model.EntityId.Equals(Guid.Empty) || model.RecordId.Equals(Guid.Empty)) { return(NotFound()); } var entityMetas = _entityFinder.FindById(model.EntityId); var entity = _dataFinder.RetrieveById(entityMetas.Name, model.RecordId); var instances = _workFlowInstanceService.Query(n => n.Take(1).Where(f => f.EntityId == model.EntityId && f.ObjectId == model.RecordId).Sort(s => s.SortDescending(f => f.CreatedOn))); WorkFlowInstance instance = null; if (instances.NotEmpty()) { instance = instances.First(); } if (instance == null) { return(NotFound()); } var processInfo = _workFlowProcessFinder.GetCurrentStep(instance.WorkFlowInstanceId, CurrentUser.SystemUserId); if (processInfo == null) { if (_workFlowProcessFinder.GetLastHandledStep(instance.WorkFlowInstanceId, CurrentUser.SystemUserId) != null) { return(JError("您已处理")); } return(JError(T["workflow_nopermission"])); } model.InstanceInfo = instance; model.ProcessInfo = processInfo; model.ProcessList = _workFlowProcessFinder.Query(n => n.Where(f => f.WorkFlowInstanceId == instance.WorkFlowInstanceId).Sort(s => s.SortAscending(f => f.StepOrder))); return(View($"~/Views/Flow/{WebContext.ActionName}.cshtml", model)); }
public bool UpdateWorkFlowInstance(WorkFlowInstance rd) { string methodName = "UpdateWorkFlowInstance"; Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + MessageType.IN + ":" + string.Format("WorkFlowInstance={0}", rd)); TransactionManager transaction = DataRepository.Provider.CreateTransaction(); try { transaction.BeginTransaction(); //插入审批步骤 bool result = DataRepository.WorkFlowInstanceProvider.Update(transaction, rd); transaction.Commit(); return(true); } catch (Exception exp) { transaction.Rollback(); Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + MessageType.Exception + ":" + string.Format("Exception={0}", exp)); throw exp; } }
private bool SaveWorkFlowInstance(string WfStatus, DateTime?SumitTime, string WfInstanceId) { bool result = false; WorkFlowInstance workFlowInstance = null; try { workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); bool isEdit = false; if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.AppId = "10105"; workFlowInstance.CreateDeptCode = CurrentEmployee.DepartCode; workFlowInstance.CreateDeptName = CurrentEmployee.DepartName; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = PaymentApplication_Common.GetErpFormTitle(this); _BPMContext.ProcID = workFlowInstance.InstanceId; } else { isEdit = true; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.AppId = "10105"; } workFlowInstance.FormId = FormId; workFlowInstance.WfStatus = WfStatus; if (SumitTime != null) { workFlowInstance.SumitTime = SumitTime; } if (WfInstanceId != "") { workFlowInstance.WfInstanceId = WfInstanceId; } if (!isEdit) { result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); } else { result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.SaveData(true);//会签数据保存 } catch (Exception ex) { throw ex; } return(result); }
private void SaveWorkItem() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = FormId, InstanceID = workFlowInstance.InstanceId, Opinion = "", ApproveAtTime = DateTime.Now, ApproveResult = "",//开始 OpinionType = "", CurrentActiveName = "拟稿", ISSign = "0", DelegateUserName = "", DelegateUserCode = "", CreateAtTime = DateTime.Now, UpdateAtTime = DateTime.Now, FinishedTime = DateTime.Now, ApproveByUserCode = _BPMContext.CurrentPWordUser.EmployeeCode, ApproveByUserName = _BPMContext.CurrentPWordUser.EmployeeName }; new BFApprovalRecord().AddApprovalRecord(appRecord); }
public List<PostDescription> Getxuqiu(WorkFlowInstance Model) { List<PostDescription> ReturnModel = new List<PostDescription>(); if (Model.Activities == null) { return null; } foreach (var item in Model.Activities) { if (Model.Assignments == null) { Model.Assignments = new List<WorkFlowEngine.Assignment>(); } PostDescription SingeModel = new PostDescription(); var id = ObjectId.Parse(item.UnitID); var activeId = item._id.ToString(); var name = Model.WorkFlow.Units.Where(c => c._id == id).Select(x => x.Name).FirstOrDefault(); var list = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.UserCode).ToList(); var keyword = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.Keyword).ToList(); var StringTime = Model.Assignments.Where(c => c.ActivityID == activeId && (c.Keyword == 12002 || c.Keyword == 12003 || c.Keyword == 12005)).Select(x => x.updatetime).ToList(); if (name != "开始" && name != "结束" && name != "重新提交") { SingeModel.Post = name; SingeModel.JobNumber = list.FirstOrDefault(); SingeModel.Time = StringTime.FirstOrDefault(); ReturnModel.Add(SingeModel); } } return ReturnModel; }
//拒绝 protected void Reject_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(id); if (workFlowInstance != null) { UploadAttachments1.SaveAttachment(id); string action = "不同意"; bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action); string Opinion = GetApproveOpinion(nodeName.Value); string ApproveResult = "不同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess && !(bool)ViewState["IsSubmit"]) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; ViewState["IsSubmit"] = true; bfApproval.AddApprovalRecord(appRecord); wf_WorkFlowInstance.UpdateStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); if (wf_Instruction.UpdateStatus(id, "01", workFlowInstance.WfInstanceId)) { WebCommon.Show(this, Resources.Message.ApplicationReviewSucess); Response.Redirect("~/Workflow/ToDoWorkList.aspx", false); } } } //WorkflowHelper.ApproveProcess //insert data to business object }
public WorkFlowBag CreateInstance(string workFlowId, string uid, string unitId) { var workFlow = Db.WorkFlow.Find(workFlowId); if (workFlow == null) { throw new Exception("不存在该工作流!workFlowId=>" + workFlowId); } var model = new WorkFlowInstance() { CreateTime = DateTime.Now, CurrentNodeID = workFlow.StartNodeID, Note = Note(uid, "创建工作流实例"), WorkFlowID = workFlowId, WorkFlowInstanceID = workFlowId + "-" + uid + "-" + DateTime.Now.Random(), InstancePeople = uid, UnitID = unitId }; Db.WorkFlowInstance.Add(model); //创建转移日志 Db.CreateInstanceChangeLog(model, "1", uid, "激活" + model.WorkFlow.Name + "实例"); if (Db.SaveChanges() > 0) { var result = new WorkFlowBag(model); return(result); } else { throw new Exception("工作流实例化失败!"); } }
public async Task <IActionResult> AddWorkFlowInstance([FromBody] WorkFlowInstance entity) { entity.UserName = User.GetUserName(); await _service.AddWorkFlowInstanceAsync(entity); return(Ok()); }
/// <summary> /// 保存流程实例 /// </summary> /// <returns></returns> private string SaveWorkFlowInstance() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.AppId = AppID; workFlowInstance.FormId = FormId; workFlowInstance.CreateDeptCode = CurrentEmployee.DepartCode; workFlowInstance.CreateDeptName = CurrentEmployee.DepartName; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = GetFormTitle(); workFlowInstance.WfStatus = "0"; wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); SaveWorkItem(workFlowInstance.InstanceId); _BPMContext.ProcID = workFlowInstance.InstanceId; } else { workFlowInstance.CreateDeptCode = CurrentEmployee.DepartCode; workFlowInstance.CreateDeptName = CurrentEmployee.DepartName; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = GetFormTitle(); wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } return(workFlowInstance == null ? "" : workFlowInstance.InstanceId); }
/// <summary> /// 保存工作流实例 /// </summary> /// <param name="p"></param> /// <param name="dateTime"></param> /// <param name="p_2"></param> /// <returns></returns> private bool SaveWorkFlowInstance(string WfStatus, DateTime?SumitTime, string WfInstanceId) { bool result = false; WorkFlowInstance workFlowInstance = null; try { workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); bool isEdit = false; if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateAtTime = DateTime.Now; //appid和应用管理创建新的管理的应用号是一致的 workFlowInstance.AppId = "10113"; workFlowInstance.CreateDeptCode = ddlDepartName.SelectedItem.Value.ToString(); workFlowInstance.CreateDeptName = ddlDepartName.SelectedItem.Text; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = tbTitle.Text; } else { isEdit = true; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = tbTitle.Text; workFlowInstance.AppId = "10113"; } workFlowInstance.FormId = FormId; workFlowInstance.WfStatus = WfStatus; if (SumitTime != null) { workFlowInstance.SumitTime = SumitTime; } if (WfInstanceId != "") { workFlowInstance.WfInstanceId = WfInstanceId; } if (!isEdit) { result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); } else { result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } FlowRelated1.ProcId = workFlowInstance.InstanceId; } catch (Exception ex) { throw ex; } return(result); }
//拒绝 protected void Reject_Click(object sender, EventArgs e) { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); if (workFlowInstance != null) { uploadAttachments.SaveAttachment(FormId); UpdateWFParams(); string action = "不同意"; ChangeResultToUnAgree(); bool isSuccess = WorkflowHelper.ApproveProcess(sn.Value, action, "founder\\" + _BPMContext.CurrentUser.LoginId); string Opinion = GetApproveOpinion(nodeName.Value); if (string.IsNullOrEmpty(Opinion)) { Opinion = "不同意"; } string ApproveResult = "不同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; if (isSuccess) { var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), WFTaskID = int.Parse(taskID.Value), FormID = FormId, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = nodeName.Value, ISSign = IsSign, CurrentActiveID = nodeID.Value, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; bfApproval.AddApprovalRecord(appRecord); wf_WorkFlowInstance.UpdateNowStatus(workFlowInstance.WfInstanceId, "1", nodeID.Value, nodeName.Value, int.Parse(taskID.Value), null, CurrentEmployee); } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('审批成功'); window.opener.location.href=window.opener.location.href; ", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } //WorkflowHelper.ApproveProcess //insert data to business object }
private void BindFormData() { string methodName = "BindFormData"; try { WorkFlowInstance Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString()); if (Instance == null) { ExceptionHander.GoToErrorPage("记录不存在"); } JC_ElevatorOrderInfo item = jc.GetElevatorOrder(Instance.FormId.ToString()); if (item == null) { ExceptionHander.GoToErrorPage("记录不存在"); } if (item != null) { cblSecurityLevel.SelectedValue = item.SecurityLevel.ToString(); cblUrgentLevel.SelectedValue = item.UrgenLevel != null?item.UrgenLevel.ToString() : "0"; tbData.Text = ((DateTime)item.Date).ToString("yyyy-MM-dd"); tbPerson.Text = item.UserName; tbDepartName.Text = item.DeptName; tbPhone.Text = item.Mobile; tbTitle.Text = item.ReportTitle; tbOrderType.Text = item.OrderType.ToString(); tbOrderID.Text = item.OrderID.ToString(); tbContent.Text = item.Url; tbNumber.Text = item.ReportCode; txtMaxCost.Text = item.MaxCost.HasValue ? FormatMoney(item.MaxCost.Value.ToString()) : ""; tbNote.Text = item.Note; //add 2014-12-23 Countersign1.CounterSignDeptId = item.StartDeptCode; } Countersign1.ProcId = ViewState["InstanceID"].ToString(); #region 审批意见框 DeptManagerApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); RealateDeptApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); CityCompanyLeaderApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); JCFirstApprovalApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); DesignerApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); ProjectOperatorApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); JCReApprovalApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); PurchaserApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); COOApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); JCMakeOrderApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); JCFinalApprovalApproveOpinion.InstanceId = ViewState["InstanceID"].ToString(); #endregion } catch (Exception ex) { Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex)); throw ex; } Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT); }
private bool SaveWorkFlowInstance(InstructionOfPKURGIInfo obj, string WfStatus, DateTime?SumitTime, string WfInstanceId) { bool result = false; WorkFlowInstance workFlowInstance = null; try { workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); bool isEdit = false; if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateDeptCode = ddlDepartName.SelectedItem.Value.ToString(); workFlowInstance.CreateDeptName = ddlDepartName.SelectedItem.Text; workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.AppId = "3001"; } else { workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; isEdit = true; } workFlowInstance.FormId = obj.FormID; workFlowInstance.FormTitle = obj.Title; workFlowInstance.WfStatus = WfStatus; if (SumitTime != null) { workFlowInstance.SumitTime = SumitTime; } if (WfInstanceId != "") { workFlowInstance.WfInstanceId = WfInstanceId; } if (!isEdit) { result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); } else { result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.SaveData(true); } catch (Exception ex) { throw ex; } return(result); }
private void SetUserControlInstance() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; UploadAttachments1.ProcId = workFlowInstance.InstanceId; hfInstanceId.Value = workFlowInstance.InstanceId; }
public async Task <bool> CreateWorkFlowInstance(int workflowId) { var account = _httpContextAccessor.HttpContext?.User?.GetUserName(); var userName = _httpContextAccessor.HttpContext?.User?.GetName(); // 获取开始节点id var startNode = await _nodeRepository.Get(n => n.WorkFlowId == workflowId && n.NodeType == NodeTypeEnum.StartNode) .FirstOrDefaultAsync(); // 工作流定义 var workflow = await _workflowRepository.GetAsync(workflowId); // 创建工作流实例 var instance = new WorkFlowInstance() { WorkFlowInstanceState = WorkFlowInstanceStateEnum.NoCommitted, CurrentNodeId = startNode.Id, CreatedTime = DateTime.Now, CreatedUserAccount = account, CreatedUserName = userName, WorkFlowName = workflow.Name, WorkFlowId = workflowId, }; // 添加节点处理记录 var routeInfo = new WorkFlowInstanceRoute { NodeId = startNode.Id, NodeName = startNode.Name, HandlePeopleName = userName, HandlePepleAccount = account, HandleState = HandleStateEnum.未处理, HandleTime = DateTime.Now, }; try { var entity = await _instanceRepository.AddAsync(instance); await _unitOfWork.SaveAsync(); routeInfo.WorkFlowInstanceId = entity.Id; await _instanceRouteRepository.AddAsync(routeInfo); await _unitOfWork.SaveAsync(); return(true); } catch (Exception e) { _logger.LogError(e.Message); _logger.LogError(e.StackTrace); return(false); } }
/// <summary> /// 初始化用户控件 /// </summary> private void SetUserControlInstance() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); string instrId = Request.QueryString["id"]; if (!string.IsNullOrEmpty(instrId)) { FlowRelated1.ProcId = instrId; hfInstanceId.Value = instrId; } }
private void BindFormData() { string methodName = "BindFormData"; Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.IN); try { JC_ElevatorOrderInfo jcInfo = jc.GetElevatorOrder(ViewState["FormID"].ToString()); cblSecurityLevel.SelectedValue = jcInfo.SecurityLevel.ToString(); cblUrgentLevel.SelectedValue = jcInfo.UrgenLevel != null?jcInfo.UrgenLevel.ToString() : "0"; ListItem item = ddlDepartName.Items.FindByValue(jcInfo.StartDeptCode); if (item != null) { ddlDepartName.SelectedIndex = ddlDepartName.Items.IndexOf(item); } UpdatedTextBox.Value = ((DateTime)jcInfo.Date).ToString("yyyy-MM-dd"); tbPerson.Text = jcInfo.UserName; tbPhone.Text = jcInfo.Mobile; tbTitle.Text = jcInfo.ReportTitle; tbOrderID.Text = jcInfo.OrderID.ToString(); tbOrderType.Text = jcInfo.OrderType.ToString(); tbNumber.Text = jcInfo.ReportCode; tbNote.Text = jcInfo.Note; //add 2015-01-14 txtMaxCost.Text = jcInfo.MaxCost.HasValue ? jcInfo.MaxCost.Value.ToString() : ""; tbContent.Text = jcInfo.Url; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(jcInfo.FormID); Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.CounterSignDeptId = jcInfo.StartDeptCode; #region 审批意见框 DeptManagerApproveOpinion.InstanceId = workFlowInstance.InstanceId; RealateDeptApproveOpinion.InstanceId = workFlowInstance.InstanceId; CityCompanyLeaderApproveOpinion.InstanceId = workFlowInstance.InstanceId; JCFirstApprovalApproveOpinion.InstanceId = workFlowInstance.InstanceId; DesignerApproveOpinion.InstanceId = workFlowInstance.InstanceId; ProjectOperatorApproveOpinion.InstanceId = workFlowInstance.InstanceId; JCReApprovalApproveOpinion.InstanceId = workFlowInstance.InstanceId; PurchaserApproveOpinion.InstanceId = workFlowInstance.InstanceId; COOApproveOpinion.InstanceId = workFlowInstance.InstanceId; JCMakeOrderApproveOpinion.InstanceId = workFlowInstance.InstanceId; JCFinalApprovalApproveOpinion.InstanceId = workFlowInstance.InstanceId; #endregion } catch (Exception ex) { Logger.Write(this.GetType(), EnumLogLevel.Fatal, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.Exception + ":" + string.Format("Exception={0}", ex)); throw ex; } Logger.Write(this.GetType(), EnumLogLevel.Info, className + ":" + methodName + ":" + Pkurg.PWorldBPM.Common.Log.MessageType.OUT); }
public WorkFlowInstanceList GetWorkFlowInstances() { //WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal; //WindowsIdentity identity = (WindowsIdentity)principal.Identity; //TrackingLog.Log(identity.Name); WorkFlowInstanceList l = new WorkFlowInstanceList(); try { TrackingDataContext dataContext = new TrackingDataContext(); IQueryable <CommonResource.Tracking> trackingQuery = from tracking in dataContext.Trackings select tracking; foreach (CommonResource.Tracking t in trackingQuery) { using (TrackingWorkFlowInteraction interaction = new TrackingWorkFlowInteraction()) { WorkFlowInstance wfi = new WorkFlowInstance(); wfi.BugId = t.bugid; wfi.Id = t.wfinstanceid.ToString(); wfi.Title = t.title; wfi.WFName = t.wfname; wfi.LastModified = t.lastmodified.ToString(); wfi.QFEStatus = t.qfestatus; wfi.AssignedTo = t.assignedto; wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.Value.ToString(); wfi.LastModifiedBy = t.lastmodifiedby; // //List<string> candiCmds = interaction.getCandidateCommands(t.wfname.Trim(), t.wfinstanceid.ToString()); //CandidateCommandList ccl = new CandidateCommandList(); //if (candiCmds != null) //{ // foreach (string cmd in candiCmds) // { // ccl.Add(cmd); // } //} //wfi.CandidateCommandList = ccl; l.Add(wfi); } } } catch (Exception e) { TrackingLog.Log(e.ToString() + "!!" + e.Message); } return(l); }
private void BindFormData() { try { WorkFlowInstance Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString()); if (Instance == null) { ExceptionHander.GoToErrorPage("记录不存在"); } InstructionOfEToGInfo obj = Vitems.Get(Instance.FormId.ToString()); if (obj == null) { ExceptionHander.GoToErrorPage("记录不存在"); } if (obj != null) { tbReportCode.Text = obj.FormID; tbDepartName.Text = obj.DeptName; lbDeptCode.Text = obj.DeptCode; tbDateTime.Text = obj.DateTime; tbUserName.Text = obj.UserName; tbMobile.Text = obj.Mobile; tbTitle.Text = obj.Title; tbContent.Text = obj.Content.Replace(" ", " ").Replace("\n", "<br/>"); cbIsReport.Checked = obj.IsReport == "1" ? true : false; cblSecurityLevel.SelectedValue = obj.SecurityLevel != null?obj.SecurityLevel.ToString() : "-1"; cblUrgenLevel.SelectedValue = obj.UrgenLevel != null?obj.UrgenLevel.ToString() : "-1"; } FlowRelated1.ProcId = ViewState["InstanceID"].ToString(); Countersign1.ProcId = ViewState["InstanceID"].ToString(); UploadAttachments1.ProcId = ViewState["InstanceID"].ToString(); #region 审批意见框 OpinionDeptDiretor.InstanceId = ViewState["InstanceID"].ToString(); OpinionDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionCountersign.InstanceId = ViewState["InstanceID"].ToString(); OpinionAP.InstanceId = ViewState["InstanceID"].ToString(); OpinionVP.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirectors.InstanceId = ViewState["InstanceID"].ToString(); OpinionCFO.InstanceId = ViewState["InstanceID"].ToString(); OpinionEVP.InstanceId = ViewState["InstanceID"].ToString(); OpinionPresident.InstanceId = ViewState["InstanceID"].ToString(); OpinionChairman.InstanceId = ViewState["InstanceID"].ToString(); #endregion } catch (Exception ex) { throw ex; } }
/// <summary> /// 保存流程实例 /// </summary> /// <returns></returns> private string SaveWorkFlowInstance() { string startDeptName = ""; if (string.IsNullOrWhiteSpace(StartDeptId)) { StartDeptId = CurrentEmployee.DepartCode; startDeptName = CurrentEmployee.DepartName; } else { Department deptInfo = new Pkurg.PWorld.Services.DepartmentService().GetByDepartCode(StartDeptId); if (deptInfo != null) { startDeptName = deptInfo.Remark; } } WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.AppId = AppID; workFlowInstance.FormId = FormId; workFlowInstance.CreateDeptCode = StartDeptId;// CurrentEmployee.DepartCode; workFlowInstance.CreateDeptName = startDeptName; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = GetFormTitle(); workFlowInstance.WfStatus = "0"; wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); SaveWorkItem(workFlowInstance.InstanceId); _BPMContext.ProcID = workFlowInstance.InstanceId; } else { workFlowInstance.CreateDeptCode = StartDeptId; workFlowInstance.CreateDeptName = startDeptName; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.FormTitle = GetFormTitle(); wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } return(workFlowInstance == null ? "" : workFlowInstance.InstanceId); }
/// <summary> /// 初始化用户控件 /// </summary> private void SetUserControlInstance() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; UploadAttachments1.ProcId = workFlowInstance.InstanceId; hfInstanceId.Value = workFlowInstance.InstanceId; OpinionDeptleader.InstanceId = workFlowInstance.InstanceId; OpinionRealateDept.InstanceId = workFlowInstance.InstanceId; OpinionTopLeaders.InstanceId = workFlowInstance.InstanceId; OpinionCEO.InstanceId = workFlowInstance.InstanceId; OpinionChairman.InstanceId = workFlowInstance.InstanceId; }
private string ChangeWorkFlowInstanceStart(int wfInstanceId) { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); if (workFlowInstance != null) { workFlowInstance.SumitTime = DateTime.Now; workFlowInstance.WfStatus = "1"; workFlowInstance.WfInstanceId = wfInstanceId.ToString(); wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); return(workFlowInstance.InstanceId); } return(""); }
private void SetUserControlInstance() { WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(FormId); FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; UploadAttachments1.ProcId = workFlowInstance.InstanceId; hfInstanceId.Value = workFlowInstance.InstanceId; #region 审批意见框 ApproveOpinionUCDeptleader.InstanceId = workFlowInstance.InstanceId; ApproveOpinionUCRealateDept.InstanceId = workFlowInstance.InstanceId; ApproveOpinionUCLeader.InstanceId = workFlowInstance.InstanceId; ApproveOpinionUCCEO.InstanceId = workFlowInstance.InstanceId; #endregion }
private void BindFormData() { try { WorkFlowInstance Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString()); if (Instance == null) { ExceptionHander.GoToErrorPage("记录不存在"); } CadresOrRemovalInfo obj = Vitems.Get(Instance.FormId.ToString()); if (obj == null) { ExceptionHander.GoToErrorPage("记录不存在"); } if (obj != null) { InitApproveList2(obj.IsGroup); tbReportCode.Text = obj.FormID; tbCadresName.Text = obj.CadresName; tbLocationCompanyDeptJob.Text = obj.LocationCompanyDeptJob.Replace(" ", " ").Replace("\n", "<br/>"); tbCadresCompanyDeptJob.Text = obj.CadresCompanyDeptJob.Replace(" ", " ").Replace("\n", "<br/>"); tbCadresContent.Text = obj.CadresContent.Replace(" ", " ").Replace("\n", "<br/>"); tbRemovalName.Text = obj.RemovalName; tbLocationCompanyDeptJobR.Text = obj.LocationCompanyDeptJobR.Replace(" ", " ").Replace("\n", "<br/>"); tbRemovalCompanyDeptjob.Text = obj.RemovalCompanyDeptjob.Replace(" ", " ").Replace("\n", "<br/>"); tbRemovalContent.Text = obj.RemovalContent.Replace(" ", " ").Replace("\n", "<br/>"); if (!string.IsNullOrEmpty(obj.chkCadresOrRemoval)) { tbCadre.Visible = obj.chkCadresOrRemoval != "1" ? true : false; tbRemoval.Visible = obj.chkCadresOrRemoval != "0" ? true : false; } } UploadAttachments1.ProcId = ViewState["InstanceID"].ToString(); OpinionDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionHRDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirector1.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirector2.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirector3.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirector4.InstanceId = ViewState["InstanceID"].ToString(); OpinionChairman.InstanceId = ViewState["InstanceID"].ToString(); } catch (Exception ex) { throw ex; } }
public WorkFlowInstance startWorkFlow(CommandInfo CommandInfo) { string WFName = CommandInfo.WFName; TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction(); string id = twfi.startProcess(WFName); WorkFlowInstance wfi = new WorkFlowInstance(); wfi.Id = id; List <string> candCmds = twfi.getCandidateCommands(WFName, id); CandidateCommandList ccl = new CandidateCommandList(); ccl.AddRange(candCmds); wfi.CandidateCommandList = ccl; return(wfi); }
private void BindFormData() { try { WorkFlowInstance Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString()); if (Instance == null) { ExceptionHander.GoToErrorPage("记录不存在"); } PurchasePaintInfo obj = Vitems.Get(Instance.FormId.ToString()); if (obj == null) { ExceptionHander.GoToErrorPage("记录不存在"); } if (obj != null) { tbReportCode.Text = obj.FormID; tbDepartName.Text = obj.DeptName; lbDeptCode.Text = obj.DeptCode; tbDateTime.Text = obj.DateTime; tbUserName.Text = obj.UserName; tbMobile.Text = obj.Mobile; tbTitle.Text = obj.Title; tbContent.Text = obj.Content.Replace(" ", " ").Replace("\n", "<br/>"); } FlowRelated1.ProcId = ViewState["InstanceID"].ToString(); Countersign1.ProcId = ViewState["InstanceID"].ToString(); UploadAttachments1.ProcId = ViewState["InstanceID"].ToString(); #region 审批意见框 OpinionDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionCountersign.InstanceId = ViewState["InstanceID"].ToString(); OpinionPresident.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupAuditor.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupProjectLeader.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupDeptLeader.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupLeader.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupAuditor2.InstanceId = ViewState["InstanceID"].ToString(); OpinionGroupReviewer.InstanceId = ViewState["InstanceID"].ToString(); #endregion } catch (Exception ex) { throw ex; } }
public WorkFlowInstance GetWorkFlowInstance(string InstanceId) { WorkFlowInstance wfi = new WorkFlowInstance(); wfi.Id = InstanceId; try { TrackingDataContext trackingContext = new TrackingDataContext(); Guid guid = new Guid(InstanceId); IQueryable <CommonResource.Tracking> trackingQuery = from tracking in trackingContext.Trackings where ((tracking.wfinstanceid == guid)) select tracking; foreach (CommonResource.Tracking t in trackingQuery) { using (TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction()) { wfi = new WorkFlowInstance(); wfi.BugId = t.bugid; wfi.Id = t.wfinstanceid.ToString(); wfi.Title = t.title; wfi.WFName = t.wfname; //wfi.LastModified = t.lastmodified==null?"N/A":t.lastmodified.ToString(); wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.ToString(); wfi.QFEStatus = t.qfestatus; wfi.AssignedTo = t.assignedto; wfi.LastModifiedBy = t.lastmodifiedby; try { CandidateCommandList ccl = twfi.getCandidateCommands(t.wfname.Trim(), InstanceId); wfi.CandidateCommandList = ccl; } catch (WorkFlowNotFoundException e) { } } return(wfi); } } catch (Exception e) { throw new WebFaultException <string>(e.ToString(), HttpStatusCode.InternalServerError); } return(null); }
//创建实例日志 public static void CreateInstanceHistory(this MyDbContext Db, WorkFlowInstance old, string typeId, string note) {/* * InstanceHistoryType * 1 正常结束 * 2 终止结束 * 3 中途删除*/ Db.InstanceHistory.Add(new InstanceHistory() { WorkFlowInstanceID = old.WorkFlowInstanceID, WorkFlowID = old.WorkFlowID, CreateTime = old.CreateTime, CurrentNodeID = old.CurrentNodeID, Note = note, InstancePeople = old.InstancePeople, InstanceHistoryTypeID = typeId, UnitID = old.UnitID }); }
public WorkFlowInstance GetWorkFlowInstance(string InstanceId) { WorkFlowInstance wfi = new WorkFlowInstance(); TrackingDataContext trackingContext = new TrackingDataContext(); Guid guid = new Guid(InstanceId); IQueryable<Tracking> trackingQuery = from tracking in trackingContext.Trackings where ((tracking.wfinstanceid == guid)) select tracking; foreach (Tracking t in trackingQuery) { TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction(); wfi = new WorkFlowInstance(); List<string> candCmds=twfi.getCandidateCommands(t.wfname, InstanceId); CandidateCommandList ccl=new CandidateCommandList(); ccl.AddRange(candCmds); wfi.CandidateCommandList = ccl; return wfi; } return null; }
public WorkFlowInstance startWorkFlow(CommandInfo CommandInfo) { string WFName = CommandInfo.WFName; TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction(); string id=twfi.startProcess(WFName); WorkFlowInstance wfi = new WorkFlowInstance(); wfi.Id = id; List<string> candCmds = twfi.getCandidateCommands(WFName, id); CandidateCommandList ccl = new CandidateCommandList(); ccl.AddRange(candCmds); wfi.CandidateCommandList = ccl; return wfi; }
public WorkFlowInstance startWorkFlow(CommandInfo CommandInfo) { WorkFlowInstance wfi = new WorkFlowInstance(); try { string WFName = CommandInfo.WFName.Trim(); TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction(); string id = twfi.startProcess(WFName); CommandInteraction cmdInteraction = new CommandInteraction(); Dictionary<string, string> paras = new Dictionary<string, string>(); paras.Add("InstanceId", id); paras.Add("WFName", CommandInfo.WFName); if (CommandInfo.ParameterList != null) { foreach (Parameter p in CommandInfo.ParameterList) { paras.Add(p.Name, p.Value); } } TrackingWorkFlowInteraction II = new TrackingWorkFlowInteraction(); StateMachineDefinition statemachineDefinition = II.getStateMachineDefinition(CommandInfo.WFName); paras.Add("QFEStatus", statemachineDefinition.InitialState); cmdInteraction.executeCommand(CommandInfo.CommandName, paras); wfi.Id = id; List<string> candCmds = twfi.getCandidateCommands(WFName, id); CandidateCommandList ccl = new CandidateCommandList(); ccl.AddRange(candCmds); wfi.CandidateCommandList = ccl; } catch (Exception e) { throw new WebFaultException<string>(e.ToString(), HttpStatusCode.InternalServerError); // TrackingLog.Log(e.Message + "!!" + e.ToString()); } return wfi; }
public WorkFlowInstanceList GetWorkFlowInstances() { //WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal; //WindowsIdentity identity = (WindowsIdentity)principal.Identity; //TrackingLog.Log(identity.Name); WorkFlowInstanceList l = new WorkFlowInstanceList(); try { TrackingDataContext dataContext = new TrackingDataContext(); IQueryable<CommonResource.Tracking> trackingQuery = from tracking in dataContext.Trackings select tracking; foreach (CommonResource.Tracking t in trackingQuery) { using (TrackingWorkFlowInteraction interaction = new TrackingWorkFlowInteraction()) { WorkFlowInstance wfi = new WorkFlowInstance(); wfi.BugId = t.bugid; wfi.Id = t.wfinstanceid.ToString(); wfi.Title = t.title; wfi.WFName = t.wfname; wfi.LastModified = t.lastmodified.ToString(); wfi.QFEStatus = t.qfestatus; wfi.AssignedTo = t.assignedto; wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.Value.ToString(); wfi.LastModifiedBy = t.lastmodifiedby; // //List<string> candiCmds = interaction.getCandidateCommands(t.wfname.Trim(), t.wfinstanceid.ToString()); //CandidateCommandList ccl = new CandidateCommandList(); //if (candiCmds != null) //{ // foreach (string cmd in candiCmds) // { // ccl.Add(cmd); // } //} //wfi.CandidateCommandList = ccl; l.Add(wfi); } } } catch (Exception e) { TrackingLog.Log(e.ToString() + "!!" + e.Message); } return l; }
public WorkFlowInstance GetWorkFlowInstance(string InstanceId) { WorkFlowInstance wfi = new WorkFlowInstance(); wfi.Id = InstanceId; try { TrackingDataContext trackingContext = new TrackingDataContext(); Guid guid = new Guid(InstanceId); IQueryable<CommonResource.Tracking> trackingQuery = from tracking in trackingContext.Trackings where ((tracking.wfinstanceid == guid)) select tracking; foreach (CommonResource.Tracking t in trackingQuery) { using (TrackingWorkFlowInteraction twfi = new TrackingWorkFlowInteraction()) { wfi = new WorkFlowInstance(); wfi.BugId = t.bugid; wfi.Id = t.wfinstanceid.ToString(); wfi.Title = t.title; wfi.WFName = t.wfname; //wfi.LastModified = t.lastmodified==null?"N/A":t.lastmodified.ToString(); wfi.LastModified = t.lastmodified == null ? "N/A" : t.lastmodified.ToString(); wfi.QFEStatus = t.qfestatus; wfi.AssignedTo = t.assignedto; wfi.LastModifiedBy = t.lastmodifiedby; try { CandidateCommandList ccl = twfi.getCandidateCommands(t.wfname.Trim(), InstanceId); wfi.CandidateCommandList = ccl; } catch (WorkFlowNotFoundException e) { } } return wfi; } } catch (Exception e) { throw new WebFaultException<string>(e.ToString(),HttpStatusCode.InternalServerError); } return null; }