Ejemplo n.º 1
0
        public object RenameFolder(Folder folder, string newTitle)
        {
            var driveFolder = GetDriveEntry(folder.ID);

            if (IsRoot(driveFolder))
            {
                //It's root folder
                GoogleDriveDaoSelector.RenameProvider(GoogleDriveProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                //rename folder
                driveFolder.Title = newTitle;
                driveFolder       = GoogleDriveProviderInfo.Storage.UpdateEntry(driveFolder);
            }

            CacheInsert(driveFolder);
            var parentDriveId = GetParentDriveId(driveFolder);

            if (parentDriveId != null)
            {
                CacheReset(parentDriveId, true);
            }

            return(MakeId(driveFolder.Id));
        }
Ejemplo n.º 2
0
 protected GoogleDriveDaoBase(GoogleDriveDaoSelector.GoogleDriveInfo googleDriveInfo, GoogleDriveDaoSelector googleDriveDaoSelector)
 {
     GoogleDriveProviderInfo = googleDriveInfo.GoogleDriveProviderInfo;
     PathPrefix             = googleDriveInfo.PathPrefix;
     GoogleDriveDaoSelector = googleDriveDaoSelector;
     TenantID = CoreContext.TenantManager.GetCurrentTenant().TenantId;
 }
Ejemplo n.º 3
0
        public IEnumerable <Tag> GetNewTags(Guid subject, Folder parentFolder, bool deepSearch)
        {
            var folderId = GoogleDriveDaoSelector.ConvertId(parentFolder.ID);

            var fakeFolderId = parentFolder.ID.ToString();

            var entryIDs = DbManager.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 = DbManager.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(GetFolderSubfolders(folderId).Select(x => MakeId(x)))
            .Concat(GetFolderFiles(folderId).Select(x => MakeId(x)));

            return(tags.Where(tag => folderFileIds.Contains(tag.EntryId.ToString())));
        }
Ejemplo n.º 4
0
        public object RenameFolder(object folderId, string newTitle)
        {
            var folder = GetFolderById(folderId);

            var oldId = MakeId(folder);
            var newId = oldId;

            if ("/".Equals(MakePath(folderId)))
            {
                //It's root folder
                GoogleDriveDaoSelector.RenameProvider(GoogleDriveProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                //rename folder
                if (GoogleDriveProviderInfo.Storage.RenameFileSystemEntry(folder, newTitle))
                {
                    //Folder data must be already updated by provider
                    //We can't search google folders by title because root can have multiple folders with the same name
                    //var newFolder = GoogleDriveProviderInfo.Storage.GetFileSystemObject(newTitle, folder.Parent);
                    newId = MakeId(folder);
                }
            }

            UpdatePathInDB(oldId, newId);

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

            return(moved);
        }
Ejemplo n.º 6
0
 public GoogleDriveFileDao(
     IServiceProvider serviceProvider,
     UserManager userManager,
     TenantManager tenantManager,
     TenantUtil tenantUtil,
     DbContextManager <FilesDbContext> dbContextManager,
     SetupInfo setupInfo,
     IOptionsMonitor <ILog> monitor,
     FileUtility fileUtility,
     CrossDao crossDao,
     GoogleDriveDaoSelector googleDriveDaoSelector,
     IFileDao <int> fileDao)
     : base(serviceProvider, userManager, tenantManager, tenantUtil, dbContextManager, setupInfo, monitor, fileUtility)
 {
     CrossDao = crossDao;
     GoogleDriveDaoSelector = googleDriveDaoSelector;
     FileDao = fileDao;
 }
Ejemplo n.º 7
0
 public GoogleDriveTagDao(GoogleDriveDaoSelector.GoogleDriveInfo providerInfo, GoogleDriveDaoSelector googleDriveDaoSelector)
     : base(providerInfo, googleDriveDaoSelector)
 {
 }
Ejemplo n.º 8
0
 public GoogleDriveFolderDao(GoogleDriveDaoSelector.GoogleDriveInfo googleDriveInfo, GoogleDriveDaoSelector googleDriveDaoSelector)
     : base(googleDriveInfo, googleDriveDaoSelector)
 {
 }