string
site =
this
.Page.Request.Url.ToString();
using
(SPSite spsSite =
new
SPSite(site))
{
using
(SPWeb web = spsSite.OpenWeb())
{
web.AllowUnsafeUpdates =
true
;
SPList splSource = web.GetList(ddlSourceList.SelectedItem.Value.ToString());
SPListItem spliDiscussion = web.GetListItem(ddlSourceDiscussion.SelectedItem.Value.ToString());
SPList splDestination = web.GetList(ddlDestinationList.SelectedItem.Value.ToString());
try
{
SPFolder fldrDiscussion = web.GetFolder(ddlSourceDiscussion.SelectedValue);
SPListItemCollection listCol = splDestination.Items;
SPListItem discussion = SPUtility.CreateNewDiscussion(listCol, spliDiscussion[SPBuiltInFieldId.Title].ToString());
discussion[SPBuiltInFieldId.Body] = spliDiscussion[SPBuiltInFieldId.Body];
discussion[SPBuiltInFieldId.Author] = spliDiscussion[SPBuiltInFieldId.Author];
discussion[SPBuiltInFieldId.Editor] = spliDiscussion[SPBuiltInFieldId.Editor];
discussion[SPBuiltInFieldId.Created] = spliDiscussion[SPBuiltInFieldId.Created];
discussion.Update();
CopyAttachments(spliDiscussion, discussion);
discussion.Update();
SPQuery q =
new
SPQuery();
q.Query =
"<OrderBy><FieldRef Name='Title'/></OrderBy>"
;
q.Folder = fldrDiscussion;
SPListItemCollection flc = splSource.GetItems(q);
foreach
(SPListItem li
in
flc)
{
SPListItem reply = SPUtility.CreateNewDiscussionReply(discussion);
reply[SPBuiltInFieldId.Body] = li[SPBuiltInFieldId.Body];
reply[SPBuiltInFieldId.Author] = li[SPBuiltInFieldId.Author];
reply[SPBuiltInFieldId.Editor] = li[SPBuiltInFieldId.Editor];
reply[SPBuiltInFieldId.Created] = li[SPBuiltInFieldId.Created];
reply.Update();
CopyAttachments(li, reply);
reply.Update();
discussion.Update();
}
spliDiscussion.Delete();
this
.Page.Response.Redirect(
this
.Page.Request.RawUrl);
}
catch
{ }
finally
{
}
}
}