private async Task <JiraAttachment> DownloadAttachmentAsync(JiraAttachment att)
        {
            if (att != null)
            {
                if (string.IsNullOrWhiteSpace(att.Url))
                {
                    att = await GetAttachmentInfo(att.Id);
                }

                if (att != null && !string.IsNullOrWhiteSpace(att.Url))
                {
                    try
                    {
                        var path = Path.Combine(Settings.AttachmentsDir, att.Id, att.Filename);
                        EnsurePath(path);

                        await DownloadWithJiraRestClientAsync(att.Url, path);

                        att.LocalPath = path;
                        Logger.Log(LogLevel.Debug, $"Downloaded attachment '{att}'");
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogLevel.Warning, $"Attachment download failed for '{att.Id}'. Reason '{ex.Message}'.");
                    }
                }
            }

            return(att);
        }
示例#2
0
        private async Task <JiraAttachment> DownloadAttachmentAsync(JiraAttachment att, WebClientWrapper web)
        {
            if (att != null)
            {
                if (string.IsNullOrWhiteSpace(att.Url))
                {
                    att = await GetAttachmentInfo(att.Id);
                }

                if (att != null && !string.IsNullOrWhiteSpace(att.Url))
                {
                    try
                    {
                        string path = Path.Combine(Settings.AttachmentsDir, att.Id, att.Filename);
                        EnsurePath(path);
                        await web.DownloadWithAuthenticationAsync(att.Url, path);

                        att.LocalPath = path;
                        Logger.Log(LogLevel.Debug, $"Downloaded attachment '{att.ToString()}'");
                    }
                    catch (Exception)
                    {
                        Logger.Log(LogLevel.Warning, $"Attachment download failed for '{att.Id}'. ");
                    }
                }
            }

            return(att);
        }
示例#3
0
        private async Task <JiraAttachment> DownloadAttachmentAsync(JiraAttachment att, WebClientWrapper web)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(att.Url))
                {
                    att = await GetAttachmentInfo(att.Id);
                }

                if (att != null && !string.IsNullOrWhiteSpace(att.Url))
                {
                    string path = Path.Combine(Settings.AttachmentsDir, att.Id, att.Filename);
                    EnsurePath(path);
                    await web.DownloadWithAuthenticationAsync(att.Url, path);

                    att.LocalPath = path;
                    Logger.Log(LogLevel.Debug, $"Downloaded attachment {att.ToString()}");
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Warning, $"Attachment download failed. Message: {ex.Message}");
            }

            if (att != null && !string.IsNullOrWhiteSpace(att.ThumbUrl))
            {
                try
                {
                    string thumbname = Path.GetFileNameWithoutExtension(att.Filename) + ".thumb" + Path.GetExtension(att.Filename);
                    var    thumbPath = Path.Combine(Settings.AttachmentsDir, att.Id, thumbname);
                    EnsurePath(thumbPath);
                    await web.DownloadWithAuthenticationAsync(att.ThumbUrl, Path.Combine(Settings.AttachmentsDir, att.Id, thumbname));

                    att.LocalThumbPath = thumbPath;
                    Logger.Log(LogLevel.Debug, $"Downloaded attachment thumbnail {att.ToString()}");
                }
                catch (Exception ex)
                {
                    Logger.Log(LogLevel.Warning, $"Attachment thumbnail ({att.ToString()}) download failed. Message: {ex.Message}");
                }
            }

            return(att);
        }