/// <summary> /// 广播消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="message">消息内容</param> /// <returns>主键</returns> public int Broadcast(UserInfo userInfo, string message) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, "广播消息"); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { string[] receiverIds = null; var userManager = new PiUserManager(dbProvider, userInfo); receiverIds = userManager.GetIds(new KeyValuePair <string, object>(PiUserTable.FieldEnabled, 1), new KeyValuePair <string, object>(PiUserTable.FieldDeleteMark, 0)); var messageManager = new CiMessageManager(dbProvider, userInfo); var messageEntity = new CiMessageEntity { Id = BusinessLogic.NewGuid(), FunctionCode = MessageFunction.Remind.ToString(), MSGContent = message, IsNew = 1, ReadCount = 0, Enabled = 1, DeleteMark = 0 }; returnValue = messageManager.BatchSend(receiverIds, string.Empty, string.Empty, messageEntity, false); }); return(returnValue); }
/// <summary> /// 发送组消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="organizeId">组织机构主键</param> /// <param name="roleId">角色主键</param> /// <param name="contents">内容</param> /// <returns></returns> public string SendGroupMessage(UserInfo userInfo, string organizeId, string roleId, string contents) { int returnValue = 0; var parameter = ParameterUtil.CreateWithLog(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var messageEntity = new CiMessageEntity { Id = BusinessLogic.NewGuid(), CategoryCode = MessageCategory.Send.ToString(), MSGContent = contents, IsNew = (int)MessageStateCode.New, ReadCount = 0, DeleteMark = 0, Enabled = 1 }; if (!string.IsNullOrEmpty(organizeId)) { messageEntity.FunctionCode = MessageFunction.OrganizeMessage.ToString(); messageEntity.ObjectId = organizeId; } if (!string.IsNullOrEmpty(roleId)) { messageEntity.FunctionCode = MessageFunction.RoleMessage.ToString(); messageEntity.ObjectId = roleId; } var messageManager = new CiMessageManager(dbProvider, userInfo); returnValue = messageManager.BatchSend(string.Empty, organizeId, roleId, messageEntity, false); }); return(returnValue.ToString()); }
/// <summary> /// 批量发送站内信息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverIds">接受者主键数组</param> /// <param name="organizeIds">组织机构主键数组</param> /// <param name="roleIds">角色主键数组</param> /// <param name="messageEntity">消息内容</param> /// <returns>影响行数</returns> public int BatchSend(UserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, CiMessageEntity messageEntity) { int returnValue = 0; var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.MessageService_BatchSend); ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider => { var messageManager = new CiMessageManager(dbProvider, userInfo); returnValue = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true); }); return(returnValue); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbProvider">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(IDbProvider dbProvider, UserInfo userInfo, PiUserEntity userEntity, out string statusCode, out string statusMessage) { string returnValue = string.Empty; var userManager = new PiUserManager(dbProvider, userInfo); returnValue = userManager.Add(userEntity, out statusCode); statusMessage = userManager.GetStateMessage(statusCode); LogManager.Instance.Add(dbProvider, userInfo, this.serviceName, RDIFrameworkMessage.UserService_AddUser, MethodBase.GetCurrentMethod()); // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 var roleManager = new PiRoleManager(dbProvider, userInfo); string[] roleIds = roleManager.GetIds(PiRoleTable.FieldCode, "Administrators", PiRoleTable.FieldId); string[] userIds = userManager.GetIds(PiUserTable.FieldCode, "Administrator", PiUserTable.FieldId); // 发送请求审核的信息 var messageEntity = new CiMessageEntity { Id = BusinessLogic.NewGuid(), FunctionCode = MessageFunction.WaitForAudit.ToString(), ReceiverId = DefaultRole.Administrator.ToString(), MSGContent = userInfo.RealName + "(" + userInfo.IPAddress + ")" + RDIFrameworkMessage.UserService_Application + userEntity.RealName + RDIFrameworkMessage.UserService_Check, IsNew = 1, ReadCount = 0, Enabled = 1, DeleteMark = 0 }; var messageManager = new CiMessageManager(dbProvider, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(returnValue); }
/// <summary> /// 指定处理人 /// </summary> /// <param name="userId">用户Id</param> /// <param name="workFlowId">流程模板Id</param> /// <param name="workTaskId">任务模板Id</param> /// <param name="workFlowInstanceId">流程实例Id</param> /// <param name="workTaskInstanceId">任务实例Id</param> /// <param name="operParam">处理者参数</param> /// <returns>是否成功</returns> public bool AssignUser(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam) { if (string.IsNullOrEmpty(operParam.OperContent)) { return(false); } switch (operParam.OperRule) { case "1": { //创建处理人实例 var operInsEntity = new OperatorInstanceEntity() { OperatorInsId = BusinessLogic.NewGuid(), WorkFlowId = workFlowId, WorkTaskId = workTaskId, WorkFlowInsId = workFlowInstanceId, WorkTaskInsId = workTaskInstanceId, //此时是新任务Id UserId = "", OperRealtion = operParam.OperRelation, OperContent = operParam.OperContent, OperContentText = operParam.OperContenText, OperType = operParam.OperType//此处保留原来的处理类型 }; string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity); //给处理者发送信息 if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0) { var messageEntity = new CiMessageEntity { Id = BusinessLogic.NewGuid(), FunctionCode = MessageFunction.Remind.ToString(), ReceiverId = DefaultRole.Administrator.ToString(), Title = "业务流程消息", MSGContent = "你有一待办任务,请到未认领任务界面认领。", IsNew = 1, ReadCount = 0, Enabled = 1, DeleteMark = 0 }; var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo); messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false); } if ((userId == operParam.OperContent) && (operParam.IsJumpSelf)) //处理者是提交人,自动处理 { var wfrun = new WorkFlowRuntime(); wfrun.Run(userId, operInsEntity.OperatorInsId, "提交"); } } break; case "2": { //创建任务实例 var newTaskId = BusinessLogic.NewGuid();//新任务实例Id var workTaskInsEntity = new WorkTaskInstanceEntity() { WorkFlowId = workFlowId, WorkTaskId = workTaskId, WorkFlowInsId = workFlowInstanceId, WorkTaskInsId = newTaskId, PreviousTaskId = workTaskInstanceId, //此时是当前任务Id TaskInsCaption = new WorkTaskManager(this.DBProvider).GetTaskCaption(workTaskId), Status = "1", }; new WorkTaskInstanceManager(this.DBProvider).Create(workTaskInsEntity); //创建处理人实例 var operInsEntity = new OperatorInstanceEntity() { OperatorInsId = BusinessLogic.NewGuid(), WorkFlowId = workFlowId, WorkTaskId = workTaskId, WorkFlowInsId = workFlowInstanceId, WorkTaskInsId = newTaskId, UserId = "", OperRealtion = operParam.OperRelation, OperContent = operParam.OperContent, OperContentText = operParam.OperContenText, OperType = 3,//此处修改为指定处理人 }; string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity); //给处理者发送信息 if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0) { var messageEntity = new CiMessageEntity { Id = BusinessLogic.NewGuid(), FunctionCode = MessageFunction.Remind.ToString(), ReceiverId = DefaultRole.Administrator.ToString(), Title = "业务流程消息", MSGContent = "你有一待办任务,请到未认领任务界面认领。", IsNew = 1, ReadCount = 0, Enabled = 1, DeleteMark = 0 }; var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo); messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false); } if ((userId == operParam.OperContent) && (operParam.IsJumpSelf)) //处理者是提交人,自动处理 { var wfrun = new WorkFlowRuntime(); wfrun.Run(userId, operInsEntity.OperatorInsId, "提交"); } } break; } return(true); }