protected override void Do()
        {
            var entries = new List <FileEntry>();

            if (Folders.Any())
            {
                entries.AddRange(FolderDao.GetFolders(Folders.ToArray()));
            }
            if (Files.Any())
            {
                entries.AddRange(FileDao.GetFiles(Files.ToArray()));
            }
            entries.ForEach(x =>
            {
                CancellationToken.ThrowIfCancellationRequested();

                FileMarker.RemoveMarkAsNew(x, ((IAccount)Thread.CurrentPrincipal.Identity).ID);

                if (x.FileEntryType == FileEntryType.File)
                {
                    ProcessedFile(x.ID.ToString());
                }
                else
                {
                    ProcessedFolder(x.ID.ToString());
                }
                ProgressStep();
            });

            var newrootfolder = FileMarker
                                .GetRootFoldersIdMarkedAsNew()
                                .Select(item => string.Format("new_{{\"key\"? \"{0}\", \"value\"? \"{1}\"}}", item.Key, item.Value));

            Status += string.Join(SPLIT_CHAR, newrootfolder.ToArray());
        }
Ejemplo n.º 2
0
        public void RunJob(DistributedTask _, CancellationToken cancellationToken)
        {
            try
            {
                CancellationToken = cancellationToken;

                CoreContext.TenantManager.SetCurrentTenant(CurrentTenant);
                Thread.CurrentPrincipal               = principal;
                Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(culture);
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);

                FolderDao     = Global.DaoFactory.GetFolderDao();
                FileDao       = Global.DaoFactory.GetFileDao();
                TagDao        = Global.DaoFactory.GetTagDao();
                ProviderDao   = Global.DaoFactory.GetProviderDao();
                FilesSecurity = new FileSecurity(Global.DaoFactory);
                LinkDao       = Global.GetLinkDao();

                Logger = Global.Logger;

                Total = InitTotalProgressSteps();

                Do();
            }
            catch (AuthorizingException authError)
            {
                Error = FilesCommonResource.ErrorMassage_SecurityException;
                Logger.Error(Error, new SecurityException(Error, authError));
            }
            catch (AggregateException ae)
            {
                ae.Flatten().Handle(e => e is TaskCanceledException || e is OperationCanceledException);
            }
            catch (Exception error)
            {
                Error = error is TaskCanceledException || error is OperationCanceledException
                            ? FilesCommonResource.ErrorMassage_OperationCanceledException
                            : error.Message;
                Logger.Error(error, error);
            }
            finally
            {
                try
                {
                    TaskInfo.SetProperty(FINISHED, true);
                    PublishTaskInfo();

                    FolderDao.Dispose();
                    FileDao.Dispose();
                    TagDao.Dispose();
                    LinkDao.Dispose();

                    if (ProviderDao != null)
                    {
                        ProviderDao.Dispose();
                    }
                }
                catch { /* ignore */ }
            }
        }
Ejemplo n.º 3
0
        protected virtual double InitProgressStep()
        {
            var count = Files.Count;

            Folders.ForEach(f => count += FolderDao.GetItemsCount(f, true));
            return(count == 0 ? 100d : 100d / count);
        }
Ejemplo n.º 4
0
        protected virtual int InitTotalProgressSteps()
        {
            var count = Files.Count;

            Folders.ForEach(f => count += 1 + (FolderDao.CanCalculateSubitems(f) ? FolderDao.GetItemsCount(f) : 0));
            return(count);
        }
Ejemplo n.º 5
0
        private object GetOrCreateHierarchy(string path, Folder root)
        {
            path = path != null?path.Trim('/') : null;

            if (string.IsNullOrEmpty(path))
            {
                return(root.ID);
            }

            var pos   = path.IndexOf("/");
            var title = 0 < pos?path.Substring(0, pos) : path;

            path = 0 < pos?path.Substring(pos + 1) : null;

            title = Global.ReplaceInvalidCharsAndTruncate(title);

            var folder = FolderDao.GetFolder(title, root.ID);

            if (folder == null)
            {
                folder = new Folder
                {
                    ParentFolderID = root.ID,
                    Title          = title,
                    FolderType     = FolderType.DEFAULT
                };
                folder.ID = FolderDao.SaveFolder(folder);
            }
            return(GetOrCreateHierarchy(path, folder));
        }
Ejemplo n.º 6
0
        private ItemNameValueCollection GetFilesInFolders(IEnumerable <object> folderIds, string path)
        {
            CancellationToken.ThrowIfCancellationRequested();

            var entriesPathId = new ItemNameValueCollection();

            foreach (var folderId in folderIds)
            {
                var folder = FolderDao.GetFolder(folderId);
                if (folder == null || !FilesSecurity.CanRead(folder))
                {
                    continue;
                }
                var folderPath = path + folder.Title + "/";

                var files = FileDao.GetFiles(folder.ID, null, FilterType.None, Guid.Empty, string.Empty);
                files = FilesSecurity.FilterRead(files).ToList();
                files.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, folderPath)));

                FileMarker.RemoveMarkAsNew(folder);

                var nestedFolders = FolderDao.GetFolders(folder.ID);
                nestedFolders = FilesSecurity.FilterRead(nestedFolders).ToList();
                if (files.Count == 0 && nestedFolders.Count == 0)
                {
                    entriesPathId.Add(folderPath, String.Empty);
                }

                var filesInFolder = GetFilesInFolders(nestedFolders.ConvertAll(f => f.ID), folderPath);
                entriesPathId.Add(filesInFolder);
            }
            return(entriesPathId);
        }
Ejemplo n.º 7
0
        public void DeleteFolder()
        {
            //  Create a new Folder and write it to the database.
            Folder folder = User.CreateAndAddFolder();

            FolderManager.Save(folder);

            //  Now delete the created Playlist and ensure it is removed.
            FolderManager.Delete(folder.Id);

            //  Remove entity from NHibernate cache to force DB query to ensure actually created.
            NHibernateSessionManager.Instance.Clear();

            Folder deletedFolder = FolderDao.Get(folder.Id);

            bool objectNotFoundExceptionEncountered = false;

            try
            {
                //  Evaluating a lazyily-loaded entity which isn't in the database will throw an ONF exception.
                Assert.IsNull(deletedFolder);
            }
            catch (ObjectNotFoundException)
            {
                objectNotFoundExceptionEncountered = true;
            }

            Assert.IsTrue(objectNotFoundExceptionEncountered);
        }
