public ExportSettingsModel GetExportSettings(int implementationGuideId, ExportFormats format) { IGSettingsManager igSettings = new IGSettingsManager(this.tdb, implementationGuideId); string settingsProperty = "ExportSettings_" + format.ToString(); if (format == ExportFormats.Microsoft_Word_DOCX) { var legacyExportSettings = this.GetLegacyMSWordExportSettings(igSettings, settingsProperty); if (legacyExportSettings != null) { return(legacyExportSettings); } } string exportSettingsJson = igSettings.GetSetting(settingsProperty); if (!string.IsNullOrEmpty(exportSettingsJson)) { var settings = JsonConvert.DeserializeObject <ExportSettingsModel>(exportSettingsJson); settings.ImplementationGuideId = implementationGuideId; settings.ExportFormat = format; return(settings); } return(new ExportSettingsModel() { ImplementationGuideId = implementationGuideId, ExportFormat = format, SelectAll = true }); }
public void SaveExportSettings([FromBody] ExportSettingsModel model, [FromUri] int implementationGuideId, [FromUri] ExportFormats format) { if (!CheckPoint.Instance.GrantEditImplementationGuide(implementationGuideId)) { throw new UnauthorizedAccessException("You do not have permissions to save default settings for this implementation guide."); } IGSettingsManager igSettings = new IGSettingsManager(this.tdb, implementationGuideId); string settingsJson = JsonConvert.SerializeObject(model); string settingsProperty = "ExportSettings_" + format.ToString(); igSettings.SaveSetting(settingsProperty, settingsJson); }
public async Task <string> ExportAsync(string inputId, ExportFormats exportToFormat, string callbackUrl = null) { var url = "web-api/operation/export"; var request = new ExportOperationRequest { InputId = inputId, ExportToFormat = exportToFormat.ToString(), CallbackUrl = callbackUrl }; var result = await PostOperationAsync(url, request); return(result); }
public async Task ExportDataAsync(Action <Stream> exportMethod, ExportFormats format, string path = null) { try { if (path == null) { path = XtraInputBox.Show($"File location: {Application.StartupPath}", "File Name", "file name") ?? "data"; } using (FileStream stream = new FileStream(Path.Combine(Application.StartupPath, $"{path}.{format.ToString().ToLower()}"), FileMode.OpenOrCreate)) { await Task.Run(() => exportMethod?.Invoke(stream)); stream.Close(); } } catch (Exception e) { _logger.Log(e.Message); } }
public void ExportData(Action <Stream> exportMethod, ExportFormats format, string path = null) { try { using (FileStream stream = new FileStream(path ?? Path.Combine(Application.StartupPath, $"data.{format.ToString().ToLower()}"), FileMode.OpenOrCreate)) { exportMethod?.Invoke(stream); stream.Close(); } } catch (Exception e) { _logger.Log(e.Message); } }