示例#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);
        }
示例#2
0
        static string CombineText(SMSTemplateEntity template, SMSTemplateMessageEmbedded templateMessage, List <Combination> combinations)
        {
            string text = templateMessage.Message;

            if (template.RemoveNoSMSCharacters)
            {
                text = SMSCharacters.RemoveNoSMSCharacters(templateMessage.Message);
                combinations.ForEach(c => c.Value = SMSCharacters.RemoveNoSMSCharacters(c.Value));
            }

            return(CombineText(text, combinations, template.MessageLengthExceeded));
        }
示例#3
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;
            }
        }
示例#4
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);
        }
示例#5
0
 public ContentResult RemoveNoSMSCharacters(string text)
 {
     return(Content(SMSCharacters.RemoveNoSMSCharacters(text)));
 }
示例#6
0
        public int RemainingCharacters([FromBody] RemainingCharactersRequest request)
        {
            var message = request.RemoveNoSMSCharacters ? SMSCharacters.RemoveNoSMSCharacters(request.Message) : request.Message;

            return(SMSCharacters.RemainingLength(message));
        }
示例#7
0
 private void removeNonSMSChars_Click(object sender, RoutedEventArgs e)
 {
     TemplateMessageDC.Message = SMSCharacters.RemoveNoSMSCharacters(TemplateMessageDC.Message);
     TemplateMessageDC         = TemplateMessageDC;
 }