Ejemplo n.º 8
0
        protected override void Do()
        {
            _trashId = FolderDao.GetFolderIDTrash(true);
            Folder root = null;

            if (0 < Folders.Count)
            {
                root = FolderDao.GetRootFolder(Folders[0]);
            }
            else if (0 < Files.Count)
            {
                root = FolderDao.GetRootFolderByFile(Files[0]);
            }
            if (root != null)
            {
                Status += string.Format("folder_{0}{1}", root.ID, SPLIT_CHAR);
            }
            if (_isEmptyTrash)
            {
                DeleteFiles(Files);
                DeleteFolders(Folders);
                MessageService.Send(_headers, MessageAction.TrashEmptied);
            }
            else
            {
                DeleteFiles(Files, true);
                DeleteFolders(Folders, true);
            }
        }
Ejemplo n.º 9
0
        public override IEnumerable <Tuple <Feed.Aggregator.Feed, object> > GetFeeds(FeedFilter filter)
        {
            var files = FileDao.GetFeeds(filter.Tenant, filter.Time.From, filter.Time.To)
                        .Where(f => f.Item1.RootFolderType != FolderType.TRASH && f.Item1.RootFolderType != FolderType.BUNCH)
                        .ToList();

            var folderIDs = files.Select(r => r.Item1.FolderID).ToArray();
            var folders   = FolderDao.GetFolders(folderIDs, checkShare: false);

            return(files.Select(f => new Tuple <Feed.Aggregator.Feed, object>(ToFeed(f, folders.FirstOrDefault(r => r.ID.Equals(f.Item1.FolderID))), f)));
        }
Ejemplo n.º 10
0
        public void SaveFolder_FolderDoesNotExist_FolderCreated()
        {
            Folder folder = new Folder();

            FolderManager.Save(folder);

            //  Remove entity from NHibernate cache to force DB query to ensure actually created.
            NHibernateSessionManager.Instance.Clear();

            Folder folderFromDatabase = FolderDao.Get(folder.Id);

            Assert.IsNotNull(folderFromDatabase);
        }
Ejemplo n.º 11
0
        private Feed ToFeed(Tuple <File, SmallShareRecord> tuple)
        {
            var file        = tuple.Item1;
            var shareRecord = tuple.Item2;

            var rootFolder = new FolderDao(Tenant, DbId).GetFolder(file.FolderID);

            if (shareRecord != null)
            {
                var feed = new Feed(shareRecord.ShareBy, shareRecord.ShareOn, true)
                {
                    Item             = sharedFileItem,
                    ItemId           = string.Format("{0}_{1}", file.ID, shareRecord.ShareTo),
                    ItemUrl          = FilesLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                    Product          = Product,
                    Module           = Name,
                    Title            = file.Title,
                    ExtraLocation    = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                    ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? FilesLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                    AdditionalInfo   = file.ContentLengthString,
                    Keywords         = string.Format("{0}", file.Title),
                    HasPreview       = false,
                    CanComment       = false,
                    Target           = shareRecord.ShareTo,
                    GroupId          = GetGroupId(sharedFileItem, shareRecord.ShareBy, file.FolderID.ToString())
                };

                return(feed);
            }

            var updated = file.Version != 1;

            return(new Feed(file.ModifiedBy, file.ModifiedOn, true)
            {
                Item = fileItem,
                ItemId = string.Format("{0}_{1}", file.ID, file.Version > 1 ? 1 : 0),
                ItemUrl = FilesLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                Product = Product,
                Module = Name,
                Action = updated ? FeedAction.Updated : FeedAction.Created,
                Title = file.Title,
                ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? FilesLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                AdditionalInfo = file.ContentLengthString,
                Keywords = string.Format("{0}", file.Title),
                HasPreview = false,
                CanComment = false,
                Target = null,
                GroupId = GetGroupId(fileItem, file.ModifiedBy, file.FolderID.ToString(), updated ? 1 : 0)
            });
        }
        private void DeleteFiles(IEnumerable <object> fileIds)
        {
            foreach (var fileId in fileIds)
            {
                CancellationToken.ThrowIfCancellationRequested();

                var    file = FileDao.GetFile(fileId);
                string tmpError;
                if (file == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FileNotFound;
                }
                else if (!_ignoreException && WithError(new[] { file }, false, out tmpError))
                {
                    Error = tmpError;
                }
                else
                {
                    FileMarker.RemoveMarkAsNewForAll(file);
                    if (!_immediately && FileDao.UseTrashForRemove(file))
                    {
                        FileDao.MoveFile(file.ID, _trashId);
                        FilesMessageService.Send(file, _headers, MessageAction.FileMovedToTrash, file.Title);

                        if (file.ThumbnailStatus == Thumbnail.Waiting)
                        {
                            file.ThumbnailStatus = Thumbnail.NotRequired;
                            FileDao.SaveThumbnail(file, null);
                        }
                    }
                    else
                    {
                        try
                        {
                            FileDao.DeleteFile(file.ID);
                            FilesMessageService.Send(file, _headers, MessageAction.FileDeleted, file.Title);
                        }
                        catch (Exception ex)
                        {
                            Error = ex.Message;
                            Logger.Error(Error, ex);
                        }

                        LinkDao.DeleteAllLink(file.ID);
                    }
                    ProcessedFile(fileId);
                }
                ProgressStep(fileId: FolderDao.CanCalculateSubitems(fileId) ? null : fileId);
            }
        }
Ejemplo n.º 13
0
        protected override void Do(IServiceScope scope)
        {
            var fileMarker = scope.ServiceProvider.GetService <FileMarker>();

            Status += string.Format("folder_{0}{1}", _toFolderId, FileOperation.SPLIT_CHAR);

            //TODO: check on each iteration?
            var toFolder = FolderDao.GetFolder(_toFolderId);

            if (toFolder == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(toFolder))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (FolderDao.GetParentFolders(toFolder.ID).Any(parent => Folders.Contains(parent.ID.ToString())))
            {
                Error = FilesCommonResource.ErrorMassage_FolderCopyError;
                return;
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (toFolder.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(scope, Folders, toFolder, _copy);
            MoveOrCopyFiles(scope, Files, toFolder, _copy);

            _needToMark.Distinct().ToList().ForEach(x => fileMarker.MarkAsNew(x));
        }
Ejemplo n.º 14
0
        private void DeleteFiles(List <object> fileIds)
        {
            foreach (var fileId in fileIds)
            {
                CancellationToken.ThrowIfCancellationRequested();

                var file = FileDao.GetFile(fileId);
                if (file == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FileNotFound;
                }
                else if (!ignoreException && EntryManager.FileLockedForMe(file.ID))
                {
                    Error = FilesCommonResource.ErrorMassage_LockedFile;
                }
                else if (!ignoreException && FileTracker.IsEditing(file.ID))
                {
                    Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteEditingFile;
                }
                else if (!ignoreException && !FilesSecurity.CanDelete(file))
                {
                    Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFile;
                }
                else
                {
                    FileMarker.RemoveMarkAsNewForAll(file);
                    if (FileDao.UseTrashForRemove(file))
                    {
                        FileDao.MoveFile(file.ID, trashId);
                        FilesMessageService.Send(file, headers, MessageAction.FileMovedToTrash, file.Title);
                    }
                    else
                    {
                        try
                        {
                            FileDao.DeleteFile(file.ID);
                            FileDao.DeleteFolder(file.ID);
                        }
                        catch (Exception ex)
                        {
                            Error = ex.Message;
                            Logger.Error(Error, ex);
                        }
                    }
                    ProcessedFile(fileId);
                }
                ProgressStep(fileId: FolderDao.CanCalculateSubitems(fileId) ? null : fileId);
            }
        }
Ejemplo n.º 15
0
        protected virtual double InitProgressStep()
        {
            var count = Files.Count;

            if (CountWithoutSubitems)
            {
                count += Folders.Count;
            }
            else
            {
                Folders.ForEach(f => count += FolderDao.GetItemsCount(f, true));
            }

            return(count == 0 ? 100d : 100d / count);
        }
Ejemplo n.º 16
0
        private Feed ToFeed(File file)
        {
            var rootFolder = new FolderDao(Tenant, DbId).GetFolder(file.FolderID);

            if (file.SharedToMeOn.HasValue)
            {
                var feed = new Feed(new Guid(file.SharedToMeBy), file.SharedToMeOn.Value, true)
                {
                    Item            = sharedFileItem,
                    ItemId          = string.Format("{0}_{1}", file.ID, file.CreateByString),
                    ItemUrl         = CommonLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                    Product         = Product,
                    Module          = Name,
                    Title           = file.Title,
                    AdditionalInfo  = file.ContentLengthString,
                    AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                    AdditionalInfo3 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                    Keywords        = string.Format("{0}", file.Title),
                    HasPreview      = false,
                    CanComment      = false,
                    Target          = file.CreateByString,
                    GroupId         = GetGroupId(sharedFileItem, new Guid(file.SharedToMeBy), file.FolderID.ToString())
                };

                return(feed);
            }

            var updated = file.Version != 1;

            return(new Feed(file.ModifiedBy, file.ModifiedOn)
            {
                Item = fileItem,
                ItemId = string.Format("{0}_{1}", file.ID, file.Version > 1 ? 1 : 0),
                ItemUrl = CommonLinkUtility.GetFileRedirectPreviewUrl(file.ID, true),
                Product = Product,
                Module = Name,
                Action = updated ? FeedAction.Updated : FeedAction.Created,
                Title = file.Title,
                AdditionalInfo = file.ContentLengthString,
                AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                AdditionalInfo3 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(file.FolderID, false) : string.Empty,
                Keywords = string.Format("{0}", file.Title),
                HasPreview = false,
                CanComment = false,
                Target = null,
                GroupId = GetGroupId(fileItem, file.ModifiedBy, file.FolderID.ToString(), updated ? 1 : 0)
            });
        }
        protected override void Do()
        {
            Percentage = 0;

            var entries = Enumerable.Empty <FileEntry>();

            if (Folders.Any())
            {
                entries = entries.Concat(FolderDao.GetFolders(Folders.ToArray()));
            }

            if (Files.Any())
            {
                entries = entries.Concat(FileDao.GetFiles(Files.ToArray()));
            }

            entries.ToList().ForEach(x =>
            {
                if (Canceled)
                {
                    return;
                }

                FileMarker.RemoveMarkAsNew(x, Owner);

                if (x is File)
                {
                    ProcessedFile(x.ID.ToString());
                    ResultedFile(x.ID.ToString());
                }
                else
                {
                    ProcessedFolder(x.ID.ToString());
                    ResultedFolder(x.ID.ToString());
                }

                ProgressStep();
            });

            var rootFolderIdAsNew =
                FileMarker.GetRootFoldersIdMarkedAsNew()
                .Select(item => string.Format("new_{{\"key\"? \"{0}\", \"value\"? \"{1}\"}}", item.Key, item.Value));

            Status += string.Join(SplitCharacter, rootFolderIdAsNew.ToArray());

            IsCompleted = true;
        }
Ejemplo n.º 18
0
        private Feed ToFeed(Tuple <Folder, SmallShareRecord> tuple)
        {
            var folder      = tuple.Item1;
            var shareRecord = tuple.Item2;

            var rootFolder = new FolderDao(Tenant, DbId).GetFolder(folder.ParentFolderID);

            if (shareRecord != null)
            {
                var feed = new Feed(shareRecord.ShareBy, shareRecord.ShareOn, true)
                {
                    Item             = sharedFolderItem,
                    ItemId           = string.Format("{0}_{1}", folder.ID, shareRecord.ShareTo),
                    ItemUrl          = FilesLinkUtility.GetFileRedirectPreviewUrl(folder.ID, false),
                    Product          = Product,
                    Module           = Name,
                    Title            = folder.Title,
                    ExtraLocation    = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                    ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? FilesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentFolderID, false) : string.Empty,
                    Keywords         = string.Format("{0}", folder.Title),
                    HasPreview       = false,
                    CanComment       = false,
                    Target           = shareRecord.ShareTo,
                    GroupId          = GetGroupId(sharedFolderItem, shareRecord.ShareBy, folder.ParentFolderID.ToString())
                };

                return(feed);
            }

            return(new Feed(folder.CreateBy, folder.CreateOn)
            {
                Item = folderItem,
                ItemId = folder.ID.ToString(),
                ItemUrl = FilesLinkUtility.GetFileRedirectPreviewUrl(folder.ID, false),
                Product = Product,
                Module = Name,
                Title = folder.Title,
                ExtraLocation = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                ExtraLocationUrl = rootFolder.FolderType == FolderType.DEFAULT ? FilesLinkUtility.GetFileRedirectPreviewUrl(folder.ParentFolderID, false) : string.Empty,
                Keywords = string.Format("{0}", folder.Title),
                HasPreview = false,
                CanComment = false,
                Target = null,
                GroupId = GetGroupId(folderItem, folder.CreateBy, folder.ParentFolderID.ToString())
            });
        }
Ejemplo n.º 19
0
        private void DeleteFiles(IEnumerable <object> fileIds, IServiceScope scope)
        {
            var fileMarker          = scope.ServiceProvider.GetService <FileMarker>();
            var filesMessageService = scope.ServiceProvider.GetService <FilesMessageService>();

            foreach (var fileId in fileIds)
            {
                CancellationToken.ThrowIfCancellationRequested();

                var file = FileDao.GetFile(fileId);
                if (file == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FileNotFound;
                }
                else if (!_ignoreException && WithError(scope, new[] { file }, false, out var tmpError))
                {
                    Error = tmpError;
                }
                else
                {
                    fileMarker.RemoveMarkAsNewForAll(file);
                    if (!_immediately && FileDao.UseTrashForRemove(file))
                    {
                        FileDao.MoveFile(file.ID, _trashId);
                        filesMessageService.Send(file, _headers, MessageAction.FileMovedToTrash, file.Title);
                    }
                    else
                    {
                        try
                        {
                            FileDao.DeleteFile(file.ID);
                            filesMessageService.Send(file, _headers, MessageAction.FileDeleted, file.Title);
                        }
                        catch (Exception ex)
                        {
                            Error = ex.Message;
                            Logger.Error(Error, ex);
                        }
                    }
                    ProcessedFile(fileId);
                }
                ProgressStep(fileId: FolderDao.CanCalculateSubitems(fileId) ? null : fileId);
            }
        }
Ejemplo n.º 20
0
        private Feed ToFeed(Folder folder)
        {
            var rootFolder = new FolderDao(Tenant, DbId).GetFolder(folder.ParentFolderID);

            if (folder.SharedToMeOn.HasValue)
            {
                var feed = new Feed(new Guid(folder.SharedToMeBy), folder.SharedToMeOn.Value, true)
                {
                    Item            = sharedFolderItem,
                    ItemId          = string.Format("{0}_{1}", folder.ID, folder.CreateByString),
                    ItemUrl         = CommonLinkUtility.GetFileRedirectPreviewUrl(folder.ID, false),
                    Product         = Product,
                    Module          = Name,
                    Title           = folder.Title,
                    AdditionalInfo  = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                    AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(folder.ParentFolderID, false) : string.Empty,
                    Keywords        = string.Format("{0}", folder.Title),
                    HasPreview      = false,
                    CanComment      = false,
                    Target          = folder.CreateByString,
                    GroupId         = GetGroupId(sharedFolderItem, new Guid(folder.SharedToMeBy), folder.ParentFolderID.ToString())
                };

                return(feed);
            }

            return(new Feed(folder.CreateBy, folder.CreateOn)
            {
                Item = folderItem,
                ItemId = folder.ID.ToString(),
                ItemUrl = CommonLinkUtility.GetFileRedirectPreviewUrl(folder.ID, false),
                Product = Product,
                Module = Name,
                Title = folder.Title,
                AdditionalInfo = rootFolder.FolderType == FolderType.DEFAULT ? rootFolder.Title : string.Empty,
                AdditionalInfo2 = rootFolder.FolderType == FolderType.DEFAULT ? CommonLinkUtility.GetFileRedirectPreviewUrl(folder.ParentFolderID, false) : string.Empty,
                Keywords = string.Format("{0}", folder.Title),
                HasPreview = false,
                CanComment = false,
                Target = null,
                GroupId = GetGroupId(folderItem, folder.CreateBy, folder.ParentFolderID.ToString())
            });
        }
Ejemplo n.º 21
0
        public override IEnumerable <Tuple <Feed, object> > GetFeeds(FeedFilter filter)
        {
            var q1 = new SqlQuery("files_folder f")
                     .Select(FolderColumns().Select(f => "f." + f).ToArray())
                     .Select(DocumentsDbHelper.GetRootFolderType("parent_id"))
                     .Select("null, null, null")
                     .Where(
                Exp.Eq("f.tenant_id", filter.Tenant) &
                Exp.Eq("f.folder_type", 0) &
                Exp.Between("f.create_on", filter.Time.From, filter.Time.To)
                );

            var q2 = new SqlQuery("files_folder f")
                     .LeftOuterJoin("files_security s",
                                    Exp.EqColumns("s.entry_id", "f.id") &
                                    Exp.Eq("s.tenant_id", filter.Tenant) &
                                    Exp.Eq("s.entry_type", (int)FileEntryType.Folder)
                                    )
                     .Select(FolderColumns().Select(f => "f." + f).ToArray())
                     .Select(DocumentsDbHelper.GetRootFolderType("parent_id"))
                     .Select("s.timestamp, s.owner, s.subject")
                     .Where(
                Exp.Eq("f.tenant_id", filter.Tenant) &
                Exp.Eq("f.folder_type", 0) &
                Exp.Lt("s.security", 3) &
                Exp.Between("s.timestamp", filter.Time.From, filter.Time.To)
                );

            List <Tuple <Folder, SmallShareRecord> > folders;

            using (var db = new DbManager(DbId))
            {
                folders = db.ExecuteList(q1.UnionAll(q2))
                          .ConvertAll(ToFolder)
                          .Where(f => f.Item1.RootFolderType != FolderType.TRASH && f.Item1.RootFolderType != FolderType.BUNCH)
                          .ToList();
            }

            var parentFolderIDs = folders.Select(r => r.Item1.ParentFolderID).ToArray();
            var parentFolders   = new FolderDao(Tenant, DbId).GetFolders(parentFolderIDs, checkShare: false);

            return(folders.Select(f => new Tuple <Feed, object>(ToFeed(f, parentFolders.FirstOrDefault(r => r.ID.Equals(f.Item1.ParentFolderID))), f)));
        }
Ejemplo n.º 22
0
        protected override void Do()
        {
            Status += string.Format("folder_{0}{1}", _toFolderId, SplitCharacter);

            //TODO: check on each iteration?
            var toFolder = FolderDao.GetFolder(_toFolderId);

            if (toFolder == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(toFolder))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (toFolder.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(Folders, toFolder, _copy);
            MoveOrCopyFiles(Files, toFolder, _copy, _resolveType);

            _needToMarkAsNew.Distinct().ToList().ForEach(x => FileMarker.MarkAsNew(x, _markAsNewRecipientIDs));
        }
Ejemplo n.º 23
0
        private ItemNameValueCollection GetEntriesPathId()
        {
            var entriesPathId = new ItemNameValueCollection();

            if (0 < Files.Count)
            {
                var files = FileDao.GetFiles(Files.ToArray());
                files = FilesSecurity.FilterRead(files).ToList();
                files.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, string.Empty)));
            }
            if (0 < Folders.Count)
            {
                FilesSecurity.FilterRead(FolderDao.GetFolders(Files.ToArray())).ToList().Cast <FileEntry>().ToList()
                .ForEach(folder => FileMarker.RemoveMarkAsNew(folder));

                var filesInFolder = GetFilesInFolders(Folders, string.Empty);
                entriesPathId.Add(filesInFolder);
            }
            return(entriesPathId);
        }
        protected override void Do()
        {
            _trashId = FolderDao.GetFolderIDTrash(true);
            Folder root = null;

            if (0 < Folders.Count)
            {
                root = FolderDao.GetRootFolder(Folders[0]);
            }
            else if (0 < Files.Count)
            {
                root = FolderDao.GetRootFolderByFile(Files[0]);
            }
            if (root != null)
            {
                Status += string.Format("folder_{0}{1}", root.ID, SPLIT_CHAR);
            }

            DeleteFiles(Files);
            DeleteFolders(Folders);
        }
