public string[] GetUserIds(string[] organizeIds, string[] roleIds)
 {
     // 要注意不能重复发信息,只能发一次。
     string[] companyUsers    = null; // 按公司查找用户
     string[] departmentUsers = null; // 按部门查找用户
     string[] workgroupUsers  = null; // 按工作组查找用户
     if (organizeIds != null)
     {
         // 这里获得的是用户主键,不是员工主键
         companyUsers    = this.GetProperties(BaseUserEntity.FieldCompanyId, organizeIds, BaseUserEntity.FieldId);
         departmentUsers = this.GetProperties(BaseUserEntity.FieldDepartmentId, organizeIds, BaseUserEntity.FieldId);
         workgroupUsers  = this.GetProperties(BaseUserEntity.FieldWorkgroupId, organizeIds, BaseUserEntity.FieldId);
     }
     string[] roleUsers = null;
     if (roleIds != null)
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper);
         roleUsers = userManager.GetUserIds(roleIds);
     }
     string[] userIds = StringUtil.Concat(companyUsers, departmentUsers, workgroupUsers, roleUsers);
     return(userIds);
 }
 public string[] GetUserIds(string[] organizeIds, string[] roleIds)
 {
     // 要注意不能重复发信息,只能发一次。
     string[] companyUsers = null; // 按公司查找用户
     string[] departmentUsers = null; // 按部门查找用户
     string[] workgroupUsers = null; // 按工作组查找用户
     if (organizeIds != null)
     {
         // 这里获得的是用户主键,不是员工主键
         companyUsers = this.GetProperties(BaseUserEntity.FieldCompanyId, organizeIds, BaseUserEntity.FieldId);
         departmentUsers = this.GetProperties(BaseUserEntity.FieldDepartmentId, organizeIds, BaseUserEntity.FieldId);
         workgroupUsers = this.GetProperties(BaseUserEntity.FieldWorkgroupId, organizeIds, BaseUserEntity.FieldId);
     }
     string[] roleUsers = null;
     if (roleIds != null)
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper);
         roleUsers = userManager.GetUserIds(roleIds);
     }
     string[] userIds = StringUtil.Concat(companyUsers, departmentUsers, workgroupUsers, roleUsers);
     return userIds;
 }
Esempio n. 3
0
        /// <summary>
        /// 发送联络单
        /// </summary>
        /// <param name="receiverIds">接收者</param>
        /// <param name="organizeIds">组织机构数组</param>
        /// <param name="roleIds">角色数组</param>
        /// <returns>影响行数</returns>
        public int Send(string contactId, string[] receiverIds, string[] organizeIds, string[] roleIds)
        {
            BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
            receiverIds = userManager.GetUserIds(receiverIds, organizeIds, roleIds);

            // 删除邮件的处理技巧、发送给部门的、发送给角色的。
            // 删除邮件的列表过滤问题解决
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);
            BaseContactDetailsEntity contactDetailsEntity = null;

            // 组织机构数组
            if (organizeIds != null)
            {
                BaseOrganizeManager organizeManager = new BaseOrganizeManager(DbHelper, UserInfo);
                for (int i = 0; i < organizeIds.Length; i++)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId = contactId;
                    contactDetailsEntity.Category = "Organize";
                    contactDetailsEntity.ReceiverId = organizeIds[i];
                    contactDetailsEntity.ReceiverRealName = organizeManager.GetProperty(organizeIds[i], BaseOrganizeEntity.FieldFullName);
                    contactDetailsEntity.IsNew = 1;
                    contactDetailsEntity.Enabled = 1;
                    contactDetailsEntity.NewComment = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
            }

            // 角色数组
            if (roleIds != null)
            {
                BaseRoleManager roleManager = new BaseRoleManager(DbHelper, UserInfo);
                for (int i = 0; i < roleIds.Length; i++)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId = contactId;
                    contactDetailsEntity.Category = "Role";
                    contactDetailsEntity.ReceiverId = roleIds[i];
                    contactDetailsEntity.ReceiverRealName = roleManager.GetProperty(roleIds[i], BaseRoleEntity.FieldRealName);
                    contactDetailsEntity.IsNew = 1;
                    contactDetailsEntity.Enabled = 1;
                    contactDetailsEntity.NewComment = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
            }

            return this.Send(contactId, receiverIds);
        }
Esempio n. 4
0
 /// <summary>
 /// 批量发送消息
 /// </summary>
 /// <param name="receiverIds">接收者主键组</param>
 /// <param name="organizeIds">组织机构主键组</param>
 /// <param name="roleIds">角色主键组</param>
 /// <param name="content">内容</param>
 /// <returns>影响行数</returns>
 public int BatchSend(string[] receiverIds, string[] organizeIds, string[] roleIds, BaseMessageEntity messageEntity, bool saveSend = true)
 {
     BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
     receiverIds = userManager.GetUserIds(receiverIds, organizeIds, roleIds);
     return this.Send(messageEntity, receiverIds, saveSend);
 }