Пример #1
0
        public void SortAndSaveAttachments(List <Attachment> atts = null)
        {
            // If no attachments are supplied, sort the list we already have
            if (atts == null)
            {
                atts = new List <Attachment>(Attachments);
            }

            atts.Sort((a, b) =>
            {
                if (a == null)
                {
                    return(-1);
                }
                else if (b == null)
                {
                    return(1);
                }
                else if (a.Hide != b.Hide)
                {
                    return(a.Hide ? 1 : -1);
                }
                else
                {
                    return(0);
                }
            });

            Attachments.Clear();
            foreach (var a in atts)
            {
                Attachments.Add(a);
            }
        }
Пример #2
0
 protected override void OnDispose(bool disposing)
 {
     if (disposing)
     {
         Attachments.Each(x => x.Dispose());
         Attachments.Clear();
     }
 }
Пример #3
0
 /// <summary>
 /// Clears all cached attachments.
 /// </summary>
 private async void ClearAttachmentsAsync()
 {
     foreach (var cachedFile in Attachments)
     {
         await cachedFile.DeleteAsync();
     }
     Attachments.Clear();
 }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     Utils.EnableBackButton(BackButton_Click);
     Attachments.Clear();
     Attachment = e.Parameter as SignalAttachment;
     Attachments.Add($"{ApplicationData.Current.LocalCacheFolder.Path}/Attachments/{Attachment.Id}.plain");
 }
Пример #5
0
 public void ClearContents()
 {
     // Clear out any previous content
     Body     = null;
     BodyHtml = null;
     Html     = null;
     Attachments.Clear();
 }
Пример #6
0
 void Clear()
 {
     Attachments.Clear();
     HtmlString = "&nbsp;";
     From       = null;
     To         = null;
     Cc         = null;
     Subject    = null;
 }
 private void HandleInteractionFinished()
 {
     Message.PropertyChanged -= HandleModelPropertyChanged;
     Message           = null;
     Date              = new DateTime();
     TextBody          = string.Empty;
     HtmlBody          = string.Empty;
     ProcessedHtmlBody = string.Empty;
     RaiseViewModelPropertiesChanged();
     Attachments.Clear();
 }
Пример #8
0
        async Task RefreshPage()
        {
            Mouse.OverrideCursor = Cursors.Wait;

            try {
                Attachments.Clear();
                HtmlString = "&nbsp;";

                MimeMessage message;

                using (var stream = await "https://wikileaks.org"
                                    .AppendPathSegment("podesta-emails/get")
                                    .AppendPathSegment(DocumentNo)
                                    .GetStreamAsync()) {
                    message = MimeMessage.Load(stream);
                }

                From    = message.From;
                To      = message.To;
                Cc      = message.Cc;
                Subject = message.Subject;

                HtmlString = message.HtmlBody;

                if (string.IsNullOrEmpty(HtmlString))
                {
                    var text = message.TextBody;
                    text = text.Replace("\r\n", "<br/>");

                    HtmlString = text;
                }
                else
                {
                    HtmlString = @"<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/><meta http-equiv='X-UA-Compatible' content='IE=edge'/>" + HtmlString;
                }

                // HighlightNames(ref html);
                GetAttachments(message);

                Validated = new EmailValidation().ValidateSource(message);
            }
            catch (Exception ex) {
                int j = 0;
            }
            finally {
                Mouse.OverrideCursor = Cursors.Arrow;
            }
        }
