public async Task <string> DownloadFileContent([FromQuery] string share, [FromQuery] string directory, [FromQuery] string fileName) { var cloudManager = new CloudStorageManager(_cloudConnectionString); var fileContent = await cloudManager.DownloadContentAsync(share, directory, fileName); return(fileContent); }
/// <summary> /// Put files to the cloud and call OMR task /// </summary> /// <param name="actionName">The action name string</param> /// <param name="fileName">The file name</param> /// <param name="fileData">The file data</param> /// <param name="functionParam">The function parameters</param> /// <param name="wasUploaded">Indicates if image was already uploaded on cloud</param> /// <param name="trackFile">Track file so that it can be deleted from cloud</param> /// <param name="additionalParam">The additional (debug) parameters</param> /// <returns>Task response</returns> public static OMRResponse RunOmrTask(string actionName, string fileName, byte[] fileData, string functionParam, bool wasUploaded, bool trackFile, string additionalParam) { if (string.IsNullOrEmpty(AppKey) || string.IsNullOrEmpty(AppSid)) { throw new Exception("Please specify App Key and App SID in Settings->Credentials in order to use OMR functions."); } if (!wasUploaded) { BusyIndicatorManager.UpdateText("Uploading files..."); if (trackFile) { CloudStorageManager.TrackFileUpload(fileName); } StorageApi storageApi = new StorageApi(AppKey, AppSid, Basepath); storageApi.PutCreate(fileName, "", "", fileData); } OmrApi omrApi = new OmrApi(AppKey, AppSid, Basepath); OMRFunctionParam param = new OMRFunctionParam(); param.FunctionParam = functionParam; param.AdditionalParam = additionalParam; BusyIndicatorManager.UpdateText("Processing task..."); OMRResponse response = omrApi.PostRunOmrTask(fileName, actionName, param, null, null); CheckForError(response); return(response); }
public Settings(CloudStorageManager storageManager) { InitializeComponent(); this.storageManager = storageManager; for (int i = 0; i < storageManager.clouds.Count; i++) { storageManager.clouds[i].settings = this; } }
public async Task <string> DownloadVisaMapContent() { if (_memoryCache.TryGetValue("WorldVisaMapSource", out string worldVisaMap)) { return(worldVisaMap); } var cloudManager = new CloudStorageManager(_cloudConnectionString); var share = _configuration.GetValue <string>("Sources:VisaMapShare"); var directory = _configuration.GetValue <string>("Sources:VisaMapDirectory"); var fileName = _configuration.GetValue <string>("Sources:VisaMapSource"); worldVisaMap = await cloudManager.DownloadContentAsync(share, directory, fileName); _memoryCache.Set("WorldVisaMapSource", worldVisaMap, TimeSpan.FromDays(1)); return(worldVisaMap); }
private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { int filesCount = CloudStorageManager.UploadedFilesCount; if (filesCount > 0) { if (DialogManager.ShowConfirmDialog("During Your session " + filesCount + " files were uploaded for recognition to Aspose.Cloud Storage. Would like to delete them?")) { try { CloudStorageManager.CleanUpStorage(); e.Cancel = true; } catch { DialogManager.ShowErrorDialog("An error occured while attempting to delete files from storage. Please visit Cloud Dashboard to manage storage files."); } } } }
private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { // run data checks in view model var mainViewModel = this.DataContext as MainViewModel; if (mainViewModel != null) { bool result = mainViewModel.CleanUpOnClosing(); // closing was cancelled by user if (!result) { e.Cancel = true; return; } } // clean up on storage int filesCount = CloudStorageManager.UploadedFilesCount; if (filesCount > 0) { if (DialogManager.ShowConfirmDialog("During Your session " + filesCount + " files were uploaded for the recognition to the Aspose.Cloud Storage. Would you like to delete them?")) { try { CloudStorageManager.CleanUpStorage(); e.Cancel = true; } catch { DialogManager.ShowErrorDialog("An error occurred while attempting to delete files from the storage. Please visit Cloud Dashboard to manage storage files."); } } } }
/// <summary> /// Put files to the cloud and call OMR task /// </summary> /// <param name="action">The executed OMR function</param> /// <param name="fileName">The file name</param> /// <param name="fileData">The file data</param> /// <param name="functionParam">The function parameters</param> /// <param name="wasUploaded">Indicates if image was already uploaded on cloud</param> /// <param name="trackFile">Track file so that it can be deleted from cloud</param> /// <param name="additionalParam">The additional (debug) parameters</param> /// <returns>Task response</returns> public static OMRResponse RunOmrTask(OmrFunctions action, string fileName, byte[] fileData, string functionParam, bool wasUploaded, bool trackFile, string additionalParam) { if (string.IsNullOrEmpty(AppKey) || string.IsNullOrEmpty(AppSid)) { throw new Exception("Please specify App Key and App SID in Settings->Credentials in order to use OMR functions."); } if (!wasUploaded) { BusyIndicatorManager.UpdateText("Uploading files..."); if (trackFile) { CloudStorageManager.TrackFileUpload(fileName); } try { string baseHost = new Uri(Basepath).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped).ToString(); Configuration storageConfiguration = new Configuration(); storageConfiguration.AppKey = AppKey; storageConfiguration.AppSid = AppSid; storageConfiguration.ApiBaseUrl = baseHost; StorageApi storageApi = new StorageApi(storageConfiguration); using (Stream stream = new MemoryStream(fileData)) { storageApi.PutCreate(new PutCreateRequest(fileName, stream)); } } catch (ApiException e) { if (e.ErrorCode == 401) { // handle authentification exception throw new Exception("Aspose Cloud Authentification Failed! Please check App Key and App SID in Settings->Credentials."); } throw; } } OmrApi omrApi = new OmrApi(AppKey, AppSid, Basepath); OMRFunctionParam param = new OMRFunctionParam(); param.FunctionParam = functionParam; param.AdditionalParam = additionalParam; string busyMessage = ""; switch (action) { case OmrFunctions.CorrectTemplate: busyMessage = "Performing Template Correction..."; break; case OmrFunctions.FinalizeTemplate: busyMessage = "Performing Template Finalization..."; break; case OmrFunctions.RecognizeImage: busyMessage = "Performing Recognition..."; break; case OmrFunctions.GenerateTemplate: busyMessage = "Generating Template..."; break; } BusyIndicatorManager.UpdateText(busyMessage); OMRResponse response = omrApi.PostRunOmrTask(fileName, action.ToString(), param, null, null); CheckForError(response); return(response); }