我在SharePoint 2007中有一个讨论板,我想在同一页面上查看所有讨论及其回复。例如,我在讨论区内有3个讨论和一些回复。我希望在页面上显示类似以下输出的内容:
(+) discussion no. 1 replies:3 (+) discussion no. 2 replies:1 (+) discussion no. 3 replies:0
然后当我点击展开(+)时,我想查看每个讨论的所有回复:
(-) discussion no. 1 replies:3 (+) this is the reply to discussion no. 1 (+) this is the 2nd reply to discussion no. 1 (+) discussion no. 2 replies:1 (+) discussion no. 3 replies:0
有谁知道如何做到这一点?
答案 0 :(得分:0)
我终于找到了解决这个问题的方法。我必须对我做事的方式做一些改变。特别是从十六进制转换接收的值必须在没有0x前缀的情况下完成。
在应用了一些不起眼的魔法之后,关键仍然是发送相同的ThreadingIndex值。以下是我用于使用SharePoint Web服务api添加对讨论的回复的代码:
String trimmedBody = itemNode.Attributes.GetNamedItem("ows_BodyAndMore").Value;
String threadIndex = itemNode.Attributes.GetNamedItem("ows_ThreadIndex").Value;
StringBuilder mesBody = new StringBuilder(1024);
mesBody.AppendFormat("Message-ID: {0}\n", Guid.NewGuid().ToString());
threadIndex = threadIndex.Substring(2);
byte[] byteArray = FromHex(threadIndex);
threadIndex = base64Encode(byteArray);
string encoded = threadIndex;
mesBody.AppendFormat("Thread-Index: {0}\n", encoded);
mesBody.AppendFormat("Subject: {0}\n", title); //the ows_Title of the discussion - messages don't always have titles...
mesBody.Append("Mime-Version: 1.0\n");
mesBody.Append("Content-type: text/html; charset=UTF-8\n\n");
mesBody.Append(body);
mesBody.Append(trimmedBody);
client.AddDiscussionBoardItem(ListName, Encoding.UTF8.GetBytes(mesBody.ToString()));
public static byte[] FromHex(string hex)
{
hex = hex.Replace("-", "");
byte[] raw = new byte[hex.Length / 2];
for (int i = 0; i < raw.Length; i++)
{
raw[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16);
}
return raw;
}
public string base64Encode(byte[] data)
{
try
{
byte[] encData_byte = data;
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
catch (Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}
希望这会有所帮助