Exemple #1
0
 public void SaveContentStream(MediaContent content, Stream stream)
 {
     RemoteServiceFactory.CreateService <IMediaContentService>().SaveBytes(new MediaContentParameter()
     {
         MediaContent = content,
         FileData     = stream.ReadData()
     });
 }
Exemple #2
0
        public MediaFolder Get(MediaFolder dummy)
        {
            var folder = RemoteServiceFactory.CreateService <IMediaFolderService>()
                         .Get(dummy.Repository.Name, dummy.FullName);

            if (folder != null)
            {
                ((IPersistable)folder).Init(dummy);
            }
            return(folder);
        }
Exemple #3
0
 public byte[] GetContentStream(MediaContent content)
 {
     if (string.IsNullOrEmpty(content.GetRepository().Name))
     {
         var webClient = new WebClient();
         return(webClient.DownloadData(content.Url));
     }
     else
     {
         var mediaContentService = RemoteServiceFactory.CreateService <IMediaContentService>();
         return(mediaContentService.GetBytes(content.Repository, content.FolderName, content.FileName));
     }
 }
Exemple #4
0
        public void Add(MediaContent content, bool overrided)
        {
            if (content.ContentFile != null)
            {
                content.FileName = content.ContentFile.FileName;

                content.UserKey = content.FileName;
                content.UUID    = content.FileName;

                RemoteServiceFactory.CreateService <IMediaContentService>().Add(
                    new MediaContentParameter()
                {
                    MediaContent = content,
                    FileData     = content.ContentFile.Stream.ReadData()
                });
            }
        }
Exemple #5
0
        public void Update(MediaContent @new, MediaContent old)
        {
            if ([email protected](old.FileName, StringComparison.OrdinalIgnoreCase))
            {
                RemoteServiceFactory.CreateService <IMediaContentService>().Move(old.Repository,
                                                                                 old.FolderName, old.FileName, @new.FolderName, @new.FileName);
            }
            else
            {
                var parameter = new MediaContentParameter()
                {
                    MediaContent = @new
                };

                RemoteServiceFactory.CreateService <IMediaContentService>().Update(parameter);
            }
        }
Exemple #6
0
 public void Update(MediaContent @new, MediaContent old)
 {
     if ([email protected](old.FileName, StringComparison.OrdinalIgnoreCase))
     {
         RemoteServiceFactory.CreateService <IMediaContentService>().Move(old.Repository,
                                                                          old.FolderName, old.FileName, @new.FolderName, @new.FileName);
     }
     else
     {
         if (@new.ContentFile != null)
         {
             RemoteServiceFactory.CreateService <IMediaContentService>().Update(new MediaContentParameter()
             {
                 MediaContent = @new,
                 FileData     = @new.ContentFile.Stream.ReadData()
             });
         }
     }
 }
Exemple #7
0
        public object Execute(IContentQuery <MediaContent> query)
        {
            var mediaQuery = (MediaContentQuery)query;


            QueryExpressionTranslator translator = new QueryExpressionTranslator();

            translator.Translate(query.Expression);

            //translator.Visite(query.Expression);
            IEnumerable <MediaContent> contents;

            switch (translator.CallType)
            {
            case CallType.Count:
                return(RemoteServiceFactory.CreateService <IMediaContentService>().Count(mediaQuery.MediaFolder.Repository.Name,
                                                                                         mediaQuery.MediaFolder.FullName, translator.Prefix));

            case CallType.First:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.First());

            case CallType.Last:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.Last());

            case CallType.LastOrDefault:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.LastOrDefault());

            case CallType.FirstOrDefault:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents.FirstOrDefault());

            case CallType.Unspecified:
            default:
                contents = Execute(mediaQuery.MediaFolder, translator);
                return(contents);
            }
        }
Exemple #8
0
        private static IEnumerable <MediaContent> Execute(MediaFolder mediaFolder, QueryExpressionTranslator translator)
        {
            var mediaContentService = RemoteServiceFactory.CreateService <IMediaContentService>();

            if (!string.IsNullOrEmpty(translator.FileName))
            {
                return(new[] { mediaContentService.Get(mediaFolder.Repository.Name, mediaFolder.FullName, translator.FileName) });
            }
            else
            {
                var maxResult = 50;
                if (translator.Take.HasValue && translator.Take.Value != 0)
                {
                    maxResult = translator.Take.Value;
                }
                var skip = 0;
                if (translator.Skip.HasValue)
                {
                    skip = translator.Skip.Value;
                }
                return(mediaContentService.All(mediaFolder.Repository.Name, mediaFolder.FullName, skip, maxResult, translator.Prefix));
            }
        }
 public string Save(Models.TextContent content, Models.ContentFile file)
 {
     return(RemoteServiceFactory.CreateService <ITextContentFileService>()
            .Add(content.Repository, content.FolderName, content.UUID, file.FileName, file.Stream.ReadData()));
 }
Exemple #10
0
 public void Add(MediaFolder item)
 {
     RemoteServiceFactory.CreateService <IMediaFolderService>().Add(item.Repository.Name, item);
 }
 public void DeleteFiles(Models.TextContent content)
 {
     RemoteServiceFactory.CreateService <ITextContentFileService>()
     .DeleteFiles(content.Repository, content.FolderName, content.UUID);
 }
Exemple #12
0
 public void Delete(MediaContent content)
 {
     RemoteServiceFactory.CreateService <IMediaContentService>().Delete(content.Repository, content.FolderName, content.UUID);
 }
Exemple #13
0
 public void Move(MediaFolder sourceFolder, string oldFileName, MediaFolder targetFolder, string newFileName)
 {
     RemoteServiceFactory.CreateService <IMediaContentService>().Move(sourceFolder.Repository.Name,
                                                                      sourceFolder.FullName, oldFileName, targetFolder.FullName, newFileName);
 }
Exemple #14
0
 public IQueryable <MediaFolder> ChildFolders(MediaFolder parent)
 {
     return(RemoteServiceFactory.CreateService <IMediaFolderService>().ChildFolders(parent.Repository.Name, parent.FullName).AsQueryable());
 }
Exemple #15
0
 public void Remove(MediaFolder item)
 {
     RemoteServiceFactory.CreateService <IMediaFolderService>().Delete(item.Repository.Name, item.FullName);
     //(new MediaContentProvider()).Delete(item);
 }
Exemple #16
0
 public void Update(MediaFolder @new, MediaFolder old)
 {
     RemoteServiceFactory.CreateService <IMediaFolderService>().Update(@new.Repository.Name, @new);
 }
Exemple #17
0
 public IQueryable <MediaFolder> All(Repository repository)
 {
     return(RemoteServiceFactory.CreateService <IMediaFolderService>().RootFolders(repository.Name)
            .Select(it => { it.Repository = repository; return it; }).AsQueryable());
 }