Ejemplo n.º 1
0
 protected BoxDaoBase(BoxDaoSelector.BoxInfo boxInfo, BoxDaoSelector boxDaoSelector)
 {
     BoxProviderInfo = boxInfo.BoxProviderInfo;
     PathPrefix      = boxInfo.PathPrefix;
     BoxDaoSelector  = boxDaoSelector;
     TenantID        = CoreContext.TenantManager.GetCurrentTenant().TenantId;
 }
Ejemplo n.º 2
0
        public object RenameFolder(Folder folder, string newTitle)
        {
            var boxFolder      = GetBoxFolder(folder.ID);
            var parentFolderId = GetParentFolderId(boxFolder);

            if (IsRoot(boxFolder))
            {
                //It's root folder
                BoxDaoSelector.RenameProvider(BoxProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                newTitle = GetAvailableTitle(newTitle, parentFolderId, IsExist);

                //rename folder
                boxFolder = BoxProviderInfo.Storage.RenameFolder(boxFolder.Id, newTitle);
            }

            BoxProviderInfo.CacheReset(boxFolder);
            if (parentFolderId != null)
            {
                BoxProviderInfo.CacheReset(parentFolderId);
            }

            return(MakeId(boxFolder.Id));
        }
Ejemplo n.º 3
0
        public Folder <int> CopyFolder(string folderId, int toFolderId, CancellationToken?cancellationToken)
        {
            var moved = CrossDao.PerformCrossDaoFolderCopy(
                folderId, this, BoxDaoSelector.GetFileDao(folderId), BoxDaoSelector.ConvertId,
                toFolderId, FolderDao, FileDao, r => r,
                false, cancellationToken);

            return(moved);
        }
Ejemplo n.º 4
0
 public BoxFileDao(
     IServiceProvider serviceProvider,
     UserManager userManager,
     TenantManager tenantManager,
     TenantUtil tenantUtil,
     DbContextManager <FilesDbContext> dbContextManager,
     SetupInfo setupInfo,
     IOptionsMonitor <ILog> monitor,
     FileUtility fileUtility,
     CrossDao crossDao,
     BoxDaoSelector boxDaoSelector,
     IFileDao <int> fileDao) : base(serviceProvider, userManager, tenantManager, tenantUtil, dbContextManager, setupInfo, monitor, fileUtility)
 {
     CrossDao       = crossDao;
     BoxDaoSelector = boxDaoSelector;
     FileDao        = fileDao;
 }
Ejemplo n.º 5
0
 public BoxFolderDao(BoxDaoSelector.BoxInfo boxInfo, BoxDaoSelector boxDaoSelector)
     : base(boxInfo, boxDaoSelector)
 {
 }
Ejemplo n.º 6
0
        public IEnumerable <Tag> GetNewTags(Guid subject, Folder parentFolder, bool deepSearch)
        {
            var folderId     = BoxDaoSelector.ConvertId(parentFolder.ID);
            var fakeFolderId = parentFolder.ID.ToString();

            using (var db = GetDb())
            {
                var entryIDs = db.ExecuteList(Query("files_thirdparty_id_mapping")
                                              .Select("hash_id")
                                              .Where(Exp.Like("id", fakeFolderId, SqlLike.StartWith)))
                               .ConvertAll(x => x[0]);

                if (!entryIDs.Any())
                {
                    return(new List <Tag>());
                }

                var sqlQuery = new SqlQuery("files_tag ft")
                               .Select("ft.name",
                                       "ft.flag",
                                       "ft.owner",
                                       "ftl.entry_id",
                                       "ftl.entry_type",
                                       "ftl.tag_count",
                                       "ft.id")
                               .Distinct()
                               .LeftOuterJoin("files_tag_link ftl",
                                              Exp.EqColumns("ft.tenant_id", "ftl.tenant_id") &
                                              Exp.EqColumns("ft.id", "ftl.tag_id"))
                               .Where(Exp.Eq("ft.tenant_id", TenantID) &
                                      Exp.Eq("ftl.tenant_id", TenantID) &
                                      Exp.Eq("ft.flag", (int)TagType.New) &
                                      Exp.In("ftl.entry_id", entryIDs));

                if (subject != Guid.Empty)
                {
                    sqlQuery.Where(Exp.Eq("ft.owner", subject));
                }

                var tags = db.ExecuteList(sqlQuery).ConvertAll(r => new Tag
                {
                    TagName   = Convert.ToString(r[0]),
                    TagType   = (TagType)r[1],
                    Owner     = new Guid(r[2].ToString()),
                    EntryId   = MappingID(r[3]),
                    EntryType = (FileEntryType)r[4],
                    Count     = Convert.ToInt32(r[5]),
                    Id        = Convert.ToInt32(r[6])
                });

                if (deepSearch)
                {
                    return(tags);
                }

                var folderFileIds = new[] { fakeFolderId }
                .Concat(GetChildren(folderId));

                return(tags.Where(tag => folderFileIds.Contains(tag.EntryId.ToString())));
            }
        }
Ejemplo n.º 7
0
 public BoxTagDao(BoxDaoSelector.BoxInfo providerInfo, BoxDaoSelector boxDaoSelector)
     : base(providerInfo, boxDaoSelector)
 {
 }
Ejemplo n.º 8
0
 public BoxSecurityDao(BoxDaoSelector.BoxInfo providerInfo, BoxDaoSelector boxDaoSelector)
     : base(providerInfo, boxDaoSelector)
 {
 }