Exemple #1
0
        static string CheckLength(string result, SMSTemplateEntity template)
        {
            if (template.RemoveNoSMSCharacters)
            {
                result = SMSCharacters.RemoveNoSMSCharacters(result);
            }

            int remainingLength = SMSCharacters.RemainingLength(result);

            if (remainingLength < 0)
            {
                switch (template.MessageLengthExceeded)
                {
                case MessageLengthExceeded.NotAllowed:
                    throw new ApplicationException(SMSCharactersMessage.TheTextForTheSMSMessageExceedsTheLengthLimit.NiceToString());

                case MessageLengthExceeded.Allowed:
                    break;

                case MessageLengthExceeded.TextPruning:
                    return(result.RemoveEnd(Math.Abs(remainingLength)));
                }
            }

            return(result);
        }
Exemple #2
0
        private void VisualCharactersToEnd()
        {
            int chLeft = SMSCharacters.RemainingLength(text.Text);

            charactersLeft.Text = chLeft.ToString();
            if (chLeft < 0)
            {
                charactersLeft.Foreground = redBrush;
                charactersLeft.Background = pinkBackground;
            }
            else
            {
                charactersLeft.Foreground = greenBrush;
                charactersLeft.Background = normalBackGround;
            }
        }
Exemple #3
0
        static string CombineText(string text, List <Combination> combinations, MessageLengthExceeded onExceeded)
        {
            string result          = literalFinder.Replace(text, m => combinations.FirstEx(c => c.Name == m.Groups["name"].Value).Value);
            int    remainingLength = SMSCharacters.RemainingLength(result);

            if (remainingLength < 0)
            {
                switch (onExceeded)
                {
                case MessageLengthExceeded.NotAllowed:
                    throw new ApplicationException(SMSCharactersMessage.TheTextForTheSMSMessageExceedsTheLengthLimit.NiceToString());

                case MessageLengthExceeded.Allowed:
                    break;

                case MessageLengthExceeded.TextPruning:
                    return(result.RemoveEnd(Math.Abs(remainingLength)));
                }
            }

            return(result);
        }
Exemple #4
0
        public int RemainingCharacters([FromBody] RemainingCharactersRequest request)
        {
            var message = request.RemoveNoSMSCharacters ? SMSCharacters.RemoveNoSMSCharacters(request.Message) : request.Message;

            return(SMSCharacters.RemainingLength(message));
        }