private void Save()
{
// Fail-safe against http://es.wikipedia.org/w/index.php?diff=28114575
if (TheArticle == null || TheArticle.Name != TheSession.Page.Title)
{
DisableButtons();
string extext = "Attempted to save a wrong page";
if (TheArticle != null)
extext += " (Article name: '" + TheArticle.Name + "', session page title: '" + TheSession.Page.Title +
"')";
else
extext += " (the article was null)";
throw new Exception(extext);
}
if (!TheSession.Editor.IsActive)
StatusLabelText = "Saving...";
else
{
StatusLabelText = "Editor busy";
return;
}
#if DEBUG
string extext2 = @"Extra validation for debug builds (don't use a debug build if you want to save blank pages): ";
// further attempts to track down blank page saving issue
if (TheArticle.ArticleText.Length.Equals(0))
{
extext2 += @"Attempted to save page with zero length ArticleText";
throw new Exception(extext2);
}
if (txtEdit.Text.Length.Equals(0))
{
extext2 += @"Attempted to save page with zero length txtEditText";
throw new Exception(extext2);
}
#endif
DisableButtons();
StartProgressBar();
if (txtEdit.Text.Length > 0 ||
(TheArticle.Exists == Exists.Yes && MessageBox.Show("Do you really want to save a blank page?", "Save?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
DialogResult.Yes))
{
SaveArticle();
}
else
SkipPage("Nothing to save - blank page");
}