Ejemplo n.º 25
0
        protected override void Do()
        {
            Status += string.Format("folder_{0}{1}", _toFolder, splitCharacter);

            //TODO: check on each iteration?
            var to = FolderDao.GetFolder(_toFolder);

            if (to == null)
            {
                return;
            }
            if (!FilesSecurity.CanCreate(to))
            {
                throw new System.Security.SecurityException(FilesCommonResource.ErrorMassage_SecurityException_Create);
            }

            if (_copy)
            {
                Folder rootFrom = null;
                if (0 < Folders.Count)
                {
                    rootFrom = FolderDao.GetRootFolder(Folders[0]);
                }
                if (0 < Files.Count)
                {
                    rootFrom = FolderDao.GetRootFolderByFile(Files[0]);
                }
                if (rootFrom != null && rootFrom.FolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy from Trash.");
                }
                if (to.RootFolderType == FolderType.TRASH)
                {
                    throw new InvalidOperationException("Can not copy to Trash.");
                }
            }

            MoveOrCopyFolders(Folders, _toFolder, _copy);
            MoveOrCopyFiles(Files, _toFolder, _copy, _resolveType);
        }
Ejemplo n.º 26
0
        private NameValueCollection GetFilesInFolders(IList <object> folderIds, string path)
        {
            if (Canceled)
            {
                return(null);
            }

            var result = new NameValueCollection();

            foreach (var folderId in folderIds)
            {
                var folder = FolderDao.GetFolder(folderId);
                if (folder == null || !FilesSecurity.CanRead(folder))
                {
                    continue;
                }
                var folderPath = path + folder.Title + "/";

                var files = FilesSecurity.FilterRead(FolderDao.GetFiles(folder.ID, null, FilterType.None, Guid.Empty, string.Empty)).ToList();
                files.ForEach(f => result.Add(folderPath + f.Title, f.ID.ToString()));
                TagDao.RemoveTags(files.Select(f => Tag.New(SecurityContext.CurrentAccount.ID, f)).ToArray());

                var nestedFolders = FilesSecurity.FilterRead(FolderDao.GetFolders(folder.ID)).ToList();
                if (files.Count == 0 && nestedFolders.Count == 0)
                {
                    result.Add(folderPath, String.Empty);
                }

                var filesInFolder = GetFilesInFolders(nestedFolders.ConvertAll(f => f.ID), folderPath);
                if (filesInFolder == null)
                {
                    return(null);
                }
                result.Add(filesInFolder);
            }
            return(result);
        }
