/// <summary> /// Gets the assignment properties. /// </summary> /// <param name="workflowInstanceId">The workflow instance id.</param> /// <param name="activityName">Name of the activity.</param> /// <returns></returns> public static PropertyValueCollection GetAssignmentProperties(Guid workflowInstanceId, string activityName) { using (WorkflowChangesScope scope = WorkflowChangesScope.Create(workflowInstanceId)) { return(GetAssignmentProperties(GetActivityByName(scope.TransientWorkflow, activityName))); } }
/// <summary> /// Gets the business process info. /// </summary> /// <param name="workflowId">The workflow id.</param> /// <returns></returns> public static BusinessProcessInfo GetBusinessProcessInfo(Guid workflowId) { BusinessProcessInfo retVal = new BusinessProcessInfo(); using (WorkflowChangesScope scope = WorkflowChangesScope.Create(workflowId)) { // Step 1. Fill BusinessProcessInfo retVal.PrimaryKeyId = (PrimaryKeyId)workflowId; retVal.Name = scope.WorkflowEntity.Properties.GetValue <string>(WorkflowInstanceEntity.FieldName); if (scope.WorkflowEntity.Properties.Contains(WorkflowInstanceEntity.FieldState)) { retVal.State = (BusinessProcessState)scope.WorkflowEntity.Properties.GetValue <int>(WorkflowInstanceEntity.FieldState); } else { retVal.State = BusinessProcessState.Pending; } retVal.PlanFinishDate = scope.WorkflowEntity.Properties.GetValue <DateTime?>(WorkflowInstanceEntity.FieldPlanFinishDate); retVal.PlanDuration = scope.WorkflowEntity.Properties.GetValue <int?>(WorkflowInstanceEntity.FieldPlanDuration); if (scope.WorkflowEntity.Properties.Contains(WorkflowInstanceEntity.FieldActualStartDate)) { retVal.ActualStartDate = scope.WorkflowEntity.Properties.GetValue <DateTime?>(WorkflowInstanceEntity.FieldActualStartDate); } if (scope.WorkflowEntity.Properties.Contains(WorkflowInstanceEntity.FieldActualFinishDate)) { retVal.ActualFinishDate = scope.WorkflowEntity.Properties.GetValue <DateTime?>(WorkflowInstanceEntity.FieldActualFinishDate); } if (scope.WorkflowEntity.Properties.Contains(WorkflowInstanceEntity.FieldExecutionResult)) { retVal.ExecutionResult = (BusinessProcessExecutionResult?)scope.WorkflowEntity.Properties.GetValue <int?>(WorkflowInstanceEntity.FieldExecutionResult); } // Step 2. Fill ActivityInfo Recursion CompositeActivity activity = scope.TransientWorkflow as CompositeActivity; if (activity != null) { EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, new FilterElement[] { FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, (PrimaryKeyId)workflowId) }); CreateBusinessProcessActivityInfo(retVal, scope, assignments, activity, retVal.Activities); // Fill Plan Finish Date if (retVal.PlanFinishDate.HasValue && retVal.State == BusinessProcessState.Active) { FillPlanFinishDate(retVal.Activities); } } } return(retVal); }
/// <summary> /// Creates the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static WorkflowChangesScope Create(WorkflowDefinitionEntity entity) { if (entity == null) { throw new ArgumentNullException("entity"); } WorkflowChangesScope retVal = new WorkflowChangesScope(entity); return(retVal); }
/// <summary> /// Creates the business process activity info. /// </summary> /// <param name="businessProcess">The business process.</param> /// <param name="scope">The scope.</param> /// <param name="parentActivity">The parent activity.</param> /// <param name="activityInfoItems">The activity info items.</param> private static void CreateBusinessProcessActivityInfo(BusinessProcessInfo businessProcess, WorkflowChangesScope scope, EntityObject[] assignments, CompositeActivity parentActivity, ActivityInfoCollection activityInfoItems) { foreach (Activity activity in parentActivity.Activities) { if (activity is CreateAssignmentAndWaitResultActivity) { CreateAssignmentAndWaitResultActivity asgActivity = (CreateAssignmentAndWaitResultActivity)activity; PropertyValueCollection properties = asgActivity.AssignmentProperties; ActivityInfo activityInfo = new ActivityInfo(); activityInfoItems.Add(activityInfo); activityInfo.Name = activity.Name; activityInfo.Type = ActivityType.Assignment; AssignmentEntity assignment = FindAssignmentByActivityName(assignments, activity.Name); if (assignment != null) { activityInfo.State = (AssignmentState)assignment.State; activityInfo.Subject = assignment.Subject; activityInfo.TimeStatus = (AssignmentTimeStatus?)assignment.TimeStatus; activityInfo.PlanStartDate = assignment.ActualStartDate; activityInfo.PlanFinishDate = assignment.PlanFinishDate; activityInfo.ActualStartDate = assignment.ActualStartDate; activityInfo.ActualFinishDate = assignment.ActualFinishDate; activityInfo.Comment = assignment.Comment; activityInfo.UserId = assignment.UserId; activityInfo.ClosedBy = assignment.ClosedBy; activityInfo.ExecutionResult = (AssignmentExecutionResult?)assignment.ExecutionResult; } else { activityInfo.State = businessProcess.State == BusinessProcessState.Closed? AssignmentState.Closed: AssignmentState.Pending; if (asgActivity.AssignmentProperties.Contains(AssignmentEntity.FieldSubject)) { activityInfo.Subject = (string)asgActivity.AssignmentProperties[AssignmentEntity.FieldSubject]; } if (asgActivity.AssignmentProperties.Contains(AssignmentEntity.FieldUserId)) { activityInfo.UserId = (int?)asgActivity.AssignmentProperties[AssignmentEntity.FieldUserId]; } // Resolve Plan Time //if (activityInfo.State == AssignmentState.Pending && // businessProcess.State == BusinessProcessState.Active && // businessProcess.PlanFinishDate.HasValue) //{ // //CalculatePlanFinishDate(businessProcess, parentActivity, activity, activityInfo); //} //if (activityInfo.PlanStartDate.HasValue && // activityInfo.PlanStartDate.Value < DateTime.Now) // activityInfo.TimeStatus = AssignmentTimeStatus.OverStart; //if (activityInfo.PlanFinishDate.HasValue && // activityInfo.PlanFinishDate.Value < DateTime.Now) // activityInfo.TimeStatus = AssignmentTimeStatus.OverDue; } // 2008-07-07 Added Assignment Properties activityInfo.AssignmentProperties.AddRange(asgActivity.AssignmentProperties); // } else if (activity is BlockActivity) { // Create Block Info ActivityInfo blockInfo = new ActivityInfo(); activityInfoItems.Add(blockInfo); blockInfo.Name = activity.Name; blockInfo.Type = ActivityType.Block; blockInfo.State = businessProcess.State == BusinessProcessState.Closed ? AssignmentState.Closed : AssignmentState.Pending; CreateBusinessProcessActivityInfo(businessProcess, scope, assignments, (BlockActivity)activity, blockInfo.Activities); if (blockInfo.State == AssignmentState.Pending) { if (blockInfo.Activities.Count > 0) { foreach (ActivityInfo childActivitiInfo in blockInfo.Activities) { if (childActivitiInfo.State == AssignmentState.Active) { blockInfo.State = AssignmentState.Active; break; } else if (childActivitiInfo.State == AssignmentState.Closed) { blockInfo.State = AssignmentState.Closed; } } } else { int blockIndex = activityInfoItems.IndexOf(blockInfo); if (blockIndex == 0) { blockInfo.State = AssignmentState.Closed; } else { blockInfo.State = activityInfoItems[blockIndex - 1].State == AssignmentState.Active? AssignmentState.Pending: activityInfoItems[blockIndex - 1].State; } } } if (blockInfo.Activities.Count > 0 && (blockInfo.State == AssignmentState.Active || blockInfo.State == AssignmentState.Closed)) { blockInfo.PlanStartDate = blockInfo.Activities[0].PlanStartDate; blockInfo.PlanFinishDate = blockInfo.Activities[0].PlanFinishDate; } } } }
/// <summary> /// Creates the business process activity info. /// </summary> /// <param name="businessProcess">The business process.</param> /// <param name="scope">The scope.</param> /// <param name="parentActivity">The parent activity.</param> /// <param name="activityInfoItems">The activity info items.</param> private static void CreateBusinessProcessActivityInfo(BusinessProcessInfo businessProcess, WorkflowChangesScope scope, EntityObject[] assignments, CompositeActivity parentActivity, ActivityInfoCollection activityInfoItems) { foreach (Activity activity in parentActivity.Activities) { if (activity is CreateAssignmentAndWaitResultActivity) { CreateAssignmentAndWaitResultActivity asgActivity = (CreateAssignmentAndWaitResultActivity)activity; PropertyValueCollection properties = asgActivity.AssignmentProperties; ActivityInfo activityInfo = new ActivityInfo(); activityInfoItems.Add(activityInfo); activityInfo.Name = activity.Name; activityInfo.Type = ActivityType.Assignment; AssignmentEntity assignment = FindAssignmentByActivityName(assignments, activity.Name); if (assignment != null) { activityInfo.State = (AssignmentState)assignment.State; activityInfo.Subject = assignment.Subject; activityInfo.TimeStatus = (AssignmentTimeStatus?)assignment.TimeStatus; activityInfo.PlanStartDate = assignment.ActualStartDate; activityInfo.PlanFinishDate = assignment.PlanFinishDate; activityInfo.ActualStartDate = assignment.ActualStartDate; activityInfo.ActualFinishDate = assignment.ActualFinishDate; activityInfo.Comment = assignment.Comment; activityInfo.UserId = assignment.UserId; activityInfo.ClosedBy = assignment.ClosedBy; activityInfo.ExecutionResult = (AssignmentExecutionResult?)assignment.ExecutionResult; } else { activityInfo.State = businessProcess.State == BusinessProcessState.Closed? AssignmentState.Closed: AssignmentState.Pending; if (asgActivity.AssignmentProperties.Contains(AssignmentEntity.FieldSubject)) activityInfo.Subject = (string)asgActivity.AssignmentProperties[AssignmentEntity.FieldSubject]; if (asgActivity.AssignmentProperties.Contains(AssignmentEntity.FieldUserId)) activityInfo.UserId = (int?)asgActivity.AssignmentProperties[AssignmentEntity.FieldUserId]; // Resolve Plan Time //if (activityInfo.State == AssignmentState.Pending && // businessProcess.State == BusinessProcessState.Active && // businessProcess.PlanFinishDate.HasValue) //{ // //CalculatePlanFinishDate(businessProcess, parentActivity, activity, activityInfo); //} //if (activityInfo.PlanStartDate.HasValue && // activityInfo.PlanStartDate.Value < DateTime.Now) // activityInfo.TimeStatus = AssignmentTimeStatus.OverStart; //if (activityInfo.PlanFinishDate.HasValue && // activityInfo.PlanFinishDate.Value < DateTime.Now) // activityInfo.TimeStatus = AssignmentTimeStatus.OverDue; } // 2008-07-07 Added Assignment Properties activityInfo.AssignmentProperties.AddRange(asgActivity.AssignmentProperties); // } else if (activity is BlockActivity) { // Create Block Info ActivityInfo blockInfo = new ActivityInfo(); activityInfoItems.Add(blockInfo); blockInfo.Name = activity.Name; blockInfo.Type = ActivityType.Block; blockInfo.State = businessProcess.State == BusinessProcessState.Closed ? AssignmentState.Closed : AssignmentState.Pending; CreateBusinessProcessActivityInfo(businessProcess, scope, assignments, (BlockActivity)activity, blockInfo.Activities); if (blockInfo.State == AssignmentState.Pending) { if (blockInfo.Activities.Count > 0) { foreach (ActivityInfo childActivitiInfo in blockInfo.Activities) { if (childActivitiInfo.State == AssignmentState.Active) { blockInfo.State = AssignmentState.Active; break; } else if (childActivitiInfo.State == AssignmentState.Closed) { blockInfo.State = AssignmentState.Closed; } } } else { int blockIndex = activityInfoItems.IndexOf(blockInfo); if(blockIndex==0) blockInfo.State = AssignmentState.Closed; else blockInfo.State = activityInfoItems[blockIndex-1].State==AssignmentState.Active? AssignmentState.Pending: activityInfoItems[blockIndex - 1].State; } } if (blockInfo.Activities.Count > 0 && (blockInfo.State == AssignmentState.Active || blockInfo.State == AssignmentState.Closed)) { blockInfo.PlanStartDate = blockInfo.Activities[0].PlanStartDate; blockInfo.PlanFinishDate = blockInfo.Activities[0].PlanFinishDate; } } } }
/// <summary> /// Creates the specified entity. /// </summary> /// <param name="entity">The entity.</param> /// <returns></returns> public static WorkflowChangesScope Create(WorkflowDefinitionEntity entity) { if (entity == null) throw new ArgumentNullException("entity"); WorkflowChangesScope retVal = new WorkflowChangesScope(entity); return retVal; }
/// <summary> /// Creates the specified instance id. /// </summary> /// <param name="instanceId">The instance id.</param> /// <returns></returns> public static WorkflowChangesScope Create(Guid instanceId) { WorkflowChangesScope retVal = new WorkflowChangesScope(instanceId); return retVal; }
/// <summary> /// Creates the specified instance id. /// </summary> /// <param name="instanceId">The instance id.</param> /// <returns></returns> public static WorkflowChangesScope Create(Guid instanceId) { WorkflowChangesScope retVal = new WorkflowChangesScope(instanceId); return(retVal); }