Ejemplo n.º 1
0
        protected override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            var exportInformation = new ExportInformation(Designation, Description);
            var filename          = Path.GetFileName(FilenameHelper.GetFilename(_jiraConfiguration.UploadFormat, captureDetails));
            var outputSettings    = new SurfaceOutputSettings(_jiraConfiguration.UploadFormat, _jiraConfiguration.UploadJpegQuality, _jiraConfiguration.UploadReduceColors);

            if (_jiraIssue != null)
            {
                try
                {
                    // Run upload in the background
                    new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
                                                     async() =>
                    {
                        var surfaceContainer = new SurfaceContainer(surface, outputSettings, filename);
                        await _jiraConnector.AttachAsync(_jiraIssue.Key, surfaceContainer);
                        surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key).AbsoluteUri;
                    }
                                                     );
                    Log.Debug().WriteLine("Uploaded to Jira {0}", _jiraIssue.Key);
                    exportInformation.ExportMade = true;
                    exportInformation.Uri        = surface.UploadUrl;
                }
                catch (Exception e)
                {
                    MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
                }
            }
            else
            {
                // TODO: set filename
                // _jiraViewModel.SetFilename(filename);
                if (_windowManager.ShowDialog(_jiraViewModel) == true)
                {
                    try
                    {
                        surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraViewModel.JiraIssue.Key).AbsoluteUri;
                        // Run upload in the background
                        new PleaseWaitForm().ShowAndWait(Description, Language.GetString("jira", LangKey.communication_wait),
                                                         async() =>
                        {
                            var attachment = new SurfaceContainer(surface, outputSettings, _jiraViewModel.Filename);

                            await _jiraConnector.AttachAsync(_jiraViewModel.JiraIssue.Key, attachment);

                            if (!string.IsNullOrEmpty(_jiraViewModel.Comment))
                            {
                                await _jiraConnector.AddCommentAsync(_jiraViewModel.JiraIssue.Key, _jiraViewModel.Comment);
                            }
                        }
                                                         );
                        Log.Debug().WriteLine("Uploaded to Jira {0}", _jiraViewModel.JiraIssue.Key);
                        exportInformation.ExportMade = true;
                        exportInformation.Uri        = surface.UploadUrl;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(Language.GetString("jira", LangKey.upload_failure) + " " + e.Message);
                    }
                }
            }
            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }
Ejemplo n.º 2
0
        protected override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails)
        {
            var exportInformation = new ExportInformation(Designation, Description);

            if (_jiraIssue != null)
            {
                try
                {
                    // Run upload in the background
                    using (var ownedPleaseWaitForm = _pleaseWaitFormFactory())
                    {
                        ownedPleaseWaitForm.Value.ShowAndWait(Description, _jiraLanguage.CommunicationWait,
                                                              async() =>
                        {
                            await _jiraConnector.AttachAsync(_jiraIssue.Key, surface).ConfigureAwait(true);
                            surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", _jiraIssue.Key)
                                                .AbsoluteUri;
                        });
                    }
                    Log.Debug().WriteLine("Uploaded to Jira {0}", _jiraIssue.Key);
                    exportInformation.ExportMade = true;
                    exportInformation.Uri        = surface.UploadUrl;
                }
                catch (Exception e)
                {
                    MessageBox.Show(_jiraLanguage.UploadFailure + " " + e.Message);
                }
            }
            else
            {
                // TODO: set filename
                // _jiraViewModel.SetFilename(filename);
                using (var jiraViewModel = _jiraViewModelFactory())
                {
                    if (_windowManager.ShowDialog(jiraViewModel.Value) == true)
                    {
                        try
                        {
                            surface.UploadUrl = _jiraConnector.JiraBaseUri.AppendSegments("browse", jiraViewModel.Value.JiraIssue.Key).AbsoluteUri;
                            // Run upload in the background
                            using (var ownedPleaseWaitForm = _pleaseWaitFormFactory())
                            {
                                ownedPleaseWaitForm.Value.ShowAndWait(Description, _jiraLanguage.CommunicationWait,
                                                                      async() =>
                                {
                                    await _jiraConnector.AttachAsync(jiraViewModel.Value.JiraIssue.Key, surface,
                                                                     jiraViewModel.Value.Filename).ConfigureAwait(true);

                                    if (!string.IsNullOrEmpty(jiraViewModel.Value.Comment))
                                    {
                                        await _jiraConnector.AddCommentAsync(jiraViewModel.Value.JiraIssue.Key,
                                                                             jiraViewModel.Value.Comment).ConfigureAwait(true);
                                    }
                                }
                                                                      );
                            }

                            Log.Debug().WriteLine("Uploaded to Jira {0}", jiraViewModel.Value.JiraIssue.Key);
                            exportInformation.ExportMade = true;
                            exportInformation.Uri        = surface.UploadUrl;
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(_jiraLanguage.UploadFailure + " " + e.Message);
                        }
                    }
                }
            }
            ProcessExport(exportInformation, surface);
            return(exportInformation);
        }