示例#1
0
        /*/// <summary>
         * /// 发送一对一消息
         * /// </summary>
         * /// <param name="info">MQ消息一对一消息业务实体</param>
         * /// <returns></returns>
         * public bool SendOneToOneMessage(EyouSoft.Model.MQStructure.OneToOneMessageInfo info)
         * {
         *  if (info == null)
         *      return false;
         *
         *  return dal.SendOneToOneMessage(info);
         * }
         *
         * /// <summary>
         * /// 发送一对多消息(消息中可以包含链接)
         * /// </summary>
         * /// <param name="info">MQ消息一对多(指定了接收人的MQ编号)消息业务实体</param>
         * /// <returns></returns>
         * public bool SendOneToManyMessage(EyouSoft.Model.MQStructure.OneToManySpecifiedMQMessageInfo info)
         * {
         *  if (info == null)
         *      return false;
         *
         *  return dal.SendOneToManyMessage(info);
         * }*/

        /// <summary>
        /// 发送一对多消息
        /// </summary>
        /// <param name="info">MQ消息一对多(未指定接收人的MQ编号)消息业务实体</param>
        /// <returns>System.Int32 发送的消息数 小于0时为相应的错误号</returns>
        public int SendOneToManyMessage(EyouSoft.Model.MQStructure.OneToManyUnspecifiedMQMessageInfo info)
        {
            if (info.SendType == EyouSoft.Model.MQStructure.SendType.聊天窗口 && info.SendMQId == 0)
            {
                return(-1);//以聊天窗口方式发送消息时未填写发送人MQ编号
            }

            if (string.IsNullOrEmpty(info.Message))
            {
                return(-2);//未填写消息内容
            }

            if (info.SendType == EyouSoft.Model.MQStructure.SendType.系统消息 && Encoding.Default.GetBytes(info.Message).Length > 399)
            {
                return(-3);//以系统消息方式发送时消息内容不能超过200个字符
            }

            if (info.SendType == EyouSoft.Model.MQStructure.SendType.聊天窗口 && Encoding.Default.GetBytes(info.Message).Length > 399)
            {
                return(-4);//以聊天窗口方式发送时消息内容不能超过200个字符
            }

            if (!info.IsAllCompanyType && (info.AcceptCompanyType == null || info.AcceptCompanyType.Count == 0) && !info.IsContainsGuest)
            {
                return(-5);//接收对象为指定类型时未指定任何类型
            }

            return(dal.SendOneToManyMessage(info));
        }
示例#2
0
        /// <summary>
        ///  发送消息
        /// </summary>
        private void SendMessage()
        {
            int    companyType  = Utils.GetInt(Utils.GetFormValue("companyType"), 1);
            string companyTypes = Utils.GetFormValue("companyTypes");

            EyouSoft.Model.MQStructure.OneToManyUnspecifiedMQMessageInfo info = new EyouSoft.Model.MQStructure.OneToManyUnspecifiedMQMessageInfo();

            info.SendType         = (EyouSoft.Model.MQStructure.SendType)Utils.GetInt(Utils.GetFormValue("sendType"), 1);
            info.SendMQId         = Utils.GetInt(Utils.GetFormValue("sendMQId"), 0);
            info.AcceptProvinceId = Utils.GetInt(Utils.GetFormValue("provinceId"), 0);
            info.AcceptCityId     = Utils.GetInt(Utils.GetFormValue("cityId"), 0);
            info.OnlineState      = (EyouSoft.Model.MQStructure.OnlineState)Utils.GetInt(Utils.GetFormValue("onlineState"), 0);
            info.Message          = Utils.GetFormValue("message");

            info.IsAllCompanyType  = true;
            info.AcceptCompanyType = new List <EyouSoft.Model.CompanyStructure.CompanyType>();

            #region 表单验证
            if (!this.CheckMasterGrant(YuYingPermission.给客户发送MQ消息))
            {
                this.SendMessageResponseWrite(false, "你没有给客户发送MQ消息权限,请联系管理员", 0);
            }

            if (companyType == 2)
            {
                info.IsAllCompanyType = false;

                if (string.IsNullOrEmpty(companyTypes))
                {
                    this.SendMessageResponseWrite(false, "请选择指定的客户类型", 0);
                }

                foreach (string s in companyTypes.Split(','))
                {
                    if (s == "-1")
                    {
                        info.IsContainsGuest = true; continue;
                    }

                    info.AcceptCompanyType.Add((EyouSoft.Model.CompanyStructure.CompanyType) int.Parse(s));
                }
            }

            if (info.SendType == EyouSoft.Model.MQStructure.SendType.聊天窗口 && info.SendMQId == 0)
            {
                this.SendMessageResponseWrite(false, "请输入指定的用户MQID", 0);
            }

            if (string.IsNullOrEmpty(info.Message))
            {
                this.SendMessageResponseWrite(false, "请输入消息内容", 0);
            }
            #endregion

            int sendResult = EyouSoft.BLL.MQStructure.IMMessage.CreateInstance().SendOneToManyMessage(info);

            if (sendResult >= 0)
            {
                this.SendMessageResponseWrite(true, "", sendResult);
            }
            else
            {
                this.SendMessageResponseWrite(false, "发送错误", 0);
            }
        }