public void Configuration(IAppBuilder app) { RVScheduler.run_jobs(); // Any connection or hub wire up and configuration should go here if (RaaiVanSettings.RealTime(null)) { app.MapSignalR("/signalr", new HubConfiguration()); } else { app.Map("/signalr", conf => { conf.Use((context, next) => { ParamsContainer paramsContainer = new ParamsContainer(HttpContext.Current); paramsContainer.file_response("var daslkdjhalskfh84t94uthgk = {\"Message\":\"-)\"};", "empty.js", "text/javascript", isAttachment: false); return(next()); }); }); } //Ignore SSL certificate check for web requests ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; //end of Ignore SSL certificate check for web requests app.Map("/ui", spa => { spa.Use((context, next) => { context.Request.Path = new PathString("/ui/build/index.html"); return(next()); }); spa.UseStaticFiles(); }); ConfigureAuth(app); }
protected void send_file(DocFileInfo file, bool logNeeded, bool addPDFCover = false, bool addPDFFooter = false, Guid?coverId = null, string pdfPassword = null, string contentType = null, bool isAttachment = true) { byte[] fileContent = file.toByteArray(paramsContainer.ApplicationID); if (fileContent.Length == 0) { send_empty_response(); return; } //Save Log if (logNeeded && paramsContainer.CurrentUserID.HasValue) { LogController.save_log(paramsContainer.Tenant.Id, new Log() { UserID = paramsContainer.CurrentUserID, Date = DateTime.Now, HostAddress = PublicMethods.get_client_ip(HttpContext.Current), HostName = PublicMethods.get_client_host_name(HttpContext.Current), Action = Modules.Log.Action.Download, SubjectID = file.FileID, Info = file.toJson(paramsContainer.Tenant.Id), ModuleIdentifier = ModuleIdentifier.DCT }); } //end of Save Log if (file.Extension.ToLower() == "pdf") { addPDFCover = addPDFCover && file.OwnerNodeID.HasValue && coverId.HasValue && paramsContainer.ApplicationID.HasValue && paramsContainer.CurrentUserID.HasValue; if (addPDFFooter || addPDFCover) { bool invalidPassword = false; fileContent = PDFUtil.get_pdf_content(paramsContainer.Tenant.Id, fileContent, pdfPassword, ref invalidPassword); if (invalidPassword) { string responseText = "{\"InvalidPassword\":" + true.ToString().ToLower() + "}"; paramsContainer.return_response(ref responseText); return; } } if (addPDFFooter) { User currentUser = !paramsContainer.CurrentUserID.HasValue ? null : UsersController.get_user(paramsContainer.Tenant.Id, paramsContainer.CurrentUserID.Value); if (currentUser == null) { currentUser = new User() { UserID = Guid.NewGuid(), UserName = "******", FirstName = "[anonymous]", LastName = "[anonymous]" }; } DownloadedFileMeta meta = new DownloadedFileMeta(PublicMethods.get_client_ip(HttpContext.Current), currentUser.UserName, currentUser.FirstName, currentUser.LastName, null); fileContent = PDFTemplates.append_footer(fileContent, meta.toString()); } if (addPDFCover) { fileContent = Wiki2PDF.add_custom_cover(paramsContainer.Tenant.Id, paramsContainer.CurrentUserID.Value, fileContent, coverId.Value, file.OwnerNodeID.Value); } if (!string.IsNullOrEmpty(pdfPassword)) { fileContent = PDFUtil.set_password(fileContent, pdfPassword); } } string retFileName = file.FileName + (string.IsNullOrEmpty(file.Extension) ? string.Empty : "." + file.Extension); paramsContainer.file_response(fileContent, retFileName, contentType: contentType, isAttachment: isAttachment); }