예제 #1
0
        public bool OpenActualDocumentFromPlaceHolder(Attachment attachment)
        {
            try
            {
                if (attachment.Size > (1024*5))
                {
                    Logger.LogTrace("Returning without doing anything as the file size is > 5k");
                    return false;
                }

                using (var lcfm = new LocalCopyOfFileManager())
                {
                    string filename = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
                    attachment.SaveAsFile(filename);

                    Logger.LogTrace("Saving placeholder file to " + filename);
                    var lah = new LargeAttachmentHelper(filename);
                    if (lah.IsLargeAttachment)
                    {
                        Logger.LogTrace("Opening actual file from" + lah.ActualPath);
                        var startInfo = new ProcessStartInfo();
                        startInfo.FileName = lah.ActualPath;
                        Process.Start(startInfo);
                        return true;
                    }
                }
                return false;
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                throw;
            }
        }
예제 #2
0
        public static bool HasLargeAttachments(MailItem mailItem)
        {
            using (var lcfm = new LocalCopyOfFileManager())
            {
                var tempfile = lcfm.GetLocalCopyOfFileTarget(Guid.NewGuid().ToString());
                mailItem.SaveAs(tempfile);

                foreach (Attachment attachment in mailItem.Attachments)
                {
                    try
                    {
                        var file = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
                        attachment.SaveAsFile(file);
                        var lah = new LargeAttachmentHelper(file);
                        if (lah.IsLargeAttachment)
                        {
                            return true;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.LogError(e);
                    }
                }
                return false;
            }
        }
예제 #3
0
        public ProtectAttachment(Microsoft.Office.Interop.Outlook.Attachment attachment)
            : this()
        {
            // 17470 [WS 8.0] Protect files is not enabled when .msg with no subject is attached through Right click->send To->Mail Recipient.ZenQ
            Name = attachment.DisplayName ?? "";

            var filename = string.Empty;
            filename = attachment.FileName.ToLower() == ".msg"
                           ? Guid.NewGuid().ToString() + ".msg"
                           : attachment.FileName;
            // --

            Index = attachment.Index.ToString(CultureInfo.InvariantCulture);
            var wsAttachment = attachment as WsAttachment;
            if (wsAttachment != null)
            {
                Id = wsAttachment.Id.ToString();
                RecordKey = wsAttachment.RecordKey;
            }
            _lcofm = new LocalCopyOfFileManager();
            filename = _lcofm.GetLocalCopyOfFileTarget(filename);
            attachment.SaveAsFile(filename);

            var lah = new LargeAttachmentHelper(filename);
            if (lah.IsLargeAttachment)
            {
                LargeAttachmentFileName = filename;
                var tempfile = _lcofm.GetLocalCopyOfFileTarget(Path.GetFileName(lah.ActualPath));
                System.IO.File.Copy(lah.ActualPath, tempfile, true);
                filename = tempfile;
                Name = Path.GetFileName(filename);
            }

            File = FcsFileFactory.Create(filename, Name);
            Position = attachment.Position;
            FileName = filename;
        }
예제 #4
0
파일: Utils.cs 프로젝트: killbug2004/WSProf
        public static bool IsLargeAttachmentFile(Attachment attachment)
        {
            if (Path.HasExtension(attachment.FileName) && Path.GetExtension(attachment.FileName).ToLower() == ".wsl")
            {
                using (var lcfm = new LocalCopyOfFileManager())
                {
                    var tempFile = lcfm.GetLocalCopyOfFileTarget(attachment.FileName);
                    attachment.SaveAsFile(tempFile);

                    var lah = new LargeAttachmentHelper(tempFile);
                    return lah.IsLargeAttachment;
                }
            }
            return false;
        }
예제 #5
0
        public void RePack(IProtectAttachment attachment, CancellationToken token)
        {
            if (token.IsCancellationRequested)
                return;

            if (attachment.HasPassword)
                return;

            foreach (IProtectAttachment child in attachment.Children)
            {
                if (token.IsCancellationRequested)
                    return;

                if (child.Children.Any())
                {
                    RePack(child, token);
                }
            }

            if (IsMsgFile(attachment.FileType))
            {
                RepackMessageFile(attachment);
            }
            else if (FileType.ZIP == attachment.FileType)
            {
                ZipFilePackager.RePack(attachment, attachment.OpenPassword, token);
            }
            else if (!string.IsNullOrEmpty(attachment.LargeAttachmentFileName))
            {
                var helper = new LargeAttachmentHelper(attachment.LargeAttachmentFileName);
                helper.ActualPath = attachment.FileName;
                helper.Save();
            }
        }