private void MoveArticle()
{
if (TheArticle == null)
{
DisableButtons();
return;
}
try
{
if (!TheSession.Page.Exists)
{
MessageBox.Show("Cannot move a non-existent page");
return;
}
if (!TheSession.User.CanMovePage(TheSession.Page))
{
MessageBox.Show(
"Current user doesn't have enough rights to move \"" + TheSession.Page.Title + "\"",
"User rights not sufficient");
return;
}
string newTitle, msg;
bool succeed = TheArticle.Move(TheSession, out newTitle);
if (succeed)
{
Article replacementArticle = new Article(newTitle);
msg = "Moved " + TheArticle.Name + " to " + newTitle;
listMaker.ReplaceArticle(TheArticle, replacementArticle);
}
else
msg = "Move of " + TheArticle.Name + " failed!";
articleActionLogControl1.LogArticleAction(TheArticle.Name, succeed, ArticleAction.Move, msg);
StatusLabelText = msg;
}
catch (ApiErrorException ae)
{
switch (ae.ErrorCode)
{
case "missingtitle":
StatusLabelText = "Article deleted, cannot move";
listMaker.Remove(TheArticle);
articleActionLogControl1.LogArticleAction(TheArticle.Name, false, ArticleAction.Move,
"Article already deleted, cannot move");
break;
case "articleexists":
StatusLabelText = "Target exists, cannot move";
MessageBox.Show(
"The destination article already exists and is not a redirect to the source article.\r\nMove not completed",
"Target exists");
articleActionLogControl1.LogArticleAction(TheArticle.Name, false, ArticleAction.Move,
"Target exists");
break;
default:
ErrorHandler.HandleException(ae);
break;
}
}
catch (ApiException ae)
{
if (ae is InvalidTitleException || ae is InterwikiException)
{
MessageBox.Show(ae.Message, "Invalid Target page");
return;
}
ErrorHandler.HandleException(ae);
}
catch (Exception ex)
{
ErrorHandler.HandleException(ex);
}
}