简体   繁体   English

从Lync数据库获取消息文本

[英]Get message text from Lync database

I have a connection to Lync sql database. 我有与Lync sql数据库的连接。 The problem is that saome messages are stored as HTML and some looke like: 问题在于,某些消息以HTML格式存储,看起来像这样:

{\rtf1\fbidis\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Segoe UI;}{\f1\fnil Segoe UI;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Riched20 15.0.4420}{\*\mmathPr\mwrapIndent1440 }\viewkind4\uc1 
\pard\cf1\embo\f0\fs20 this\embo0  \embo is\embo0  \embo from\embo0  \embo 
db\embo0\f1\par
{\*\lyncflags rtf=1}}

It's easy to handle HTML-encoded messages, but how can I get at least text from the other type? 处理HTML编码的消息很容易,但是如何至少从其他类型中获取文本呢?
Deoes Lync SDK allows to do this? Deoes Lync SDK允许这样做吗? I didn't find how to do this with Lync SDK. 我没有找到如何使用Lync SDK执行此操作。
Even if Lync SDK allows to get message text I don't want to install SDK just for this purpose. 即使Lync SDK允许获取消息文本,我也不想为此安装SDK。 Hope that there is a better way. 希望有更好的方法。 Maybe there are free 3rd party parsers for this? 也许有免费的第三方解析器吗?

The text is in RTF fornmat. 文本在RTF格式中。 You can convert the RTF text to plain text using the RichTextBox inthe System.Windows.Forms namespace. 您可以使用System.Windows.Forms命名空间中的RichTextBox将RTF文本转换为纯文本。

First you create a richtextbox and provide it with the text. 首先,您创建一个richtextbox,并为其提供文本。

System.Windows.Forms.RichTextBox richTextBox = new System.Windows.Forms.RichTextBox();
richTextBox.Rtf = rtfText;

You can then read the plain text 然后,您可以阅读纯文本

string plainText = richTextBox.Text;

When doing this on the text in your example it plainText returns: this is from db. 在示例中的文本上执行此操作时,plainText返回:这是来自db。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM