public FileResult GetPresentation([FromBody] PresentationFile presentation) { _pythonCaller.callPython(PythonPath, presentation); byte[] fileBytes = System.IO.File.ReadAllBytes(@"Presentations\DemoPresentationWithPython.pptx"); string fileName = "DemoPresentation.pptx"; return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); }
public async Task <OperationResult <string> > SaveFile(Stream fileStream) { var fileId = Guid.NewGuid().ToString("N"); fileStream.Seek(0, SeekOrigin.Begin); var thumbResult = await _thumbnailsRepo.AddThumbnailFor(fileId, fileStream); if (thumbResult.ErrorMessageIfAny != null) { return(new OperationResult <string> { ErrorMessageIfAny = thumbResult.ErrorMessageIfAny }); } var newFile = new PresentationFile(); newFile.FileID = fileId; await _context.PresentationFiles.AddAsync(newFile); await _context.SaveChangesAsync(); var filePathResult = CreatePathFor(fileId); if (filePathResult.ErrorMessageIfAny != null) { return(new OperationResult <string> { ErrorMessageIfAny = filePathResult.ErrorMessageIfAny }); } var fs = AirshowUtils.CreateFileToWriteAtPath(filePathResult.Value); if (fs == null) { return(new OperationResult <string> { ErrorMessageIfAny = OperationStatus.kInvalidFileNameOrAlreadyExists }); } fileStream.Seek(0, SeekOrigin.Begin); await fileStream.CopyToAsync(fs); fs.Dispose(); return(new OperationResult <string> { Value = newFile.FileID }); }
public void callPython(string pathToPython, PresentationFile presentation) { ProcessStartInfo start = new ProcessStartInfo(); start.FileName = pathToPython; start.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\" \"{3}\"", @"PythonScripts\PowerPointScript", presentation.ChartTitle, presentation.FirstValue, presentation.SecondValue); start.UseShellExecute = false; // Do not use OS shell start.CreateNoWindow = true; // We don't need new window start.RedirectStandardOutput = true; // Any output, generated by application will be redirected back start.RedirectStandardError = true; // Any error in standard output will be redirected back (for example exceptions) using (Process process = Process.Start(start)) { } }
/// <summary> /// /// </summary> /// <param name="result"></param> private void CreatePresentationCallBackMethod(PresentationFile result) { string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name); Logging.LogBeginMethod(logger, methodNamespace); try { if (result != null && result.PresentationId > 0) { Logging.LogMethodParameter(logger, methodNamespace, result, 1); /* eventAggregator.GetEvent<ToolboxUpdateEvent>().Publish(DashboardCategoryType.INVESTMENT_COMMITTEE_PRESENTATIONS); * ICNavigation.Update(ICNavigationInfo.MeetingInfo, iCPresentationOverviewInfo); * regionManager.RequestNavigate(RegionNames.MAIN_REGION, "ViewDashboardICPresentation", UriKind.Relative);*/ iCPresentationOverviewInfo.PresentationID = result.PresentationId; DownloadStream.Write(result.FileStream, 0, result.FileStream.Length); DownloadStream.Close(); DownloadStream = null; ICNavigation.Update(ICNavigationInfo.PresentationOverviewInfo, iCPresentationOverviewInfo); eventAggregator.GetEvent <ToolboxUpdateEvent>().Publish(DashboardCategoryType.INVESTMENT_COMMITTEE_IC_PRESENTATION); regionManager.RequestNavigate(RegionNames.MAIN_REGION, new Uri("ViewDashboardICPresentation", UriKind.Relative)); } else { Logging.LogMethodParameterNull(logger, methodNamespace, 1); } } catch (Exception ex) { Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK); Logging.LogException(logger, ex); } finally { Logging.LogEndMethod(logger, methodNamespace); BusyIndicatorNotification(); } }