public async Task DoDownloadAndOpen(SFAttachment attachment)
        {
            var array = await Task.Run(() => ((SFConnector)SFConnector.Instance).DownloadAttachment(attachment));

            string directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string docName = attachment.Name;

            // In here we save the file but saved file doesn't shown for some reason! Thats why I'm struggling all day.
            File.WriteAllBytes(Path.Combine(directory, docName), array);

            //var bytes = File.ReadAllBytes(Path.Combine(directory, docName));
            //string externalStoragePath = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, docName);
            //File.WriteAllBytes(externalStoragePath, bytes);



            //Android.Net.Uri uri = Android.Net.Uri.Parse("file://" + Path.Combine(directory, docName));
            //Intent intent = new Intent(Intent.ActionView);
            //intent.SetDataAndType(uri, "application/" + attachment.Extention.Substring(attachment.Extention.IndexOf('.') + 1));
            //intent.SetFlags(ActivityFlags.NewTask);
            //Android.App.Application.Context.StartActivity(intent);

            await Share(docName, docName, Path.Combine(directory, docName));

            //  Device.OpenUri(new Uri(Path.Combine(directory, docName)));
        }
Example #2
0
        public CustomWebPage(string filepath, SFAttachment attachment)
        {
            InitializeComponent();
            switch (attachment.AttachmentType)
            {
            case AttachmentType.Excel:
                break;

            case AttachmentType.Word:
                break;

            case AttachmentType.Text:
                break;

            case AttachmentType.Message:
                break;

            case AttachmentType.Pdf:
                customWebView.Uri = filepath;
                WebViewVisible    = true;
                break;

            case AttachmentType.Image:
                picture.Source = filepath;
                PictureVisible = true;
                break;

            case AttachmentType.Other:
                break;

            default:
                break;
            }
        }
        public async Task <string> DownloadAndGetURI(SFAttachment attachment)
        {
            var array = await Task.Run(() => ((SFConnector)SFConnector.Instance).DownloadAttachment(attachment));

            string directory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            directory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string docName = attachment.Name;

            File.WriteAllBytes(Path.Combine(directory, docName), array);
            return(Path.Combine(directory, docName));
        }
Example #4
0
        public async Task <IList <IAttachment> > GetAttachmentsAsync(string caseId)
        {
            IAsyncEnumerable <SFAttachment> result;

            try
            {
                string qry = @"SELECT Id, ParentId, Name, ContentType, 
                    Owner.Id, Owner.Name, 
                    CreatedBy.Id, CreatedBy.Name,
                    Description,
                    BodyLength, Body 
                    FROM Attachment where Attachment.ParentId = '" + caseId + "'";

                var client = await GetForceClient();

                result = client.QueryAsync <SFAttachment>(qry);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }

            IList <IAttachment> attachments = new List <IAttachment>();

            using (IAsyncEnumerator <SFAttachment> contactsEnumerator = result.GetEnumerator())
            {
                // MoveNext() will execute the query and get the first batch of results.
                // Once the inital result batch has been exhausted, the remaining batches, if any, will be retrieved.
                while (await contactsEnumerator.MoveNext())
                {
                    SFAttachment attachment = contactsEnumerator.Current;
                    attachments.Add(attachment);
                }
            }
            return(attachments);
        }
Example #5
0
 public async Task <string> DownloadAndGetURI(SFAttachment attachment)
 {
     return(await DependencyService.Get <IDonwloadAttachment>().DownloadAndGetURI(attachment));
 }
Example #6
0
 private async Task DoDownloadAndOpen(SFAttachment attachment)
 {
     await DependencyService.Get <IDonwloadAttachment>().DoDownloadAndOpen(attachment);
 }