<commit_before>﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Bloom.Book;
using Bloom.web;
using Bloom.WebLibraryIntegration;
using Bloom.Workspace;
using L10NSharp;
using SIL.Extensions;
using SIL.IO;
using SIL.Progress;
using SIL.Reporting;
using YouTrackSharp.Infrastructure;
using YouTrackSharp.Issues;


namespace Bloom.MiscUI
{
	/// <summary>
	/// This dialog lets users bring up an issue with us.
	/// It can include a description, a screenshot, and the file they were working on.
	/// It can try to send directly via internet. If this fails, it can make a single
	/// zip file and direct the user to email that to us.
	/// </summary>
	public partial class ProblemReporterDialog : Form
	{
		private string _shortErrorHtml = "";
		public delegate ProblemReporterDialog Factory(Control targetOfScreenshot);//autofac uses this

		protected enum State { WaitingForSubmission, UploadingBook, Submitting, CouldNotAutomaticallySubmit, Success }

		public Book.Book Book;
		private string _projectName;
		private Bitmap _screenshot;
		protected State _state;
		private string _emailableReportFilePath;
		private readonly string YouTrackUrl;
		protected string _youTrackProjectKey = "BL";

		private readonly Connection _youTrackConnection = new Connection(UrlLookup.LookupUrl(UrlType.IssueTrackingSystemBackend, false, true), 80, false, "youtrack");
		private IssueManagement _issueManagement;

		private string _youTrackIssueId = "unknown";
		private dynamic _youTrackIssue;

		public ProblemReporterDialog()
			: this(null)
		{ }

		public ProblemReporterDialog(Control targetOfScreenshot, BookSelection bookSelection)
			: this(targetOfScreenshot)
		{
			Book = bookSelection.CurrentSelection;
		}

		public ProblemReporterDialog(Control targetOfScreenshot)
		{
			// Haven't tried https here, as we're not using it for live YouTrack. Someday we may want to.
			// If so, check Linux, as we had problems there with the old Jira reporting. Until
			// then we use the unsecured URL.
			YouTrackUrl = UrlLookup.LookupUrl(UrlType.IssueTrackingSystemBackend);
			Summary = "User Problem Report {0}";
<commit_msg>Suppress youtrack port number and use ssl<commit_after>﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net.Mail;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Bloom.Book;
using Bloom.web;
using Bloom.WebLibraryIntegration;
using Bloom.Workspace;
using L10NSharp;
using SIL.Extensions;
using SIL.IO;
using SIL.Progress;
using SIL.Reporting;
using YouTrackSharp.Infrastructure;
using YouTrackSharp.Issues;


namespace Bloom.MiscUI
{
	/// <summary>
	/// This dialog lets users bring up an issue with us.
	/// It can include a description, a screenshot, and the file they were working on.
	/// It can try to send directly via internet. If this fails, it can make a single
	/// zip file and direct the user to email that to us.
	/// </summary>
	public partial class ProblemReporterDialog : Form
	{
		private string _shortErrorHtml = "";
		public delegate ProblemReporterDialog Factory(Control targetOfScreenshot);//autofac uses this

		protected enum State { WaitingForSubmission, UploadingBook, Submitting, CouldNotAutomaticallySubmit, Success }

		public Book.Book Book;
		private string _projectName;
		private Bitmap _screenshot;
		protected State _state;
		private string _emailableReportFilePath;
		private readonly string YouTrackUrl;
		protected string _youTrackProjectKey = "BL";

		private readonly Connection _youTrackConnection = new Connection(UrlLookup.LookupUrl(UrlType.IssueTrackingSystemBackend, false, true), 0 /* BL-5500 don't specify port */, true, "youtrack");
		private IssueManagement _issueManagement;

		private string _youTrackIssueId = "unknown";
		private dynamic _youTrackIssue;

		public ProblemReporterDialog()
			: this(null)
		{ }

		public ProblemReporterDialog(Control targetOfScreenshot, BookSelection bookSelection)
			: this(targetOfScreenshot)
		{
			Book = bookSelection.CurrentSelection;
		}

		public ProblemReporterDialog(Control targetOfScreenshot)
		{
			// Haven't tried https here, as we're not using it for live YouTrack. Someday we may want to.
			// If so, check Linux, as we had problems there with the old Jira reporting. Until
			// then we use the unsecured URL.
			YouTrackUrl = UrlLookup.LookupUrl(UrlType.IssueTrackingSystemBackend);
			Summary = "User Problem Report {0}";

{'fraction_non_alphanumeric': 0.0768400604360026, 'fraction_numerical': 0.002805957263112454, 'mean_word_length': 4.720987654320988, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2640983', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1296, 'n_words': 452}