/// <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));
        }
        /// <summary>
        /// 发送联络单
        /// </summary>
        /// <param name="contactId">联络单主键</param>
        /// <param name="receiverIds">接收者</param>
        /// <returns>影响行数</returns>
        public int Send(string contactId, string[] receiverIds)
        {
            int returnValue = 0;
            // 是否给自己发过这封邮件
            bool findSend = false;
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);
            BaseUserManager           userManager           = new BaseUserManager(DbHelper, UserInfo);
            BaseUserEntity            useEntity             = null;
            BaseContactDetailsEntity  contactDetailsEntity  = null;

            for (int i = 0; i < receiverIds.Length; i++)
            {
                useEntity = userManager.GetEntity(int.Parse(receiverIds[i]));
                // 是有效的用户,而且是未必删除的用户才发邮件
                if (useEntity.Enabled == 1 && useEntity.DeletionStateCode == 0)
                {
                    contactDetailsEntity = new BaseContactDetailsEntity();
                    // 这里一定要给个不可猜测的主键,为了提高安全性
                    contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
                    contactDetailsEntity.ContactId        = contactId;
                    contactDetailsEntity.Category         = "User";
                    contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
                    contactDetailsEntity.ReceiverRealName = useEntity.RealName;
                    contactDetailsEntity.IsNew            = 1;
                    contactDetailsEntity.Enabled          = 1;
                    contactDetailsEntity.NewComment       = 0;
                    contactDetailsManager.Add(contactDetailsEntity, false);
                }
                // 若已经有发过,就不用再判断了
                if (!findSend)
                {
                    if (UserInfo.Id.Equals(receiverIds[i]))
                    {
                        findSend = true;
                    }
                }
                returnValue++;
            }
            // 没有给自己发过
            if (!findSend)
            {
                // 发送给自己一份
                this.Send(contactId);
                returnValue++;
            }
            // 设置总共发送了几个人
            this.SetProperty(new KeyValuePair <string, object>(BaseContactEntity.FieldId, contactId), new KeyValuePair <string, object>(BaseContactEntity.FieldSendCount, receiverIds.Length.ToString()));
            return(returnValue);
        }
        /// <summary>
        /// 发送给自己一份
        /// </summary>
        /// <param name="contactId">联络单主键</param>
        public string Send(string contactId)
        {
            BaseUserManager          userManager          = new BaseUserManager(DbHelper, UserInfo);
            BaseUserEntity           useEntity            = useEntity = userManager.GetEntity(int.Parse(UserInfo.Id));
            BaseContactDetailsEntity contactDetailsEntity = new BaseContactDetailsEntity();

            // 这里一定要给个不可猜测的主键,为了提高安全性
            contactDetailsEntity.Id               = BaseBusinessLogic.NewGuid();
            contactDetailsEntity.ContactId        = contactId;
            contactDetailsEntity.Category         = "User";
            contactDetailsEntity.ReceiverId       = useEntity.Id.ToString();
            contactDetailsEntity.ReceiverRealName = useEntity.RealName;
            contactDetailsEntity.IsNew            = 0;
            contactDetailsEntity.Enabled          = 1;
            contactDetailsEntity.NewComment       = 0;
            BaseContactDetailsManager contactDetailsManager = new BaseContactDetailsManager(DbHelper, UserInfo);

            return(contactDetailsManager.Add(contactDetailsEntity, false));
        }