public void getPaticipantFromGuid_validDynamicUserGuid_returnDynamicUserPaticipant() { FlowDynamicUser flowDynamicUser = db.flowDynamicUsers.Create(); flowDynamicUser.name = "Integration_Test_XXXYYYZZZ"; db.flowDynamicUsers.Add(flowDynamicUser); db.SaveChanges(); Paticipant result = FlowTemplateDefHelper.getPaticipantFromGuid(flowDynamicUser.guid); Assert.NotNull(result); Assert.AreEqual(result.PaticipantType, "dynamic"); Assert.AreEqual(result.PaticipantObj.guid, flowDynamicUser.guid); }
public void getPaticipantFromGuid_validUserGuid_returnUserPaticipant() { using (EnouFlowOrgMgmtContext dbOrg = new EnouFlowOrgMgmtContext()) { UserHelper userHelper = new UserHelper(dbOrg); var user = userHelper.createObject(); user.name = "Integration_Test_XXXYYYZZZ"; userHelper.saveCreatedObject(user); Paticipant result = FlowTemplateDefHelper.getPaticipantFromGuid(user.guid); Assert.NotNull(result); Assert.AreEqual(result.PaticipantType, "user"); Assert.AreEqual(result.PaticipantObj.guid, user.guid); } }
public void getPaticipantFromGuid_validRoleGuid_returnRolePaticipant() { using (EnouFlowOrgMgmtContext dbOrg = new EnouFlowOrgMgmtContext()) { RoleHelper roleHelper = new RoleHelper(dbOrg); var role = roleHelper.createObject(); role.name = "Integration_Test_XXXYYYZZZ"; roleHelper.saveCreatedObject(role); Paticipant result = FlowTemplateDefHelper.getPaticipantFromGuid(role.guid); Assert.NotNull(result); Assert.AreEqual(result.PaticipantType, "role"); Assert.AreEqual(result.PaticipantObj.guid, role.guid); } }
private static List <UserDTO> resolvePaticipantToUserDTOs( Paticipant paticipant, FlowInstance flowInstance) { if (paticipant.PaticipantType == "user") // 用户 { var result = new List <UserDTO>(); using (var db = new EnouFlowOrgMgmtContext()) { result.Add( new UserHelper(db).getUserDTO( (int)paticipant.PaticipantObj.userId)); } return(result); } if (paticipant.PaticipantType == "role") // 角色 { using (var db = new EnouFlowOrgMgmtContext()) { return(new UserHelper(db).getUserDTOsOfRole((int)paticipant.PaticipantObj.roleId)); } } if (paticipant.PaticipantType == "dynamic") // 流程动态用户 { FlowDynamicUser flowDynamicUser; using (var db = new EnouFlowTemplateDbContext()) { flowDynamicUser = db.flowDynamicUsers.Find( paticipant.PaticipantObj.flowDynamicUserId); } if (flowDynamicUser != null) { return(ResolveFlowDynamicUser( flowDynamicUser.script, flowDynamicUser.name, flowInstance)); } } return(new List <UserDTO>()); }
public void getPaticipantFromGuid_invalidGuid_returnNull(string guid) { Paticipant result = FlowTemplateDefHelper.getPaticipantFromGuid(guid); Assert.Null(result); }