Esempio n. 1
0
        public async Task <IActionResult> Export(string id)
        {
            try
            {
                Guid processId;
                Guid.TryParse(id, out processId);

                Process process = repository.GetOne(processId);

                if (process == null || process.BinaryObjectId == null || process.BinaryObjectId == Guid.Empty)
                {
                    ModelState.AddModelError("Process Export", "No process or process file found");
                    return(BadRequest(ModelState));
                }

                var fileObject = manager.Export(process.BinaryObjectId.ToString());
                return(File(fileObject?.Result?.BlobStream, fileObject?.Result?.ContentType, fileObject?.Result?.Name));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
        public async Task <IActionResult> ExportAsset(string id)
        {
            try
            {
                Guid assetId;
                Guid.TryParse(id, out assetId);

                Asset asset = repository.GetOne(assetId);

                if (asset == null || asset.BinaryObjectID == null || asset.BinaryObjectID == Guid.Empty)
                {
                    ModelState.AddModelError("Asset Export", "No asset or asset file found");
                    return(BadRequest(ModelState));
                }

                var fileObject = processManager.Export(asset.BinaryObjectID.ToString());
                var file       = File(fileObject?.Result?.BlobStream, fileObject?.Result?.ContentType, fileObject?.Result?.Name);
                return(file);
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }