private bool SaveComment()
{
if(BoxSummary.Text=="")
{
MessageBox.Show(this, "Summary needs to be not empty", "Message from BEurtle", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return true;
}
if (CommentAuthor.Text == "")
{
MessageBox.Show(this, "Author needs to be not empty", "Message from BEurtle", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return true;
}
if (CommentAuthor.Text.Contains("set full name in user account settings"))
{
MessageBox.Show(this, "Author needs to be set properly", "Message from BEurtle", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return true;
}
if (BoxShortName.Text.Length == 0)
{
// Need to create a new issue first
string[] outputs = plugin.callBEcmd(plugin.rootpath, new string[1] { "new \"" + BoxSummary.Text + "\"" });
// Format is "Created bug with ID 701/356"
if (outputs[0].StartsWith("Created bug with ID "))
{
BoxShortName.Text = outputs[0].Substring(20, 7);
int uuid_idx=outputs[0].LastIndexOf('/');
BoxUUID.Text = outputs[0].Substring(uuid_idx + 1);
if (BoxUUID.Text[BoxUUID.Text.Length - 1] != ')') throw new Exception("BE isn't returning UUIDs when it creates issues! Do you have an old BE version?");
BoxUUID.Text = BoxUUID.Text.Substring(0, BoxUUID.Text.Length - 1);
}
else
{
MessageBox.Show(this, "Error adding issue: " + outputs[0]);
return false;
}
}
{
string mimetype=DraggableIcon.Items[0].Text;
string commentbody=CommentBody.Document.Body.InnerHtml;
if (commentbody != null)
{
if (mimetype.StartsWith("text/")) mimetype = "text/html";
string cmd = "comment --author=\"" + CommentAuthor.Text.Replace("\"", "\\\"") + "\" --content-type=" + mimetype + " " + (commentingupon != null ? commentingupon : BoxShortName.Text) + " -";
string[] outputs = plugin.callBEcmd(plugin.rootpath,
new string[1] { cmd },
new string[1] { commentbody });
// Format is "Created comment with ID 701/356/xxx/xxx/xxx"
if (!outputs[0].StartsWith("Created comment with ID "))
{
MessageBox.Show(this, "Error adding comment: " + outputs[0]);
return false;
}
}
}
// Force master XML reload
plugin.writeHTML(this);
plugin.loadIssues(this);
CommentEditCancel_Click(null, null);
return false;
}