public object RenameFolder(Folder folder, string newTitle)
        {
            var onedriveFolder = GetOneDriveItem(folder.ID);
            var parentFolderId = GetParentFolderId(onedriveFolder);

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

                //rename folder
                onedriveFolder = OneDriveProviderInfo.Storage.RenameItem(onedriveFolder.Id, newTitle);
            }

            OneDriveProviderInfo.CacheReset(onedriveFolder.Id);
            if (parentFolderId != null)
            {
                OneDriveProviderInfo.CacheReset(parentFolderId);
            }

            return(MakeId(onedriveFolder.Id));
        }
 protected OneDriveDaoBase(OneDriveDaoSelector.OneDriveInfo onedriveInfo, OneDriveDaoSelector onedriveDaoSelector)
 {
     OneDriveProviderInfo = onedriveInfo.OneDriveProviderInfo;
     PathPrefix           = onedriveInfo.PathPrefix;
     OneDriveDaoSelector  = onedriveDaoSelector;
     TenantID             = CoreContext.TenantManager.GetCurrentTenant().TenantId;
 }
示例#3
0
        public Folder <int> CopyFolder(string folderId, int toFolderId, CancellationToken?cancellationToken)
        {
            var moved = CrossDao.PerformCrossDaoFolderCopy(
                folderId, this, OneDriveDaoSelector.GetFileDao(folderId), OneDriveDaoSelector.ConvertId,
                toFolderId, FolderDao, FileDao, r => r,
                false, cancellationToken);

            return(moved);
        }
示例#4
0
 public OneDriveFileDao(
     IServiceProvider serviceProvider,
     UserManager userManager,
     TenantManager tenantManager,
     TenantUtil tenantUtil,
     DbContextManager <FilesDbContext> dbContextManager,
     SetupInfo setupInfo,
     IOptionsMonitor <ILog> monitor,
     FileUtility fileUtility,
     CrossDao crossDao,
     OneDriveDaoSelector oneDriveDaoSelector,
     IFileDao <int> fileDao)
     : base(serviceProvider, userManager, tenantManager, tenantUtil, dbContextManager, setupInfo, monitor, fileUtility)
 {
     CrossDao            = crossDao;
     OneDriveDaoSelector = oneDriveDaoSelector;
     FileDao             = fileDao;
 }
示例#5
0
 public OneDriveFileDao(OneDriveDaoSelector.OneDriveInfo providerInfo, OneDriveDaoSelector onedriveDaoSelector)
     : base(providerInfo, onedriveDaoSelector)
 {
 }
 public OneDriveFolderDao(OneDriveDaoSelector.OneDriveInfo onedriveInfo, OneDriveDaoSelector onedriveDaoSelector)
     : base(onedriveInfo, onedriveDaoSelector)
 {
 }
 public OneDriveSecurityDao(OneDriveDaoSelector.OneDriveInfo onedriveInfo, OneDriveDaoSelector onedriveDaoSelector)
     : base(onedriveInfo, onedriveDaoSelector)
 {
 }
示例#8
0
        public IEnumerable <Tag> GetNewTags(Guid subject, Folder parentFolder, bool deepSearch)
        {
            var folderId     = OneDriveDaoSelector.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())));
            }
        }