Пример #9
0
        private async void OnPlusIconTapped(object sender, EventArgs e)
        {
            await CrossMedia.Current.Initialize();

            var mediaOption = new PickMediaOptions()
            {
                PhotoSize = PhotoSize.Small
            };
            var selectedImage = await CrossMedia.Current.PickPhotosAsync(mediaOption);

            var storageStatus = await CrossPermissions.Current.CheckPermissionStatusAsync <StoragePermission>();

            if (storageStatus == PermissionStatus.Granted && selectedImage != null)
            {
                Attachments.Clear();
                for (int i = 0; i < selectedImage.Count; i++)
                {
                    Attachments.Add(new AttachmentsViewModel
                    {
                        AttachmentsLink = System.IO.Path.GetFileName(selectedImage.ElementAt(i).Path),
                        AttachmentImage = new Image
                        {
                            Source =
                                ImageSource.FromStream(() => selectedImage.ElementAt(i).GetStream())
                        },

                        // AttachmentsUsername ="******"+Application.Current.Properties["UserName"].ToString(),
                        AttachmentsUsername = "******" + "Qbs.support",
                        AttachmentsDate     = DateTime.Now.ToString(),
                        FullUrl1            = selectedImage.ElementAt(i).Path
                    });
                    AttachmentsImages.Add(selectedImage.ElementAt(i));
                    //  var issueSend=await _issuesAPI.SentAttanchments(selectedImage.ElementAt(1), IssueId, Application.Current.Properties["token"].ToString());
                    //AttachmentsImgLayer
                    //    .Children
                    //    .Add
                    //    (new Image
                    //    {
                    //        Source =
                    //    ImageSource.FromStream(() => selectedImage.ElementAt(i).GetStream())
                    //    });
                }
            }
            else
            {
            }
        }
Пример #10
0
        private List <OrderAttachmentHistoryEntry> ChangeAttachments(IEnumerable <int> updatedAttachments)
        {
            //before changing the attachments
            var orderAttachmentHistoryEntries = Attachments.Select(a => new OrderAttachmentHistoryEntry {
                AttachmentId = a.AttachmentId
            }).ToList();

            List <int> ordergroupAttachmentIdsToRemove = Enumerable.Empty <int>().ToList();

            IEnumerable <int> orderAttachmentIds             = Attachments.Select(a => a.AttachmentId);
            IEnumerable <int> orderGroupAttachmentIds        = OrderGroupId.HasValue ? Group.Attachments.Select(ag => ag.AttachmentId) : Enumerable.Empty <int>();
            IEnumerable <int> oldOrderAttachmentIdsToCompare = orderAttachmentIds.Union(orderGroupAttachmentIds);

            //all attachments removed
            if (oldOrderAttachmentIdsToCompare.Any() && !updatedAttachments.Any())
            {
                Attachments.Clear();
                if (orderGroupAttachmentIds.Any())
                {
                    ordergroupAttachmentIdsToRemove.AddRange(orderGroupAttachmentIds);
                }
            }
            else
            {
                //add those that should be removed from group
                ordergroupAttachmentIdsToRemove.AddRange(orderGroupAttachmentIds.Except(updatedAttachments));
                //new added attachments
                Attachments.AddRange(updatedAttachments.Except(oldOrderAttachmentIdsToCompare).Select(a => new OrderAttachment {
                    AttachmentId = a
                }).ToList());
                //removed from order
                foreach (int i in orderAttachmentIds.Except(updatedAttachments).ToList())
                {
                    var attachment = Attachments.Single(a => a.AttachmentId == i);
                    Attachments.Remove(attachment);
                }
            }
            orderAttachmentHistoryEntries.AddRange(ordergroupAttachmentIdsToRemove.Select(a => new OrderAttachmentHistoryEntry {
                AttachmentId = a, OrderGroupAttachmentRemoved = true
            }));
            return(orderAttachmentHistoryEntries);
        }
Пример #11
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);
            if (this.session != null)
            {
                this.session.Dispose();
                this.session = null;
            }

            if (Attachments?.Any() ?? false)
            {
                Attachments.ForEach(x =>
                {
                    if (x.ContentStream != null)
                    {
                        x.ContentStream.Dispose();
                    }
                });

                Attachments.Clear();
            }
        }
Пример #12
0
        public void UpdateInventoryCategories()
        {
            Injectors.Clear();
            Attachments.Clear();
            Relic.Clear();

            foreach (var gameItem in _inventory)
            {
                if (gameItem is Injector)
                {
                    Injectors.Add(gameItem);
                }
                if (gameItem is Attachment)
                {
                    Attachments.Add(gameItem);
                }
                if (gameItem is Relic)
                {
                    Relic.Add(gameItem);
                }
            }
        }
