/// <summary> /// 发送即时通讯提醒 /// </summary> /// <param name="id">主键</param> /// <param name="auditStatus">审核状态</param> /// <param name="auditIdea">审核意见</param> /// <param name="userId">发送给用户主键</param> /// <param name="roleId">发送给角色主键</param> /// <returns>影响行数</returns> public int SendRemindMessage(string id, AuditStatus auditStatus, string auditIdea, string[] userIds, string[] organizeIds, string[] roleIds) { int returnValue = 0; // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); // 这里是回调的类,用反射要回调的 messageEntity.FunctionCode = this.GetType().ToString(); messageEntity.ObjectId = id; // 这里是网页上的显示地址 // messageEntity.Title = this.GetUrl(id); // messageEntity.Content = BaseBusinessLogic.GetAuditStatus(auditStatus) + ":" + this.GetEntity(id).Title + " 请查收" // + Environment.NewLine // + this.GetUrl(id) // + auditIdea; messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo); returnValue = messageManager.BatchSend(userIds, organizeIds, roleIds, messageEntity, false); return(returnValue); }
public int SendGroupMessage(BaseUserInfo userInfo, string organizeId, string roleId, string contents) { int result = 0; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) => { // 发给角色里所有的 BaseMessageEntity entity = new BaseMessageEntity(); //messageEntity.Id = Guid.NewGuid().ToString("N"); entity.CategoryCode = MessageCategory.Send.ToString(); if (!string.IsNullOrEmpty(organizeId)) { entity.FunctionCode = MessageFunction.OrganizeMessage.ToString(); entity.ObjectId = organizeId; } if (!string.IsNullOrEmpty(roleId)) { entity.FunctionCode = MessageFunction.RoleMessage.ToString(); entity.ObjectId = roleId; } entity.Contents = contents; entity.IsNew = (int)MessageStateCode.New; entity.ReadCount = 0; entity.DeletionStateCode = 0; var manager = new BaseMessageManager(dbHelper, userInfo); manager.Identity = true; result = manager.BatchSend(string.Empty, organizeId, roleId, entity, false); }); return(result); }
/// <summary> /// 广播消息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="message">消息内容</param> /// <returns>主键</returns> public int Broadcast(BaseUserInfo userInfo, string message) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string[] receiverIds = null; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); receiverIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1), new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); messageEntity.FunctionCode = MessageFunction.Remind.ToString(); messageEntity.Contents = message; messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; returnValue = messageManager.BatchSend(receiverIds, string.Empty, string.Empty, messageEntity, false); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="entity">用户实体</param> /// <param name="userContactEntity">用户联系方式</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string CreateUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity entity, BaseUserContactEntity userContactEntity, out string statusCode, out string statusMessage) { string result = string.Empty; // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif var userManager = new BaseUserManager(dbHelper, userInfo); result = userManager.Add(entity); statusCode = userManager.StatusCode; statusMessage = userManager.GetStateMessage(); // 20140219 JiRiGaLa 添加成功的用户才增加联系方式 if (!string.IsNullOrEmpty(result) && statusCode.Equals(Status.OKAdd.ToString()) && userContactEntity != null) { // 添加联系方式 userContactEntity.Id = result; var userContactManager = new BaseUserContactManager(dbHelper, userInfo); userContactEntity.CompanyId = entity.CompanyId; userContactManager.Add(userContactEntity); } // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (entity.Enabled == 0 && statusCode.Equals(Status.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string[] roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); string[] userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString(); // Pcsky 2012.05.04 显示申请的用户名 messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + entity.UserName + AppMessage.UserService_Check; //messageEntity.Contents = result.RealName + "(" + result.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; var messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(result); }
/// <summary> /// 批量发送站内信息 /// </summary> /// <param name="userInfo">用户</param> /// <param name="receiverIds">接受者主键数组</param> /// <param name="ids">组织机构主键数组</param> /// <param name="roleIds">角色主键数组</param> /// <param name="messageEntity">消息内容</param> /// <returns>影响行数</returns> public int BatchSend(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity) { int result = 0; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessMessageDb(userInfo, parameter, (dbHelper) => { var manager = new BaseMessageManager(dbHelper, userInfo); //manager.Identity = false; result = manager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true); }); return(result); }
/// <summary> /// 发送即时通讯提醒 /// </summary> /// <param name="workFlowCurrentEntity">当前审核流实体信息</param> /// <param name="auditStatus">审核状态</param> /// <param name="auditIdea">审核意见</param> /// <param name="userIds">发送给用户主键</param> /// <param name="roleIds">发送给角色主键</param> /// <returns>影响行数</returns> public virtual int SendRemindMessage(BaseWorkFlowCurrentEntity workFlowCurrentEntity, AuditStatus auditStatus, string[] userIds, string organizeId, string roleId) { // string currentId, string objectId, string objectFullName int returnValue = 0; // 不用给自己发消息了,消息多了也烦恼 userIds = StringUtil.Remove(userIds, this.UserInfo.Id); // BaseUserEntity userEntity = userManager.GetEntity(userId); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.Id = BaseBusinessLogic.NewGuid(); // 这里是回调的类,用反射要回调的 messageEntity.FunctionCode = MessageFunction.Remind.ToString(); // messageEntity.FunctionCode = this.GetType().ToString(); messageEntity.ObjectId = workFlowCurrentEntity.ObjectId; // 这里是网页上的显示地址 // messageEntity.Title = this.GetUrl(id); string auditIdea = string.Empty; if (!string.IsNullOrEmpty(workFlowCurrentEntity.AuditIdea)) { auditIdea = " 批示: " + workFlowCurrentEntity.AuditIdea; } // messageEntity.Contents = userEntity.DepartmentName + " " + userEntity.RealName messageEntity.Contents = workFlowCurrentEntity.CreateBy + " 发出审批申请: " + "<a title='点击这里,直接查看单据' target='_blank' href='" + this.GetUrl(workFlowCurrentEntity.Id) + "'>" + workFlowCurrentEntity.ObjectFullName + "</a> " + Environment.NewLine + this.UserInfo.RealName + " " + BaseBusinessLogic.GetAuditStatus(auditStatus) + " " + Environment.NewLine + auditIdea; messageEntity.Contents = "有单据" + BaseBusinessLogic.GetAuditStatus(auditStatus); messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.Enabled = 1; messageEntity.DeletionStateCode = 0; BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo); returnValue = messageManager.BatchSend(userIds, organizeId, roleId, messageEntity, false); return(returnValue); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage) { // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif string returnValue = string.Empty; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 若是系统需要用加密的密码,这里需要加密密码。 if (BaseSystemInfo.ServerEncryptPassword) { userEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword); // 安全通讯密码、交易密码也生成好 userEntity.CommunicationPassword = userManager.EncryptUserPassword(userEntity.CommunicationPassword); } returnValue = userManager.Add(userEntity, out statusCode); statusMessage = userManager.GetStateMessage(statusCode); // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string[] roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); string[] userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString(); // Pcsky 2012.05.04 显示申请的用户名 messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.UserName + AppMessage.UserService_Check; //messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(returnValue); }
/// <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(BaseUserInfo userInfo, string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); returnValue = messageManager.BatchSend(receiverIds, organizeIds, roleIds, messageEntity, true); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.MessageService_BatchSend, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 发送即时通讯提醒 /// </summary> /// <param name="workFlowCurrentEntity">当前审核流实体信息</param> /// <param name="auditStatus">审核状态</param> /// <param name="auditIdea">审核意见</param> /// <param name="userIds">发送给用户主键</param> /// <param name="roleIds">发送给角色主键</param> /// <returns>影响行数</returns> public virtual int SendMessage(BaseWorkFlowCurrentEntity workFlowCurrentEntity, AuditStatus auditStatus, string[] userIds, string organizeId, string roleId) { // 这里是考虑了,同时发给多个人的情况 List <string> userList = new List <string>(); foreach (var userid in userIds) { if (!string.IsNullOrEmpty(userid)) { if (userid.IndexOf(',') > 0) { string[] users = userid.Split(',').Distinct <string>().Where(t => !string.IsNullOrEmpty(t)).ToArray(); foreach (var id in users) { if (!string.IsNullOrEmpty(id)) { userList.Add(id); } } } else { userList.Add(userid); } } } userIds = userList.ToArray(); // string currentId, string objectId, string objectFullName int result = 0; // 不用给自己发消息了,消息多了也烦恼 userIds = StringUtil.Remove(userIds, this.UserInfo.Id); // BaseUserEntity userEntity = userManager.GetObject(userId); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); //messageEntity.Id = BaseBusinessLogic.NewGuid(); // 这里是回调的类,用反射要回调的 messageEntity.FunctionCode = MessageFunction.Remind.ToString(); // messageEntity.FunctionCode = this.GetType().ToString(); messageEntity.ObjectId = workFlowCurrentEntity.ObjectId; // 这里是网页上的显示地址 // messageEntity.Title = this.GetUrl(id); string auditIdea = string.Empty; if (!string.IsNullOrEmpty(workFlowCurrentEntity.AuditIdea)) { auditIdea = " 批示: " + workFlowCurrentEntity.AuditIdea; } // messageEntity.Contents = userEntity.DepartmentName + " " + userEntity.RealName if (!BaseSystemInfo.SimpleReminders) { messageEntity.Contents = workFlowCurrentEntity.CreateBy + " 发出审批申请: " + "<a title='点击这里,直接查看单据' target='_blank' href='" + this.GetUrl(workFlowCurrentEntity.Id) + "'>" + workFlowCurrentEntity.ObjectFullName + "</a> " + Environment.NewLine + this.UserInfo.RealName + " " + BaseBusinessLogic.GetAuditStatus(auditStatus) + " " + Environment.NewLine + auditIdea; } else { messageEntity.Contents = "有单据" + BaseBusinessLogic.GetAuditStatus(auditStatus); } messageEntity.IsNew = 1; messageEntity.ReadCount = 0; messageEntity.DeletionStateCode = 0; BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo); messageManager.Identity = true; result = messageManager.BatchSend(userIds, organizeId, roleId, messageEntity, false); return(result); }