Exemple #1
0
 public FilePathEmbedded(FileTypeSymbol fileType, FilePathEmbedded cloneFrom) //Usefull for Email Attachments when combined with WeekFileReference
 {
     this.FileType   = fileType;
     this.Suffix     = cloneFrom.Suffix;
     this.Hash       = cloneFrom.Hash;
     this.FileLength = cloneFrom.FileLength;
     this.fileName   = cloneFrom.FileName;
 }
Exemple #2
0
 public static PrintLineEntity CreateLine(Entity referred, FilePathEmbedded file)
 {
     return(new PrintLineEntity
     {
         Referred = referred.ToLite(),
         State = PrintLineState.ReadyToPrint,
         File = file,
     }.Save());
 }
        public static FilePathEmbedded SaveFile(this FilePathEmbedded efp)
        {
            var alg = efp.FileType.GetAlgorithm();

            alg.ValidateFile(efp);
            alg.SaveFile(efp);
            efp.BinaryFile = null !;
            return(efp);
        }
 public static void DeleteFileOnCommit(this FilePathEmbedded efp)
 {
     Transaction.PostRealCommit += dic =>
     {
         efp.FileType.GetAlgorithm().DeleteFiles(new List <IFilePath> {
             efp
         });
     };
 }
Exemple #5
0
 public static EmailMessageEntity WithAttachment(this EmailMessageEntity email, FilePathEmbedded filePath, string?contentId = null)
 {
     email.Attachments.Add(new EmailAttachmentEmbedded
     {
         ContentId = contentId ?? Guid.NewGuid().ToString(),
         File      = filePath,
     });
     return(email);
 }
Exemple #6
0
        public FileStreamResult DownloadFilePathEmbedded(string fileTypeKey, string suffix, string fileName)
        {
            var fileType = SymbolLogic <FileTypeSymbol> .ToSymbol(fileTypeKey);

            var virtualFile = new FilePathEmbedded(fileType)
            {
                Suffix   = suffix,
                FileName = fileName,
            };

            return(GetFileStreamResult(virtualFile.OpenRead(), virtualFile.FileName));
        }
Exemple #7
0
        public HttpResponseMessage DownloadFilePathEmbedded(string fileTypeKey, string suffix, string fileName)
        {
            var fileType = SymbolLogic <FileTypeSymbol> .ToSymbol(fileTypeKey);

            var virtualFile = new FilePathEmbedded(fileType)
            {
                Suffix   = suffix,
                FileName = fileName,
            };

            return(GetHttpReponseMessage(virtualFile.OpenRead(), virtualFile.FileName));
        }
Exemple #8
0
        public FileResult DownloadEmbedded(Lite <FileTypeSymbol> lite, string suffix, string fileName)
        {
            var virtualFile = new FilePathEmbedded(lite.Retrieve())
            {
                Suffix   = suffix,
                FileName = fileName
            };

            var pair = FileTypeLogic.FileTypes.GetOrThrow(lite.Retrieve()).GetPrefixPair(virtualFile);

            var fullPhysicalPath = Path.Combine(pair.PhysicalPrefix, suffix);

            return(new FilePathResult(fullPhysicalPath, MimeMapping.GetMimeMapping(fullPhysicalPath))
            {
                FileDownloadName = fileName
            });
        }
Exemple #9
0
 public static WebImage WebImage(this FilePathEmbedded efp, FileTypeSymbol fileType)
 {
     return(WebImageExpression.Evaluate(efp, fileType));
 }
Exemple #10
0
 public static WebDownload WebDownload(this FilePathEmbedded fp)
 {
     return(WebDownloadExpression.Evaluate(fp));
 }
 public static Stream OpenRead(this FilePathEmbedded efp)
 {
     return(efp.FileType.GetAlgorithm().OpenRead(efp));
 }
Exemple #12
0
 public static WebDownload WebDownload(this FilePathEmbedded fp, FileTypeSymbol fileType)
 {
     return(WebDownloadExpression.Evaluate(fp, fileType));
 }
 public static byte[] GetByteArray(this FilePathEmbedded efp)
 {
     return(efp.BinaryFile ?? efp.FileType.GetAlgorithm().ReadAllBytes(efp));
 }
 static PrefixPair CalculatePrefixPair(this FilePathEmbedded efp)
 {
     using (new EntityCache(EntityCacheType.ForceNew))
         return(efp.FileType.GetAlgorithm().GetPrefixPair(efp));
 }
 public static WebImage?WebImage(this FilePathEmbedded fp) =>
 As.Expression(() => fp == null ? null ! : new WebImage {
Exemple #16
0
 public static FilePathEmbedded SaveFile(this FilePathEmbedded efp)
 {
     efp.FileType.GetAlgorithm().SaveFile(efp);
     efp.BinaryFile = null;
     return(efp);
 }
Exemple #17
0
 public static WebImage?WebImage(this FilePathEmbedded fp)
 {
     return(WebImageExpression.Evaluate(fp));
 }