/// <summary>
        /// Ons the given event.
        /// </summary>
        /// <param name="event"> The event.</param>
        public void On(Event <LogEventData> @event)
        {
            var connection = GetConnection();

            if (connection == null)
            {
                return;
            }

            try
            {
                var issueManagement = new IssueManagement(connection);

                dynamic issue = new Issue();

                var payload = GetPayload(@event);
                issue.Summary          = this._summaryTemplate.Value(payload);
                issue.Description      = this._bodyTemplate.Value(payload);
                issue.ProjectShortName = this.ProjectId;
                issue.Type             = this.YouTrackIssueType.IsSet() ? this.YouTrackIssueType : "Auto-reported Exception";

                string issueNumber = issueManagement.CreateIssue(issue);

                if (issueNumber.IsSet())
                {
                    Log.Information(
                        "Issue {YouTrackIssueNumber} Created in YouTrack {IssueUrl}",
                        issueNumber,
                        $"{GetYouTrackUri().ToFormattedUrl()}/issue/{issueNumber}");

                    issueManagement.ApplyCommand(issueNumber, "comment", $"Posted from Seq Event Timestamp UTC: {@event.TimestampUtc}");

                    if (AttachCopyOfEventToIssue)
                    {
                        var file = GetJsonEventFile(@event, issueNumber);
                        issueManagement.AttachFileToIssue(issueNumber, file);
                        try
                        {
                            File.Delete(file);
                        }
                        catch
                        {
                            // can't say I care too much...
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                // failure creating issue
                this.Log.Error(ex, "Failure Creating Issue on YouTrack {YouTrackUrl}", GetYouTrackUri().ToFormattedUrl());
            }
        }
        public void Test_Post_File_To_Issue()
        {
            Uri        uri = new Uri("http://yt.wolfgang.com/youtrack/");
            RestClient rc  = new RestClient {
                CookieContainer = new CookieContainer(), BaseUrl = uri
            };

            rc.AddHandler("application/json", new NewtonsoftJsonDeserializer());

            _restSharpConnection.Authenticate("*****@*****.**", "mozart");
            IssueManagement issueManagement = new IssueManagement(_restSharpConnection);

            issueManagement.AttachFileToIssue("NAT-50", @"C:\Users\mecombs\Downloads\Grey-Wolf.jpg");
        }
Esempio n. 3
0
 private void AddAttachment(string file)
 {
     _issueManagement.AttachFileToIssue(_youTrackIssueId, file);
 }
Esempio n. 4
0
        public void AttachFile(string issueId, string pathToFile)
        {
            var im = new IssueManagement(Connection);

            im.AttachFileToIssue(issueId, pathToFile);
        }