Ejemplo n.º 27
0
        private ItemNameValueCollection GetEntriesPathId(out List <File> filesForSend, out List <Folder> folderForSend)
        {
            filesForSend  = new List <File>();
            folderForSend = new List <Folder>();

            var entriesPathId = new ItemNameValueCollection();

            if (0 < Files.Count)
            {
                filesForSend = FilesSecurity.FilterDownload(FileDao.GetFiles(Files));
                filesForSend.ForEach(file => entriesPathId.Add(ExecPathFromFile(file, string.Empty)));
            }
            if (0 < Folders.Count)
            {
                folderForSend = FolderDao.GetFolders(Folders);
                folderForSend = FilesSecurity.FilterDownload(folderForSend);
                folderForSend.ForEach(folder => FileMarker.RemoveMarkAsNew(folder));

                var filesInFolder = GetFilesInFolders(folderForSend.Select(x => x.ID), string.Empty);
                entriesPathId.Add(filesInFolder);
            }

            if (Folders.Count == 1 && Files.Count == 0)
            {
                var entriesPathIdWithoutRoot = new ItemNameValueCollection();

                foreach (var path in entriesPathId.AllKeys)
                {
                    entriesPathIdWithoutRoot.Add(path.Remove(0, path.IndexOf('/') + 1), entriesPathId[path]);
                }

                return(entriesPathIdWithoutRoot);
            }

            return(entriesPathId);
        }
        private void MoveOrCopyFiles(ICollection fileIds, Folder toFolder, bool copy)
        {
            if (fileIds.Count == 0)
            {
                return;
            }

            var toFolderId = toFolder.ID;

            foreach (var fileId in fileIds)
            {
                CancellationToken.ThrowIfCancellationRequested();

                var file = FileDao.GetFile(fileId);
                if (file == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FileNotFound;
                }
                else if (!FilesSecurity.CanRead(file))
                {
                    Error = FilesCommonResource.ErrorMassage_SecurityException_ReadFile;
                }
                else if (Global.EnableUploadFilter &&
                         !FileUtility.ExtsUploadable.Contains(FileUtility.GetFileExtension(file.Title)))
                {
                    Error = FilesCommonResource.ErrorMassage_NotSupportedFormat;
                }
                else if (file.ContentLength > SetupInfo.AvailableFileSize &&
                         file.ProviderId != toFolder.ProviderId)
                {
                    Error = string.Format(copy ? FilesCommonResource.ErrorMassage_FileSizeCopy : FilesCommonResource.ErrorMassage_FileSizeMove,
                                          FileSizeComment.FilesSizeToString(SetupInfo.AvailableFileSize));
                }
                else
                {
                    var parentFolder = FolderDao.GetFolder(file.FolderID);
                    try
                    {
                        var conflict = resolveType == FileConflictResolveType.Duplicate
                                           ? null
                                           : FileDao.GetFile(toFolderId, file.Title);
                        if (conflict != null && !FilesSecurity.CanEdit(conflict))
                        {
                            Error = FilesCommonResource.ErrorMassage_SecurityException;
                        }
                        else if (conflict != null && EntryManager.FileLockedForMe(conflict.ID))
                        {
                            Error = FilesCommonResource.ErrorMassage_LockedFile;
                        }
                        else if (conflict == null)
                        {
                            if (copy)
                            {
                                File newFile = null;
                                try
                                {
                                    newFile = FileDao.CopyFile(file.ID, toFolderId); //Stream copy will occur inside dao
                                    FilesMessageService.Send(file, toFolder, headers, MessageAction.FileCopied, file.Title, parentFolder.Title, toFolder.Title);

                                    if (Equals(newFile.FolderID.ToString(), this.toFolderId))
                                    {
                                        needToMark.Add(newFile);
                                    }

                                    if (ProcessedFile(fileId))
                                    {
                                        Status += string.Format("file_{0}{1}", newFile.ID, SPLIT_CHAR);
                                    }
                                }
                                catch
                                {
                                    if (newFile != null)
                                    {
                                        FileDao.DeleteFile(newFile.ID);
                                    }
                                    throw;
                                }
                            }
                            else
                            {
                                if (EntryManager.FileLockedForMe(file.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_LockedFile;
                                }
                                else if (FileTracker.IsEditing(file.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                }
                                else if (FilesSecurity.CanDelete(file))
                                {
                                    FileMarker.RemoveMarkAsNewForAll(file);

                                    var newFileId = FileDao.MoveFile(file.ID, toFolderId);
                                    FilesMessageService.Send(file, toFolder, headers, MessageAction.FileMoved, file.Title, parentFolder.Title, toFolder.Title);

                                    if (Equals(toFolderId.ToString(), this.toFolderId))
                                    {
                                        needToMark.Add(FileDao.GetFile(newFileId));
                                    }

                                    if (ProcessedFile(fileId))
                                    {
                                        Status += string.Format("file_{0}{1}", newFileId, SPLIT_CHAR);
                                    }
                                }
                                else
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFile;
                                }
                            }
                        }
                        else
                        {
                            if (resolveType == FileConflictResolveType.Overwrite)
                            {
                                if (EntryManager.FileLockedForMe(conflict.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_LockedFile;
                                }
                                else if (FileTracker.IsEditing(conflict.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                }
                                else
                                {
                                    var newFile = conflict;
                                    newFile.Version++;
                                    newFile.ContentLength = conflict.ContentLength;

                                    using (var stream = FileDao.GetFileStream(file))
                                    {
                                        newFile = FileDao.SaveFile(newFile, stream);
                                    }

                                    needToMark.Add(newFile);

                                    if (copy)
                                    {
                                        FilesMessageService.Send(file, toFolder, headers, MessageAction.FileCopiedWithOverwriting, file.Title, parentFolder.Title, toFolder.Title);
                                        if (ProcessedFile(fileId))
                                        {
                                            Status += string.Format("file_{0}{1}", newFile.ID, SPLIT_CHAR);
                                        }
                                    }
                                    else
                                    {
                                        if (Equals(file.FolderID.ToString(), toFolderId.ToString()))
                                        {
                                            if (ProcessedFile(fileId))
                                            {
                                                Status += string.Format("file_{0}{1}", newFile.ID, SPLIT_CHAR);
                                            }
                                        }
                                        else
                                        {
                                            if (EntryManager.FileLockedForMe(file.ID))
                                            {
                                                Error = FilesCommonResource.ErrorMassage_LockedFile;
                                            }
                                            else if (FileTracker.IsEditing(file.ID))
                                            {
                                                Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                            }
                                            else if (FilesSecurity.CanDelete(file))
                                            {
                                                FileDao.DeleteFile(file.ID);
                                                FileDao.DeleteFolder(file.ID);

                                                FilesMessageService.Send(file, toFolder, headers, MessageAction.FileMovedWithOverwriting, file.Title, parentFolder.Title, toFolder.Title);

                                                if (ProcessedFile(fileId))
                                                {
                                                    Status += string.Format("file_{0}{1}", newFile.ID, SPLIT_CHAR);
                                                }
                                            }
                                            else
                                            {
                                                Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFile;
                                            }
                                        }
                                    }
                                }
                            }
                            else if (resolveType == FileConflictResolveType.Skip)
                            {
                                //nothing
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Error = ex.Message;
                        Logger.Error(Error, ex);
                    }
                }
                ProgressStep(fileId: FolderDao.CanCalculateSubitems(fileId) ? null : fileId);
            }
        }
        private void MoveOrCopyFolders(ICollection folderIds, Folder toFolder, bool copy)
        {
            if (folderIds.Count == 0)
            {
                return;
            }

            var toFolderId = toFolder.ID;
            var isToFolder = Equals(toFolderId.ToString(), this.toFolderId);

            foreach (var folderId in folderIds)
            {
                CancellationToken.ThrowIfCancellationRequested();

                var folder = FolderDao.GetFolder(folderId);
                if (folder == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FolderNotFound;
                }
                else if (!FilesSecurity.CanRead(folder))
                {
                    Error = FilesCommonResource.ErrorMassage_SecurityException_ReadFolder;
                }
                else if (!Equals((folder.ParentFolderID ?? string.Empty).ToString(), toFolderId.ToString()) || resolveType == FileConflictResolveType.Duplicate)
                {
                    try
                    {
                        //if destination folder contains folder with same name then merge folders
                        var conflictFolder = FolderDao.GetFolder(folder.Title, toFolderId);

                        if (copy || conflictFolder != null)
                        {
                            Folder newFolder;
                            if (conflictFolder != null)
                            {
                                newFolder = conflictFolder;

                                if (isToFolder)
                                {
                                    needToMark.Add(conflictFolder);
                                }
                            }
                            else
                            {
                                newFolder = FolderDao.CopyFolder(folder.ID, toFolderId);
                                FilesMessageService.Send(folder, toFolder, headers, MessageAction.FolderCopied, folder.Title, toFolder.Title);

                                if (isToFolder)
                                {
                                    needToMark.Add(newFolder);
                                }

                                if (ProcessedFolder(folderId))
                                {
                                    Status += string.Format("folder_{0}{1}", newFolder.ID, SPLIT_CHAR);
                                }
                            }

                            if (FolderDao.UseRecursiveOperation(folder.ID, toFolderId))
                            {
                                MoveOrCopyFiles(FileDao.GetFiles(folder.ID), newFolder, copy);
                                MoveOrCopyFolders(FolderDao.GetFolders(folder.ID).Select(f => f.ID).ToList(), newFolder, copy);

                                if (!copy)
                                {
                                    if (FolderDao.IsEmpty(folder.ID) && FilesSecurity.CanDelete(folder))
                                    {
                                        FolderDao.DeleteFolder(folder.ID);
                                        if (ProcessedFolder(folderId))
                                        {
                                            Status += string.Format("folder_{0}{1}", newFolder.ID, SPLIT_CHAR);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (conflictFolder != null)
                                {
                                    object newFolderId;
                                    if (copy)
                                    {
                                        newFolder   = FolderDao.CopyFolder(folder.ID, toFolderId);
                                        newFolderId = newFolder.ID;
                                        FilesMessageService.Send(folder, toFolder, headers, MessageAction.FolderCopiedWithOverwriting, folder.Title, toFolder.Title);

                                        if (isToFolder)
                                        {
                                            needToMark.Add(newFolder);
                                        }
                                    }
                                    else
                                    {
                                        newFolderId = FolderDao.MoveFolder(folder.ID, toFolderId);
                                        FilesMessageService.Send(folder, toFolder, headers, MessageAction.FolderMovedWithOverwriting, folder.Title, toFolder.Title);

                                        if (isToFolder)
                                        {
                                            needToMark.Add(FolderDao.GetFolder(newFolderId));
                                        }
                                    }

                                    if (ProcessedFolder(folderId))
                                    {
                                        Status += string.Format("folder_{0}{1}", newFolderId, SPLIT_CHAR);
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (FilesSecurity.CanDelete(folder))
                            {
                                FileMarker.RemoveMarkAsNewForAll(folder);

                                var newFolderId = FolderDao.MoveFolder(folder.ID, toFolderId);
                                FilesMessageService.Send(folder, toFolder, headers, MessageAction.FolderMoved, folder.Title, toFolder.Title);

                                if (isToFolder)
                                {
                                    needToMark.Add(FolderDao.GetFolder(newFolderId));
                                }

                                if (ProcessedFolder(folderId))
                                {
                                    Status += string.Format("folder_{0}{1}", newFolderId, SPLIT_CHAR);
                                }
                            }
                            else
                            {
                                Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFolder;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Error = ex.Message;

                        Logger.Error(Error, ex);
                    }
                }
                ProgressStep(FolderDao.CanCalculateSubitems(folderId) ? null : folderId);
            }
        }
Ejemplo n.º 30
0
        private void MoveOrCopyFiles(ICollection fileIds, Folder toFolder, bool copy)
        {
            if (fileIds.Count == 0)
            {
                return;
            }

            var toFolderId = toFolder.ID;

            foreach (var fileId in fileIds)
            {
                if (Canceled)
                {
                    return;
                }

                var file = FileDao.GetFile(fileId);
                if (file == null)
                {
                    Error = FilesCommonResource.ErrorMassage_FileNotFound;
                }
                else if (!FilesSecurity.CanRead(file))
                {
                    Error = FilesCommonResource.ErrorMassage_SecurityException_ReadFile;
                }
                else if (Global.EnableUploadFilter &&
                         !FileUtility.ExtsUploadable.Contains(FileUtility.GetFileExtension(file.Title)))
                {
                    Error = FilesCommonResource.ErrorMassage_NotSupportedFormat;
                }
                else // if (!Equals(file.FolderID.ToString(), toFolderId.ToString()) || _resolveType == FileConflictResolveType.Duplicate)
                {
                    var parentFolder = FolderDao.GetFolder(file.FolderID);
                    try
                    {
                        var conflict = _resolveType == FileConflictResolveType.Duplicate
                                           ? null
                                           : FileDao.GetFile(toFolderId, file.Title);
                        if (conflict != null && !FilesSecurity.CanEdit(conflict))
                        {
                            Error = FilesCommonResource.ErrorMassage_SecurityException;
                        }
                        else if (conflict != null && EntryManager.FileLockedForMe(conflict.ID))
                        {
                            Error = FilesCommonResource.ErrorMassage_LockedFile;
                        }
                        else if (conflict == null)
                        {
                            if (copy)
                            {
                                File newFile = null;
                                try
                                {
                                    newFile = FileDao.CopyFile(file.ID, toFolderId); //Stream copy will occur inside dao
                                    FilesMessageService.Send(file, toFolder, httpRequestHeaders, MessageAction.FileCopied, file.Title, parentFolder.Title, toFolder.Title);

                                    if (Equals(newFile.FolderID.ToString(), _toFolderId))
                                    {
                                        _needToMarkAsNew.Add(newFile);
                                    }

                                    if (ProcessedFile(fileId))
                                    {
                                        Status += string.Format("file_{0}{1}", newFile.ID, SplitCharacter);
                                        ResultedFile(newFile.ID);
                                    }
                                }
                                catch
                                {
                                    if (newFile != null)
                                    {
                                        FileDao.DeleteFile(newFile.ID);
                                    }
                                    throw;
                                }
                            }
                            else
                            {
                                if (EntryManager.FileLockedForMe(file.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_LockedFile;
                                }
                                else if (FileTracker.IsEditing(file.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                }
                                else if (FilesSecurity.CanDelete(file))
                                {
                                    FileMarker.RemoveMarkAsNewForAll(file);

                                    var newFileId = FileDao.MoveFile(file.ID, toFolderId);
                                    FilesMessageService.Send(file, toFolder, httpRequestHeaders, MessageAction.FileMoved, file.Title, parentFolder.Title, toFolder.Title);

                                    if (Equals(toFolderId.ToString(), _toFolderId))
                                    {
                                        _needToMarkAsNew.Add(FileDao.GetFile(newFileId));
                                    }

                                    if (ProcessedFile(fileId))
                                    {
                                        Status += string.Format("file_{0}{1}", newFileId, SplitCharacter);
                                        ResultedFile(newFileId);
                                    }
                                }
                                else
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFile;
                                }
                            }
                        }
                        else
                        {
                            if (_resolveType == FileConflictResolveType.Overwrite)
                            {
                                if (EntryManager.FileLockedForMe(conflict.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_LockedFile;
                                }
                                else if (FileTracker.IsEditing(conflict.ID))
                                {
                                    Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                }
                                else
                                {
                                    conflict.Version++;
                                    using (var stream = FileDao.GetFileStream(file))
                                    {
                                        conflict.ContentLength = stream.Length;
                                        conflict.Comment       = string.Empty;
                                        conflict = FileDao.SaveFile(conflict, stream);

                                        _needToMarkAsNew.Add(conflict);
                                    }

                                    if (copy)
                                    {
                                        FilesMessageService.Send(file, toFolder, httpRequestHeaders, MessageAction.FileCopiedWithOverwriting, file.Title, parentFolder.Title, toFolder.Title);
                                        if (ProcessedFile(fileId))
                                        {
                                            Status += string.Format("file_{0}{1}", conflict.ID, SplitCharacter);
                                            ResultedFile(conflict.ID);
                                        }
                                    }
                                    else
                                    {
                                        if (Equals(file.FolderID.ToString(), toFolderId.ToString()))
                                        {
                                            if (ProcessedFile(fileId))
                                            {
                                                Status += string.Format("file_{0}{1}", conflict.ID, SplitCharacter);
                                                ResultedFile(conflict.ID);
                                            }
                                        }
                                        else
                                        {
                                            if (EntryManager.FileLockedForMe(file.ID))
                                            {
                                                Error = FilesCommonResource.ErrorMassage_LockedFile;
                                            }
                                            else if (FileTracker.IsEditing(file.ID))
                                            {
                                                Error = FilesCommonResource.ErrorMassage_SecurityException_UpdateEditingFile;
                                            }
                                            else if (FilesSecurity.CanDelete(file))
                                            {
                                                FileDao.DeleteFile(file.ID);
                                                FileDao.DeleteFolder(file.ID);

                                                FilesMessageService.Send(file, toFolder, httpRequestHeaders, MessageAction.FileMovedWithOverwriting, file.Title, parentFolder.Title, toFolder.Title);

                                                if (ProcessedFile(fileId))
                                                {
                                                    Status += string.Format("file_{0}{1}", conflict.ID, SplitCharacter);
                                                    ResultedFile(conflict.ID);
                                                }
                                            }
                                            else
                                            {
                                                Error = FilesCommonResource.ErrorMassage_SecurityException_DeleteFile;
                                            }
                                        }
                                    }
                                }
                            }
                            else if (_resolveType == FileConflictResolveType.Skip)
                            {
                                //nothing
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Error = ex.Message;
                        Logger.Error(Error, ex);
                    }
                }
                ProgressStep();
            }
        }