CrystalReportSource binding - crystal-reports

Hello I have a crystalReportViewer and CrystalReportSource on a web form.
I need to be able to bind the reportSource at run time to different report files.
I have the file data stored in a blob in a DB.
The mechanism I am using now is to save the blob to a file and then
this.CrystalReportSource1.Report.FileName = myFileName;
The issue is that I want to avoid saving the file on disk and somehow bind the report directly to a file stream.
Is that possible?
Thanks

In C#, I believe that you should be able to use something like the following, but I haven't tested it out on my system.
ReportDocument rpt = new ReportDocument();
rpt.Load(filestream); //filestream is your filestream object
Give it a try and let me know if you have issues.

Related

ObjectScript file create from stream

how can I create file (PDF file for example) from binary stream I have stored in global? I have stream stored in caché global and I need to create and save the file created by the stream using ObjectScript.
Thanks :)
It is not so easy. There is only one official way to create pdf in Cache, and it is ZEN reports. With ZEN reports you could create not only pdf, also possible to make html, xlsx. ZEN Reports used Apache FOP for generating it, any other ways also possible, but you should do it only by yourself.
Or maybe I misunderstood you, and you mean that your binary stream already contains PDF, and you just want to save it to some file. If so, you just have to copy your globalstream to filestream, with code like this:
set fs=##class(%Stream.FileBinary).%New()
set fs.Filename="c:\temp.pdf"
set tSC=fs.CopyFrom(yourStream)
set tSC=fs.%Save()

Creating PDF documents and exporting download links from the Tableau server

Is it possible to create PDF documents (e.g. on a nightly schedule) with Tableau and have those documents exposed by a URL by the Tableau server?
This sort of approach is common in the Jasper Reports and BIRT world, so I was wondering if the same approach is possible with Tableau?
I couldn't see any documentation on the Tableau site for creating PDFs, other than print to PDF
With Tableau Server, you can access your published workbook in a pdf format with this URL:
http://nameofyourtableauserver/views/NameOfYourWorkbook/NameOfYourView.pdf
Simply, the url is the url of your view + you add ".pdf".
The pdf file will be generated dynamically when accessing the URL.
Another option is to program your own script with tabcmd.
You can have more info on tabcmd here: http://kb.tableausoftware.com/articles/knowledgebase/using-tabcmd
The same technique also works for PNG. You can control filters using ?field_name=value. You can even select multiple values like this ?field_name=value1,value2.
Parameters can be set the same way.
Personally I've had the best luck with discrete dimensions instead of continuous ones.
I use the Windows Task Scheduler with batch files and Tabcmd.
Programs needed:
Tabcmd
Windows TaskScheduler (All Programs- Accessories - system tools)
http://onlinehelp.tableausoftware.com/v8.1/server/en-us/tabcmd_overview.htm
(tabcmd, how it works?)
Batchfile (create a text file and then save with file extension .bat):
1- Locate tabcmd and login
2- use function tabcmd get "http:\..." and -f "C:...pdf" to save to file.
3- concatenate the filters you want to use to the end of your URL as shown in other answers(all filters on the view must be included(filled out))
4- Save Batch file
Windows Task Scheduler:
1- create a task that will execute the batch file
2- TEST
You can do this by typing
http://server/views/WorkbookName/SheetName.pdf?:format=pdf
Another option will be using javascript api like below..
function exportPDF() {
viz.showExportPDFDialog();
}

Open a file from crystal report export to stream function

How can i open a file directly from stream which is exported through crystal report export to stream function? I am using vs2010 and sap crystal report.
MemoryStream m = (MemoryStream)(PReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
FileStream f = new FileStream(purchaseCombo.SelectedItem.ToString(),FileMode.Create,System.IO.FileAccess.Write);
byte[] bytes = new byte[m.Length];
m.Read(bytes, 0, (int)m.Length);
f.Write(bytes, 0, bytes.Length);
f.Close();
m.Close();
It depends on the file that you are exporting. Since Crystal Reports can export a number of different file types and each of them has a specific program that can handle it, you will need to search for the exact file type that you're interested. For example with a quick search on the internet, I found that a stream of an html file can be directly previewed inside a WebBrowser component (in a WPF app) by using the NavigateToStream method. Maybe there are some 3rd party components that expose methods for directly opening files from memory.
Though, the easiest way would be to export a temporary file to disk instead of memory by using the ExportToDisk method and delete it after its usage, since many components read from paths rather than memory. Before exporting the file, you can use the GetTempFileName method which creates and names a temporary file.

How to write an Enterprise Library dataConfig.config file?

I have 'inherited' a test harness application which uses Enterprise Library for its SQL data access. In the app.config file (enterpriselibrary.configurationSettings), it references a "configurationSection" with a path to "dataConfig.config", which is encrypted. I would like to change the database connection properties, but EntLibConfig.exe will not open the dataConfig.config or app.config (I have the FileKeyAlgorithmPairStorageProviderData file).
The test harness application runs, so its configured ok.
I can, in code, using (Microsoft.Practices.EnterpriseLibrary.Data.Configuration.ConfigurationManager.GetConfiguration("dataConfiguration")) read the data configuration, and can navigate all the instances and connection strings (security isn't an issue for this test harness). I can dump everything I need to a hand-crafted XML file (using GetType().AssemblyQualifiedName to get the full name for the classes which read the config file) and then change the app.config to read my new, unencrypted, xml dataConfig file.
All is fine, I can now change my database config settings.
However... given that ConfigurationManager.GetConfiguration("dataConfiguration") returns a fully populated instance of a DatabaseSettings object, is there not a method I can call which will write the XML file (dataConfig.config) for me ?
I appreciate that this is probably a really big hammer way to edit the data configuration, but after half a day of trying, I fell back on the old coding maxim... if you can't find the tool to do what you want, write your own !
Thanks
Well... turns out that its not that hard.
I added a new "configurationSection" to my app.config (dataConfiguration2), with encrypt set to false, with a path pointing to an new empty text file (dataConfiguration.config2). I then copied my encrypted dataConfiguration details using the following code:
using Entlib = Microsoft.Practices.EnterpriseLibrary.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
:
DatabaseSettings settings = (DatabaseSettings)Entlib.ConfigurationManager.GetConfiguration("dataConfiguration");
Entlib.ConfigurationManager.WriteConfiguration("dataConfiguration2", settings);
...and it filled the empty file with the (unencrypted) configuration details.

How send a file in email without saving file to disk?

I need to send a vcal file via email. I want to send the file without creating it on disk.
I have the file in string format.
Here's what I think you are looking for in C#
System.IO.StringReader stream = new System.IO.StringReader("xyz");
Attachment attach = new Attachment(stream);
MailMessage msg = new MailMessage();
msg.Attachments.Add(attach);
SmtpClient client = new SmtpClient();
client.Send(msg);
"xyz" should be replaced with the string of the attachment. The code above will allow you to add an attachment to a MailMessage object without ever having to retrieve that object's data from disk, which is what I think you meant instead of 'memory'.
Probably the best you can do (if you're using a graphical email program) is just save the .vcal file to a temporary directory, then pass that path to the mail program.
You can generate temporary filenames with functions like mktemp.
I'm not sure what you mean by not 'creating it memory'. Operating systems work by reading any file from disk into in-memory buffers. So, chances are that the file will still reside in memory at some point. Furthermore, when you pass the file over to the programme or tool that will dispatch it, it will also pass through some memory buffer.