Example #1
0
        public async Task <bool> DownloadAttachment(string fileUrl, string fileName)
        {
            HttpResponseMessage response = null;

            try
            {
                response = await httpManager.DownloadAttachment(fileUrl, true, App.UserName, App.Password);

                response.EnsureSuccessStatusCode();

                var data = await response.Content.ReadAsByteArrayAsync();

                await StorageHelper.WriteDataToIsolatedStorageFile(fileName, data);

                var local      = Windows.ApplicationModel.Package.Current.InstalledLocation;
                var dataFolder = await local.GetFolderAsync("Attachments");

                var storageFile = await dataFolder.GetFileAsync(fileName);

                await Launcher.LaunchFileAsync(storageFile);
            }
            catch (Exception exception)
            {
                var extras = BugSenseHandler.Instance.CrashExtraData;
                extras.Add(new CrashExtraData
                {
                    Key   = "Method",
                    Value = "JiraService.DownloadAttachment"
                });

                BugSenseHandler.Instance.LogException(exception, extras);
            }

// ReSharper disable once PossibleNullReferenceException
            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            return(false);
        }