Пример #13
0
        private async Task DisplayAttachmentAsync(MailMessageContext message)
        {
            var attachmentContexts = new List <AttachmentContext>();

            using (var context = new DatabaseContext()) {
                var mimeMessage = await context.MimeMessages.FirstOrDefaultAsync(x => x.MessageId == message.Id);

                if (mimeMessage == null)
                {
                    return;
                }

                var reader      = new MailMessageReader(mimeMessage.Data);
                var attachments = reader.FindAllAttachments();

                attachments.Where(x => x.ContentId == null)
                .ForEach(y => attachmentContexts.Add(new AttachmentContext(y)));
            }
            Application.Current.Dispatcher.Invoke(() => {
                Attachments.Clear();
                Attachments.AddRange(attachmentContexts);
            });
        }
        private void LoadAttachments(string mimeSource)
        {
            // Clear the files in temporary storage.
            DirectoryInfo di = new DirectoryInfo(attachmentDirPath);

            foreach (FileInfo file in di.GetFiles())
            {
                file.Delete();
            }
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }

            this.savedAttachments.Clear();
            MimeUtility.SaveAttachments(mimeSource, attachmentDirPath, this.savedAttachments);

            Attachments.Clear();
            foreach (string path in this.savedAttachments.Values)
            {
                Attachments.Add(new AttachmentViewModel(path));
            }
        }
Пример #15
0
 void setAttachments(MultipleAttachmentsInfo attachments)
 {
     if (attachments != null && attachments.LinkUrls != null && attachments.DisplayTextValues != null)
     {
         int count = Math.Max(attachments.LinkUrls.Count(), attachments.DisplayTextValues.Count());
         if (Attachments == null)
         {
             Attachments = new ObservableCollection <AttachmentInfo>();
         }
         else
         {
             Attachments.Clear();
         }
         for (int i = 0; i < count; i++)
         {
             string url  = attachments.LinkUrls.ElementAtOrDefault(i);
             string name = attachments.DisplayTextValues.ElementAtOrDefault(i);
             Attachments.Add(new AttachmentInfo()
             {
                 Name = name, Url = url
             });
         }
     }
 }
Пример #16
0
 private void wipe()
 {
     Message            = string.Empty;
     UrlOfImageToUpload = string.Empty;
     Attachments.Clear();
 }
Пример #17
0
        public void LoadInfos()
        {
            if (!Client.IsConnected)
            {
                throw new EMailException {
                          ExceptionType = EMAIL_EXCEPTION_TYPE.NOT_CONNECTED
                }
            }
            ;
            Client.Fetch(
                true,
                IMAP_t_SeqSet.Parse(UID),
                new IMAP_t_Fetch_i[] {
                new IMAP_t_Fetch_i_Rfc822()
            },
                (sender, e) =>
            {
                if (e.Value is IMAP_r_u_Fetch)
                {
                    IMAP_r_u_Fetch fetchResp = (IMAP_r_u_Fetch)e.Value;
                    try
                    {
                        if (fetchResp.Rfc822 != null)
                        {
                            fetchResp.Rfc822.Stream.Position = 0;
                            Mail_Message mime = Mail_Message.ParseFromStream(fetchResp.Rfc822.Stream);
                            fetchResp.Rfc822.Stream.Dispose();

                            if (String.IsNullOrWhiteSpace(mime.BodyText))
                            {
                                _TextBody = mime.BodyHtmlText;
                            }
                            else
                            {
                                _TextBody = mime.BodyText;
                            }
                            Attachments.Clear();
                            foreach (MIME_Entity entity in mime.Attachments)
                            {
                                IMAP_Mail_Attachment att = new IMAP_Mail_Attachment();
                                if (entity.ContentDisposition != null && entity.ContentDisposition.Param_FileName != null)
                                {
                                    att.Text = entity.ContentDisposition.Param_FileName;
                                }
                                else
                                {
                                    att.Text = "untitled";
                                }
                                att.Body = ((MIME_b_SinglepartBase)entity.Body).Data;
                                Attachments.Add(att);
                            }
                        }
                    }
                    catch (Exception exe)
                    {
                        throw new EMailException {
                            ExceptionType = EMAIL_EXCEPTION_TYPE.ERROR_ON_GET_MESSAGE, InnerException = exe
                        };
                    }
                }
            }
                );
        }
Пример #18
0
 public void ClearContents()
 {
     Message.ClearContents();
     Attachments.Clear();
 }