Graphs and ASP.Net MVC - asp.net-mvc

I have a graph which I would like to represent using an image on a website. The problem is generating this image dynamically based on the current state of the graph.
I'm using ASP.Net MVC 3 with C#.
I've been thinking about generating the image on the harddisk using some tool(Graphviz etc.) and then passing the path of the file to the view.
Security isn't a real issue, as this is just internal project based work for now, it is much more important that its easy to implement.
I've been trying quickgraph, and eventually i've had it generating DOT files (apperently it ignores my attempts to make PNG's) but the code fails because the program don't have access to where the files are generated. I suppose this is easy to fix, though.
Do you have any suggestions to how I could do this (If i should do something completely different or how i can get the DOT files rendered as PNG)?
Best regards,
Daniel

Just wanted to note that I solved this using the Google Image Chart, they have experimental Graphviz support: http://code.google.com/apis/chart/image/docs/gallery/graphviz.html
Simply generate an URL and insert an external image on your page.

If the graph library allows you, write the result to a memory stream and place it in the Cache (System.Web.HttpRuntime.Cache) with a key.
Use that key to generate the img tag in the view and point to an action ('View'?) in a controller ('Image') like "/Image/View/392838".
Create this controller and view and serve the contents (make sure to include proper MIME type, content type etc.) from there.
In the cache specify a decent lifetime for the object, such as 15 seconds, sliding expiration.

Related

Printing a ticket in xpages

In a xpages application I need to mount a label with a certain layout, analogous to the layout of a ticket. Searching, I have verified that the most used practice is to use openoffice to design the odt model and in java to use bilbiotec to JOD Reports. Do you advise to follow this line yourself, or do you have any suggestions?
I would concur with Marcus. The way forward is PDF output. There are a couple of ways to do this, depending on your constraints.
When user must design every aspect of the ticket using openoffice is a suitable approach, however you need a headless openoffice install for the rendering
If everything can be code, then PDFBox is a good way to go. Wrap your code into a managed bean
The middle path would be XSL:FO and Apache FOP. It allows alteration of the layout by providing a different style sheet. I wrote an article series outlining that approach.
Let us know what works for you!
There is also the POI4XPages plugin. You could design your form with Word and then use placeholders to populate the document and output as a pdf.
See https://poi4xpages.openntf.org/main.nsf/project.xsp?r=project/POI%204%20XPages/releases/E80C4FC9FB07E1E4852580E3006E02C7
Download the latest version (1.4) at http://p2.openntf.org/repository.nsf/home.xsp/poi4xpages/snapshots
Howard
I was able to solve my problem, because I discovered that here in the company there is the abcpdf software. Through a web service that uses the APis of this software, I pass the html code of the ticket and the web service returns the pdf document in an array of bytes. I created a managed javabean to consume the web service and display the pdf in the browser.
Thanks to all who have contributed in some way with suggestions.

can i use input type = file in my single page application

I'm writing my first single page application and have a requirement by where the user is going to need to upload documents and/or images.
Is this a show stopper for using a spa or is there a work around?
I seem to be able to find very little on this on the net so I'm wondering if this requirement would mean creating a normal mvc site?
Its possible to upload files using ajax, so no show stopper there. you might need a controller to accept the file though, but that shouldn't be an issue.
Check out this tutorial on an ajax upload
http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/
or you can check out uploadify, i think that does file upload via ajax too

MD5 in ActionScript

I am trying to build a web based flash application. I am quite new to flash. I would like to develop it in two forms - demo and paid version. For this application to act as a paid version I need to have some kind of serial key. In order to achieve this I googled and came across something like this
MD5(MD5(thisuri)+thisuri)
I think 'thisuri' points to the current url page but I don't know how to get that url and I don't know whether '+' acts as a character or an operator.
Can you please help me?
It seems that a library exists in AS3.0 : as3corelib
An ActionScript 3 Library that contains a number of classes and utilities for working with ActionScript? 3. These include classes for MD5 and SHA 1 hashing, Image encoders, and JSON serialization as well as general String, Number and Date APIs.
To use it, just download the zip file, decompress it and copy the contents of "src" directory to the root of your project.
Then in your actionscript code, simply do the following :
import com.adobe.crypto.MD5;
var hash:String = MD5.hash(”test”);
source in french
To add to #Julien's recommendation of using as3corelib, you will also need the advice from this post to get the current url: Get Current Browser URL - ActionScript 3
Somehow I think there's a more elegant way to get the url, but I don't remember it.
While this may provide you with some basic check for the paid version, a determined hacker will easily fool this algorithm. For example, I could fool the environment into thinking that its being served from a domain that you've registered as part of the "paid" version. Also, since the client has the flash code, they can decompile the binary and potentially see the algorithm you're using. Depending on what you're offering in the app, this extreme case may or may not be acceptable to you.
Look into more secure authentication mechanisms if you're serious about security.

Best way to display non-public images in a rails view

I am trying to find the best way to render confidential images in a view, without storing the images within the rails application flat-filesystem, as I have no idea where to place the images. I am storing the image data binary as :text in a sqlite3 database table and successfully display the images using
<% s = "data:image/png;base64,#{ActiveSupport::Base64.encode64(#my_image)}"%>
<img style = 'width:100%; height:600px' src = '<%= s %>'/>
This works for me in Firefox and Chrome, but my client cannot get the images to display. I'll find out in an hour or two what browser they are using. Client says they want the image src url to look like a relative path within a controller's folder, which seems to contradict the notion of not storing the image in the flat-file system.
I think I am missing something very small here, but I would like to know the proper way to store images and documents in an application that are not public to all users. If my question is not clear or you need information, please let me know and I will provide more information.
I have read of attachment_fu and paperclip, but they appear to allow attachment downloads, and I just need to display an image inline on a page. Any help is greatly appreciated. Thank you much in advance.
You can keep files in non-public repositories and have controllers action with send_file(path, options = {}) It allows you store files somewhere on the hard disc and keep access logic inside your controller.
Have you tried the paperclip gem? You can upload images to amazon and amazon allows you to set permissions for files...if you want to do it that way.
As Artem says, Amazon is a great way to achieve this. But if I get you right, they want to see an URL to the image directly (i.e. be able to type the source into the address-field if they want to).
You need to decide wether everyone should be able to access the image (given they know the name/path), or to have authentication, in which case I don't think a relative path is worth anything.
Can't you just have an image-folder containing all images (not accessible by URL), and a table to lookup wether userX is allowed to see imageY?

Issues with Filemaker IWP working with hyperlinks on images

I have a filemaker database that I need to be able to link records and all associated data (including container field data) to various points placed on a large PDF image, and then make that data appear via instant web publishing when someone clicks on the marker for that area on the PDF. For example the PDF may be an image of a car, and then I would have various close up images of issues with the car and descriptions of those images as records in the database. I would then want to drop points on the base PDF image and when you clicked on those points be able to see the close up images and other data related to those images.
I'm being told this is too much for IWP because:
I need to place the markers outside filemaker via PDF annotation
Filemaker IWP can't handle the number of markers that may be necessary (it could be up to 1,000 on an E sized image.
Does anyone have a work around or explanation why this is a problem?
If I understand correctly, you would like to setup a PDF with links that will open a browser and show data related to what was clicked. Assuming that is the case, the reason this wont work is because IWP does not provide a unique URL for a unique page. For example, here on StackOverflow you can directly link to any question based on its URL:
http://stackoverflow.com/questions/3207775/ -- this question
http://stackoverflow.com/questions/4973921/ -- some other question
IWP uses Javascript and session variables to manipulate the output to the screen, so there is no way to link to a specific section of your IWP site, since the URL is always something like:
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product A
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product B
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product C
Because of the limited nature of IWP, you will not be able to workaround this issue. You'll need to build your own web-interface using the Custom Web Publishing Engine, either using the built-in PHP extensions or some other technology where you invoke the XML publishing API.
I agree with Nate
IWP is the wrong solution to this problem. You'd be better off simply hosting those images on a webserver.
Now here comes the plug, you can use SuperContainer to really simplify the management of the images from FileMaker.

Resources