public static WorkflowInfo ProcessAdapter(IWfProcess procInstance, bool isMainStream) { WorkflowInfo result = new WorkflowInfo(); if (procInstance == null) return result; AdaptProcessProperties(procInstance, result, isMainStream); if (isMainStream == false || procInstance.MainStream == null) { foreach (IWfActivity instanceAct in procInstance.Activities) { result.Activities.Add(AdaptActivityProperties(instanceAct.Descriptor, isMainStream)); result.Transitions.AddRange(AdaptTransitionProperties(procInstance, instanceAct)); } } else { foreach (IWfActivityDescriptor instanceActDesc in procInstance.MainStream.Activities) { result.Activities.Add(AdaptActivityProperties(instanceActDesc, isMainStream)); result.Transitions.AddRange(AdaptMainStreamTransitionProperties(instanceActDesc)); } } return result; }
private static void AdaptProcessProperties(IWfProcess procInstance, WorkflowInfo targetDTO, bool isMainStream) { targetDTO.Key = procInstance.ID; targetDTO.Name = procInstance.RuntimeProcessName; targetDTO.UpdateTag = procInstance.UpdateTag; IWfProcessDescriptor instanceDesc = GetProcessDescriptor(procInstance, isMainStream); if (targetDTO.Name.IsNullOrEmpty()) targetDTO.Name = instanceDesc.Name; targetDTO.GraphDescription = instanceDesc.GraphDescription; targetDTO.ApplicationName = instanceDesc.ApplicationName; targetDTO.ProgramName = instanceDesc.ProgramName; targetDTO.ResourceID = procInstance.ResourceID; targetDTO.Status = EnumItemDescriptionAttribute.GetDescription(procInstance.Status); targetDTO.StartTime = procInstance.StartTime; targetDTO.EndTime = procInstance.EndTime; targetDTO.Creator = (procInstance.Creator == null ? "" : procInstance.Creator.Name); targetDTO.OwnerDepartment = (procInstance.OwnerDepartment == null ? string.Empty : procInstance.OwnerDepartment.Name); targetDTO.CurrentActivityKey = (procInstance.CurrentActivity == null ? string.Empty : procInstance.CurrentActivity.Descriptor.Key); }