public async Task EnsureStartedAsync(string fileName = null) { using (await _lock.LockAsync()) { try { //we keep just one instance of the server manager per projec if (CurrentProject != null && GetActiveProject(fileName).UniqueName != GetCurrentProjectUniqueNameSafely()) { _overwriteTemplatesDuringNextSync = true; await StopAsync(); } Trace.WriteLine("Creating server"); _serverManager = _serverManager ?? CreateServerManager(fileName); Trace.WriteLine("Created"); await RemoteTask.ClientComplete(_serverManager.EnsureStartedAsync(), CancellationToken.None) .ConfigureAwait(false); } catch (Exception e) { CurrentProject = null; _serverManager = null; Trace.TraceError("Failed to start jsreport server " + e); throw; } } }
public async Task <object> RenderAsync(string shortid, string sampleData) { return (await RemoteTask.ClientComplete(_serverManager.RenderAsync(shortid, sampleData), CancellationToken.None) .ConfigureAwait(false)); }
public async Task <int> SynchronizeTemplatesAsync() { //we want to provide all the jsrep files into shadow bin folder where is actual jsreport.Client running FileSystemHelpers.DeleteFilesInDirectory(CurrentBinFolder, "*.jsrep*"); FileSystemHelpers.DeleteFilesInDirectory(CurrentShadowBinFolder, "*.jsrep*"); //problem is visual studio does not delete old files in bin folder when moving files between folders, therefor //I need to take files from vs project and cannot rely on bin fodler string projectPath = new FileInfo(GetActiveProject().FullName).DirectoryName; foreach ( ProjectItem reportItem in GetActiveProject().GetAllProjectItems().Where(i => i.Name.Contains(".jsrep"))) { string filePath = Path.Combine(new FileInfo(reportItem.FileNames[0]).DirectoryName, reportItem.Name); File.Copy(filePath, filePath.Replace(projectPath, CurrentBinFolder), true); } FileSystemHelpers.Copy(CurrentBinFolder, CurrentShadowBinFolder, "*.jsrep*", _overwriteTemplatesDuringNextSync); _overwriteTemplatesDuringNextSync = false; return (await RemoteTask.ClientComplete(_serverManager.SynchronizeTemplatesAsync(), CancellationToken.None) .ConfigureAwait(false)); }
public async Task StopAsync() { using (await _lock.LockAsync()) { Trace.WriteLine("Stopping server"); try { ClearCache(); if (_serverManager != null) { IReportingServerManager tmpServerManager = _serverManager; _serverManager = null; await RemoteTask.ClientComplete(tmpServerManager.StopAsync(), CancellationToken.None) .ConfigureAwait(false); } } //stopping does not need to go well catch (Exception e) { Trace.TraceError(e.ToString()); } finally { Trace.WriteLine("Stoppedr"); } } }
public async Task <IEnumerable <string> > GetEnginesAsync(string fileName) { if (_cachedEngines == null) { await EnsureStartedAsync(fileName).ConfigureAwait(false); _cachedEngines = await RemoteTask.ClientComplete(_serverManager.GetEnginesAsync(), CancellationToken.None) .ConfigureAwait(false); } return(_cachedEngines); }