Пример #1
0
        protected virtual string ExtractBlobFromRow(List list, Row row, Column column, string listBlobsPath)
        {
            if (list == null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }

            if (column == null)
            {
                throw new ArgumentNullException(nameof(column));
            }

            if (listBlobsPath == null)
            {
                throw new ArgumentNullException(nameof(listBlobsPath));
            }

            var blobProperties = row.GetValue <Dictionary <string, object> >(column.Name, null);

            if (blobProperties == null)
            {
                return(null);
            }

            var blob = new Blob(blobProperties, column, row, list.Parent.Server);

            if (blob == null)
            {
                return(null);
            }

            blob.DownloadFile();
            if (blob.TempFilePath == null)
            {
                return(null);
            }

            LongPath.DirectoryCreate(listBlobsPath);

            var blobFilePath = GetUniqueBlobFilePath(blob, listBlobsPath);

            LongPath.FileCopy(blob.TempFilePath, blobFilePath, true);

            AddMessage("Blob extracted",
                       folderId: list.Parent.IdN,
                       folderName: list.Parent.DisplayName,
                       listId: list.IdN,
                       listName: list.DisplayName,
                       rowId: row.IdN,
                       rowName: row.DisplayName,
                       blobId: blob.ImageUrl,
                       blobName: ((IUploadableFile)blob).FormName);

            return(blobFilePath);
        }
Пример #2
0
        protected virtual void ExportFolderContent(Folder folder, string targetPath, bool recursive)
        {
            string folderExportPath;

            try
            {
                if (!WriteFolder(folder, targetPath, out folderExportPath))
                {
                    AddMessage("Folder skipped", folderId: folder.IdN, folderName: folder.DisplayName);
                    return;
                }

                if (folderExportPath == null)
                {
                    // it means it will not be hierarchical
                    folderExportPath = targetPath;
                }

                LongPath.DirectoryCreate(folderExportPath);
                AddMessage("Folder created", folderId: folder.IdN, folderName: folder.DisplayName);
            }
            catch (Exception ex)
            {
                AddError(ex, folder.IdN, folder.DisplayName);
                return;
            }

            folder.LazyLoadChildren();
            if (recursive)
            {
                foreach (var childFolder in folder.Children.OfType <Folder>())
                {
                    ExportFolderContent(childFolder, folderExportPath, true);
                    if (_errorMessages.Count > 0 && !Options.ContinueOnError)
                    {
                        AddMessage("Folder processing failed", folderId: folder.IdN, folderName: folder.DisplayName);
                        return;
                    }
                }
            }

            foreach (var childList in folder.Children.OfType <List>())
            {
                try
                {
                    string listPath;
                    var    msg = WriteList(childList, folderExportPath, out listPath) ? "created" : "skipped";
                    AddMessage("List " + msg,
                               folderId: childList.Parent.IdN,
                               folderName: childList.Parent.DisplayName,
                               listId: childList.IdN,
                               listName: childList.DisplayName);
                }
                catch (Exception ex)
                {
                    AddError(ex,
                             folderId: childList.Parent.IdN,
                             folderName: childList.Parent.DisplayName,
                             listId: childList.IdN,
                             listName: childList.DisplayName);

                    if (!Options.ContinueOnError)
                    {
                        AddMessage("Folder processing failed", folderId: folder.IdN, folderName: folder.DisplayName);
                        return;
                    }
                }
            }

            AddMessage("Folder processed", folderId: folder.IdN, folderName: folder.DisplayName);
        }