private IDocumentEntity ManageFilesAndFolderTree(IDocumentEntity entity, IEnumerable <IDocumentEntity> entities) { var folders = entities.Where(c => c.ParentId == entity.ContractResourceFileGuid).ToList(); foreach (var f in folders) { var f1 = ManageFilesAndFolderTree(f, entities); f1.FilePath = f1.FilePath.Replace("\\", "/"); entity.Subfolders.Add(f1); } return(entity); }
public void CreateFileOrFolder(IDocumentEntity entity) { var sql = @"INSERT INTO [ContractResourceFile] ([ContractResourceFileGuid] ,[MasterStructureGuid] ,[MasterFolderGuid] ,[ParentId] ,[ResourceGuid] ,[UploadFileName] ,[ResourceType] ,[Keys] ,[MimeType] ,[IsActive] ,[IsDeleted] ,[CreatedBy] ,[UpdatedBy] ,[CreatedOn] ,[UpdatedOn] ,[IsCsv] ,[Description] ,[FilePath] ,[FileSize] ,[UploadUniqueFileName] ,[IsFile] ,[IsReadOnly]) VALUES (@ContractResourceFileGuid ,@MasterStructureGuid ,@MasterFolderGuid ,@ParentId ,@ResourceGuid ,@UploadFileName ,@ResourceType ,@Keys ,@MimeType ,@IsActive ,@IsDeleted ,@CreatedBy ,@UpdatedBy ,@CreatedOn ,@UpdatedOn ,@IsCsv ,@Description ,@FilePath ,@FileSize ,@UploadUniqueFileName ,@IsFile ,@IsReadOnly)"; _context.Connection.Execute(sql, entity); }
private IDocumentEntity ManageFolderTree(IDocumentEntity entity, IEnumerable <IDocumentEntity> entities) { var folders = entities.Where(c => c.ParentId == entity.ContractResourceFileGuid && c.IsFile == false).ToList(); foreach (var f in folders) { var f1 = ManageFolderTree(f, entities); f1.FilePath = f1.FilePath.Replace("\\", "/"); //f1.folderfilecounts = CountChildern(f, entities); entity.Subfolders.Add(f1); f1.UploadFileName = f1.UploadFileName + " <small style='color:red'>(" + f1.folderfilecounts + ")</small>"; } return(entity); }
private void onRenameChildFoldersAndFiles(IDocumentEntity entity, Guid userGuid) { var result = _repository.GetFilesAndFoldersByParentId(entity.ResourceType, entity.ContractResourceFileGuid); foreach (var folder in result) { folder.FilePath = entity.FilePath + "/" + folder.UploadFileName; folder.UploadUniqueFileName = folder.UploadFileName; folder.UpdatedBy = userGuid; folder.UpdatedOn = DateTime.UtcNow; _repository.UpdateFileOrFolder(folder); if (folder.IsFile == false) { onRenameChildFoldersAndFiles(folder, userGuid); } } }
public void UpdateFileOrFolder(IDocumentEntity entity) { var sql = @"UPDATE [ContractResourceFile] SET [ParentId] = @ParentId ,[UploadFileName] = @UploadFileName ,[MimeType] = @MimeType ,[IsActive] = @IsActive ,[IsDeleted] = @IsDeleted ,[UpdatedBy] = @UpdatedBy ,[UpdatedOn] = @UpdatedOn ,[IsCsv] = @IsCsv ,[Description] = @Description ,[FilePath] = @FilePath ,[FileSize] = @FileSize ,[UploadUniqueFileName] = @UploadUniqueFileName ,[IsFile] = @IsFile WHERE ContractResourceFileGuid=@ContractResourceFileGuid "; _context.Connection.Execute(sql, entity); }
private int CountChildern(IDocumentEntity entity, IEnumerable <IDocumentEntity> entities) { //var xt = (from x in entities where x.IsFile == true && x.ParentId == entity.ContractResourceFileGuid select x).Count() + entity.Subfolders.Sum(ch => CountChildern(ch, entities)); //return xt; return(entity.folderfilecounts); }
/// <summary> /// Saves or updates the entities having reference to <see cref="IDocumentEntity"/> interface. /// </summary> /// <param name="iDocumentEntity"><see cref="IDocumentEntity"/> interface</param> /// <param name="isCopy">If set to <c>true</c> SaveOrUpdateCopy will be used, else SaveOrUpdate.</param> public void SaveOrUpdateDocumentEntity(IDocumentEntity iDocumentEntity, bool isCopy) { try { DocumentGateway documentGateway = new DocumentGateway(); if (iDocumentEntity.GetType().Equals(typeof(DocumentInfoEntity))) { documentGateway.SaveOrUpdateDocumentInfoSP(iDocumentEntity); } else if (isCopy) documentGateway.SaveOrUpdateInMemoryEntity<IDocument>(AllInOne.Legal.DataMapper.BackEnd.DomainToNHibernate.ObjectMapper.DocumentMapper.GetDocumentEntity<IDocumentEntity>(iDocumentEntity)); else documentGateway.SaveOrUpdateEntity<IDocument>(AllInOne.Legal.DataMapper.BackEnd.DomainToNHibernate.ObjectMapper.DocumentMapper.GetDocumentEntity<IDocumentEntity>(iDocumentEntity)); } catch (Exception ex) { Logger.Error("Error at SaveOrUpdateDocumentEntity", ex); Logger.Error("Error in SaveOrUpdateDocumentEntity: Message - " + ex.Message + " StackTrace - " + ex.StackTrace); throw; } }
public void CreateFileOrFolder(IDocumentEntity entity) { _repository.CreateFileOrFolder(entity); }