Example #1
0
        public string RenameFolder(Folder <string> folder, string newTitle)
        {
            var dropboxFolder    = GetDropboxFolder(folder.ID);
            var parentFolderPath = GetParentFolderPath(dropboxFolder);

            if (IsRoot(dropboxFolder))
            {
                //It's root folder
                DaoSelector.RenameProvider(ProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                newTitle = GetAvailableTitle(newTitle, parentFolderPath, IsExist);

                //rename folder
                dropboxFolder = ProviderInfo.Storage.MoveFolder(MakeDropboxPath(dropboxFolder), parentFolderPath, newTitle);
            }

            ProviderInfo.CacheReset(dropboxFolder);
            if (parentFolderPath != null)
            {
                ProviderInfo.CacheReset(parentFolderPath);
            }

            return(MakeId(dropboxFolder));
        }
Example #2
0
        public string RenameFolder(Folder <string> folder, string newTitle)
        {
            var entry = GetFolderById(folder.ID);

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

            if ("/".Equals(MakePath(folder.ID)))
            {
                //It's root folder
                DaoSelector.RenameProvider(ProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                var parentFolder = GetFolderById(folder.ParentFolderID);
                newTitle = GetAvailableTitle(newTitle, parentFolder, IsExist);

                //rename folder
                if (ProviderInfo.Storage.RenameFileSystemEntry(entry, 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 = SharpBoxProviderInfo.Storage.GetFileSystemObject(newTitle, folder.Parent);
                    newId = MakeId(entry);
                }
            }

            UpdatePathInDB(oldId, newId);

            return(newId);
        }
        public string RenameFolder(Folder <string> folder, string newTitle)
        {
            var driveFolder = GetDriveEntry(folder.ID);

            if (IsRoot(driveFolder))
            {
                //It's root folder
                DaoSelector.RenameProvider(ProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                //rename folder
                driveFolder.Name = newTitle;
                driveFolder      = ProviderInfo.Storage.RenameEntry(driveFolder.Id, driveFolder.Name);
            }

            ProviderInfo.CacheReset(driveFolder);
            var parentDriveId = GetParentDriveId(driveFolder);

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

            return(MakeId(driveFolder.Id));
        }
Example #4
0
        public string RenameFolder(Folder <string> folder, string newTitle)
        {
            var boxFolder      = GetBoxFolder(folder.ID);
            var parentFolderId = GetParentFolderId(boxFolder);

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

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

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

            return(MakeId(boxFolder.Id));
        }
Example #5
0
        public IEnumerable <Tag> GetNewTags(Guid subject, Folder <string> parentFolder, bool deepSearch)
        {
            var folderId = DaoSelector.ConvertId(parentFolder.ID);

            var fakeFolderId = parentFolder.ID.ToString();

            var entryIDs = FilesDbContext.ThirdpartyIdMapping
                           .Where(r => r.Id.StartsWith(fakeFolderId))
                           .Select(r => r.HashId)
                           .ToList();

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

            var q = FilesDbContext.Tag
                    .Join(FilesDbContext.TagLink.DefaultIfEmpty(),
                          r => new TagLink {
                TenantId = r.TenantId, Id = r.Id
            },
                          r => new TagLink {
                TenantId = r.TenantId, Id = r.TagId
            },
                          (tag, tagLink) => new { tag, tagLink },
                          new TagLinkComparer())
                    .Where(r => r.tag.TenantId == TenantID)
                    .Where(r => r.tag.Flag == TagType.New)
                    .Where(r => r.tagLink.TenantId == TenantID)
                    .Where(r => entryIDs.Any(a => a == r.tagLink.EntryId));

            if (subject != Guid.Empty)
            {
                q = q.Where(r => r.tag.Owner == subject);
            }

            var tags = q
                       .ToList()
                       .Select(r => new Tag
            {
                TagName   = r.tag.Name,
                TagType   = r.tag.Flag,
                Owner     = r.tag.Owner,
                EntryId   = MappingID(r.tagLink.EntryId),
                EntryType = r.tagLink.EntryType,
                Count     = r.tagLink.TagCount,
                Id        = r.tag.Id
            });

            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())));
        }
        // ===============================================================================
        //                                                                      Initialize
        //                                                                      ==========
        public void InitializeConditionBeanMetaData()
        {
            Map <String, DBMeta> dbmetaMap = DBMetaInstanceHandler.GetUnmodifiableDBMetaMap();
            Collection <DBMeta>  dbmetas   = dbmetaMap.values();
            DateTime?            before    = null;

            if (_log.IsInfoEnabled)
            {
                before = DateTime.Now;
                _log.Info("/= = = = = = = = = = = = = = = = = InitializeConditionBeanMetaData()");
            }
            foreach (DBMeta dbmeta in dbmetas)
            {
                DaoReadable dao    = DaoSelector.ByName(dbmeta.TableDbName);
                MethodInfo  method = dao.GetType().GetMethod("InitializeDaoMetaData");
                if (method == null)
                {
                    continue;
                }
                method.Invoke(dao, new Object[] { "SelectList" });
            }
            if (_log.IsInfoEnabled)
            {
                DateTime after = DateTime.Now;
                _log.Info("Initialized Count: " + dbmetas.size());
                _log.Info("= = = = = = = = = =/ [" + TraceViewUtil.ConvertToPerformanceView(before.Value, after) + "]");
            }
        }
Example #7
0
        public File <string> SaveFile(File <string> file, Stream fileStream)
        {
            if (fileStream == null)
            {
                throw new ArgumentNullException("fileStream");
            }

            if (file.ID != null)
            {
                var sharePointFile = ProviderInfo.CreateFile(file.ID, fileStream);

                var resultFile = ProviderInfo.ToFile(sharePointFile);
                if (!sharePointFile.Name.Equals(file.Title))
                {
                    var folder = ProviderInfo.GetFolderById(file.FolderID);
                    file.Title = GetAvailableTitle(file.Title, folder, IsExist);

                    var id = ProviderInfo.RenameFile(DaoSelector.ConvertId(resultFile.ID).ToString(), file.Title);
                    return(GetFile(DaoSelector.ConvertId(id)));
                }
                return(resultFile);
            }

            if (file.FolderID != null)
            {
                var folder = ProviderInfo.GetFolderById(file.FolderID);
                file.Title = GetAvailableTitle(file.Title, folder, IsExist);
                return(ProviderInfo.ToFile(ProviderInfo.CreateFile(folder.ServerRelativeUrl + "/" + file.Title, fileStream)));
            }

            return(null);
        }
Example #8
0
        public string RenameFolder(Folder <string> folder, string newTitle)
        {
            var oldId       = ProviderInfo.MakeId(folder.ID);
            var newFolderId = oldId;

            if (ProviderInfo.SpRootFolderId.Equals(folder.ID))
            {
                //It's root folder
                DaoSelector.RenameProvider(ProviderInfo, newTitle);
                //rename provider customer title
            }
            else
            {
                newFolderId = (string)ProviderInfo.RenameFolder(folder.ID, newTitle);
            }
            UpdatePathInDB(oldId, newFolderId);
            return(newFolderId);
        }