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); }
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)); }
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; } }
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); }
public ContentResult RemoveNoSMSCharacters(string text) { return(Content(SMSCharacters.RemoveNoSMSCharacters(text))); }
public int RemainingCharacters([FromBody] RemainingCharactersRequest request) { var message = request.RemoveNoSMSCharacters ? SMSCharacters.RemoveNoSMSCharacters(request.Message) : request.Message; return(SMSCharacters.RemainingLength(message)); }
private void removeNonSMSChars_Click(object sender, RoutedEventArgs e) { TemplateMessageDC.Message = SMSCharacters.RemoveNoSMSCharacters(TemplateMessageDC.Message); TemplateMessageDC = TemplateMessageDC; }