Beispiel #1
0
        /// <summary>
        /// Valida os dados para envio de mensagem multipla
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        private bool validateSend(MultipleMessage message)
        {
            String content = message.Content;

            if (String.IsNullOrEmpty(content))
            {
                throw new ClientHumanException("Was not informed to send a list of messages.");
            }

            String[] line = null;
            if (content.Contains("\r\n"))
            {
                line = content.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                line = content.Split(new Char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            }

            for (int i = 0; i < line.Length; i++)
            {
                this.validateMessage(message.Type, line[i]);
            }
            return(true);
        }
Beispiel #2
0
        public List <String> send(Message msg)
        {
            this.validateAccountAndPassword();

            MultipleMessage message = (MultipleMessage)msg;

            this.validateSend(message);

            StringBuilder parameters = new StringBuilder();

            parameters.Append(MultipleSending.PARAM_DISPATCH).Append("=").Append(MultipleSending.SEND_MULTIPLE).Append("&");
            parameters.Append(MultipleSending.PARAM_ACCOUNT).Append("=").Append(this.Account).Append("&");
            parameters.Append(MultipleSending.PARAM_CODE).Append("=").Append(this.Password).Append("&");
            parameters.Append(MultipleSending.PARAM_TYPE).Append("=").Append((char)message.Type).Append("&");
            parameters.Append(MultipleSending.PARAM_CALLBACK_OPTION).Append("=").Append((int)message.Callback).Append("&");
            parameters.Append(MultipleSending.PARAM_LIST).Append("=").Append(message.Content);

            base.ContentType = BaseServiceSending.CONTENT_TYPE_APP_URLENCODED;
            return(base.send(parameters.ToString()));
        }