Esempio n. 1
0
 public async Task <IActionResult> Export(string id, string driveName = null)
 {
     try
     {
         var fileObject = _manager.Export(id, driveName);
         return(File(fileObject.Result?.Content, fileObject.Result?.ContentType, fileObject.Result?.Name));
     }
     catch (Exception ex)
     {
         return(ex.GetActionResult());
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> Export(string id)
        {
            try
            {
                Guid automationId;
                Guid.TryParse(id, out automationId);

                Automation automation = repository.GetOne(automationId);

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

                var fileObject = manager.Export(automation.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(NotFound(ModelState));
                }

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